Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7949737

Browse filesBrowse files
hyperhhlivecodeali
authored andcommitted
[[ SVGPath ]] Add bounding box properties
1 parent e9e0f34 commit 7949737
Copy full SHA for 7949737

File tree

Expand file treeCollapse file tree

1 file changed

+65
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+65
-1
lines changed

‎extensions/widgets/svgpath/svgpath.lcb

Copy file name to clipboardExpand all lines: extensions/widgets/svgpath/svgpath.lcb
+65-1Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use com.livecode.library.widgetutils
3232
-- adding metadata to ensure the extension displays correctly in livecode
3333
metadata title is "SVG Icon"
3434
metadata author is "LiveCode"
35-
metadata version is "2.1.1"
35+
metadata version is "3.0.0"
3636
metadata svgicon is "M61.8,0H4C1.8,0,0,1.8,0,4v27.8c0,2.2,1.8,4,4,4h57.8c2.2,0,4-1.8,4-4V4C65.8,1.8,64,0,61.8,0z M20.9,25.3c-1.2,0.9-2.8,1.4-4.9,1.4c-0.8,0-1.6-0.1-2.2-0.2c-0.7-0.1-1.3-0.3-1.9-0.5c-0.1,0.2-0.3,0.4-0.5,0.5s-0.5,0.2-0.8,0.2c-0.6,0-1-0.1-1.2-0.3c-0.2-0.2-0.4-0.6-0.4-1.2l-0.1-3.2v-0.2c0-0.6,0.1-1,0.3-1.3c0.2-0.2,0.6-0.4,1.2-0.4c0.6,0,1.1,0.4,1.5,1.3c0.1,0.2,0.2,0.4,0.2,0.5c0.4,0.7,0.9,1.2,1.5,1.6c0.6,0.4,1.4,0.5,2.4,0.5c0.8,0,1.5-0.2,2-0.5c0.5-0.4,0.7-0.8,0.7-1.5c0-1-1.1-1.7-3.2-2.2c-0.6-0.1-1.1-0.3-1.5-0.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.8,20.6c-0.3,0.3-0.6,0.4-1.1,0.4h-0.2v3.3v0.2c0,0.3,0,0.5-0.1,0.6s-0.2,0.2-0.4,0.4c-0.5,0.3-1.4,0.6-2.5,0.8c-1.1,0.2-2.3,0.4-3.5,0.4c-2.4,0-4.4-0.8-5.9-2.4c-1.5-1.6-2.2-3.7-2.2-6.2c0-2.5,0.8-4.5,2.3-6.2c1.5-1.6,3.4-2.5,5.8-2.5c0.6,0,1.3,0.1,1.9,0.2s1.3,0.4,2,0.7c0.2-0.3,0.4-0.6,0.6-0.7c0.2-0.1,0.4-0.2,0.7-0.2c0.5,0,0.8,0.1,1,0.4c0.2,0.2,0.3,0.6,0.3,1.2l0,3.6c0,0.6-0.1,1.1-0.3,1.3c-0.2,0.2-0.6,0.3-1.1,0.3c-0.4,0-0.7-0.1-0.9-0.3c-0.2-0.2-0.4-0.5-0.5-1C53.3,14,53,13.4,52.5,13s-1.2-0.6-2.2-0.6c-1.4,0-2.5,0.5-3.3,1.4c-0.8,1-1.1,2.3-1.1,4.2s0.4,3.2,1.2,4.2c0.8,1,1.9,1.5,3.4,1.5c0.3,0,0.7,0,1.1-0.1c0.4-0.1,0.9-0.2,1.5-0.4V21h-1.6c-0.6,0-1.1-0.1-1.3-0.3c-0.3-0.2-0.4-0.6-0.4-1.1c0-0.6,0.1-0.9,0.4-1.2s0.7-0.4,1.3-0.4h5c0.6,0,1.1,0.1,1.4,0.3s0.4,0.6,0.4,1.2C58.2,20,58.1,20.4,57.8,20.6z"
3737
metadata _ide is "true"
3838

@@ -254,6 +254,46 @@ metadata fillRule.default is "non-zero"
254254
metadata fillRule.label is "Fill rule"
255255
--
256256

257+
/**
258+
Syntax:
259+
get the pathBoundingBox of <widget>
260+
261+
Summary: The bounding box of property iconPath
262+
263+
Description:
264+
Returns the bounding box of the current iconPath property. This is the rectangle of the path in local widget coordinates.
265+
*/
266+
property "pathBoundingBox" get getBB
267+
metadata pathBoundingBox.editor is "com.livecode.pi.string"
268+
metadata pathBoundingBox.default is ""
269+
metadata pathBoundingBox.section is "Basic"
270+
metadata pathBoundingBox.label is "Bounding Box"
271+
272+
/**
273+
Syntax:
274+
get the tranlatedPathBoundingBox of <widget>
275+
276+
Summary: The boundng box of the translated path
277+
278+
Description:
279+
The result should start with "0,0" and is then followed by the width and height of the translated path.
280+
Use the <translatedPathBoundingBox> property together with the <translatedIconPath> property when using the current iconPath of the widget outside of the widget.
281+
*/
282+
property "translatedPathBoundingBox" get getTranslatedBB
283+
metadata translatedPathBoundingBox.user_visible is "false"
284+
285+
/**
286+
Syntax:
287+
get the translatedIconPath of <widget>
288+
289+
Summary: The current iconPath translated to have a bounding box with topleft (0,0).
290+
291+
Description:
292+
Use the <translatedIconPath> property together with the <translatedPathBoundingBox> property whenusing the current iconPath of the widget outside of the widget.
293+
*/
294+
property "translatedIconPath" get getTranslatedPath
295+
metadata translatedIconPath.user_visible is "false"
296+
257297
----------
258298
-- called when widget is created
259299
public handler OnCreate()
@@ -371,6 +411,30 @@ public handler setFillRule(in pRule as String) returns nothing
371411
redraw all
372412
end handler
373413

414+
handler getBB() returns String
415+
return the bounding box of mPath
416+
end handler
417+
418+
handler getTranslatedBB() returns String
419+
return the bounding box of translatePath()
420+
end handler
421+
422+
handler translatePath() returns Path
423+
variable tPath as Path
424+
variable tRect as Rectangle
425+
put mPath into tPath
426+
put the bounding box of tPath into tRect
427+
translate tPath by [-the left of tRect, -the top of tRect]
428+
return tPath
429+
end handler
430+
431+
handler getTranslatedPath() returns String
432+
variable tS as String
433+
put the instructions of translatePath() into tS
434+
replace ".000000" with "" in tS
435+
return tS
436+
end handlery
437+
374438
----------
375439
-- called whenever LiveCode needs to redraw the widget
376440
public handler OnPaint()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.