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

[[ PI ]] Enable scrolling of PI content #1566

Merged
merged 4 commits into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
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
238 changes: 159 additions & 79 deletions Toolset/palettes/behaviors/revinspectorbehavior.livecodescript
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,106 @@ on inspectorOpenEditor pEditor
end inspectorOpenEditor

# Layout inspector
on inspectorLayout
on inspectorLayout pForceHeight
//put "layout inspector" & return after msg
lock screen

# Get the section of the PI we should be laying out
local tSelectedGroup
put inspectorSectionGet() into tSelectedGroup

inspectorLayoutGroups sDataA[tSelectedGroup]["grouplist"]
inspectorLayoutGroups sDataA[tSelectedGroup]["grouplist"], pForceHeight

unlock screen
end inspectorLayout

on inspectorLayoutGroups pGroupList
private function inspectorCalculateLayout pGroupList, pLeft, pTop, pRowWidth, pSubsections, pCurSection, pExpandableExtra, @rCanExpand
local tLeft, tTop
put pLeft into tLeft
put pTop into tTop

local tMaxRowWidth, tInspectorHeight, tColumnNumber, tColumnTop,
local tCanExpand, tRowGroup, tThisCanExpand
put 1 into tColumnNumber
put 0 into tCanExpand
repeat for each element tElement in pGroupList
if pSubsections and tElement["subsection"] is not empty then
# If we have a new subsection, create the subsection header
if tElement["subsection"] is not pCurSection then
lock messages
set the width of group ("Subsection_" & tElement["subsection"]) of me to the formattedwidth of field tElement["subsection"] of group ("Subsection_" & tElement["subsection"]) of me
set the width of field tElement["subsection"] of group ("Subsection_" & tElement["subsection"]) of me to the formattedwidth of field tElement["subsection"] of group ("Subsection_" & tElement["subsection"]) of me
set the topleft of group ("Subsection_" & tElement["subsection"]) of me to tLeft,tTop
unlock messages
add (the formattedheight of field tElement["subsection"] of group ("Subsection_" & tElement["subsection"]) of me) to tTop
put tElement["subsection"] into pCurSection
end if
end if

if there is not a group tElement["label"] of group "inspector" of me then next repeat
put the long id of group tElement["label"] of group "inspector" of me into tRowGroup

# set the width and topleft of the editor
lock messages
set the topleft of tRowGroup to tLeft,tTop
set the lockloc of tRowGroup to true
set the width of tRowGroup to pRowWidth
unlock messages

# Tell the row to resize
dispatch "rowResize" to tRowGroup

local tEditorHeight
# If the editor does not report its own height, use the formatted height
# This tends to report slightly strange values, otherwise we could just use it
# all the time.
put the editorHeight of tRowGroup into tEditorHeight
if not tEditorHeight > 0 then
put the formattedheight of tRowGroup into tEditorHeight
end if

dispatch function "canExpandVertically" to tRowGroup
put the result into tThisCanExpand
if tThisCanExpand then
add 1 to tCanExpand
if pExpandableExtra > 0 then
lock messages
set the height of tRowGroup to tEditorHeight + pExpandableExtra
unlock messages
dispatch "rowResize" to tRowGroup
end if
end if

# Get the margin, padding
local tPadding, tMargin
put the palettePadding of me into tPadding
put the paletteMargin of me into tMargin
lock messages
add tEditorHeight + tPadding to tTop

if pRowWidth > tMaxRowWidth then
put pRowWidth into tMaxRowWidth
end if
if tTop > tInspectorHeight then
put tTop into tInspectorHeight
end if
unlock messages
end repeat

local tHeightDiff
put the height of me - 2* tMargin - tInspectorHeight into tHeightDiff
if pExpandableExtra is 0 and tCanExpand > 0 and tHeightDiff > 0 then
local tExpandableExtra, tDummy
put tHeightDiff / tCanExpand into tExpandableExtra
get inspectorCalculateLayout(pGroupList, pLeft, pTop, pRowWidth, pSubsections, pCurSection, tExpandableExtra, tDummy)
end if

put tCanExpand > 0 into rCanExpand
return tInspectorHeight
end inspectorCalculateLayout

local sManualHeight
on inspectorLayoutGroups pGroupList, pForceHeight
lock screen
# Get the margin, padding
local tMargin, tPadding
Expand All @@ -88,16 +175,19 @@ on inspectorLayoutGroups pGroupList
local tTop, tLeft, tContentRect
put the contentRect of me into tContentRect
put item 1 of tContentRect + tMargin into tLeft
put tLeft into item 1 of tContentRect
put item 2 of tContentRect + tMargin into tTop
put tTop into item 2 of tContentRect

