Notifications
Clear all

[Closed] How to make your own Timeline (NOT ENCRYPTED)


(dotnetclass "Screen").AllScreens[1].bounds.height
(dotnetclass "Screen").AllScreens[2].bounds.height
1200
1200
 
(dotnetclass "Screen").AllScreens[1].workingarea.height
(dotnetclass "Screen").AllScreens[2].workingarea.height
1050
1170


 lo1
(dotnetclass "Screen").AllScreens[1].bounds.height
(dotnetclass "Screen").AllScreens[2].bounds.height
1024
1200

:shrug:

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

hmm… puzzle.

solved! i needed to restart computer to update the info. which is sucks.

it’s a great idea but i already have this kind of tool. i did it as a popup-dialog with a list of tags and tagged intervals.

ok. i’ve changed my plan for tomorrow. because there is no solution for #1 an #2 problems for the numericupdown texboxbase key enter let’s do something else.
so i will play with timeline slider look. let’s try to make it looks nice and works smooth.

ps. solutions for #1 and #2 will come themselves. later… trust me.

sorry for this offtopic…

There are many encrypted max scripts now. Too many… Why? I think that a developer just tries to hide some none-perfection of his code. Why do I think so? Because sometimes I don’t see any other reason to hide that a wheel is round and 2×2 equals 4.

Every beginner’s code looks ugly and dirty. same as my code 10 years old. but… it might look poor by technique, but be bright by idea.

My point is… if you feel that some code can make your money… great! Cell it! But if you want to grow with your code leave it free and open, and be ready to be critiqued, compared, contested, and judged.

my best!

ok… i was busy all day and didn’t have time to play with the project… but i still have some progress.
let me remind you what I had:


  try(destroydialog timelineRollout) catch()
  rollout timelineRollout "timelineRollout" width:780 height:24
  (
  	mapped fn setLifetimeControl control = dotnet.setLifetimeControl control #dotnet
  	dotnetcontrol panel "UserControl" pos:[2,2] width:776 height:20
  	
  	on panel Paint s e do if s.tag != off do
  	(
  		s.tag = off
  		s.Refresh()
  		s.tag = on
  	)	
  	on timelineRollout resized size do panel.Width = size.x
  	
  	local dotcolor = dotnetclass "System.Drawing.Color"
  	local dock = dotnetclass "DockStyle"
  	
  	local slidepanel
  	fn makeSlidePanel = 
  	(
  		panel.backcolor = panel.backcolor.Gray
  		
  		slidepanel = dotnetobject "UserControl"
  		slidepanel.dock = dock.Fill
  
  		slider = dotnetobject "UserControl"
  		slider.Width = 100 
  		slider.height = 20
  		
  		s_bt = dotnetobject "Button"
  		s_bt.dock = dock.Left
  		
  		e_bt = dotnetobject "Button"
  		e_bt.dock = dock.Right
  		
  		a_bt = dotnetobject "Button"
  		a_bt.backcolor = s_bt.backcolor.LightBlue
  		a_bt.dock = dock.Fill
  		
  		#(s_bt, e_bt).width = 10
  		#(s_bt, e_bt).height = 20
  		#(s_bt, e_bt).backcolor = s_bt.backcolor.SkyBlue
  		#(a_bt, s_bt, e_bt).flatstyle = s_bt.flatstyle.flat
  		a_bt.flatappearance.bordercolor = s_bt.backcolor.steelblue
  		s_bt.flatappearance.bordercolor = e_bt.flatappearance.bordercolor = s_bt.backcolor.darkslategray
  		slider.controls.addrange #(a_bt, s_bt, e_bt)
  		
  		slidepanel.controls.addrange #(slider)
  		panel.controls.addrange #(slidepanel)
  		
  		fn onMouseDown s e = (s.tag = e.x)
  		dotnet.addeventhandler a_bt "MouseDown" onMouseDown
  		dotnet.addeventhandler s_bt "MouseDown" onMouseDown
  		dotnet.addeventhandler e_bt "MouseDown" onMouseDown
  		
  		fn onMouseMove s e = if e.Button == e.Button.Left do
  		(
  			d = s.parent.location.x + e.x - s.tag
  			if d >= 0 and (d + s.parent.width) <= s.parent.parent.width do s.parent.location.x = d
  		)
  		dotnet.addeventhandler a_bt "MouseMove" onMouseMove
  		fn onMouseMove s e = if e.Button == e.Button.Left do
  		(
  			d = e.x - s.tag
  			if (s.parent.width - d) > 40 do 
  			(
  				s.parent.location.x += d
  				s.parent.width -= d
  			)
  		)
  		dotnet.addeventhandler s_bt "MouseMove" onMouseMove
  		fn onMouseMove s e = if e.Button == e.Button.Left do
  		(
  			d = e.x - s.tag
  			if (s.parent.width + d) > 40 do s.parent.width += d
  		)
  		dotnet.addeventhandler e_bt "MouseMove" onMouseMove
  		
  		fn onSizeChanged s e = if s.controls.count > 0 do
  		(
  			c = s.controls.item[0] 
  			if (c.location.x + c.width) > s.width do c.location.x = amax 0 (s.width - c.width)
  			if c.width > s.width do c.width = amax 40 s.width
  		)
  		dotnet.addeventhandler slidepanel "Resize" onSizeChanged
  
  		setLifetimeControl #(a_bt, s_bt, e_bt, slidepanel)
  		slidepanel
  	)
  	
  	on timelineRollout open do slidepanel = makeSlidePanel()
  )
  createdialog timelineRollout
  

