Skip to content

Commit 88df2aa

Browse files
[[Bugfix 19619]] Added <dayMinuteHandColor> and <nightMinuteHandColor> to clock widget
The properies <dayMinuteHandColor> and <nightMinuteHandColor> have been added to the clock widget to allow the colors of the minute hand of the clock to be changed and for a different color to be displayed at night time (as set by the <isDay> read-only property).
1 parent 3caecbd commit 88df2aa

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

extensions/widgets/clock/clock.lcb

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,41 @@ metadata nightHourHandColor.default is "255,255,255"
150150
metadata nightHourHandColor.section is "Colors"
151151
metadata nightHourHandColor.label is "Hour hand color (night)"
152152

153+
/**
154+
Syntax: set the dayMinuteHandColor of <widget> to <color>
155+
Syntax: get the dayMinuteHandColor of <widget>
156+
157+
Summary: Determines the color of the minute hand on the clock during the day
158+
159+
Description:
160+
Use the <dayMinuteHandColor> property to get or set the color of the minute
161+
hand of the clock during the day. To determine if the clock is
162+
displaying its daytime or night-time colors, use the read-only property
163+
<isDay>.
164+
*/
165+
property dayMinuteHandColor get getDayMinuteHandColor set setDayMinuteHandColor
166+
metadata dayMinuteHandColor.editor is "com.livecode.pi.color"
167+
metadata dayMinuteHandColor.default is "0,0,0"
168+
metadata dayMinuteHandColor.section is "Colors"
169+
metadata dayMinuteHandColor.label is "Minute hand color (day)"
170+
171+
/**
172+
Syntax: set the nightMinuteHandColor of <widget> to <color>
173+
Syntax: get the nightMinuteHandColor of <widget>
174+
175+
Summary: Determines the color of the minute hand on the clock during the night
176+
177+
Description:
178+
Use the <nightMinuteHandColor> property to get or set the color of the minute
179+
hand of the clock during the night. To determine if the clock is
180+
displaying its daytime or night-time colors, use the read-only property
181+
<isDay>.
182+
*/
183+
property nightMinuteHandColor get getNightMinuteHandColor set setNightMinuteHandColor
184+
metadata nightMinuteHandColor.editor is "com.livecode.pi.color"
185+
metadata nightMinuteHandColor.default is "255,255,255"
186+
metadata nightMinuteHandColor.section is "Colors"
187+
metadata nightMinuteHandColor.label is "Minute hand color (night)"
153188
--
154189

155190
-- private instance variables
@@ -163,6 +198,8 @@ private variable mDayNumberColor as Color
163198
private variable mNightNumberColor as Color
164199
private variable mDayHourHandColor as Color
165200
private variable mNightHourHandColor as Color
201+
private variable mDayMinuteHandColor as Color
202+
private variable mNightMinuteHandColor as Color
166203
--
167204

168205
-- constants
@@ -181,6 +218,8 @@ public handler OnSave(out rProperties as Array)
181218
put colorToString(mNightNumberColor,true) into rProperties["nightNumberColor"]
182219
put colorToString(mDayHourHandColor,true) into rProperties["dayHourHandColor"]
183220
put colorToString(mNightHourHandColor,true) into rProperties["nightHourHandColor"]
221+
put colorToString(mDayMinuteHandColor,true) into rProperties["dayMinuteHandColor"]
222+
put colorToString(mNightMinuteHandColor,true) into rProperties["nightMinuteHandColor"]
184223
end handler
185224

186225
public handler OnLoad(in pProperties as Array)
@@ -206,6 +245,16 @@ public handler OnLoad(in pProperties as Array)
206245
else
207246
put color kWhite into mNightHourHandColor
208247
end if
248+
if "dayMinuteHandColor" is among the keys of pProperties then
249+
put stringToColor(pProperties["dayMinuteHandColor"]) into mDayMinuteHandColor
250+
else
251+
put color kBlack into mDayMinuteHandColor
252+
end if
253+
if "nightMinuteHandColor" is among the keys of pProperties then
254+
put stringToColor(pProperties["nightMinuteHandColor"]) into mNightMinuteHandColor
255+
else
256+
put color kWhite into mNightMinuteHandColor
257+
end if
209258
end handler
210259

211260
-- called when widget is created
@@ -380,6 +429,13 @@ private handler getPaint(in pObject as String) returns Paint
380429
return solid paint with color kBlack
381430
end if
382431

432+
else if pObject is "minute hand" then
433+
if mIsDay is true then
434+
return solid paint with mDayMinuteHandColor
435+
else
436+
return solid paint with mNightMinuteHandColor
437+
end if
438+
383439
else if pObject is "second hand" or pObject is "inner nub" then
384440
return solid paint with color kRed
385441

@@ -505,4 +561,22 @@ public handler setNightHourHandColor(in pColor as String)
505561
redraw all
506562
end handler
507563

564+
public handler getDayMinuteHandColor() returns String
565+
return colorToString(mDayMinuteHandColor, true)
566+
end handler
567+
568+
public handler setDayMinuteHandColor(in pColor as String)
569+
put stringToColor(pColor) into mDayMinuteHandColor
570+
redraw all
571+
end handler
572+
573+
public handler getNightMinuteHandColor() returns String
574+
return colorToString(mNightMinuteHandColor, true)
575+
end handler
576+
577+
public handler setNightMinuteHandColor(in pColor as String)
578+
put stringToColor(pColor) into mNightMinuteHandColor
579+
redraw all
580+
end handler
581+
508582
end widget

0 commit comments

Comments
 (0)