@@ -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()
183182end handler
184183
185184public 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
258261end 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+
260285private 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
263288end handler
264289
265290private 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
298323end handler
299324
0 commit comments