Scripting Rollouts for tabs

I'm in the process of working on scripts for public release.
I was curious to get some opinions of ways people would see as the best route to go when making this particular UI with rollouts.
I need to have multiple tabs/rollouts and in needing that I've decided to go in the direction similar to fumeFX. When the button is pressed it adds a rollout and removes any previous ones.

My two concerns are
1. What is the best way to store the settings/values of each rollout item control and reload them when that tab/rollout is reopened
2. Best way to streamline the ability to remove/add rollouts.

My thoughts for the settings/values would be to just make them all local variables to the main rollout, otherwise worst case scenierio is to make them save to an ini file when the rollout is closed or any parameter is changed and then load it on AddSubRollout.

I've created a rough example here and posted in for users to build on and possibly better streamline. In a way that if others would like to use this as a starting point they could.
It may include building a function that would remove all rollouts except that one associated with that button. Right now mine is a bit redundant.

Lastly, I had a last second idea of making it so instead of removing any rollouts just making a function that would hide the rollout.visible state?!!!

You can access all the controls in a ui by the .controls propertie

So maybe we could write a function that would just run through the targeted rollout on open and close which would store the settings for each item in a bitArray.

Example Idea: (does not work, just a basic idea of a potential concept)
Code:

fn fnSaveRolloutSettings trgRollout = (--//Saves active rollout ui controls to bitArray
     for item = trgRollout.controls do (
     save settings from item to array
     )
)
 
fn fnLoadRolloutSettings trgRollout = (--//Loads active rollout ui controls from bitArray
     for item = trgRollout.controls do (
     load settings from array to item
     )
)

I look forward to hearing back from you guys.

Thanks

JokerMartini

Base Starting code:

try(destroyDialog ::rltest)catch()
 
rollout rltest "test"
( 
	subrollout srWin "test1" pos:[8,36] width:154 height:60
 
	label lb style_sunkenedge:true width:48 height:20 pos:[8,8]
	checkbutton cbA "A" width:46 height:18 pos:[9,9]
	label lb0 style_sunkenedge:true width:48 height:20 pos:[59,8]
	checkbutton cbB "B" width:46 height:18 pos:[60,9]
	label lb3 style_sunkenedge:true width:48 height:20 pos:[110,8]
 	checkbutton cbC "C" width:46 height:18 pos:[111,9]
 
	on cbA changed state do (
		if state then (
			rltest.height = 106
			for rl in srWin.rollouts do removeSubRollout rltest.srWin rl
			AddSubRollout rltest.srWin rlAa
		) else (
			rltest.height = 36
			for rl in srWin.rollouts do removeSubRollout rltest.srWin rl	
		)
	)
	on cbB changed state do (
		if state then (
			rltest.height = 106
			for rl in srWin.rollouts do removeSubRollout rltest.srWin rl
			AddSubRollout rltest.srWin rlB
		) else (
			rltest.height = 36
			for rl in srWin.rollouts do removeSubRollout rltest.srWin rl	
		)
	)
	on cbC changed state do (
		if state then (
			rltest.height = 106
			for rl in srWin.rollouts do removeSubRollout rltest.srWin rl
			AddSubRollout rltest.srWin rlC
		) else (
			rltest.height = 36
			for rl in srWin.rollouts do removeSubRollout rltest.srWin rl	
		)
	)
)
 
rollout rlAa "A" 
( 
  spinner test1as "test1as" width:100
)
 
rollout rlB "B" 
( 
  spinner test1as "test1as" width:100
)
rollout rlC "C" 
( 
  spinner test1as "test1as" width:100
)
 
createdialog rltest 170 36

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

Yeah, exactly

That's we talk about :) I was fairly sure you'll like the idea and will finish the code with subRollout.visible

Your code is fine. I made some changes though.

if classOf ::roMain == RolloutClass do DestroyDialog ::roMain
rollout roSubRollA "Group A"
(
	label lblA "Label A" pos:[20,5]
	spinner spnA "Spinner A:" range:[0,100,10] pos:[20,23]
)
 
rollout roSubRollB "Group B"
(
	label lblB "Label B" pos:[20,5]
	button btnB "BBBBBB" pos:[20,33]
	spinner spnB "Spinner B:" range:[0,300,30] pos:[20,63]
)
 
rollout roMain "Clevar SubRoll"
(
	checkButton chbShowA "Show A" checked:on across:2
	checkButton chbShowB "Show B" checked:off
 
	subRollout roSubA "" height:160 width:140 pos:[10,30]
	subRollout roSubB "" height:160 width:140 visible:false pos:[10,30]
 
	on roMain open do (
		AddSubRollout roMain.roSubA roSubRollA
		AddSubRollout roMain.roSubB roSubRollB
	)
 
	on chbShowA changed state do 
	(
		chbShowB.state = not state
		roMain.roSubA.visible = state
		roMain.roSubB.visible = not state
	)
 
	on chbShowB changed state do 
	(
		chbShowA.state = not state
		roMain.roSubA.visible = not state
		roMain.roSubB.visible = state
	)
)
createDialog roMain 160 200

