Sliders

Find quick help here to get you started with Hollywood
Post Reply
ocean77
Posts: 111
Joined: Mon Jan 28, 2019 8:34 pm

Sliders

Post by ocean77 »

Anyone have some information or a tutorial on how to set up some sliders to affect settings like volume etc?
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: Sliders

Post by Bugala »

Are you planning on using it on Designer or without Designer.

If without Designer, then do you plan to use it With LAYERS on, or off?

Those all affect the code.

But generally speaking you need following:

1. Some way to display the slider (how this is done is affected by your answer to the question at the beginning)

2. you need to do it in a way that when mousebutton is pushed down on top of that graphic, you save the graphics X and Y, and also the current Mouse X and Y.

3. You also need to make some sort of variable like "slidermoving" which you set to "TRUE"

4. after 2 and 3, you will then have this function which will be executed only when "slidermoving" is TRUE.

5. This Function mentioned in 4 needs to check the current mouse X and Y, and compare it to original/previous X and Y, and based upon this, the graphics X and Y in 2 needs to be changed. As example, if Mouse X have moved 10x, then graphics should change into Slider1Gfx = Slider1Gfx + 10.

6. You also need to limit the SliderGFX movement, since you need to have 0 percent and 100 percent location. So if mouse moves 1000x, and there is only 300x of movement available for the slider, then you gap it at that 300.

7. To actually adjust the Volume for example, you need a variable called "Volume" which could have values between 0 to 100 as example.

8. To determine Volumes value, you need to compare Slider1Gfx X to the minimum and maximum X. That suppose following:

Minimum X Slider1Gfx can be is 500, max it can be is 800.
If current Slider1Gfx is at location 650, then you do following calculation:

650 - 500 = 150 (This tells you the current volume location)
800 - 500 = 300 (This tells you the max volume)
300 / 100 = 3 (amount of one percentage of volume)
150 / 3 = 50 (actual Volume)

Using this information, you can now adjust the volume.

9. Naturally, when mouse button goes up, you set "Slidermoving" variable into FALSE and therefore stop executing the function at step 4.
Flinx
Posts: 192
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Sliders

Post by Flinx »

Look at HollyAmp.hws from the Hollywood examples, this could be a good start. And it works in the way Bugala explained.
ocean77
Posts: 111
Joined: Mon Jan 28, 2019 8:34 pm

Re: Sliders

Post by ocean77 »

Thanks for replying, guys.

I'm working in Designer 6 at the moment.
I've had a look at HollyAmp as Flinx suggested. You'd be surprised how difficult these things are to decipher for a non-programmer.

Another, perhaps easier, method would be to just use clickable arrow-buttons to set the volume up or down. I also, preferably, need to write the set values to a file for later retrieval.
ocean77
Posts: 111
Joined: Mon Jan 28, 2019 8:34 pm

Re: Sliders

Post by ocean77 »

If I did something like this, which I think is something I can handle with relative ease in Designer:
https://drive.google.com/file/d/15natdA ... sp=sharing

Do you think the jumps in volume would be too jarring? Since it is only four levels(16, 32, 48 and 64), plus zero.
Guess I'll have to try to know for sure, but it might be a waste of time.
Flinx
Posts: 192
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Sliders

Post by Flinx »

ocean77 wrote: Tue Aug 30, 2022 7:38 pm Do you think the jumps in volume would be too jarring? Since it is only four levels(16, 32, 48 and 64), plus zero.
I think this is not fine enough. For example I have made a player with HiFiBberry Amp2, and there are used mostly the low volumes, so that I had to spread the low volume area to make it usable on the tiny touch screen. 16 is already too much for this use case.
Maybe you can make four buttons, one for big steps and one for only one step?
ocean77
Posts: 111
Joined: Mon Jan 28, 2019 8:34 pm

Re: Sliders

Post by ocean77 »

I guess I could further divide each 16 step and have the opacity of the inner box be the visual cue for loudness. But the complexity grows. Sliders seem like a better option now.
User avatar
Redlion
Posts: 96
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: Sliders

Post by Redlion »

Hi ocean77,

Have a look at the post "Simple Cross-Platform Gadgets with string input" there is a slider in there.

You can download the demo from the link a few posts down.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
ocean77
Posts: 111
Joined: Mon Jan 28, 2019 8:34 pm

Re: Sliders

Post by ocean77 »

Redlion wrote: Fri Sep 02, 2022 2:35 am Hi ocean77,

Have a look at the post "Simple Cross-Platform Gadgets with string input" there is a slider in there.

You can download the demo from the link a few posts down.

Cheers
Leo
Sorry for the late reply. Computer issues. If anyone's interested: on the Linux Fedora side, going the standard workstation (gnome) route instead of any official/non-official spins is the way to go. Seemed to resolve a whole host of problems with graphics drivers especially. Love KDE though and I miss it.

Anyway, thanks for the tip. I'll be sure to check it out asap. :)
Post Reply