Why aren't my trackbar controls responsive?

BlitzMax Forums/MaxGUI Module/Why aren't my trackbar controls responsive?

sswift(Posted 2009) [#1]
My trackbar controls aren't as responsive as the regular sliders in a window are. The movment of a regular slider is super smooth, whereas the trackbar feels almost like it's being updated at a lower framerate.

Changing the maximum value doesn't seem to have any effect. MSDN indicates sliders have some kinda tick incremnent which can be set, but Blitzmax appears to provide no interface for this. I wonder if perhaps internally BlitzMax doesn't set this value high enough.


SebHoll(Posted 2009) [#2]
Can you post an example?

Are you using an event queue or an event hook?

Also, iirc, the tick increment for all the slider controls is set to 1.


sswift(Posted 2009) [#3]
I'm not using either. I'm just laying out the gadgets right now.





The slider of interest is the horizontal one at the top on the right side. The "shading strength" slider. The other ones don't have min and max values set to something sensible as I just ported the code from BlitzPlus.

The top slider I tried min and max values of 0 and 100, 0 and 1000 and 0 and 10,000 and saw no difference. All somewhat choppy movement. The regular sliders in the left side panel though move super smooth.


sswift(Posted 2009) [#4]
Hm, that's odd. I think I found the problem, though I don't know the cause.

The problem is the delay(100) I have in the main loop. For some reason, giving LESS time back to the operating system, ie, getting rid of that or setitng it to 1, makes the slider move more smoothly.

What I don't get is why that would have the opposite effect you expect and why it only affects the one type of slider.


sswift(Posted 2009) [#5]
Yep, that's definitely the problem. Setting it to 1000 makes the app take a moment to draw and makes the trackbars almost completely unresponsive. The regular window sliders continue to behave normally however.


jsp(Posted 2009) [#6]
No need for a delay, just use WaitEvent() and it will be super smooth.
Repeat
	WaitEvent()
	'Delay(100)
Until KeyHit(KEY_ESCAPE) '? may better to act on window close? 



SebHoll(Posted 2009) [#7]
sswift, this is a standard MaxGUI event loop that I recommend you should use instead:

Repeat
	Select WaitEvent()
		Case EVENT_APPTERMINATE, EVENT_WINDOWCLOSE;End
	EndSelect
Forever
A little technical explanation just in case you are curious: the reason why you were experiencing different behaviour with trackbars and scrollbars is because scrollbars go into a modal system loop when they are being scrolled (effectively halting the execution of your main application until the scroll position has been obtained). As such, this means that the Delay in your main-loop was not executed during the scroll. On the otherhand, the trackbar isn't modal and so will be still running the loop and executing the Delay statement while you are scrolling.


sswift(Posted 2009) [#8]
If application code doesn't execute when in a modal event loop then how did I update my textboxes in realtime as the user moved the sliders inb BlitzPlus?

And how am I to scroll stuff in a canvas when the sliders are being moved? I don't want the canvas to only be updated when the user lets go of the slider control.


SebHoll(Posted 2009) [#9]
If application code doesn't execute when in a modal event loop then how did I update my textboxes in realtime as the user moved the sliders inb BlitzPlus?

You could have done easily with certain sliders, but not other types. That's what I'm trying to say - trackbars yep, scrollbars no (unless see below).

And how am I to scroll stuff in a canvas when the sliders are being moved? I don't want the canvas to only be updated when the user lets go of the slider control.

If you want your program to update while the system is in a modal loop, then you must use Event Hooks - see Assari's amazing tutorial here.

Also, MaxGUI now has a new CreateScrollPanel() gadget that will handle moving panels around for you. See here for more info.


sswift(Posted 2009) [#10]
Seb:
I used scrollbars when I did it in Blitzplus. Blitzplus didn't have trackbars. And I didn't use an event hook either. I just had your standard event handler. Same thing for scrolling the canvas.

I guess Blitzplus worked differently, but I don't know how mark managed that.