PDA

View Full Version : sticky rollout - how to create a second rollout that sticks to the first like


abyjoe
05-18-2008, 03:10 PM
i want to create a second rollout that sticks to the frame of the first one once its enabled... like UVTools and winamp...

and would it be possible to grab it and let it to float around...?

ZeBoxx2
05-18-2008, 04:32 PM
i want to create a second rollout that sticks to the frame of the first one once its enabled... like UVTools and winamp...

and would it be possible to grab it and let it to float around...?

As long as they're dialogs, it's easy. If they're not dialogs, you'll need a timer.

Here's an example using dialogs:

global test_a
global test_b
global dialogBorderWidth = 3

rollout test_a "Test Alpha" width:100 height:100 (
label foo "foo"

on test_a moved pos do (
setDialogPos test_b (pos + [test_a.width + dialogBorderWidth * 2,0])
)
)
rollout test_b "Test Beta" width:50 height:50 (
label bar "bar"
)

createDialog test_a
createDialog test_b test_b.height test_b.width ((getDialogPos test_a).x + test_a.width + dialogBorderWidth * 2) (getDialogPos test_a).y


Note that you need the dialogBorderWidth tweak as the rollout's width value is for the -client- area, not the entire window's area.

abyjoe
05-18-2008, 05:04 PM
thanks man.. now i am going to write some docking and rollout snapping code so when its close to the border of the first rollout it automatically snaps to it....

ZeBoxx2
05-18-2008, 05:13 PM
you should have all the required elements there, except for an array of all the rollouts/dialogs that are open (so you can get their positions and dimensions). As long as they're yours, you can easily keep track of that yourself :)

abyjoe
05-18-2008, 05:25 PM
where does the rollout floater come into picture...!!!

ZeBoxx2
05-18-2008, 08:05 PM
If you're using rollout floaters, rather than dialogs, then you don't get an event for when the rollout is moved. So you'll have to set up a timer (either maxscript or .net) that checks the rollout's position and adjust another rollout (or dialog) that way.

Example for two rollout floaters:


global test_a_roll, test_b_roll, test_a_floater, test_b_floater
global floaterBorderWidth = 7

rollout test_a_roll "Test Alpha" width:100 height:100 (
label foo "foo"
timer tick_tock interval:100 active:true

local oldPos = [0,0]
on tick_tock tick do (
curPos = test_a_floater.pos
if (curPos != oldPos) then (
test_b_floater.pos = [curPos.x + test_a_floater.size.x + floaterBorderWidth * 2,curPos.y]
oldPos = curPos
)
)
)
test_a_floater = newRolloutFloater "Test Alpha" test_a_roll.width test_a_roll.height
addRollout test_a_roll test_a_floater

rollout test_b_roll "Test Beta" width:50 height:50 (
label bar "bar"
)
test_b_floater = newRolloutFloater "Test Beta" test_b_roll.width test_b_roll.height (test_a_floater.pos.x + test_a_floater.size.x + floaterBorderWidth * 2) test_a_floater.pos.y
addRollout test_b_roll test_b_floater


Consider whether you really need floaters, or whether you can use a dialog with SubRollouts instead. Floaters are rarely a necessary evil.

abyjoe
05-18-2008, 08:37 PM
cool, i am sticking to the dialog... i've got the rollout snapping to work now... cheers

CGTalk Moderation
05-18-2008, 08:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.