slider-like !bang-launcher Thread last updated on 2004-05-04 17:34:27

Posted by member 333 on 2003-11-14 04:06:05

Like the title of the thread says, I'd love to see a slider-like module that would be able to launch !bangs. I'm thinking that it could be nice to have a small slider in a box or something, and depending on position it shows different modules in the box (i.e. use mzscript to show/hide vwm/clock/whatever).

example (use your imagination and think of the following as a slider in different positions ;):
|--*-| = vwm visible
|-*--| = clock visible

I guess it would be a good idea to only launch the !bangs on MouseUp, so that they won't be active until you release the slider.

anyway, I'd love to actually be able to code this myself, but I'm afraid I'm a programming-imbecile.

Posted by member 12798 on 2003-11-14 07:06:13 link

i like the idea, could go along with some nice visuals :)

regarding benefits from it, what do you have in mind? this could also be made with shortcuts or the like, except for the not having a slider.

Posted by member 333 on 2003-11-14 08:09:33 link

well, the benefit would, to put it simple, be to have another way of launching !bangs. As you say, this could be done through shortcuts (or skinbox) and obviously a million other ways, but I'd like to have a slider to do this, basically. I guess I could try to accomplish this through scripting (probably extensive) and skinbox... maybe it's doable...

but I'd still like this module for whatever reasons, hehe

I think it would be cool to for instance have a box with geekamp/jamptoo + two sliders: one slider for controlling volume, and one to actually control the player (play/rew...).

not a necessary module, but just a nice addition to the LS-mod family.

Posted by member 1316 on 2003-11-14 12:50:38 link

tuck, I believe ltd-evolution has something like this. I'm not sure if there's an ots2 version yet, but you should be able to find the original on customize.org

Posted by member 99 on 2003-11-14 13:15:02 link

SliderStepsX 4
SliderStepsY 1
SliderStep1Cmd '!alert "Position 1"'
SliderStep2Cmd '!alert "Position 2"'
SliderStep3Cmd '!alert "Position 3"'
SliderStep4Cmd '!alert "Position 4"'

SliderWaitForRelease true
SliderWidth 96
SliderHeight 0
SliderHandleWidth 16
SliderHandleHeight 16
SliderPaddingX 8
SliderPaddingY 8

; ----------

*skinbox SliderBox
SliderBoxWidth $SliderWidth+2*SliderPaddingX+SliderHandleWidth$
SliderBoxHeight $SliderHeight+2*SliderPaddingY+SliderHandleHeight$

*script bang !SliderInit
*script exec !SkinBoxOnTop %{\1} false
*script exec !SkinBoxExec %{\1} !SkinBoxLoadBoxHook "name=%{\2}" ":" {@ih}
*script exec !SkinBoxAction %{\2} LButtonDown !SliderBeginDrag %{\2} %{\1}
*script exec !SkinBoxAction %{\2} LButtonUp !SliderEndDrag %{\2}
*script exec !SkinBoxMove %{\2} $SliderPaddingX$ $SliderPaddingY$
*script ~bang

*script bang !SliderBeginDrag
*script exec !SkinBoxAction %{\1} MouseMove !SliderDragTo {@in} %{\2} {@mxs} {@mys}
*script ~bang

*script bang !SliderEndDrag
*script gotoif ("$SliderWaitForRelease$" = "false") SliderEndDragFinish
*script exec !SkinBoxExec %{\1} {SliderStep%{SliderStep}Cmd}
*script label SliderEndDragFinish
*script exec !SkinBoxAction %{\1} MouseMove
*script ~bang

SliderStepXSize $SliderWidth/(SliderStepsX-1)$
SliderStepYSize $SliderHeight/(SliderStepsY-1)$
SliderStepXShift $SliderStepXSize/2-SliderPaddingX$
SliderStepYShift $SliderStepYSize/2-SliderPaddingY$

