Tabs and UI components


#1

Hello :slight_smile:

I’ve searched this forum about a problem I have, and still not found exactly what I’m looking for … To summarize: I need to do a script interface using tabs. I managed to get the tabs I want. Now I’d like to put directly my UI components (checkboxes, sliders and so on) in the tab “window”, without using any kind of rollout in the tabs …
Please check the code sample I’m on so far … but I don’t want/need to use rollouts :frowning:


 (
 	global VFBTabs 
 	try(destroyDialog VFBTabs)catch()
 	
 	local LastSubRollout = 1
 	
 	rollout VFBTabsRollout01 "Rollout 01"
 	(
 		spinner spn_spinner "Spinner"
 	)
 	rollout VFBTabsRollout02 "Rollout 02"
 	(
 		button btn_button "Button"
 	)
 	rollout VFBTabsRollout03 "Rollout 03"
 	(
 		label lbl_label "This is some text"
 	)
 	rollout VFBTabsRollout04 "Rollout 04"
 	(
 		colorpicker clr_picker "Color Picker"
 	)
 	rollout VFBTabsRollout05 "Rollout 05"
 	(
 		checkbox chk_box "Checkbox"
 	)
 	
 	VFBTabs_Rollouts = #(
 		#("Global Options",#(VFBTabsRollout01)),
 		#("GI & Skylight",#(VFBTabsRollout02)),
 		#("Raytracer",#(VFBTabsRollout03)),
 		#("Blurries Manager",#(VFBTabsRollout04))
 	)	
 	
 	rollout VFBTabs "VFB-Tabs"
 	(
 			dotNetControl dn_tabs "System.Windows.Forms.TabControl" height:20 width:420 align:#left
 			subRollout theSubRollout width:658 height:190 align:#center
 			
 			on dn_tabs Selected itm do
 			(
 				if LastSubRollout != (itm.TabPageIndex+1) do --do not update if the same tab clicked twice
 				(
 					for subroll in VFBTabs_Rollouts[LastSubRollout][2] do
 						removeSubRollout theSubRollout subroll
 					for subroll in VFBTabs_Rollouts[LastSubRollout = itm.TabPageIndex+1][2] do	
 						addSubRollout theSubRollout subroll
 				) 
 			)--end tabs clicked		
 			
 			on VFBTabs open do
 			(
 				for aTab in VFBTabs_Rollouts do
 				(
 					dn_tabs.TabPages.add aTab[1]
 				)
 				for subroll in VFBTabs_Rollouts[1][2] do 
 					addSubRollout theSubRollout subroll				
 			)
 	)
 
 	createDialog VFBTabs 658 190
 )	
 
 

#2

Seems to me that a more “correct” approach would be to use .net controls directly inside the tabs, instead of trying to combine it with standard MAX controls. That way you can use the .NET methods for adding controls instead of having to use the rollout method.

Nice to see ya here Nicolas… =D


#3

Hi Marco :slight_smile:

Ok, I understand your point of view, but would you have any sample to show or better, a direct addition to my script (in the first tab for example) ? Honestly, I’m only starting to use dotNet, and I don’t like it very much … matter of practice certainly :wink:

Best regards.


#4

