GLBasic forum

Codesnippets => DD-GUI => Topic started by: MrTAToad on 2010-Mar-23

Title: handleslider
Post by: MrTAToad on 2010-Mar-23
In order to get a slider working, I've had to change the code slightly to the following :

Code (glbasic) Select
@FUNCTION DDgui_handleslider%: ddgui_vals AS DDGUI_DLG, wdg AS DDGUI_WDG, mx%, my%, b1%, b2%
wdg.wclicked = b1
IF b1 = -1
IF (mx>0 AND my>0 AND mx<wdg.wwidth% AND my<wdg.wheight%)
ddgui_vals.focus$ = wdg.wid$
ENDIF
ENDIF

IF ddgui_vals.focus$ = wdg.wid$ AND b1% // MOUSEAXIS(3) // Lclick - set position
// 0..1
LOCAL pos = MIN(1.0, MAX(0.0, (mx-5.0)/(wdg.wwidth%-9.0) ))
// bring in range
pos = wdg.wminval + pos * (wdg.wmaxval-wdg.wminval)
// round
IF wdg.wstep>0
LOCAL iSteps% = pos / wdg.wstep + 0.4
pos = wdg.wstep * iSteps
wdg.wtext$ = pos
ELSE
wdg.wtext$ = FORMAT$(0,2,pos)
ENDIF

wdg.wclicked% = TRUE
ENDIF

IF b1%=-1 AND ddgui_vals.focus$ = wdg.wid$ THEN ddgui_vals.focus$ = ""
//IF MOUSEAXIS(3)=0 AND ddgui_vals.focus$ = wdg.wid$ THEN ddgui_vals.focus$ = ""
ENDFUNCTION
Title: Re: handleslider
Post by: Kitty Hello on 2010-Mar-23
I see the problem. I'll fix that, too.

Also, I have the impression that the kerning font printing is too slow. I think about extending the LOADFONT routine with an space_between_characters argument, so you can have font kerning built in or (set that to 0) have monospace texts.
Title: Re: handleslider
Post by: MrTAToad on 2010-Mar-23
Might be an idea - might be worth looking at Moru's new proportional font system which now also works on the iPhone and is quick.
Title: Re: handleslider
Post by: Kitty Hello on 2010-Mar-23
There's a great impact on using MID$ for every character. But there's only a few characters after all. Not much work to implement, though I think.