Skip to content

Commit

Permalink
#106 Implement Meter Digits Style setting
Browse files Browse the repository at this point in the history
  • Loading branch information
warmsound committed Apr 27, 2019
1 parent 974ec0a commit 7a08f04
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
1 change: 1 addition & 0 deletions resources/settings/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<property id="LeftGoalType" type="number">0</property>
<property id="RightGoalType" type="number">1</property>
<property id="GoalMeterStyle" type="number">0</property>
<property id="GoalMeterDigitsStyle" type="number">0</property>
<property id="CaloriesGoal" type="number">2000</property>

<property id="FieldCount" type="number">3</property>
Expand Down
8 changes: 8 additions & 0 deletions resources/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
</settingConfig>
</setting>

<setting propertyKey="@Properties.GoalMeterDigitsStyle" title="@Strings.MeterDigitsStyleTitle">
<settingConfig type="list">
<listEntry value="0">@Strings.CurrentTarget</listEntry>
<listEntry value="1">@Strings.Current</listEntry>
<listEntry value="2">@Strings.Hidden</listEntry>
</settingConfig>
</setting>

<setting propertyKey="@Properties.CaloriesGoal" title="@Strings.CaloriesGoalTitle">
<settingConfig type="numeric" min="1" max="10000" required="true"/>
</setting>
Expand Down
47 changes: 28 additions & 19 deletions source/DataArea.mc
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,35 @@ class DataArea extends Ui.Drawable {
}

function drawGoalValues(dc, x, currentValue, maxValue, align) {
if (currentValue != null) {
dc.setColor(gMonoLightColour, Gfx.COLOR_TRANSPARENT);
dc.drawText(
x,
mRow1Y,
gNormalFont,
currentValue,
align | Graphics.TEXT_JUSTIFY_VCENTER
);
}
var digitStyle = App.getApp().getProperty("GoalMeterDigitsStyle");

// #107 Only draw values if digit style is not Hidden.
if (digitStyle != 2 /* HIDDEN */) {
if (currentValue != null) {
dc.setColor(gMonoLightColour, Gfx.COLOR_TRANSPARENT);
dc.drawText(
x,

// #107 Draw current value vertically centred if digit style is Current (i.e. not drawing max/target).
(digitStyle == 1 /* CURRENT */) ? ((mRow1Y + mRow2Y) / 2) : mRow1Y,

gNormalFont,
currentValue,
align | Graphics.TEXT_JUSTIFY_VCENTER
);
}

if (maxValue != null) {
dc.setColor(gMonoDarkColour, Gfx.COLOR_TRANSPARENT);
dc.drawText(
x,
mRow2Y,
gNormalFont,
maxValue,
align | Graphics.TEXT_JUSTIFY_VCENTER
);
// #107 Only draw max/target goal value if digit style is set to Current/Target.
if ((maxValue != null) && (digitStyle == 0) /* CURRENT_TARGET */) {
dc.setColor(gMonoDarkColour, Gfx.COLOR_TRANSPARENT);
dc.drawText(
x,
mRow2Y,
gNormalFont,
maxValue,
align | Graphics.TEXT_JUSTIFY_VCENTER
);
}
}
}
}

0 comments on commit 7a08f04

Please sign in to comment.