Here’s something I coded up real quickly:

 (
 	--Create scroll bars (for later use in the textbox)
 	ScrollBars = dotNetClass "System.Windows.Forms.ScrollBars"
 	--Create the first tab 
 	newTab = dotnetobject "System.Windows.Forms.TabPage"
 	newTab.text = "hello"
 	--Create a textbox and set properties
 	TB1TextBox = dotNetObject "System.Windows.Forms.TextBox"
 	  TB1TextBox.Location = dotNetObject "System.Drawing.Point" 10 10
 	  TB1TextBox.Width = 365
 	  TB1TextBox.Height = 120
 	  TB1TextBox.Visible = true
 	  TB1TextBox.MultiLine = true
 	  TB1TextBox.ScrollBars = ScrollBars.Vertical
 	  TB1TextBox.AcceptsReturn = true
 	  TB1TextBox.AcceptsTab = true
 	  TB1TextBox.WordWrap = true
 	--Create a button and set properties 
 	button01 = dotnetobject "System.Windows.Forms.button"
 	button01.text = "Click me"
 	button01.Location = dotNetObject "System.Drawing.Point" 300 138
 	 --Add textbox and button to first tab
 	newTab.controls.add TB1TextBox
 	newTab.controls.add button01
 	--Create second tab
 	newTab2 = dotnetobject "System.Windows.Forms.TabPage"
 	newTab2.text = "goodbye"
 	--Create a tab control object and set properties
 	TabControl = dotnetobject "System.Windows.Forms.TabControl" 
 	 tabControl.size = dotnetobject "system.drawing.size" 400 225
 	tabControl.Location = dotnetobject "System.Drawing.Point" 0 0 
 	--Add the tabs to the tab control
 	TabControl.controls.add newTab
 	TabControl.controls.add newTab2	
 	-- Create Form (this is sort of like the rollout creation in maxscript) and set properties
 	  TabForm = dotNetObject "System.Windows.Forms.Form"
 	  TabForm.Size = dotNetObject "System.Drawing.Size" 400 225
 	  TabForm.Text = "Title"
 	  TabForm.TopMost = true
 	  FormBorderStyle = dotNetClass "System.Windows.Forms.FormBorderStyle"
 	  TabForm.FormBorderStyle = FormBorderStyle.FixedDialog
 	  TabForm.ShowInTaskbar = false
 	  TabForm.MinimizeBox = true
 	  TabForm.MaximizeBox = false
 	  Tabform.helpbutton = true
 	--Add the tab control to the form
 	 TabForm.Controls.Add(tabcontrol)
 	--Show the form (sort of like createDialog)
    TabForm.showdialog()
 )

You’ll notice that this is straight .net stuff… no maxscripts rollouts. And yes it will be confusing to understand at first… until you get the hang of it. NET can be a real bitch when it feels like.

Let me know if you still have problems.


#5

Oh, cool ! let me check that !


#6

Hi Nicolas,

There’s a TabControl for MAXScript that was developed by Rezn8 studio that is way better than the .NET Form TabControl. It’s very powerful because you have just to add a rollout as a tab page and avoid hiding/showing stuff or having to use .NET controls.

To download the Rezn8 DLX :

http://www.maxplugins.de/r9_files/rezn8/rezn8mxs_max9_v1.34.zip
or
http://www.maxplugins.de/r2009_files/feltman/rezn8mxs_Max2009_v1.34.zip

See the help and examples sources for more information.

PS: In this DLX there’s also a SplitterControl that is useful too…


#7

Hello Yannick,

Thanks a lot for your suggestion, it seems highly interesting !! If I can avoid converting all my script (mostly already ready) to .Net, I’ll be happy for sure :wink: I’ll check that ASAP.

Thanks again,

Regards.


#8

Hey, Yannick, thanks for the tip. I was dealing with tabs some time ago and that would have been quite useful :slight_smile:

NicolasC, I remember a couple of threads in this section talking about .NET and rollouts in tabs. They shouldn’t be hard to find, and it’s plenty of information in there.


#9

Hello,

Yes, I know, I’ve searched the forum before posting :wink: but you know, if I can avoid using .NET, or at least minimize the use of it, I’ll feel better !

Regards.


#10

I’ve discovered a bad, bad thing when I wanted to share my WIP-script with a friend using max2009 64b … rezn8 extensions aren’t available for 64b !!! and his support email adress isn’t valid anymore apparently … any idea, please ?

Thanks in advance !


#11

you might contact Dave from maxplugins.de

dave@maxplugins.de

i don’t know if it’s true for the rezn8 extension, but he has access to many of the free plugin’s sourcecode. But maybe there’s a specific reason for 32 bit only, i guess activex dependency


#12

Thank you, SpaceFrog … I’ve just sent him an email :wink:


