Skip to content

Commit b2d3ff8

Browse files
[[New Widget]] default fonts and heights as constants, drop shadow for Android(Raised) button, call handler to update variables when widget is created, added release notes, removed exisitng button, modified extension.gyp file so that new button widget gets built in extensions project
1 parent 7d3c0c9 commit b2d3ff8

4 files changed

Lines changed: 42 additions & 267 deletions

File tree

extensions/extensions.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
'libraries/iconsvg/iconsvg.lcb',
2323
'libraries/json/json.lcb',
2424

25-
'widgets/button/button.lcb',
2625
#'widgets/button-popup/button-popup.lcb',
2726
#’widgets/chart/chart.lcb',
2827
'widgets/checkbox/checkbox.lcb',
@@ -36,6 +35,7 @@
3635
'widgets/paletteactions/paletteactions.lcb',
3736
#’widgets/pinkcircle/pinkcircle.lcb',
3837
'widgets/progressbar/progressbar.lcb',
38+
'widgets/pushButton/pushButton.lcb',
3939
'widgets/radiobutton/radiobutton.lcb',
4040
'widgets/segmented/segmented.lcb',
4141
#'widgets/segmented-popup/segmented-popup.lcb',

extensions/widgets/button/button.lcb

Lines changed: 0 additions & 260 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Push Button Widget Added
2+
3+
Push button widget.
4+
5+
This theme of this widget can either be:
6+
- iOS
7+
- Android(Raised)
8+
- Android(Flat)
9+
10+
The default theme is iOS.

extensions/widgets/pushButton/pushButton.lcb

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ public handler OnCreate() returns nothing
178178

179179
put false into mShowBorder
180180
put color [0, 121/255, 1] into mDefaultColor
181-
put (my height)*(17/29) into mIosFontSize
182-
put (my height)*(14/36) into mAndroidFontSize
181+
updateVariables()
183182
end handler
184183

185184
public handler OnPaint() returns nothing
@@ -220,7 +219,10 @@ private handler drawAndroidRaisedButton() returns nothing
220219
checkBackgroundColor(tColorString)
221220

222221
-- shadow
222+
variable tShadow as Effect
223+
put drawDropShadow() into tShadow
223224

225+
begin layer with tShadow on this canvas
224226
-- background
225227
set the paint of this canvas to fetchPaint("background")
226228
fill fetchPath("background") on this canvas
@@ -231,6 +233,7 @@ private handler drawAndroidRaisedButton() returns nothing
231233
set the stroke width of this canvas to 0.5
232234
stroke fetchPath("border") on this canvas
233235
end if
236+
end layer on this canvas
234237

235238
-- label
236239
variable tLabel as String
@@ -257,9 +260,31 @@ private handler drawAndroidFlatButton() returns nothing
257260
fill text tLabel at center of my bounds on this canvas
258261
end handler
259262

263+
private handler drawDropShadow() returns Effect
264+
variable tProps as Array
265+
put the empty array into tProps
266+
267+
put color [186/255, 186/255, 186/255] into tProps["color"]
268+
put "source over" into tProps["blend mode"]
269+
put 125 into tProps["opacity"]
270+
put 0 into tProps["spread"]
271+
put 1 into tProps["size"]
272+
put 2 into tProps["distance"]
273+
put 90 into tProps["angle"]
274+
275+
variable tEffect as Effect
276+
put outer shadow effect with properties tProps into tEffect
277+
return tEffect
278+
end handler
279+
280+
constant kIosDefaultFontSize is 17
281+
constant kIosDefaultHeight is 29
282+
constant kAndroidDefaultFontSize is 14
283+
constant kAndroidDefaultHeight is 36
284+
260285
private handler updateVariables() returns nothing
261-
put (my height)*(17/29) into mIosFontSize
262-
put (my height)*(14/36) into mAndroidFontSize
286+
put (my height)*(kIosDefaultFontSize/kIosDefaultHeight) into mIosFontSize
287+
put (my height)*(kAndroidDefaultFontSize/kAndroidDefaultHeight) into mAndroidFontSize
263288
end handler
264289

265290
private handler fetchPaint(in pObject as String) returns Paint
@@ -290,10 +315,10 @@ private handler fetchPath(in pObject as String) returns Path
290315
if mWidgetTheme is "iOS" then
291316
return rounded rectangle path of my bounds with radius 5
292317
else if mWidgetTheme is "Android(Raised)" then
293-
return rounded rectangle path of my bounds with radius 2
318+
return rounded rectangle path of rectangle [0,0,(my width)-3,(my height)-3] with radius 2
294319
end if
295320
else if pObject is "border" then
296-
return rounded rectangle path of my bounds with radius 2
321+
return rounded rectangle path of rectangle [0,0,(my width)-3,(my height)-3] with radius 2
297322
end if
298323
end handler
299324

0 commit comments

Comments
 (0)