Skip to content

Commit

Permalink
suggested changes from Marco Trevisan
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-costas committed Mar 12, 2024
1 parent c23ed4c commit 6722911
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions appIconIndicators.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,39 +876,35 @@ class UnityIndicator extends IndicatorBase {
offsetEnd: defaultValues.offsetEnd ?? 1.0,
};

let hasValue, value1, value2;

[hasValue, value1] = node.lookup_color(elementName, false);
if (hasValue) {
output.colorStart = value1;
const [hasElementName, elementNameValue] = node.lookup_color(elementName, false);
if (hasElementName) {
output.colorStart = elementNameValue;
output.colorEnd = null;
} else {
[hasValue, value1] = node.lookup_color(`${elementName}-color-start`, false);
if (hasValue) {
[hasValue, value2] = node.lookup_color(`${elementName}-color-end`, false);
if (hasValue) {
output.colorStart = value1;
output.colorEnd = value2;
}
const [hasColorStart, colorStartValue] = node.lookup_color(`${elementName}-color-start`, false);
const [hasColorEnd, colorEndValue] = node.lookup_color(`${elementName}-color-end`, false);
if (hasColorStart && hasColorEnd) {
output.colorStart = colorStartValue;
output.colorEnd = colorEndValue;
}
}

[hasValue, value1] = node.lookup_color(`${elementName}-offset-start`, false);
if (hasValue)
output.offsetStart = value1;
const [hasOffsetStart, offsetStartvalue] = node.lookup_color(`${elementName}-offset-start`, false);
if (hasOffsetStart)
output.offsetStart = offsetStartvalue;

[hasValue, value1] = node.lookup_color(`${elementName}-offset-end`, false);
if (hasValue)
output.offsetEnd = value1;
const [hasOffsetEnd, offsetEndValue] = node.lookup_color(`${elementName}-offset-end`, false);
if (hasOffsetEnd)
output.offsetEnd = offsetEndValue;

return output;
}

_readElementData(node, elementName, defaultValues) {
let lineWidth = defaultValues.lineWidth ?? 1.0;
const [hasValue, value1] = node.lookup_double(`${elementName}-line-width`, false);
if (hasValue)
lineWidth = value1;
const defaultLineWidth = defaultValues.lineWidth ?? 1.0;
let [hasValue, lineWidth] = node.lookup_double(`${elementName}-line-width`, false);
if (!hasValue)
lineWidth = defaultLineWidth;

return {
background: this._readGradientData(node, `${elementName}-background`, defaultValues.background),
Expand All @@ -918,10 +914,8 @@ class UnityIndicator extends IndicatorBase {
}

_createGradient(values, x0, y0, x1, y1) {
let gradient;

if (values.colorEnd) {
gradient = new Cairo.LinearGradient(x0, y0, x1, y1);
const gradient = new Cairo.LinearGradient(x0, y0, x1, y1);
gradient.addColorStopRGBA(values.offsetStart,
values.colorStart.red / 255,
values.colorStart.green / 255,
Expand All @@ -932,13 +926,14 @@ class UnityIndicator extends IndicatorBase {
values.colorEnd.green / 255,
values.colorEnd.blue / 255,
values.colorEnd.alpha / 255);
return gradient;
} else {
gradient = Cairo.SolidPattern.createRGBA(values.colorStart.red / 255,
const gradient = Cairo.SolidPattern.createRGBA(values.colorStart.red / 255,
values.colorStart.green / 255,
values.colorStart.blue / 255,
values.colorStart.alpha / 255);
return gradient;
}
return gradient;
}

_drawProgressOverlay(area) {
Expand Down

0 comments on commit 6722911

Please sign in to comment.