Placement of exterior subwindows
thomas_braun
I'm using exterior subwindows quite a lot for adding GUI controls to graphs.
Now I'm facing the problem that I'm starting to run out of vertical space as I don't seem to be able to place them space efficiently.
The following code
Window Panel0() : Panel
PauseUpdate; Silent 1 // building window...
NewPanel/K=1/W=(387,658,914,1141)
NewPanel/HOST=#/EXT=1/W=(49,0,0,237)
ModifyPanel fixedSize=0
RenameWindow #,P0
SetActiveSubwindow ##
NewPanel/HOST=#/EXT=1/W=(50,0,0,237)
ModifyPanel fixedSize=0
RenameWindow #,P1
SetActiveSubwindow ##
EndMacro
PauseUpdate; Silent 1 // building window...
NewPanel/K=1/W=(387,658,914,1141)
NewPanel/HOST=#/EXT=1/W=(49,0,0,237)
ModifyPanel fixedSize=0
RenameWindow #,P0
SetActiveSubwindow ##
NewPanel/HOST=#/EXT=1/W=(50,0,0,237)
ModifyPanel fixedSize=0
RenameWindow #,P1
SetActiveSubwindow ##
EndMacro
gives a graph and two exterior subwindows P1 and P0 on the left of the graph. Is it possible to move P1 below P0?
Thanks,
Thomas
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
February 13, 2017 at 05:09 pm - Permalink
February 13, 2017 at 05:14 pm - Permalink
-Matthew
February 14, 2017 at 07:31 am - Permalink
It looks interesting! I'm a bit concerned about the "grueling coding" as I'm the one how has to code it and also needs to adapt it quite often.
How have you implemented the triangle for opening/closing the sub groups?
February 15, 2017 at 05:36 am - Permalink
Constant ndepth = 120
Constant nwidth = 255
Constant cdepth = 20
Constant cwidth = 255
// the control in the panel creation procedure
Button XtendD,pos={4,5},size={15,20},proc=XtendDown,title="v", userData="opened"
// the function to open/close the panel below the arrow
Function XtendDown(ba) : ButtonControl
STRUCT WMButtonAction &ba
SVAR/SDFR=$thePackageFolder cw = currWin
DFREF cwDFR = $(thePackageFolder + ":" + cw)
SVAR pn = cwDFR:panelName
switch( ba.eventCode )
case 2: // mouse up
strswitch(ba.userData)
case "closed":
Button XtendD win=$(cw + "#" + pn), title="v", userData="opened"
MoveSubWindow/W=$(cw + "#" + pn) fnum=(0,0,nwidth,ndepth)
break
case "opened":
Button XtendD win=$(cw + "#" + pn), title=">", userData="closed"
MoveSubWindow/W=$(cw + "#" + pn) fnum=(0,0,cwidth,cdepth)
break
endswitch
break
endswitch
return 0
end
Controls below the collapsed panel "disappear" when the panel is collapsed.
Check out the ScrollTraces package for details.
http://www.igorexchange.com/project/ScrollTracesPanel
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
February 15, 2017 at 06:09 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
February 15, 2017 at 12:04 pm - Permalink
The basic strategy I use is to test each one of those triangles for if it is active, and update the disable state for each of "its" controls (hiding or showing as appropriate). If to be shown, I update each control's position (this is the grueling part), based on its local position plus an overall offset. That overall offset gets incremented with each grouping.
Maybe a simplified snippet will explain better:
STRUCT WMCheckboxAction &cba
variable thispos = 0, tempcheck
// update what controls are showing, and where they are
// Group 1
tempcheck = checkval ("Group1Check", cba.win) // checkval returns the true-false state of a checkbox
ModifyControlList "Group1Group;Group1SetVar1;Group1SetVar2", disable=(1-tempcheck), win=$(cba.win) // hides or shows all controls in the group
CheckBox Group1Check, pos={2,3 + thispos}, win=$(cba.win) // update y-position of disclosure triangle
if (tempcheck) // showing, so update y-positions of everyone in the group
SetVariable Group1SetVar1, pos={8, 17 + thispos}, win=$(cba.win)
SetVariable Group1SetVar2, pos={24, 36 + thispos}, win=$(cba.win)
GroupBox Group1Group, pos={1,1 + thispos}, win=$(cba.win) // it is nice to frame these groups of controls
thispos += 79 // next group starts way down, well clear of these controls
else // not showing, so just just update start position of next group
thispos += 18 // next group starts just clear of the disclosure triangle
endif
// Group2
tempcheck = checkval ("Group2Check", cba.win)
ModifyControlList "Group2Group;Group2SetVar1;Group2SetVar2" disable=(1-tempcheck), win=$(cba.win) // update show/hide of next group
CheckBox Group2Check, pos={2,3 + thispos}, win=$(cba.win) // update position of disclosure triangle
if (tempcheck)
... // move next groups as appropriate
It is a little fiddly getting all the spacings just right.
-Matthew
p.s. Thanks for pointing out "Extract" somewhere. How did I miss that one? Very useful.
March 3, 2017 at 12:38 pm - Permalink
March 3, 2017 at 02:35 pm - Permalink