#13

hi nicolas,

if you are desperate to keep backward compatibility, here’s a hacky way of faking a tabstrip look. If you build a line of checkbuttons so that they resemble a tabstrip, (there was a layout style that allowed it to look like this anyway) on each checkbutton press you could store the last dialog position, destroy the dialog and create the other dialog in the same position. Effectively the checkbutton doesnt change its state, and resets the others, they are on each rollout at the top

-- Fake Tabstrip Test
  
  rollout one "Rollout One" width:162 height:137
  (
  	checkbutton ckb1 "1" pos:[4,3] width:51 height:20 checked:true
  	checkbutton ckb2 "2" pos:[56,3] width:51 height:20
  	checkbutton ckb3 "3" pos:[108,3] width:51 height:20
  	GroupBox grp1 "" pos:[4,16] width:155 height:115
  	colorPicker cp1 "ColorPicker" pos:[27,47] width:109 height:18
  	dropdownList ddl1 "DropDownList" pos:[24,74] width:117 height:40
  	
  	on ckb1 changed state do
  	(
  	ckb1.state = true
  	)
  	on ckb2 changed state do
  	(
  	local dialogpos = getdialogpos one
  	createdialog two pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
  	destroydialog one	
  	)
  	on ckb3 changed state do
  	(
  	local dialogpos = getdialogpos one
  	createdialog three pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
  	destroydialog three
  	)
  )
  
  rollout two "Rollout Two" width:162 height:137
  (
  	checkbutton ckb1 "1" pos:[4,3] width:51 height:20 
  	checkbutton ckb2 "2" pos:[56,3] width:51 height:20 checked:true
  	checkbutton ckb3 "3" pos:[108,3] width:51 height:20
  	GroupBox grp1 "" pos:[4,16] width:155 height:115
  	progressBar pb1 "ProgressBar" pos:[16,47] width:123 height:15
  	slider sld1 "Slider" pos:[15,76] width:127 height:44
  	
  	on ckb1 changed state do
  	(
  	local dialogpos = getdialogpos two
  	createdialog one pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
  	destroydialog two		
  	)
  	on ckb2 changed state do
  	(
  	ckb2.state = true		
  	)
  	on ckb3 changed state do
  	(
  	local dialogpos = getdialogpos two
  	createdialog three pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
  	destroydialog two
  	)
  )
  
  rollout three "Rollout Three" width:162 height:137
  (
  	checkbutton ckb1 "1" pos:[4,3] width:51 height:20 
  	checkbutton ckb2 "2" pos:[56,3] width:51 height:20
  	checkbutton ckb3 "3" pos:[108,3] width:51 height:20 checked:true
  	GroupBox grp1 "" pos:[4,16] width:155 height:115
  	radioButtons rdo1 "RadioButtons" pos:[14,46] width:29 height:78 labels:#("1", "2", "3", "4","5","6","7","8") default:1 columns:2
  	
  	on ckb1 changed state do
  	(
  	local dialogpos = getdialogpos three
  	createdialog one pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
  	destroydialog three		
  	)
  	on ckb2 changed state do
  	(
  	local dialogpos = getdialogpos three
  	createdialog two pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
  	destroydialog three
  	)
  	on ckb3 changed state do
  	(
  	ckb3.state = true	
  	)
  )
  
  createdialog one style:#(#style_toolwindow, #style_sysmenu)

By using dialogs and not subrollouts you avoid the rollout window bar issue you spoke of. otherwise, you are going to have to go for a dotnet version to keep 32/64 bit compatibility.


#14

Hi Pete,

Thanks a lot for your suggestion, I take this sample ! in fact, I had done a similar thing with the previous version of the script I’m working on again … I wanted to use tabs because I thought it was the “nice & clean” way to do it. But really, I’m still trying to be at ease with maxscript, and I want to avoid as much as possible to use .Net stuff :frowning: I’ll see what solution become the evidence :wink:

Thanks again !

regards.


#15

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.