we have some problems there:
#1 when we move the slider fast it doesn’t stop correctly at the edges sometime
#2 when we move the range buttons they can go out of edges
#3 when we move the left range button (start range) the right side of the slider ugly flickers

so I had to solve these problems and add some beauty to the control.

to be continued…

and now we have:


try(destroydialog timelineRollout2) catch()
rollout timelineRollout2 "timelineRollout" width:780 height:24
(
	mapped fn setLifetimeControl control = dotnet.setLifetimeControl control #dotnet
	dotnetcontrol panel "UserControl" pos:[2,2] width:776 height:20
	
	on panel Paint s e do if s.tag != off do
	(
		s.tag = off
		s.Refresh()
		s.tag = on
	)	
	on timelineRollout resized size do panel.Width = size.x
	
	local dotcolor = dotnetclass "System.Drawing.Color"
	local dock = dotnetclass "DockStyle"
	
	local slidepanel
	fn makeSlidePanel = 
	(
		panel.backcolor = panel.backcolor.Gray
		
		slidepanel = dotnetobject "UserControl"
		slidepanel.dock = dock.Fill

		slider = dotnetobject "Button"
		slider.backcolor = slider.backcolor.LightSteelBlue
		slider.flatstyle = slider.flatstyle.flat
		slider.flatappearance.bordercolor = slider.backcolor.Azure

		slider.Width = 100 
		slider.height = 20
		
		s_bt = dotnetobject "Button"
		s_bt.dock = dock.Left

		e_bt = dotnetobject "Button"
		e_bt.dock = dock.Right

		#(s_bt, e_bt).width = 16
		#(s_bt, e_bt).backcolor = s_bt.backcolor.Transparent
		slider.controls.addrange #(s_bt, e_bt)
		
		slidepanel.controls.addrange #(slider)
		panel.controls.addrange #(slidepanel, sr_sp, sa_sp, er_sp, ea_sp)

		fn onMouseDown s e = (s.tag = e.x)
		dotnet.addeventhandler slider "MouseDown" onMouseDown
		dotnet.addeventhandler s_bt "MouseDown" onMouseDown
		dotnet.addeventhandler e_bt "MouseDown" onMouseDown
		
		fn onMouseMove s e = if e.Button == e.Button.Left do
		(
			d = amin (s.parent.width - s.width) (amax 0 (s.location.x + e.x - s.tag))
			s.location.x = d
		)
		dotnet.addeventhandler slider "MouseMove" onMouseMove
		fn onMouseMove s e = if e.Button == e.Button.Left do
		(
			d = e.x - s.tag
			if d  >= 0 then
			(
				w = amax 34 (s.parent.Width - d)
				dx = s.parent.Location.x + (s.parent.Width - w)
			)
			else
			(
				dx = amax 0 (s.parent.Location.x + d)
				w = amax 34 (s.parent.Width + (s.parent.Location.x - dx))
			)
			s.parent.Bounds = dotnetobject "System.Drawing.Rectangle" dx s.parent.Location.y w s.parent.Height
		)
		dotnet.addeventhandler s_bt "MouseMove" onMouseMove
		fn onMouseMove s e = if e.Button == e.Button.Left do
		(
			d = e.x - s.tag
			w = amin (s.parent.parent.Width - s.parent.Location.x) (amax 34 (s.parent.Width + d))
			s.parent.width = w
		)
		dotnet.addeventhandler e_bt "MouseMove" onMouseMove
		
		setLifetimeControl #(slider, s_bt, e_bt, slidepanel)
		slidepanel
	)
	
	on timelineRollout2 open do slidepanel = makeSlidePanel()
)
createdialog timelineRollout2


tomorrow if i have time i will show how to remove the focus rectangle from the range buttons (blue frame) , add text (start/end time range) to the slider, … maybe something else.