# Loop through the editors and get the minimum width of the labels and editors
# To work out an initial row width
local tMinRowWidth, tMinEditorsWidth, tRowWidth, tMinLabelWidth
local tMinRowWidth, tMinEditorsWidth, tRowWidth, tMinLabelWidth, tRowGroup
repeat for each element tElement in pGroupList
if there is not a group tElement["label"] of me then next repeat
if there is not a group tElement["label"] of group "inspector" of me then next repeat
put the long id of group tElement["label"] of group "inspector" of me into tRowGroup
local tEditorsReportedWidth, tLabelReportedWidth
put the rowMinWidth of group tElement["label"] of me into tEditorsReportedWidth
put the rowLabelWidth of group tElement["label"] of me into tLabelReportedWidth
put the rowMinWidth of tRowGroup into tEditorsReportedWidth
put the rowLabelWidth of tRowGroup into tLabelReportedWidth

if tEditorsReportedWidth > tMinEditorsWidth then
put tEditorsReportedWidth into tMinEditorsWidth
Expand Down Expand Up @@ -125,64 +215,23 @@ on inspectorLayoutGroups pGroupList
local tInspectorWidthWithMargins
put tRowWidth + (tMargin * 2) into tInspectorWidthWithMargins

if there is a group "inspector" of me and \
the vscrollbar of group "inspector" of me then
subtract the scrollbarwidth of group "inspector" of me from tRowWidth
end if

local tSubsections, tCurSection, tNewSubsection
# Check if this inspector wants to show subsections
put the showSubSections of me into tSubsections

local tMaxRowWidth, tInspectorHeight, tColumnNumber, tColumnTop
put 1 into tColumnNumber
repeat for each element tElement in pGroupList
if tSubsections and tElement["subsection"] is not empty then
# If we have a new subsection, create the subsection header
if tElement["subsection"] is not tCurSection then
lock messages
set the width of group ("Subsection_" & tElement["subsection"]) of me to the formattedwidth of field tElement["subsection"] of group ("Subsection_" & tElement["subsection"]) of me
set the width of field tElement["subsection"] of group ("Subsection_" & tElement["subsection"]) of me to the formattedwidth of field tElement["subsection"] of group ("Subsection_" & tElement["subsection"]) of me
set the topleft of group ("Subsection_" & tElement["subsection"]) of me to tLeft,tTop
unlock messages
add (the formattedheight of field tElement["subsection"] of group ("Subsection_" & tElement["subsection"]) of me) to tTop
put tElement["subsection"] into tCurSection
end if
end if

if there is a group tElement["label"] of me then
# set the width and topleft of the editor
lock messages
set the topleft of group tElement["label"] of me to tLeft,tTop
set the lockloc of group tElement["label"] of me to true
set the width of group tElement["label"] of me to tRowWidth
unlock messages

# Tell the row to resize
dispatch "rowResize" to group tElement["label"] of me

local tEditorHeight
# If the editor does not report its own height, use the formatted height
# This tends to report slightly strange values, otherwise we could just use it
# all the time.
put the editorHeight of group tElement["label"] of me into tEditorHeight
if not tEditorHeight > 0 then
put the formattedheight of group tElement["label"] of me into tEditorHeight
end if

lock messages
add tEditorHeight + tPadding to tTop

if tRowWidth > tMaxRowWidth then
put tRowWidth into tMaxRowWidth
end if
if tTop > tInspectorHeight then
put tTop into tInspectorHeight
end if
unlock messages
end if
end repeat
local tInspectorHeight, tCanExpand
put inspectorCalculateLayout(pGroupList, tLeft, tTop, tRowWidth, \
tSubsections, tCurSection, 0, tCanExpand) into tInspectorHeight

local tStackTop, tStackLeft
put the top of me into tStackTop
put the left of me into tStackLeft


if there is a field "noObjects" of me then
set the width of field "noObjects" of me to 1000
put the formattedWidth of field "noObjects" of me into tMinRowWidth
Expand All @@ -202,20 +251,42 @@ on inspectorLayoutGroups pGroupList
layoutFrame
end if

set the left of me to tStackLeft

local tStackHeight
if tInspectorHeight is empty then
put kInspectorMinHeight into tStackHeight
else
put tInspectorHeight + tMargin into tStackHeight
end if

set the minheight of me to tStackHeight
set the maxheight of me to tStackHeight
set the height of me to tStackHeight
if tCanExpand then
set the maxheight of me to 65535
else
set the maxheight of me to tStackHeight
end if

if pForceHeight and not sManualHeight then
-- Make stack smaller rather than go offscreen
local tScreenRect
put revIDEStackScreenRect(the long id of me, true) into tScreenRect
set the height of me to min(tStackHeight, item 4 of tScreenRect - tStackTop)
end if
set the left of me to tStackLeft
set the top of me to tStackTop

