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

Commit ae3c945

Browse files
committed
[[ ExtensionStandaloneSettings ]] Make settings editable on inclusions list
This patch adds a settings icon to the inclusions pane of the standalone settings when there are per-extension standalone settings available. Clicking on this pops up a modeless 'inspector' for any properties declared in standaloneSettings metadata in the extension.
1 parent 9e6ab57 commit ae3c945

3 files changed

Lines changed: 58 additions & 7 deletions

File tree

Toolset/palettes/inspector/behaviors/revinspectoreditorbehavior.livecodescript

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,18 @@ after editorPopup pClickLoc
205205
exit editorPopup
206206
end if
207207
create invisible stack tStackName
208-
dispatch "setAsBehavior" to stack revIDEPaletteResourcePath("behaviors/revinspectorpopupstackbehavior.livecodescript", the long id of stack "revInspector") with the long id of stack tStackName
208+
dispatch "setAsBehavior" to stack \
209+
revIDEPaletteResourcePath("behaviors/revinspectorpopupstackbehavior.livecodescript", \
210+
the long id of stack "revInspector") with the long id of stack tStackName
209211
set the frameHidden of stack tStackName to true
210212
dispatch "inspectorGenerateGroups" to stack tStackName with sPropertyInfo["popup"]
211213
dispatch "inspectorLayoutGroups" to stack tStackName with sPropertyInfo["popup"]
212214
dispatch "inspectorFillGroups" to stack tStackName with sPopupData
213215
set the editorTarget of stack tStackName to the long id of me
214216
// In LC 9.0 DP-7 you can resize the inspector window, by putting all the contents in a group "inspector" and adding a vScrollbar to the group
215217
// but 'modeless stack X' breaks the vScrollbar of groups, so ensure the popup stack has the correct height before going 'modeless'
216-
set the height of stack tStackName to the formattedHeight of group "inspector"
218+
set the height of stack tStackName to \
219+
the formattedHeight of group "inspector" of stack tStackName
217220
set the title of stack tStackName to the rowLabel of the owner of me
218221
modeless stack tStackName
219222
end editorPopup

Toolset/palettes/standalone settings/revstandalonesettingsbehavior.livecodescript

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,13 @@ command updateCardSize
175175
end updateCardSize
176176

177177
on resumeStack
178-
if the short name of this stack is "revStandaloneSettings" then
179-
send "preOpenCard" to the current card
180-
end if
178+
if the short name of this stack is "revStandaloneSettings" then
179+
local tMainstack
180+
put the mainStack of the topStack into tMainstack
181+
if tMainstack is getTargetStack() then
182+
send "preOpenCard" to this card of me in 0 millisecs
183+
end if
184+
end if
181185
end resumeStack
182186

183187
# Parameters

Toolset/palettes/standalone settings/revstandalonesettingsinclusionsrowbehavior.livecodescript

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on FillInData pDataA, pRow
1111
else if pDataA["label"] is not empty then put pDataA["label"] into tLabel
1212
if tLabel is empty then put "Extension Title" into tLabel
1313

14+
set the cLabel of me to tLabel
15+
1416
if pDataA["author"] is not empty then put pDataA["author"] into tAuthor
1517
if tAuthor is empty then put "Unknown Author" into tAuthor
1618

1719
put tLabel into field "description" of me
1820

1921
local tIconName, tIconPath
20-
revSBInclusionIconFromType pDataA["type"], pDataA["id"], tIconName, tIconPath
22+
revIDEExtensionIconFromType pDataA["type"], pDataA["id"], tIconName, tIconPath
2123

2224
if tIconPath is not empty then
2325
set the iconPath of widget "icon" of me to tIconPath
@@ -33,6 +35,13 @@ on FillInData pDataA, pRow
3335
end if
3436
end repeat
3537

38+
if revIDEExtensionStandaloneSettingsInfo(pDataA["id"]) \
39+
is not empty then
40+
show widget "Settings" of me
41+
else
42+
hide widget "Settings" of me
43+
end if
44+
3645
set the cRow of me to pRow
3746
end FillInData
3847

@@ -75,12 +84,47 @@ on LayoutControl pControlRect
7584
put the left of image tItem of me into tRight
7685
end repeat
7786

87+
subtract 2*tPadding from tRight
88+
set the right of widget "Settings" of me to tRight
7889
end LayoutControl
7990

8091
on mouseUp
81-
dispatch "rowClicked" to card "inclusions" of this stack with the cRow of me
92+
if the long id of the target is \
93+
the long id of widget "Settings" of me then
94+
popupExtensionStandaloneSettings the cTypeId of me, the mouseLoc
95+
else
96+
dispatch "rowClicked" to card "inclusions" of this stack with the cRow of me
97+
end if
8298
end mouseUp
8399

100+
command popupExtensionStandaloneSettings pId, pClickLoc
101+
-- TODO: Fetch existing value!
102+
set the behavior of the long id of widget "Settings" of me \
103+
to the long id of stack revIDEPaletteResourcePath("behaviors/revinspectoreditorbehavior.livecodescript", the long ID of stack "revInspector")
104+
set the rowLabel of me to the cLabel of me && "Standalone Settings"
105+
local tPropertyInfo, tPropData, tStack
106+
dispatch function "getTargetStack" to me
107+
put the result into tStack
108+
put "Extension Standalone Settings" into tPropertyInfo["property_name"]
109+
put revIDEStandaloneSettingsInfoOfExtension(pId) \
110+
into tPropertyInfo["popup"]
111+
set the editorPropertyInfo of widget "Settings" of me to tPropertyInfo
112+
set the editorPopupData of widget "Settings" of me to \
113+
revIDEStandaloneSettingsOfExtension(tStack, pId)
114+
send "editorPopup pClickLoc" to widget "Settings" of me
115+
end popupExtensionStandaloneSettings
116+
117+
on valueChanged pProp, pValue
118+
-- extension standalone settings don't get set directly
119+
-- they live in cRevStandaloneSettings[<ext id>][key]
120+
-- and get merged at build time
121+
local tSettings
122+
dispatch function "getSettings" to me
123+
put the result into tSettings
124+
put pValue into tSettings[the cTypeId of me][pProp]
125+
dispatch "setSettings" to me with tSettings
126+
end valueChanged
127+
84128
on mouseDown
85129

86130
end mouseDown

0 commit comments

Comments
 (0)