my recent MAXScripts RSS (archive here)

JokerMartini's picture

Hey Anubis

Great ideas.
I took it a step further and I believe it is actually even more simple.

Make a subrollout for each tab and just hide that instead of the UI items. That could be a problem for some people if they have UI items that are only visible when a button is pressed. I'm sure you could easily add checks and whatnot into the script but it seems like this might be an easier route.

now just make a function and a few locals and we could easily just wire up the button being pressed to the rollout it needs to open and the rollouts it needs to hide.
check it out!

--//Instead of adjust each UI item just make a subrollout for each button and hide the SubRollout using the visible property.
try(DestroyDialog roMain)catch()
rollout roSubRoll "Group A"
(
	label lblA "Label A" pos:[20,5]
	spinner spnA "Spinner A:" range:[0,100,10] pos:[20,23]
)
 
rollout roSubRollB "Group B"
(
	label lblB "Label B" pos:[20,5]
	button btnB "BBBBBB" pos:[20,33]
	spinner spnB "Spinner B:" range:[0,300,30] pos:[20,63]
)
 
rollout roMain "Clevar SubRoll"
(
	checkButton chbShowA "Show A" checked:on across:2
	checkButton chbShowB "Show B" checked:off
 
	subRollout roSub "" height:160 width:140 pos:[10,30]
	subRollout roSubB "" height:160 width:140 visible:false pos:[10,30]
 
	on roMain open do (
		AddSubRollout roMain.roSub roSubRoll
		AddSubRollout roMain.roSubB roSubRollB
	)
 
	on chbShowA changed state do 
	(
		chbShowB.state = not state
 
		if state==true then (
			roMain.roSub.visible = true
			roMain.roSubB.visible = false
			)else(
			roMain.roSub.visible = false
			roMain.roSubB.visible = true
		)
	)
 
	on chbShowB changed state do 
	(
		chbShowA.state = not state
 
		if state==true then (
			roMain.roSub.visible = false
			roMain.roSubB.visible = true
			)else(
			roMain.roSub.visible = true
			roMain.roSubB.visible = false
		)
	)
)
createDialog roMain 160 200

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

subRollout.visible

Hey, i miss that subRollout also have .visible property. Its not described in the help docs, but this...

roMain.roSub.visible = false
roMain.roSub.visible = true

works fine (on above code) ;)

[edit] Demn confusing mxs-help!
The SubRollout is UI item and for that it has .visible property, hehe... :)

my recent MAXScripts RSS (archive here)

Anubis's picture

here is what i do

Hi John,
yes, removing rollouts actualy close them. We can hide the whole dialog by moving it position out of the screen, but no way to hide only a subRollout. The .visible property available only for UI items, and my idea that I share many times and that some people like it, others not (who knows why) is to play with UI items visibility. Here is example (very simplified) to illustrate my "cheat" :)

rollout roSubRoll "Group A"
(
	label lblA "Label A" pos:[20,5]
	spinner spnA "Spinner A:" range:[0,100,10] pos:[20,23]
 
	label lblB "Label B" pos:[20,5] visible:off
	spinner spnB "Spinner B:" range:[0,300,30] pos:[20,23] visible:off 
)
 
rollout roMain "Clevar SubRoll"
(
	local itemsA = #(roSubRoll.lblA, roSubRoll.spnA)
	local itemsB = #(roSubRoll.lblB, roSubRoll.spnB)
 
	checkButton chbShowA "Show A" checked:on across:2
	checkButton chbShowB "Show B" checked:off
 
	subRollout roSub "" height:60
 
	on roMain open do (
		AddSubRollout roMain.roSub roSubRoll
	)
 
	on chbShowA changed state do (
		chbShowB.state = not state
		itemsA.visible = state
		itemsB.visible = not state
		roSubRoll.title = if state then "Group A" else "Group B"
	)
 
	on chbShowB changed state do (
		chbShowA.state = not state
		itemsA.visible = not state
		itemsB.visible = state
		roSubRoll.title = if state then "Group B" else "Group A"
	)
)
createDialog roMain 160 100

The idea is simple - to have easy of access to all controlles values without need to store them (to file or variables). In the example above I use 1 subRollout but the idea can be applied to dialog only as well. Maybe is important to note that the UI items are aligned using Pos property.

Hope its helpful to you,
Cheers!

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.