*script bang !SliderDragTo
*script exec !SkinBoxExec %{\2} !varSet SliderStepX \d(%{\3}-{@ix}+SliderStepXShift)/SliderStepXSize\d
*script gotoif ("%{SliderStepX}" = "0") NoClipXBottom
*script exec !varSet SliderStepX 0
*script label NoClipXBottom
*script exec !SkinBoxExec %{\2} !varSet SliderStepY \d(%{\4}-{@iy}+SliderStepYShift)/SliderStepYSize\d
*script gotoif ("%{SliderStepY}" = "0") NoClipYBottom
*script exec !varSet SliderStepY 0
*script label NoClipYBottom
*script exec !SkinBoxExec . !varSet SliderStep \d%{SliderStepX}+%{SliderStepY}*SliderStepsX+1\d
*script gotoif ("$SliderWaitForRelease$" = "true") SliderDragToWait
*script exec !SkinBoxExec %{\1} "\dSliderStep%{SliderStep}Cmd\d"
*script label SliderDragToWait
*script exec !SkinBoxExec . !varSet SliderHandleX \d%{SliderStepX}*SliderStepXSize+SliderPaddingX\d
*script exec !SkinBoxExec . !varSet SliderHandleY \d%{SliderStepY}*SliderStepYSize+SliderPaddingY\d
*script exec !SkinBoxExec . !SkinBoxMove %{\1} %{SliderHandleX} %{SliderHandleY}
*script ~bang

*script start !SliderInit SliderBox SliderHandle
There seems to be a bug in drawing with colors when using the boxhook, but otherwise this works.

Posted by member 99 on 2003-11-14 15:32:01 link

Or at least it would work, if posting it here hadn't wiped out the bit to clip the x and y values to the range. Grr.

Posted by member 7223 on 2003-11-14 16:45:55 link

Yeah !!!
Skinbox is finally released !!!

I'm happy :D

Posted by member 333 on 2003-11-15 06:32:30 link

interesting, RabidCow. I'll be sure to test this :)

Posted by member 99 on 2003-11-15 11:02:23 link

*script gotoif ("%{SliderStepX}" = "0") NoClipXBottom
*script exec !varSet SliderStepX 0
*script label NoClipXBottom

should be
*script gotoif ("%{SliderStepX}" < "$SliderStepsX$") NoClipXTop
*script exec !varSet SliderStepX $SliderStepsX-1$
*script label NoClipXTop
*script gotoif ("%{SliderStepX}" >= "0") NoClipXBottom
*script exec !varSet SliderStepX 0
*script label NoClipXBottom

and similarly for Y.

Posted by member 333 on 2003-11-18 11:05:16 link

RabidCow, you are great! What more can I say. The script works just like I want it to! Add enough SliderStepXCmd's and the sliding looks perfect!

Thanks a lot!


oh, and programmers: I guess the module-request can be ignored for now ;)

Posted by member 12798 on 2003-11-18 12:51:21 link

this should be moved to the code forum then :)

Posted by member 71746 on 2003-11-21 20:07:09 link

Rabid... do you sleep??

Posted by member 99 on 2003-11-22 02:21:08 link

Yeah, once or twice.

Posted by member 128640 on 2004-05-03 06:49:31 link

Hi !

Smurth gave me the link to this post because I'm trying to make a slider with mzscript.

In fact, I would like to do a slider that return the value of the knob's position... so I use your script with 256 positions but I don't know how to modify a var dynamically without !reload

*script bang !SliderEndDrag
*script gotoif ("$SliderWaitForRelease$" = "false") SliderEndDragFinish
*script exec !SkinBoxExec %{\1} {SliderStep%{SliderStep}Cmd}
*script label SliderEndDragFinish
*script exec !SkinBoxAction %{\1} MouseMove
*script ~bang
so, using %{SliderStep} in a var bozo and then make a
!SkinBoxAlpha myfirstskinbox bozo


can you help me ?

Posted by member 12025 on 2004-05-03 12:48:35 link

