Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 97c7f9c

Browse files
authored
Revert "[[ WidgetUtils ]] Use icon library for placeholder icons where possible"
1 parent 4b29ad3 commit 97c7f9c

10 files changed

Lines changed: 55 additions & 19 deletions

File tree

extensions/modules/widget-utils/widget-utils.lcb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ module com.livecode.library.widgetutils
2323

2424
use com.livecode.canvas
2525
use com.livecode.engine
26-
use com.livecode.library.iconsvg
2726

2827
metadata version is "1.0.0"
2928
metadata author is "LiveCode"
@@ -286,6 +285,7 @@ end handler
286285

287286
constant kMacPlaceholderSvgIcon is "M14.926,0.656H1.067C0.478,0.656,0,1.137,0,1.73v9.844c0,0.594,0.478,1.074,1.067,1.074h5.316 c0,0-0.934,2.149-3.493,2.149v0.537h1.88h4.568h3.493v-0.537c-2.631,0-3.226-2.149-3.226-2.149h5.32 c0.588,0,1.065-0.48,1.065-1.074V1.73C15.992,1.137,15.514,0.656,14.926,0.656z M7.996,12.427c-0.331,0-0.599-0.268-0.599-0.599 c0-0.33,0.268-0.598,0.599-0.598c0.33,0,0.599,0.268,0.599,0.598C8.594,12.159,8.326,12.427,7.996,12.427z M14.849,10.906H1.143 V1.798H14.85L14.849,10.906L14.849,10.906zM6.824,9.133c0.393-0.016,0.542-0.255,1.017-0.255c0.476,0,0.609,0.255,1.024,0.247 C9.288,9.117,9.556,8.74,9.814,8.363c0.3-0.438,0.423-0.862,0.431-0.883c-0.01-0.005-0.824-0.317-0.833-1.255 c-0.008-0.786,0.642-1.163,0.67-1.182C9.718,4.51,9.149,4.437,8.947,4.429C8.465,4.38,8.005,4.713,7.759,4.713 c-0.244,0-0.623-0.277-1.023-0.27C6.209,4.451,5.724,4.75,5.452,5.221c-0.547,0.95-0.14,2.356,0.393,3.127 C6.105,8.725,6.416,9.148,6.824,9.133z M8.953,2.928c-0.312,0.013-0.689,0.208-0.914,0.47c-0.2,0.233-0.376,0.604-0.329,0.96 c0.349,0.027,0.704-0.177,0.921-0.439C8.847,3.656,8.993,3.292,8.953,2.928z"
288287
constant kIosPlaceholderSvgIcon is "M4.621 6.965c0 1.368-.833 2.38-2.262 2.38-1.19 0-2.083-1.012-2.083-2.38 0-1.31.952-2.381 2.202-2.381 1.31 0 2.143 1.071 2.143 2.381zM1.327 78.5V23.78H3.57V78.5H1.327zM78.174 39.512c0 27.588-15.315 40.129-32.079 40.129-17.125 0-30.993-13.565-30.993-38.988C15.102 14.549 29.453.526 47.301.526 64.787.524 78.174 14.318 78.174 39.512zm-60.799.57C17.375 61 27.513 77.25 46.201 77.25c18.818 0 29.611-16.75 29.611-37.406 0-19.155-8.648-36.636-28.382-36.636S17.375 19.667 17.375 40.082zM86.406 72.571c3.763 2.508 10.258 4.93 15.844 4.93 10.602 0 20.031-7.417 20.031-18.334 0-10.131-6.281-15.417-16.945-19.958-9.544-4.064-18.125-8.475-18.125-19.305 0-11.285 8.891-19.267 20.975-19.267 6.498 0 11.4 1.824 13.68 3.42l-.906 1.968c-1.938-1.367-7.176-3.109-12.874-3.109-12.771 0-18.334 9.65-18.334 16.754 0 9.812 7.606 13.093 17.41 17.767 11.399 5.585 17.44 10.51 17.44 21.227 0 11.514-8.207 20.86-22.799 20.86-6.043 0-12.996-2.051-16.416-4.674l1.019-2.279z"
288+
constant kAndroidPlaceholderSvgIcon is "M493 615Q509 615 520.5 603.5 532 592 532 576 532 560 520.5 548.5 509 537 493 537 477 537 466 548.5 455 560 455 576 455 592 466 603.5 477 615 493 615ZM915 615Q931 615 942 603.5 953 592 953 576 953 560 942 548.5 931 537 915 537 899 537 887.5 548.5 876 560 876 576 876 592 887.5 603.5 899 615 915 615ZM103 799Q145 799 175 829 205 859 205 901L205 1331Q205 1374 175.5 1404 146 1434 103 1434 60 1434 30 1404 0 1374 0 1331L0 901Q0 859 30 829 60 799 103 799ZM1163 818L1163 1484Q1163 1530 1131 1562 1099 1594 1054 1594L979 1594 979 1821Q979 1864 949 1894 919 1924 876 1924 833 1924 803 1894 773 1864 773 1821L773 1594 635 1594 635 1821Q635 1864 605 1894 575 1924 532 1924 490 1924 460 1894 430 1864 430 1821L429 1594 355 1594Q309 1594 277 1562 245 1530 245 1484L245 818 1163 818ZM931 413Q1038 468 1102 566.5 1166 665 1166 782L241 782Q241 665 305 566.5 369 468 477 413L406 282Q399 269 411 262 424 256 431 268L503 400Q598 358 704 358 810 358 905 400L977 268Q984 256 997 262 1009 269 1002 282ZM1408 901L1408 1331Q1408 1374 1378 1404 1348 1434 1305 1434 1263 1434 1233 1404 1203 1374 1203 1331L1203 901Q1203 858 1233 828.5 1263 799 1305 799 1348 799 1378 828.5 1408 858 1408 901Z"
289289
/**
290290
Summary: Returns a placeholder icon for a given operating system
291291

@@ -306,13 +306,7 @@ public handler placeholderIcon(in pOS as String) returns String
306306
else if pOS is "ios" then
307307
return kIosPlaceholderSvgIcon
308308
else if pOS is "android" then
309-
return iconSVGPathFromName("android")
310-
else if pOS is "windows" then
311-
return iconSVGPathFromName("windows")
312-
else if pOS is "linux" then
313-
return iconSVGPathFromName("linux")
314-
else if pOS is "emscripten" then
315-
return iconSVGPathFromName("html5")
309+
return kAndroidPlaceholderSvgIcon
316310
else
317311
throw "no placeholder icon for" && pOS && "operating system"
318312
end if

extensions/widgets/androidfield/tests/properties.livecodescript

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
1717
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818

1919
on TestSetup
20-
TestLoadExtension "com.livecode.library.iconsvg"
2120
TestLoadExtension "com.livecode.library.widgetutils"
2221
TestLoadExtension "com.livecode.library.scriptitems"
2322
TestLoadExtension "com.livecode.library.androidutils"

extensions/widgets/browser/tests/basic.livecodescript

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
1717
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818

1919
on TestSetup
20-
TestLoadExtension "com.livecode.library.iconsvg"
2120
TestLoadExtension "com.livecode.library.widgetutils"
2221
TestLoadExtension "com.livecode.widget.browser"
2322
end TestSetup

extensions/widgets/graph/tests/properties.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ private function getGraphData
2626
end getGraphData
2727

2828
on TestSetup
29-
TestLoadExtension "com.livecode.library.iconsvg"
3029
TestLoadExtension "com.livecode.library.widgetutils"
30+
TestLoadExtension "com.livecode.library.iconsvg"
3131
TestLoadExtension "com.livecode.widget.linegraph"
3232

3333
create stack

extensions/widgets/header/tests/properties.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
1717
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818

1919
on TestSetup
20-
TestLoadExtension "com.livecode.library.iconsvg"
2120
TestLoadExtension "com.livecode.library.widgetutils"
21+
TestLoadExtension "com.livecode.library.iconsvg"
2222
TestLoadExtension "com.livecode.widget.headerbar"
2323
create widget "testHeader" as "com.livecode.widget.headerbar"
2424
end TestSetup

extensions/widgets/html5button/html5button.lcb

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use com.livecode.emscripten
2525
use com.livecode.widget
2626
use com.livecode.canvas
2727
use com.livecode.engine
28-
use com.livecode.library.widgetutils
2928

3029
metadata version is "1.0.0"
3130
metadata author is "LiveCode"
@@ -126,6 +125,53 @@ private handler OnJSClick(pEvent as JSObject) returns nothing
126125
post "mouseUp"
127126
end handler
128127

128+
private handler expandRectangle(in pRect as Rectangle, in pExp as Number) returns Rectangle
129+
return rectangle [ the left of pRect - pExp, the top of pRect - pExp, the right of pRect + pExp, the bottom of pRect + pExp]
130+
end handler
131+
132+
constant kBorderWidth is 5
133+
private handler paintPlaceholderLabel(in pCanvas as Canvas, in pBounds as Rectangle, \
134+
in pLabel as String, in pFont as optional Font, in pColor as optional Color)
135+
save state of pCanvas
136+
137+
// Draw the border
138+
variable tFillPaint as Paint
139+
variable tStrokePaint as Paint
140+
put solid paint with color [0.875, 0.875, 0.875] into tFillPaint
141+
put solid paint with color [0.75, 0.75, 0.75] into tStrokePaint
142+
143+
set the paint of pCanvas to tFillPaint
144+
fill rectangle path of pBounds on this canvas
145+
set the paint of this canvas to tStrokePaint
146+
set the stroke width of this canvas to kBorderWidth
147+
set the join style of this canvas to "bevel"
148+
stroke rectangle path of expandRectangle(pBounds, -kBorderWidth / 2) on this canvas
149+
150+
// Draw the control name
151+
put solid paint with color [1, 1, 1] into tFillPaint
152+
153+
if pFont is nothing then
154+
put font "Arial" at size 14 into pFont
155+
end if
156+
157+
if pColor is nothing then
158+
put color [0.25, 0.25, 0.25] into pColor
159+
end if
160+
put solid paint with pColor into tStrokePaint
161+
162+
variable tTextBounds as Rectangle
163+
put the image bounds of text pLabel on pCanvas into tTextBounds
164+
165+
translate pCanvas by [ the width of pBounds / 2, the height of pBounds / 2]
166+
translate pCanvas by [ -(the width of tTextBounds / 2), the height of tTextBounds / 2]
167+
set the paint of pCanvas to tFillPaint
168+
fill rounded rectangle path of expandRectangle(tTextBounds, kBorderWidth) with radius 5 on pCanvas
169+
set the paint of pCanvas to tStrokePaint
170+
fill text pLabel at point [0, 0] on pCanvas
171+
172+
restore state of pCanvas
173+
end handler
174+
129175
public handler OnPaint()
130176
if IsHTML5() then
131177
return
@@ -138,8 +184,7 @@ public handler OnPaint()
138184
put mLabel into tLabel
139185
end if
140186

141-
paintPlaceholderImage(this canvas, my bounds, \
142-
placeholderIcon("emscripten"), tLabel, my font, nothing)
187+
paintPlaceholderLabel(this canvas, my bounds, tLabel, my font, color [0,0,0])
143188
end handler
144189

145190
public handler SetLabel(in pLabel as String)

extensions/widgets/mactextfield/tests/properties.livecodescript

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
1717
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818

1919
on TestSetup
20-
TestLoadExtension "com.livecode.library.iconsvg"
2120
TestLoadExtension "com.livecode.library.widgetutils"
2221
TestLoadExtension "com.livecode.library.scriptitems"
2322
TestLoadExtension "com.livecode.widget.native.mac.textfield"

extensions/widgets/navbar/tests/properties.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
1717
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818

1919
on TestSetup
20-
TestLoadExtension "com.livecode.library.iconsvg"
2120
TestLoadExtension "com.livecode.library.widgetutils"
21+
TestLoadExtension "com.livecode.library.iconsvg"
2222
TestLoadExtension "com.livecode.widget.navbar"
2323
create widget "testNavBar" as "com.livecode.widget.navbar"
2424
end TestSetup

extensions/widgets/paletteactions/tests/basic.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
1717
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818

1919
on TestSetup
20-
TestLoadExtension "com.livecode.library.iconsvg"
2120
TestLoadExtension "com.livecode.library.widgetutils"
21+
TestLoadExtension "com.livecode.library.iconsvg"
2222
TestLoadExtension "com.livecode.widget.paletteactions"
2323
end TestSetup
2424

extensions/widgets/svgpath/tests/properties.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ private function getPathData
2121
end getPathData
2222

2323
on TestSetup
24-
TestLoadExtension "com.livecode.library.iconsvg"
2524
TestLoadExtension "com.livecode.library.widgetutils"
25+
TestLoadExtension "com.livecode.library.iconsvg"
2626
TestLoadExtension "com.livecode.widget.svgpath"
2727
create widget "testSvgPath" as "com.livecode.widget.svgpath"
2828
end TestSetup

0 commit comments

Comments
 (0)