diff --git a/.gitattributes b/.gitattributes index 88fa646..a553685 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,7 +4,7 @@ *.html linguist-detectable=true *.json linguist-detectable=true -# Set default behaviour, in case users don't have core.autocrlf set. +# Set default behaviour, in case users don't have core.autoLF set. * text=auto # Explicitly declare text files we want to always be normalized and converted @@ -15,13 +15,13 @@ *.html text # Declare files that will always have LF line endings on checkout. -*.json text eol=CRLF -*.livecodescript text eol=CRLF -*.livecodescript text eol=CRLF -*.html text eol=CRLF +*.json text eol=LF +*.livecodescript text eol=LF +*.livecodescript text eol=LF +*.html text eol=LF -# These files are processed by cygwin+bash so make sure they don't end with CRLF -prebuilt/versions/* text eol=CRLF +# These files are processed by cygwin+bash so make sure they don't end with LF +prebuilt/versions/* text eol=LF # Denote all files that are truly binary and should not be modified. *.png binary diff --git a/DevGuides Installer.livecode b/DevGuides Installer.livecode index 9c79baf..b451cf6 100644 Binary files a/DevGuides Installer.livecode and b/DevGuides Installer.livecode differ diff --git a/DevGuides.livecodescript b/DevGuides.livecodescript index 907101e..38fcdae 100644 --- a/DevGuides.livecodescript +++ b/DevGuides.livecodescript @@ -1,19 +1,19 @@ script "community.ferruslogic.plugin.devguides" /* * DevGuides -* (c) FerrusLogic Team +* ( c ) FerrusLogic Team * August 2021 -* version 1.0.2 +* version 1.0.3 * * This code is part of DevGuides extension created by FerrusLogic team to provide design guides to * help LiveCode developers in the process of designing graphic interfaces in an easy and modern way */ local sMessageID, sGridSystem, sThisCard, sControls, sLabels, sPendingMessages -constant kGuideLineColor = "255,0,255" , kGuideLabelColor = "56,56,255" +constant kGuideLineColor = "255,0,255" ,kGuideLabelColor = "56,56,255" on extensionInitialize - if the target is not me then pass extensionInitialize + if the target is not me or the long id of me is among the lines of the backscripts then pass extensionInitialize insert the script of me into back set the _ideoverride of me to true @@ -22,6 +22,7 @@ on extensionInitialize revIDESubscribe "ideMouseMove" revIDESubscribe "ideSelectedObjectChanged" revIDESubscribe "ideOpenStack" + get _enableDevGuides() put empty into sMessageID end extensionInitialize @@ -35,55 +36,70 @@ end extensionFinalize on closeCard - deleteDevGuides + _deleteDevGuides pass closeCard end closeCard on preOpenCard - deleteDevGuides + _deleteDevGuides pass preOpenCard end preOpenCard on closeCard - deleteDevGuides + _deleteDevGuides pass closeCard end closeCard on ideToolChanged - deleteDevGuides + _deleteDevGuides end ideToolChanged on ideSelectedObjectChanged - deleteDevGuides + _deleteDevGuides end ideSelectedObjectChanged -on rawKeyDown - deleteDevGuides +on rawKeyDown pKeyCode + if pKeyCode >= 65361 and pKeyCode <= 65364 then + _arrowKeyUp + + else if the controlKey is down and the shiftKey is down then - _enableDevGuides + _enableDevGuides + + else if the controlKey is "up" then + _deleteDevGuides + end if - pass rawKeyDown + end if + + pass rawKeyDown end rawKeyDown -on rawKeyUp - ideMouseMove + +on rawKeyUp pKeyCode + if not(pKeyCode >= 65361 and pKeyCode <= 65364) then + _deleteDevGuides + if sMessageID is a number then cancel sMessageID + end if + pass rawKeyUp end rawKeyUp + on ideMouseMove pX, pY local tSelectedObjects, tThisStack, tThisCard, tDefaultStack put the selectedObjects into tSelectedObjects if the tool <> "pointer tool" or tSelectedObjects is empty then exit ideMouseMove - put the short name of the topstack into tThisStack + if sMessageID is an integer or word 1 of tSelectedObjects is in "stack card" or _stackNameIsIDEStack( tThisStack ) then - deleteDevGuides empty, sThisCard + _deleteDevGuides empty, sThisCard exit ideMouseMove end if @@ -93,30 +109,36 @@ on ideMouseMove pX, pY set the defaultStack to tDefaultStack if sMessageID is a number then cancel sMessageID - send "updateDevGuides tThisCard" to me in 10 millisec - put the result into sMessageID - + if sPendingMessages is not true then + lock screen + send "updateDevGuides tThisCard" to me in 10 millisec + put the result into sMessageID + end if end ideMouseMove on updateDevGuides pThisCard local tSelectedObjects, tTergetProperty - if sPendingMessages is true or not _enableDevGuides() then exit updateDevGuides - put true into sPendingMessages + if sPendingMessages is true or not _enableDevGuides() + then exit updateDevGuides + + + put true into sPendingMessages put pThisCard into sThisCard put empty into sMessageID put the selectedObjects into tSelectedObjects lock screen; lock messages + _deleteDevGuides + if the tool <> "pointer tool" then - deleteDevGuides put false into sPendingMessages unlock messages; unlock screen exit updateDevGuides - else if mouse( 1 ) is up and controlKey() is up then - deleteDevGuides + + else if mouse(1) is "up" and controlKey() is "up" then put false into sPendingMessages unlock messages; unlock screen exit updateDevGuides @@ -137,262 +159,235 @@ on updateDevGuides pThisCard unlock messages; unlock screen end updateDevGuides +private command _arrowKeyUp + --lock screen + ideMouseMove + --unlock screen +end _arrowKeyUp +private command _deleteDevGuides + if sControls is an array then -command deleteDevGuides pLongId - local tChildControlIDs, tThisCard - - if there is a pLongId then - delete pLongId - exit deleteDevGuides - end if - + repeat for each element tControl in sControls + if there is a tControl then delete tControl + end repeat - if the tool <> "pointer tool" then - repeat for each element e in sControls - if there is a e then - delete e - end if - end repeat - delete variable sControls - exit deleteDevGuides - end if - - if sControls is an array then - repeat for each element e in sControls - if there is a e then - delete e - end if - end repeat - delete variable sControls - end if - - if sThisCard is no empty and there is no sThisCard then exit deleteDevGuides - if sThisCard is empty then put the long id of this card into tThisCard - else put sThisCard into tThisCard - - _childControlIDs tThisCard, tChildControlIDs - - repeat for each line tControl in tChildControlIDs - if the cDevDesigns of tControl is true then - delete tControl - end if - end repeat + delete variable sControls + end if - put empty into sThisCard -end deleteDevGuides + put empty into sThisCard +end _deleteDevGuides private command _childControlIDs @pThisCard, @pChildControlIDs, pSelectedObjects local tNumControl, tLongId, tOwner, tOwners - + if pSelectedObjects is no empty then - put the selectedObjects into pSelectedObjects - - repeat for each line tLine in pSelectedObjects - put _biggestOwner( tLine ) into tOwner - - if tOwner is not empty and tOwner is no pThisCard then - put tOwner & cr after tOwners - - end if - end repeat - end if - + put the selectedObjects into pSelectedObjects + + repeat for each line tLine in pSelectedObjects + put _biggestOwner( tLine ) into tOwner + + if tOwner is not empty and tOwner is no pThisCard then + put tOwner & cr after tOwners + + end if + end repeat + end if + put empty into tOwner - + put the number of controls of pThisCard into tNumControl - + repeat with x = 1 to tNumControl - - put the long id of control x of pThisCard into tLongId - put _biggestOwner( tLongId ) into tOwner - - if tLongId is among the lines of pSelectedObjects or tOwner is among the lines of pSelectedObjects then next repeat - if tOwner is pThisCard or (tOwners is no empty and tOwner is among the lines of tOwners) then - put tLongId & cr after pChildControlIDs - end if - + + put the long id of control x of pThisCard into tLongId + put _biggestOwner( tLongId ) into tOwner + + if tLongId is among the lines of pSelectedObjects or tOwner is among the lines of pSelectedObjects then next repeat + if tOwner is pThisCard or (tOwners is no empty and tOwner is among the lines of tOwners) then + put tLongId & cr after pChildControlIDs + end if + end repeat - + end _childControlIDs -private command _drawGuides pLongIdCd, tSelectedObjects , tTergetProperty, pX, pY +private command _drawGuides pLongIdCd, tSelectedObjects ,tTergetProperty, pX, pY local tChildControlIDs, tLongId, tLoc, tX, tY,tValue, tRect local tVerticalPoint1, tVerticalPoint2, tVerticalPoint3, tHorizontalPoint1, tHorizontalPoint2, tHorizontalPoint3 - local tWidthCard, tHeightCard, tDisMinV, tDisMinH, tDifferenceV, tDifferenceH, tMargins - - put 0 into tMargins + local tWidthCard, tHeightCard, tDisMinV, tDisMinH, tDifferenceV, tDifferenceH + put 1 into tDisMinV put 1 into tDisMinH - + _childControlIDs pLongIdCd, tChildControlIDs, tSelectedObjects - + put the width of pLongIdCd into tWidthCard put the height of pLongIdCd into tHeightCard - - + + # the loc of this card put the loc of pLongIdCd into tLoc - + # the rect of this card - put the left of pLongIdCd + tMargins into tRect["left"] - put the top of pLongIdCd + tMargins into tRect["top"] - put the right of pLongIdCd - tMargins into tRect["right"] - put the bottom of pLongIdCd - tMargins into tRect["bottom"] - + put the left of pLongIdCd into tRect["left"] + put the top of pLongIdCd into tRect["top"] + put the right of pLongIdCd into tRect["right"] + put the bottom of pLongIdCd into tRect["bottom"] + put the item 1 of tLoc into tRect["x"] put the item 2 of tLoc into tRect["y"] - + # Left _calcGuideLineProp pLongIdCd, "left", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint1, tHeightCard, tDisMinV, tDifferenceV # X _calcGuideLineProp pLongIdCd, "x", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint2, tHeightCard, tDisMinV, tDifferenceV # Right _calcGuideLineProp pLongIdCd, "right", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint3, tHeightCard, tDisMinV, tDifferenceV - + # Top _calcGuideLineProp pLongIdCd, "top", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint1, tWidthCard, tDisMinH, tDifferenceH # y _calcGuideLineProp pLongIdCd, "y", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint2, tWidthCard, tDisMinH, tDifferenceH # bottom _calcGuideLineProp pLongIdCd, "bottom", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint3, tWidthCard, tDisMinH, tDifferenceH - - + + # Calc repeat for each line tLongID in tChildControlIDs - - -- Ignora a los objetos seleccionados. - if the visible of tLongID is false or tTergetProperty["ignore"][tLongID] is true then next repeat - - -- Elimina los posibles residuos de DevGuides - if the cTemporaryGraphic of tLongId is true then - try - delete tLongId - end try - next repeat - end if - - - # the loc of this control - put the loc of tLongId into tLoc - - # the rect of this control - put the left of tLongId into tRect["left"] - put the top of tLongId into tRect["top"] - put the right of tLongId into tRect["right"] - put the bottom of tLongId into tRect["bottom"] - put the item 1 of tLoc into tRect["x"] - put the item 2 of tLoc into tRect["y"] - - ---> Vertical guides <--- - # Left - _calcGuideLineProp tLongId, "left", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint1, tHeightCard, tDisMinV, tDifferenceV - # Right - _calcGuideLineProp tLongId, "right", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint3, tHeightCard, tDisMinV, tDifferenceV - # X - _calcGuideLineProp tLongId, "x", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint2, tHeightCard, tDisMinV, tDifferenceV - - - --> Horizontal guides <--- - # Top - _calcGuideLineProp tLongId, "top", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint1, tWidthCard, tDisMinH, tDifferenceH - # y - _calcGuideLineProp tLongId, "y", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint2, tWidthCard, tDisMinH, tDifferenceH - # bottom - _calcGuideLineProp tLongId, "bottom", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint3, tWidthCard, tDisMinH, tDifferenceH - + + -- Ignora a los objetos seleccionados. + if the visible of tLongID is false or tTergetProperty["ignore"][tLongID] is true then next repeat + + -- Elimina los posibles residuos de DevGuides + if the cTemporaryGraphic of tLongId is true then + try + delete tLongId + end try + next repeat + end if + + + # the loc of this control + put the loc of tLongId into tLoc + + # the rect of this control + put the left of tLongId into tRect["left"] + put the top of tLongId into tRect["top"] + put the right of tLongId into tRect["right"] + put the bottom of tLongId into tRect["bottom"] + put the item 1 of tLoc into tRect["x"] + put the item 2 of tLoc into tRect["y"] + + ---> Vertical guides <--- + # Left + _calcGuideLineProp tLongId, "left", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint1, tHeightCard, tDisMinV, tDifferenceV + # Right + _calcGuideLineProp tLongId, "right", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint3, tHeightCard, tDisMinV, tDifferenceV + # X + _calcGuideLineProp tLongId, "x", "left", "right", "top", "bottom", "min", "max","x", tTergetProperty, tRect, tVerticalPoint2, tHeightCard, tDisMinV, tDifferenceV + + + --> Horizontal guides <--- + # Top + _calcGuideLineProp tLongId, "top", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint1, tWidthCard, tDisMinH, tDifferenceH + # y + _calcGuideLineProp tLongId, "y", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint2, tWidthCard, tDisMinH, tDifferenceH + # bottom + _calcGuideLineProp tLongId, "bottom", "top", "bottom", "left", "right", "min", "max","y", tTergetProperty, tRect, tHorizontalPoint3, tWidthCard, tDisMinH, tDifferenceH + end repeat - - + + -- draw limit _drawLimit tVerticalPoint1, tVerticalPoint2, tVerticalPoint3, tDisMinV _drawLimit tHorizontalPoint1, tHorizontalPoint2, tHorizontalPoint3, tDisMinH - + local tNewLeft = true, tNewTop = true, tDrawLimitUp = true, tDrawLimitDown = true - + -- Vertical if tVerticalPoint1[ "create" ] is true and tVerticalPoint1["distance"] is tDisMinV then - _drawingGuideLine tVerticalPoint1, tTergetProperty, "height", "top", "left", 0 - - put tVerticalPoint1["hook"] into tNewLeft + _drawingGuideLine tVerticalPoint1, tTergetProperty, "height", "top", "left", 0 + + put tVerticalPoint1["hook"] into tNewLeft else - put false into tVerticalPoint1[ "create" ] + put false into tVerticalPoint1[ "create" ] end if - + if tVerticalPoint2[ "create" ] is true and tVerticalPoint2["distance"] is tDisMinV then - if tNewLeft then - put tVerticalPoint2["hook"] into tNewLeft - end if - - add (tTergetProperty["x"] - tTergetProperty["left"]) to tVerticalPoint2["hook"] - _drawingGuideLine tVerticalPoint2, tTergetProperty, "height", "top", "left", 0 - + if tNewLeft then + put tVerticalPoint2["hook"] into tNewLeft + end if + + add (tTergetProperty["x"] - tTergetProperty["left"]) to tVerticalPoint2["hook"] + _drawingGuideLine tVerticalPoint2, tTergetProperty, "height", "top", "left", 0 + else - put false into tVerticalPoint2[ "create" ] + put false into tVerticalPoint2[ "create" ] end if - - + + if tVerticalPoint3[ "create" ] is true and tVerticalPoint3["distance"] is tDisMinV then - if tNewLeft then - put tVerticalPoint3["hook"] into tNewLeft - end if - - add tTergetProperty["width"] to tVerticalPoint3["hook"] - _drawingGuideLine tVerticalPoint3, tTergetProperty, "height", "top", "left", 0 - + if tNewLeft then + put tVerticalPoint3["hook"] into tNewLeft + end if + + add tTergetProperty["width"] to tVerticalPoint3["hook"] + _drawingGuideLine tVerticalPoint3, tTergetProperty, "height", "top", "left", 0 + else - put false into tVerticalPoint3[ "create" ] + put false into tVerticalPoint3[ "create" ] end if - - + + -- Horizontal if tHorizontalPoint1[ "create" ] is true and tHorizontalPoint1["distance"] is tDisMinH then - _drawingGuideLine tHorizontalPoint1, tTergetProperty, "width", "left", "top", 10 - - put tHorizontalPoint1["hook"] into tNewTop + _drawingGuideLine tHorizontalPoint1, tTergetProperty, "width", "left", "top", 10 + + put tHorizontalPoint1["hook"] into tNewTop else - put false into tHorizontalPoint1[ "create" ] + put false into tHorizontalPoint1[ "create" ] end if - + if tHorizontalPoint2[ "create" ] is true and tHorizontalPoint2["distance"] is tDisMinH then - if tNewTop then - put tHorizontalPoint2["hook"] into tNewTop - end if - - add (tTergetProperty["y"] - tTergetProperty["top"]) to tHorizontalPoint2["hook"] - - _drawingGuideLine tHorizontalPoint2, tTergetProperty, "width", "left", "top", 10 - + if tNewTop then + put tHorizontalPoint2["hook"] into tNewTop + end if + + add (tTergetProperty["y"] - tTergetProperty["top"]) to tHorizontalPoint2["hook"] + + _drawingGuideLine tHorizontalPoint2, tTergetProperty, "width", "left", "top", 10 + else - put false into tHorizontalPoint2[ "create" ] + put false into tHorizontalPoint2[ "create" ] end if - + if tHorizontalPoint3[ "create" ] is true and tHorizontalPoint3["distance"] is tDisMinH then - if tNewTop then - put tHorizontalPoint3["hook"] into tNewTop - end if - - add tTergetProperty["height"] to tHorizontalPoint3["hook"] - - _drawingGuideLine tHorizontalPoint3, tTergetProperty, "width", "left", "top", 10 + if tNewTop then + put tHorizontalPoint3["hook"] into tNewTop + end if + + add tTergetProperty["height"] to tHorizontalPoint3["hook"] + + _drawingGuideLine tHorizontalPoint3, tTergetProperty, "width", "left", "top", 10 else - put false into tHorizontalPoint3[ "create" ] + put false into tHorizontalPoint3[ "create" ] end if - - + + if tNewLeft is an integer then - _toHook tSelectedObjects , tTergetProperty, "left", tNewLeft + _toHook tSelectedObjects , tTergetProperty, "left", tNewLeft end if - + if tNewTop is an integer then - _toHook tSelectedObjects , tTergetProperty, "top", tNewTop + _toHook tSelectedObjects , tTergetProperty, "top", tNewTop end if - - + + end _drawGuides @@ -400,22 +395,22 @@ private command _drawLimit @pPoint1, @pPoint2, @pPoint3, @pDis # Draw limit up if pPoint1["distance"] is pDis and pPoint1["drawLimitUp"] is true and pPoint2["drawLimitUp"] is true then - put false into pPoint2["drawLimitUp"] + put false into pPoint2["drawLimitUp"] end if if pPoint1["distance"] is pDis and pPoint1["drawLimitUp"] is true and pPoint3["drawLimitUp"] is true or\ - pPoint2["distance"] is pDis and pPoint2["drawLimitUp"] is true and pPoint3["drawLimitUp"] is true then - put false into pPoint3["drawLimitUp"] + pPoint2["distance"] is pDis and pPoint2["drawLimitUp"] is true and pPoint3["drawLimitUp"] is true then + put false into pPoint3["drawLimitUp"] end if # Draw limit down if pPoint1["distance"] is pDis and pPoint1["drawLimitDown"] is true and pPoint2["drawLimitDown"] is true then - put false into pPoint2["drawLimitDown"] + put false into pPoint2["drawLimitDown"] end if if pPoint1["distance"] is pDis and pPoint1["drawLimitDown"] is true and pPoint3["drawLimitDown"] is true or\ - pPoint2["distance"] is pDis and pPoint2["drawLimitDown"] is true and pPoint3["drawLimitDown"] is true then - put false into pPoint3["drawLimitDown"] + pPoint2["distance"] is pDis and pPoint2["drawLimitDown"] is true and pPoint3["drawLimitDown"] is true then + put false into pPoint3["drawLimitDown"] end if end _drawLimit @@ -429,10 +424,10 @@ private command _drawingGuideLine @pVerticalPoint, @pTergetProperty, pMainSize, put _createTemporaryGraphic() into tLongId if pCrossStart is "top" then - put "bottom" into tCrossEnd + put "bottom" into tCrossEnd else if pCrossStart is "left" then - put "right" into tCrossEnd + put "right" into tCrossEnd end if @@ -445,100 +440,100 @@ private command _drawingGuideLine @pVerticalPoint, @pTergetProperty, pMainSize, if pVerticalPoint[ "drawLimitUp" ] is true then - # Back of label 1 - - put pTergetProperty[ pCrossStart ] - pVerticalPoint[ "LimitUp" ] into pVerticalPoint[ "sizeLimitUp" ] - put pVerticalPoint[ "sizeLimitUp" ] into pVerticalPoint[ "label-1" ] - - put _createTemporaryGraphic() into tLongId - try - set the pMainSize of tLongId to pVerticalPoint["sizeLimitUp"] - set the pCrossStart of tLongId to pVerticalPoint["LimitUp"] - set the pMainStart of tLongId to pVerticalPoint["hook"] - set the backColor of tLongId to kGuideLabelColor - set the foregroundColor of tLongId to kGuideLabelColor - set the visible of tLongId to true - put the loc of tLongId into tLoc - end try - - if there is no a tLongId then exit _drawingGuideLine - - if item 2 of tLoc > 25 then - subtract pSpace from item 2 of tLoc - else - add pSpace to item 2 of tLoc - end if - - # Label 1 - put _createTemporaryGraphic() into tLongId - - try - set the height of tLongId to 20 - set the width of tLongId to 50 - set the backColor of tLongId to kGuideLabelColor - set the foregroundColor of tLongId to kGuideLabelColor - set the opaque of tLongId to false - set the showName of tLongId to true - set the label of tLongId to pVerticalPoint[ "label-1" ] - put tLongId into sLabels[1][pCrossStart] - end try - - if pVerticalPoint["hook"] < 50 then - set the textAlign of tLongId to "left" - add 28 to the item 1 of tLoc - else - subtract 28 from the item 1 of tLoc - set the textAlign of tLongId to "right" - end if - - set the loc of tLongId to tLoc - set the visible of tLongId to true + # Back of label 1 + + put pTergetProperty[ pCrossStart ] - pVerticalPoint[ "LimitUp" ] into pVerticalPoint[ "sizeLimitUp" ] + put pVerticalPoint[ "sizeLimitUp" ] into pVerticalPoint[ "label-1" ] + + put _createTemporaryGraphic() into tLongId + try + set the pMainSize of tLongId to pVerticalPoint["sizeLimitUp"] + set the pCrossStart of tLongId to pVerticalPoint["LimitUp"] + set the pMainStart of tLongId to pVerticalPoint["hook"] + set the backColor of tLongId to kGuideLabelColor + set the foregroundColor of tLongId to kGuideLabelColor + set the visible of tLongId to true + put the loc of tLongId into tLoc + end try + + if there is no a tLongId then exit _drawingGuideLine + + if item 2 of tLoc > 25 then + subtract pSpace from item 2 of tLoc + else + add pSpace to item 2 of tLoc + end if + + # Label 1 + put _createTemporaryGraphic() into tLongId + + try + set the height of tLongId to 20 + set the width of tLongId to 50 + set the backColor of tLongId to kGuideLabelColor + set the foregroundColor of tLongId to kGuideLabelColor + set the opaque of tLongId to false + set the showName of tLongId to true + set the label of tLongId to abs(pVerticalPoint[ "label-1" ]) + put tLongId into sLabels[1][pCrossStart] + end try + + if pVerticalPoint["hook"] < 50 then + set the textAlign of tLongId to "left" + add 28 to the item 1 of tLoc + else + subtract 28 from the item 1 of tLoc + set the textAlign of tLongId to "right" + end if + + set the loc of tLongId to tLoc + set the visible of tLongId to true end if if pVerticalPoint[ "drawLimitDown" ] is true then - # Back of label 2 - put pVerticalPoint[ "LimitDown" ] - pTergetProperty[ tCrossEnd ] into pVerticalPoint[ "sizeLimitDown" ] - put pVerticalPoint[ "sizeLimitDown" ]into pVerticalPoint[ "label-2" ] - put _createTemporaryGraphic() into tLongId - - set the pMainSize of tLongId to pVerticalPoint["sizeLimitDown"] - set the tCrossEnd of tLongId to pVerticalPoint["LimitDown"] - set the pMainStart of tLongId to pVerticalPoint["hook"] - set the backColor of tLongId to kGuideLabelColor - set the foregroundColor of tLongId to kGuideLabelColor - set the visible of tLongId to true - put the loc of tLongId into tLoc - - if item 2 of tLoc > 25 then - subtract pSpace from item 2 of tLoc - else - add pSpace to item 2 of tLoc - end if - - # Label 2 - put _createTemporaryGraphic() into tLongId - - set the height of tLongId to 20 - set the width of tLongId to 50 - set the backColor of tLongId to kGuideLabelColor - set the foregroundColor of tLongId to kGuideLabelColor - set the opaque of tLongId to false - set the showName of tLongId to true - set the label of tLongId to pVerticalPoint[ "label-2" ] - put tLongId into sLabels[2][pCrossStart] - - if pVerticalPoint["hook"] < 50 then - set the textAlign of tLongId to "left" - add 28 to the item 1 of tLoc - else - subtract 28 from the item 1 of tLoc - set the textAlign of tLongId to "right" - end if - - set the loc of tLongId to tLoc - set the visible of tLongId to true + # Back of label 2 + put pVerticalPoint[ "LimitDown" ] - pTergetProperty[ tCrossEnd ] into pVerticalPoint[ "sizeLimitDown" ] + put pVerticalPoint[ "sizeLimitDown" ] into pVerticalPoint[ "label-2" ] + put _createTemporaryGraphic() into tLongId + + set the pMainSize of tLongId to pVerticalPoint["sizeLimitDown"] + set the tCrossEnd of tLongId to pVerticalPoint["LimitDown"] + set the pMainStart of tLongId to pVerticalPoint["hook"] + set the backColor of tLongId to kGuideLabelColor + set the foregroundColor of tLongId to kGuideLabelColor + set the visible of tLongId to true + put the loc of tLongId into tLoc + + if item 2 of tLoc > 25 then + subtract pSpace from item 2 of tLoc + else + add pSpace to item 2 of tLoc + end if + + # Label 2 + put _createTemporaryGraphic() into tLongId + + set the height of tLongId to 20 + set the width of tLongId to 50 + set the backColor of tLongId to kGuideLabelColor + set the foregroundColor of tLongId to kGuideLabelColor + set the opaque of tLongId to false + set the showName of tLongId to true + set the label of tLongId to abs( pVerticalPoint[ "label-2" ]) + put tLongId into sLabels[2][pCrossStart] + + if pVerticalPoint["hook"] < 50 then + set the textAlign of tLongId to "left" + add 28 to the item 1 of tLoc + else + subtract 28 from the item 1 of tLoc + set the textAlign of tLongId to "right" + end if + + set the loc of tLongId to tLoc + set the visible of tLongId to true end if end _drawingGuideLine @@ -551,17 +546,17 @@ private command _calcGuideLineProp pLongId, pMain, pMainStart, pMainEnd, pCrossS if tValue["distance"] < pDistance then - _resetLimit pTergetProperty, tValue, pDistance, pPointArray, pMaxLimit, pMainStart, pCrossStart, pCrossEnd + _resetLimit pTergetProperty, tValue, pDistance, pPointArray, pMaxLimit, pMainStart, pCrossStart, pCrossEnd - _updateLimit pLongId, pTergetProperty, pMainStart, pCrossStart, pCrossEnd, tValue, pPointArray + _updateLimit pLongId, pTergetProperty, pMainStart, pCrossStart, pCrossEnd, tValue, pPointArray else if tValue["distance"] = pDistance then - if pPointArray[ "create" ] is not true then - _resetLimit pTergetProperty, tValue, pDistance, pPointArray, pMaxLimit, pMainStart, pCrossStart, pCrossEnd - end if + if pPointArray[ "create" ] is not true then + _resetLimit pTergetProperty, tValue, pDistance, pPointArray, pMaxLimit, pMainStart, pCrossStart, pCrossEnd + end if - _updateLimit pLongId, pTergetProperty, pMainStart, pCrossStart, pCrossEnd, tValue, pPointArray + _updateLimit pLongId, pTergetProperty, pMainStart, pCrossStart, pCrossEnd, tValue, pPointArray end if end _calcGuideLineProp @@ -599,13 +594,13 @@ private command _updateLimit @pLongId, @pTergetProperty, @pMainStart, @pCrossSta put the pCrossStart of pLongId into tCrossStartValue if pPointArray[ "min" ] >= tCrossStartValue then - put tCrossStartValue into pPointArray[ "min" ] + put tCrossStartValue into pPointArray[ "min" ] end if --- put the pCrossEnd of pLongId into tCrossEndValue if pPointArray[ "max" ] <= tCrossEndValue then - put tCrossEndValue into pPointArray[ "max" ] + put tCrossEndValue into pPointArray[ "max" ] end if --------------------------------------------- @@ -614,24 +609,24 @@ private command _updateLimit @pLongId, @pTergetProperty, @pMainStart, @pCrossSta # Limit Up if tLimitMax >= pPointArray[ "limitUp" ] and tLimitMax <= pTergetProperty[pCrossStart] then - put tLimitMax into pPointArray[ "limitUp" ] - put true into pPointArray[ "drawLimitUp" ] + put tLimitMax into pPointArray[ "limitUp" ] + put true into pPointArray[ "drawLimitUp" ] else if tLimitMin >= pPointArray[ "limitUp" ] and tLimitMin <= pTergetProperty[pCrossStart] then - put tLimitMin into pPointArray[ "limitUp" ] - put true into pPointArray[ "drawLimitUp" ] + put tLimitMin into pPointArray[ "limitUp" ] + put true into pPointArray[ "drawLimitUp" ] end if # Limit Down if tLimitMin <= pPointArray[ "limitDown" ] and tLimitMin >= pTergetProperty[pCrossEnd] then - put tLimitMin into pPointArray[ "limitDown" ] - put true into pPointArray[ "drawLimitDown" ] + put tLimitMin into pPointArray[ "limitDown" ] + put true into pPointArray[ "drawLimitDown" ] else if tLimitMax <= pPointArray[ "limitDown" ] and tLimitMax >= pTergetProperty[pCrossEnd] then - put tLimitMax into pPointArray[ "limitDown" ] - put true into pPointArray[ "drawLimitDown" ] + put tLimitMax into pPointArray[ "limitDown" ] + put true into pPointArray[ "drawLimitDown" ] end if end _updateLimit @@ -643,18 +638,16 @@ private command _toHook @pSelectedObjects , @pTergetProperty, pPropName, pNewVal put pNewValue - pTergetProperty[ pPropName ] into tOff - if tOff is 0 then exit _toHook - repeat for each line tControl in pSelectedObjects - set the pPropName of tControl to (the pPropName of tControl + tOff) + set the pPropName of tControl to (the pPropName of tControl + tOff) end repeat if there is a sLabels[ 1 ][pPropName] then - set the label of sLabels[ 1 ][pPropName] to the label of sLabels[ 1 ][pPropName] + tOff + set the label of sLabels[ 1 ][pPropName] to abs( the label of sLabels[ 1 ][pPropName] + tOff ) end if if there is a sLabels[ 2 ][pPropName] then - set the label of sLabels[ 2 ][pPropName] to the label of sLabels[ 1 ][pPropName] + tOff + set the label of sLabels[ 2 ][pPropName] to abs( the label of sLabels[ 2 ][pPropName] + tOff ) end if end _toHook @@ -671,29 +664,29 @@ private function _hook pCurrentValue, pPoint1, pPoint2, pPoint3, pMinOrMax put abs(tDifference3) into tDis3 if pMinOrMax is "max" then - put max( tDis1, tDis2, tDis3) into tValue + put max( tDis1, tDis2, tDis3) into tValue else - put min( tDis1, tDis2, tDis3) into tValue + put min( tDis1, tDis2, tDis3) into tValue end if switch tValue - case tDis1 - put pPoint1 into tValue["value"] - put tDis1 into tValue["distance"] - put tDifference1 * -1 into tValue["difference"] - break - - case tDis2 - put pPoint2 into tValue["value"] - put tDis2 into tValue["distance"] - put tDifference2* -1 into tValue["difference"] - break - - case tDis3 - put pPoint3 into tValue["value"] - put tDis3 into tValue["distance"] - put tDifference3 * -1 into tValue["difference"] - break + case tDis1 + put pPoint1 into tValue["value"] + put tDis1 into tValue["distance"] + put tDifference1 * -1 into tValue["difference"] + break + + case tDis2 + put pPoint2 into tValue["value"] + put tDis2 into tValue["distance"] + put tDifference2* -1 into tValue["difference"] + break + + case tDis3 + put pPoint3 into tValue["value"] + put tDis3 into tValue["distance"] + put tDifference3 * -1 into tValue["difference"] + break end switch @@ -703,12 +696,13 @@ end _hook private function _mouseControl - local tMouseControl + local tMouseControl, tMouseStack put the mouseControl into tMouseControl - - if there is not a tMouseControl then return empty - return _biggestOwner( the long id of tMouseControl ) + put the mouseStack into tMouseStack + if tMouseControl is empty then return empty + set the defaultStack to tMouseStack + return _biggestOwner( the long id of tMouseControl ) end _mouseControl @@ -721,35 +715,35 @@ private function _tergetProperty pThisCard, pControls put the top of pThisCard into tBottom repeat for each line tControl in pControls - if there is a no tControl then exit to top + if there is a no tControl then exit to top - # calc the Left of rectangle - if the left of tControl < tLeft then - put the left of tControl into tLeft - end if + # calc the Left of rectangle + if the left of tControl < tLeft then + put the left of tControl into tLeft + end if - # calc the top of rectangle - if the top of tControl < tTop then - put the top of tControl into tTop - end if + # calc the top of rectangle + if the top of tControl < tTop then + put the top of tControl into tTop + end if - # calc the right of rectangle - if the right of tControl > tRight then - put the right of tControl into tRight - end if + # calc the right of rectangle + if the right of tControl > tRight then + put the right of tControl into tRight + end if - # calc the bottom of rectangle - if the bottom of tControl > tBottom then - put the bottom of tControl into tBottom - end if + # calc the bottom of rectangle + if the bottom of tControl > tBottom then + put the bottom of tControl into tBottom + end if - put _biggestOwner(tControl) into tOwner + put _biggestOwner(tControl) into tOwner - if word 1 of tOwner is not "card" then - put true into tResult["ignore"][tOwner] - else - put true into tResult["ignore"][tControl] - end if + if word 1 of tOwner is not "card" then + put true into tResult["ignore"][tOwner] + else + put true into tResult["ignore"][tControl] + end if end repeat @@ -775,9 +769,9 @@ private function _biggestOwner pLongId put wordOffSet("card", pLongId) into tOffset if tOffset is 5 then - return the word 5 to - 1 of pLongId + return the word 5 to - 1 of pLongId else - return the word tOffset - 4 to - 1 of pLongId + return the word tOffset - 4 to - 1 of pLongId end if end _biggestOwner @@ -815,7 +809,7 @@ private function _createTemporaryGraphic set the cDevDesigns of tGrc to true set the cTemporaryGraphic of tGrc to true - + set the width of tGrc to 1 set the height of tGrc to 1 set the textAlign of tGrc to "center" @@ -824,7 +818,7 @@ private function _createTemporaryGraphic set the cantSelect of tGrc to true set the opaque of tGrc to true set the margins of tGrc to 0 - + put tGrc into sControls[ tGrc] unlock messages @@ -836,10 +830,10 @@ private command _enableDevGuides lock screen; lock messages if _enableDevGuides() then - put false into url ("file:" & revEnvironmentUserCachePath() & "/devguide") + put false into url ("file:" & revEnvironmentUserCachePath() & "/devguide") else - put true into url ("file:" & revEnvironmentUserCachePath() & "/devguide") + put true into url ("file:" & revEnvironmentUserCachePath() & "/devguide") end if @@ -847,13 +841,14 @@ private command _enableDevGuides end _enableDevGuides -private function _enableDevGuides + private function _enableDevGuides if there is no a file(revEnvironmentUserCachePath() & "/devguide") then - put true into url ("file:" & revEnvironmentUserCachePath() & "/devguide") + put true into url ("file:" & revEnvironmentUserCachePath() & "/devguide") end if put false into sPendingMessages put empty into sMessageID + return url ("file:" & revEnvironmentUserCachePath() & "/devguide") end _enableDevGuides diff --git a/README.md b/README.md index 3443e2f..27d9211 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ### August 2021 -### Version 1.0.2 +### Version 1.0.3 DevGuides extension created by FerrusLogic team to provide design guides to help LiveCode developers in the process of designing graphic interfaces in an easy and modern way diff --git a/images/devguides.ico b/images/devguides.ico new file mode 100644 index 0000000..9634d43 Binary files /dev/null and b/images/devguides.ico differ diff --git a/images/devguides.png b/images/devguides.png new file mode 100644 index 0000000..d7af118 Binary files /dev/null and b/images/devguides.png differ