Of course it'd be really great if LSSlider simply allowed a slider to return it's value as you moved it.
*Slider ... [NOTVOLUME] !execute [!varSet tmp (escape code)][!script_to_deal_with_it]

or something

Posted by member 35 on 2004-05-03 18:09:50 link

it used to support it, but was removed, nobody used it =P

Posted by member 37809 on 2004-05-03 22:58:12 link

that was way back when there weren't any useful modules :)

Posted by member 99 on 2004-05-04 12:40:26 link

martoh: I'm not sure if I understand what you're trying to do, but perhaps replace
*script exec !SkinBoxExec %{\1} {SliderStep%{SliderStep}Cmd}
with
*script exec !SkinBoxAlpha myfirstskinbox %{SliderStep}
?

Really it sounds like you could get by with a simpler version of this script...

Posted by member 128640 on 2004-05-04 17:34:27 link

thanks, finally I did it with a var containing the bang value... same work as your last code RabidCow...

I post here the code :

in theme.rc
*SkinBox sliderbg1 0 0 256 13 #1tl
sliderbg1x 50
sliderbg1y 100
sliderbg1bitmap slider_bg.png
sliderbg1Tile true


in theme.mz
*script bang !tohSliderInit
*script exec !SkinBoxCreate %{\1}Knob 50 50 8 13 #1tl
*script exec !SkinBoxBitmap %{\1}Knob slider_knob.png
*script exec !skinboxexec %{\1} !varset lpx {@ix}
*script exec !skinboxexec %{\1} !varset lpy {@iy}
*script exec !skinboxexec %{\1} !varset hpx {@isx}
*script exec !skinboxexec %{\1} !varadd hpx %{lpx}
*script exec !SkinBoxAction %{\1}Knob LButtonDown !knobdrag %{\1}Knob
*script exec !SkinBoxAction %{\1}Knob LButtonUp !knobdragstop %{\1}Knob
*script exec !SkinBoxMove %{\1}Knob %{lpx} %{lpy}
*script exec !varSet tohaction %{\2}
*script exec !varSet tohvictime %{\3}
*script ~bang

; !knobdrag [skinboxname] [skinbox"parent"name]
; x, y, dx, dy modified

*script bang !knobdrag
*script exec !skinboxexec %{\1} !varset dx {@mx}
*script exec !skinboxexec %{\1} !varset dy {@my}
*script exec !timerupdate drag #l 75 '!knobdragloop %{\1}'
*script exec !timerstart drag
*script ~bang


*script bang !knobdragloop
*script exec !skinboxexec %{\1} !varset %{\1}x {@mxs}
*script exec !skinboxexec %{\1} !varset %{\1}y {@iys}
*script exec !varadd %{\1}x -%{dx}
*script exec !varset x {%{\1}x}
*script exec !varset x %%{x}
*script exec !ifEval ("%{x}" &gt "%{hpx}") !varset x %{hpx}
*script exec !ifEval ("%{x}" &lt "%{lpx}") !varset x %{lpx}
*script exec !skinboxexec %{\1} !varset posactuelle %{x}
*script exec !varset y {%{\1}y}
*script exec !varset y %%{y}
*script exec !skinboxmove %{\1} %#%{x}-resolutionx%# %#%{y}-resolutiony%#
*script ~bang


*script bang !knobdragstop
*script exec !timerkill drag
*script exec !varadd posactuelle -%{lpx}
*script exec %{tohaction} %{tohvictime} %{posactuelle}
*script ~bang


*script start !tohSliderInit sliderbg1 !SkinBoxAlpha Skinboxtomodify

;*script start !tohSliderInit [nameoftheslider] [action to do when release] [Skinboxtomodify]


This code is a compilation of the script from RabidCow and the script from Smurth for dragging skinboxes.

I do not hook the knob for keeping full alpha possibilities.

It's working well for the Alpha... but... need RabidCow to implement Hue, Saturation and Color replacement on the SkinBox now :D

btw thank you all for your help !