[Closed] Little bitty slider controls??
I’m working on a rollout that is going to have a large number of sliders on it. As it is now, the slider toggles are looking extremely bulky (in fact I find them that way in general). I’ve been using a plugin that has as part of its UI some sliders with toggles that are both smaller and narrower than on standard sliders. I’m sure I’ve seen this sort of thing before, but can’t remember where. Does anyone know how to make these?
Maybe you can use dotnet TrackBar-class:
(
global trackBarRollout
try destroydialog trackBarRollout catch()
Rollout trackBarRollout "trackbar"
(
dotnetControl myTrackBar "system.windows.forms.trackbar"
on trackBarRollout open do
(
myTrackBar.AutoSize = false
myTrackBar.Size = dotNetObject "System.Drawing.Size" 170 20
)
)
createDialog trackBarRollout 200 50
)
Thanks much! One other question then… since it’s not a MaxScript slider, I guess I can’t automatically wire it to scene object properties. What would be the best way to set the sliders up as 2-way controls (i.e. they both affect and are affected by things they control in the scene?)
I dont think there is a way to automatically wire it. What kind of properties you need to wire it to? I’ve never used slider so I have no idea what you can do with it
If you don’t mind “hacky” way, maybe you could create normal maxscript slider and wire it (and do what you normally do with it) and put it somewhere outside dialog so user cant see it. Then when user changes values in dotnet trackbar, update your “hidden” slider according trackbar values. And other way around, when user changes something in scene, hidden slider gets updated and it changes dotnet trackbar values.
Well it doesn’t need to be actually wired. All I am concerned about is that the value of the trackbar and the value in the scene that it corresponds to can both be updated based on the other. In other words, if I have a trackbar set to control the radius of a sphere, and then manipulate that radius through Max’s built in utilities or through an unrelated script, I would like the value shown on the slider bar to update accordingly.
In recent versions of Max, this behavior is extremely easy to implement in slider controls. And I’m not familiar enough with dotNet to know how to set up the scenario I described above.
try(delete objects) catch()
theNode = box width:10
theNode.width.controller = bezier_float()
try(destroydialog paramRol) catch()
rollout paramRol ""
(
dotnetControl slider "system.windows.forms.trackbar"
fn updateParams param: = if iscontroller param do slider.value = param.value
on slider ValueChanged v do if isvalidnode theNode do theNode.width = slider.value
on paramRol open do
(
slider.AutoSize = off
slider.TickStyle = slider.TickStyle.None
slider.Minimum = 0
slider.Maximum = 200
slider.Size = dotNetObject "System.Drawing.Size" 200 16
if isvalidnode theNode do slider.value = theNode.width
if isvalidnode theNode do
(
deleteAllChangeHandlers id:#my_callback
when parameters theNode.width.controller changes id:#my_callback c do updateParams param:c
)
)
on paramRol close do
(
deleteAllChangeHandlers id:#my_callback
)
)
createdialog paramRol width:230 height:30
if the parameter that you want to bind is your custom scripted parameter you can use its
on set event in parameter block section to change the slider value.
All right, I’m getting close now… Just one more thing that I need, and that is for the trackbar value to update when the time slider is changed (I’m going to be working with animated values, so that will be very important to have!)
I tried using the standard registerTimeCallback to match the trackbar value to the controller value, and it seems that sometimes the controller value starts getting changed along with or instead of the trackbar value.
Never mind, it was a mistake on my part. The time change callback works fine!
Thanks for all the help
Aaaaand okay, that was a hasty statement on my part. After further examination, I am still having the same problem. The reason I didn’t realize it is that the track view does not update until I click on it somewhere.
I think the problem is that the way things are set up now, the slider value changes based on the track view value AND the track view value changes based on the slider value, leading to some kind of undesired feedback loop. Not really sure, but that’s my best guess. Any ideas for solutions?
Well, I’m primarily working with a third party plugin, but I’ve posted the basic setup I’m using below. There are 2 serious problems occuring here: 1) The creation of unwanted keys by sliding along the time track, and 2) Failure to unregister time callbacks.
-- Scene setup
delete objects
fn setControllers b =
(
b.height.controller = bezier_float()
b.length.controller = bezier_float()
b.width.controller = bezier_float()
)
b1 = box pos:[0,0,0]
b2 = box pos:[100,100,100]
setControllers b1; setControllers b2
-- end scene setup
try(destroyDialog RO_Trackbar)catch()
boxArray = #()
struct myBox (object, h, l, w)
fn boxStruct obj = (myBox object:obj h:obj.height l:obj.length w:obj.width)
fn createSubRollouts =
(
for i = RO_Trackbar.subRO.rollouts.count to 1 by -1 do (removeSubRollout RO_Trackbar.subRO RO_Trackbar.subRO.rollouts[i])
dynRO = stringstream ""
format "rollout RO_Objects \"Objects\"
" to:dynRO
format "(
" to:dynRO
for i = 1 to boxArray.count do (format "label lbl% \"%\"
" i boxArray[i].object.name to:dynRO)
format ")
" to:dynRO
format "addSubRollout RO_TrackBar.subRO RO_Objects
" to:dynRO
format "rollout RO_Height \"Height\"
" to:dynRO
format "(
" to:dynRO
for i = 1 to boxArray.count do (format "dotNetControl tb% \"system.windows.forms.trackbar\" pos:[15,%]
" i ((i*20)-20) to:dynRO)
format "on RO_Height open do
" to:dynRO
format "(
" to:dynRO
for i = 1 to boxArray.count do
(
format "tb%.minimum = 0
" i to:dynRO
format "tb%.maximum = 50
" i to:dynRO
format "tb%.value = %
" i boxArray[i].h to:dynRO
format "unregisterTimeCallback updateSliderH%
" i to:dynRO
format "fn updateSliderH% =
" i to:dynRO
format "(
" to:dynRO
format "format \"testing3\
\"
" to:dynRO
format "try(tb%.value = boxArray[%].h)catch()
" i i to:dynRO
format ")
" to:dynRO
format "registerTimeCallback updateSliderH%
" i to:dynRO
)
format ")
" to:dynRO
for i = 1 to boxArray.count do (format "on tb% valueChanged v do boxArray[%].object.height = (tb%.value as float)
" i i i to:dynRO)
format ")
" to:dynRO
format "addSubRollout RO_Trackbar.subRO RO_Height
" to:dynRO
dynRO = dynRO as string
execute dynRO
)
rollout RO_Trackbar "Trackbar Test"
(
pickButton pck_Box "Pick a box"
subRollout subRO width:155 height:200 offset:[-10,0]
on pck_Box picked obj do
(
theBox = boxStruct obj
append boxArray theBox
createSubRollouts()
)
)
createDialog RO_Trackbar