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.

[[ SVGPath ]] Add bounding box properties #6699

Open
wants to merge 1 commit into
base: develop
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion 66 extensions/widgets/svgpath/svgpath.lcb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use com.livecode.library.widgetutils
-- adding metadata to ensure the extension displays correctly in livecode
metadata title is "SVG Icon"
metadata author is "LiveCode"
metadata version is "2.1.1"
metadata version is "3.0.0"
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.4c-1.8-0.5-3-1.1-3.7-1.8c-0.7-0.7-1-1.7-1-2.9c0-1.6,0.6-2.9,1.8-3.9c1.2-1,2.7-1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.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"
metadata _ide is "true"

Expand Down Expand Up @@ -254,6 +254,46 @@ metadata fillRule.default is "non-zero"
metadata fillRule.label is "Fill rule"
--

/**
Syntax:
get the pathBoundingBox of <widget>

Summary: The bounding box of property iconPath

Description:
Returns the bounding box of the current iconPath property. This is the rectangle of the path in local widget coordinates.
*/
property "pathBoundingBox" get getBB
metadata pathBoundingBox.editor is "com.livecode.pi.string"
metadata pathBoundingBox.default is ""
metadata pathBoundingBox.section is "Basic"
metadata pathBoundingBox.label is "Bounding Box"

/**
Syntax:
get the tranlatedPathBoundingBox of <widget>

Summary: The bounding box of the translated path

Description:
The result should start with "0,0" and is then followed by the width and height of the translated path.
Use the <translatedPathBoundingBox> property together with the <translatedIconPath> property when using the current iconPath of the widget outside of the widget.
*/
property "translatedPathBoundingBox" get getTranslatedBB
metadata translatedPathBoundingBox.user_visible is "false"

/**
Syntax:
get the translatedIconPath of <widget>

Summary: The current iconPath translated to have a bounding box with topleft (0,0).

Description:
Use the <translatedIconPath> property together with the <translatedPathBoundingBox> property whenusing the current iconPath of the widget outside of the widget.
*/
property "translatedIconPath" get getTranslatedPath
metadata translatedIconPath.user_visible is "false"

----------
-- called when widget is created
public handler OnCreate()
Expand Down Expand Up @@ -371,6 +411,30 @@ public handler setFillRule(in pRule as String) returns nothing
redraw all
end handler

handler getBB() returns String
return the bounding box of mPath
end handler

handler getTranslatedBB() returns String
return the bounding box of translatePath()
end handler

handler translatePath() returns Path
variable tPath as Path
variable tRect as Rectangle
put mPath into tPath
put the bounding box of tPath into tRect
translate tPath by [-the left of tRect, -the top of tRect]
return tPath
end handler

handler getTranslatedPath() returns String
variable tS as String
put the instructions of translatePath() into tS
replace ".000000" with "" in tS
return tS
end handler

----------
-- called whenever LiveCode needs to redraw the widget
public handler OnPaint()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.