if there is a group "inspector" of me then
if the height of me < tStackHeight then
put true into sManualHeight
set the vscrollbar of group "inspector" of me to true
else
put false into sManualHeight
set the vscrollbar of group "inspector" of me to false
end if
set the rect of group "inspector" of me to \
item 1 of tContentRect, \
item 2 of tContentRect, \
the right of this card of me, \
the bottom of this card of me - tMargin
end if
unlock messages
unlock screen
end inspectorLayoutGroups
Expand Down Expand Up @@ -313,9 +384,6 @@ on inspectorGenerateGroups pGroupList
set the margins of the templategroup to 0
set the visible of the templategroup to false

local tStackPath
set the behavior of the templategroup to the long ID of stack revIDEPaletteResourcePath("behaviors/revinspectorgroupbehavior.livecodescript", the long ID of stack "revInspector")

set the traversalon of the templatefield to false
set the threed of the templatefield to false
set the showborder of the templatefield to false
Expand All @@ -328,10 +396,20 @@ on inspectorGenerateGroups pGroupList

lock messages
if there is not a group "template" then
local tBehavior
put the long ID of stack revIDEPaletteResourcePath( \
"behaviors/revinspectorgroupbehavior.livecodescript", \
the long ID of stack "revInspector") into tBehavior
create group "template"
set the behavior of it to tBehavior
create field "rowlabel" in group "template"
set the topleft of field "rowlabel" of group "template" to the topleft of group "template"
end if

if there is not a group "inspector" then
create group "inspector"
set the rect of it to the rect of this card of me
end if
unlock messages

local tSubsections
Expand Down Expand Up @@ -359,20 +437,22 @@ on inspectorGenerateGroups pGroupList
end if

lock messages
copy group "template" to me
local tRowGroup
copy group "template" to group "inspector" of me
set the name of it to tElement["label"]
show group tElement["label"] of me
put the long id of group tElement["label"] of group "inspector" of me into tRowGroup
show tRowGroup
unlock messages
set the rowShowLabel of group tElement["label"] of me to true
set the rowShowLabel of tRowGroup to true

local tName
put the short name of group tElement["label"] of me into tName
if exists(group tElement["label"] of me) then
put the short name of tRowGroup into tName
if exists(tRowGroup) then
local tPropList, tProperty
repeat with y = 1 to the number of elements in tElement["proplist"]
put tElement["proplist"][y] into tProperty
if tProperty["user_visible"] is false then next repeat
dispatch "propertyRegister" to group tElement["label"] of me with tProperty
dispatch "propertyRegister" to tRowGroup with tProperty

# Build the list of properties to display in the tooltip for the row
if tPropList is empty then
Expand All @@ -393,16 +473,16 @@ on inspectorGenerateGroups pGroupList
put tElement["label"] into tLabel
end if

set the rowTooltip of group tElement["label"] of me to tTooltip
set the rowTooltip of tRowGroup to tTooltip
if tElement["label"] is not tElement["subsection"] then
set the rowLabel of group tElement["label"] of me to tLabel
set the rowLabel of tRowGroup to tLabel
end if
end if
put empty into tPropList
end repeat
reset the templatefield
reset the templategroup

show group "inspector"
unlock screen
end inspectorGenerateGroups

Expand Down Expand Up @@ -445,7 +525,7 @@ on inspectorChanged
inspectorFill

# Layout
inspectorLayout
inspectorLayout true

unlock screen
end inspectorChanged
Expand Down Expand Up @@ -506,8 +586,8 @@ end inspectorFill
on inspectorFillGroups pGroupData
local tRow
repeat for each key tRow in pGroupData
if there is a group tRow of me then
set the rowData of group tRow of me to pGroupData[tRow]
if there is a group tRow of group "inspector" of me then
set the rowData of group tRow of group "inspector" of me to pGroupData[tRow]
end if
end repeat
end inspectorFillGroups
Expand Down Expand Up @@ -566,10 +646,10 @@ private function rowLabelWidthCalculate
local tMaxWidth, tLabelWidth, tChildren
put 0 into tMaxWidth

put the childControlNames of this card of me into tChildren
put the childControlNames of group "inspector" of me into tChildren
repeat for each line tControl in tChildren
if there is a field "rowlabel" of group tControl of me then
put the rowLabelWidth of group tControl of me into tLabelWidth
if there is a field "rowlabel" of group tControl of group "inspector" of me then
put the rowLabelWidth of group tControl of group "inspector" of me into tLabelWidth
end if
if tLabelWidth > tMaxWidth then
put tLabelWidth into tMaxWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,12 @@ on editorFinalize
dispatch "popupDismissed" to me
end if
end editorFinalize

local sExpandVertical
setProp editorExpandVertical pValue
put pValue into sExpandVertical
end editorExpandVertical

getProp editorExpandVertical
return sExpandVertical
end editorExpandVertical
Loading