everyone who wants can make your own design for slider and share with the community.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

before i show the solution does anyone know how to do it?

ha! here is a minimalistic version of the slider:


 try(destroydialog timelineRollout3) catch()
 rollout timelineRollout3 "timelineRollout" width:780 height:24
 (
 	mapped fn setLifetimeControl control = dotnet.setLifetimeControl control #dotnet
 	dotnetcontrol panel "UserControl" pos:[2,2] width:776 height:20 across:3
 	
 	on panel Paint s e do if s.tag != off do
 	(
 		s.tag = off
 		s.Refresh()
 		s.tag = on
 	)	
 	on timelineRollout resized size do panel.Width = size.x
 	
 	local dotcolor = dotnetclass "System.Drawing.Color"
 	local dock = dotnetclass "DockStyle"
 	
 	local slidepanel
 	fn makeSlidePanel = 
 	(
 		panel.backcolor = panel.backcolor.Gray
 		
 		slidepanel = dotnetobject "UserControl"
 		slidepanel.dock = dock.Fill
 
 		slider = dotnetobject "Button"
 		slider.backcolor = slider.backcolor.Transparent
 
 		fn onTransform s e = 
 		(
 			x = s.Location.x
 			w = s.Width
 			str = x as string + "   " + (x + w) as string
 			if ((dotnetclass "TextRenderer").MeasureText str s.Font).width > s.Width-8 do str = ""
 			s.Text = str
 		)
 		dotnet.addeventhandler slider "Move" onTransform
 		dotnet.addeventhandler slider "Resize" onTransform
 		
 		slider.Width = 100 
 		slider.height = 20
 		
 		slidepanel.controls.addrange #(slider)
 		panel.controls.addrange #(slidepanel, sr_sp, sa_sp, er_sp, ea_sp)
 
 		fn onMouseDown s e = 
 		(
 			c = dotnetclass "System.Windows.Forms.Cursors"
 			s.tag = case of
 			(
 				(e.x < 5): 
 				(
 					s.Cursor.Current = c.SizeWE
 					#(e.x,0,0)
 				)
 				(e.x > s.width - 5): 
 				(
 					s.Cursor.Current = c.SizeWE
 					#(e.x,2,0)
 				)
 				default: 
 				(
 					s.Cursor.Current = c.Default
 					#(e.x,1,0)
 				)
 			)
 		)
 		dotnet.addeventhandler slider "MouseDown" onMouseDown
 		fn onMouseMove s e = 
 		(
 			case e.Button of
 			(
 				(e.Button.None):
 				(
 					c = dotnetclass "System.Windows.Forms.Cursors"
 					s.Cursor.Current = if (e.x < 5 or e.x > s.width-5) then c.SizeWE else c.Default
 				)
 				(e.Button.Left): if s.tag[3] == 0 then
 				(
 					tag = s.tag
 					d = e.x - tag[1]
 					tag[3] = 1
 					case s.tag[2] of
 					(
 						0:
 						(
 							if d  >= 0 then
 							(
 								w = amax 20 (s.width - d)
 								dx = s.location.x + (s.width - w)
 							)
 							else
 							(
 								dx = amax 0 (s.location.x + d)
 								w = amax 20 (s.width + (s.location.x - dx))
 							)
 							s.bounds = dotnetobject "system.drawing.rectangle" dx s.location.y w s.height
 						)
 						2:
 						(
 							w = amin (s.parent.width - s.location.x) (amax 20 (s.width + d))
 							tag[1] += w - s.width
 							s.width = w
 						)
 						default:
 						(
 							x = amin (s.parent.width - s.width) (amax 0 (s.location.x + d))
 							s.location.x = x
 						)
 					)
 					s.tag = tag
 				)
 				else 
 				(
 					tag = s.tag
 					tag[3] = 0
 					s.tag = tag
 				)
 			)
 		)
 		dotnet.addeventhandler slider "MouseMove" onMouseMove
 		
 		setLifetimeControl #(slider, slidepanel)
 		slidepanel
 	)
 	
 	on timelineRollout3 open do slidepanel = makeSlidePanel()
 )
 createdialog timelineRollout3 style:#(#style_titlebar, #style_sysmenu, #style_resizing) lockWidth:on lockHeight:on 
 

the project is finished. at least for me. i realized everything that i wanted. i tried to use minimum of .net, and the project is 99% pure maxscript now. also i had a plan to make the tool as only one file of distribution.
this weekend i will start the show of the development process step-by-step.
i have two days to add some features, realize some ideas… so if you have any please let me know. any requests, comments are welcome.

Page 3 / 8