It is currently September 14th, 2024, 10:16 pm

Volume Slider [Solved!]

Get help with creating, editing & fixing problems with skins
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider

Post by JpsCrazy »

You know.
I read all of this. And decided, I'm gonna copy the equation and test it myself.
I figured it out, and was about to confirm with you what I discovered.
...and then realized you spelled it all out for me 3 lines down.

How would I do the minimum equal to 0?
Min=0 seems a bit too simple...
[Edit] Similar problem I'd imagine.
The up direction has no limit, so the bar can go off the screen...

[Editx2]Alright. I fixed the limit for the meter, but the virtual placement of the meter is still there.
Like, the bar stops at the top, but if you keep clicking up it #var# gets bigger which controls the bar position. So, it'll be maxed out, but you have click down a bunch of times to make it actually come down.

Code: Select all

[Rainmeter]
Author=JpsCrazy, scroll bar code by Smurfier
Update=200
BackgroundMode=2
SolidColor=50,50,50,100

[Variables]
;Path to NirCmd (uneccesary to change if in \Windows directory)
NirCmdPath=NirCmd.exe

;How many pixels the bar moves by
line.amount=9

;Variable for volume
var=15
;Maximum var
mult=15

;Starting Y value for strings
S.H=0
;Starting Y value for bar
start.value=143

;Don't mess with these ones
Num=1
Move=0
Max=10
Tot=10

;Calculate the Volume=========================================
[msVolume]
Measure=Calc
Formula=#var#*(65535/#mult#)

;Scrollbar and Buttons =======================================
[mtUp]
Meter=Image
ImageName=Arrow.png
ImageFlip=Vertical
AntiAlias=1
LeftMouseUpAction=!Execute [!RainmeterSetVariable Move 0]["#NirCmdPath#" changesysvolume [msVolume]][!RainmeterSetVariable Var [msVarUp]]

[msVarUp]
Measure=Calc
Formula=#Var#+1
DynamicVariables=1

[msMaxVar]
Measure=Calc
Formula=#Var# > 15

[msBarPlace]
Measure=Calc
Formula=(#start.value#+((-#var#)*#line.amount#) > 8) ? #start.value#+((-#var#)*#line.amount#) : 8
DynamicVariables=1

[mtBar]
Meter=Image
ImageName=Circle.png
W=10
H=10
Y=[msBarPlace]
X=3
DynamicVariables=1

[mtDown]
Meter=Image
ImageName=Arrow.png
Y=((#Max#*15)+25+(#S.H#-20))
LeftMouseUpAction=!Execute [!RainmeterSetVariable Move 0]["#NirCmdPath#" changesysvolume -[msVolume]][!RainmeterSetVariable Var [msVarDown]]
AntiAlias=1
DynamicVariables=1

[msVarDown]
Measure=Calc
Formula=#Var#-1
DynamicVariables=1
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Volume Slider

Post by smurfier »

Code: Select all

[msIncrease]
;10 is the maximum value that this can go up to.
Measure=Calc
Formula=(#Var#+1)>10?10:(#Var#+1)
DynamicVariables=1

[msDecrease]
Measure=Calc
;0 is the minimum value that can go down to.
Formula=(#Var#-1)<0?0:(#Var#-1)
DynamicVariables=1
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider

Post by JpsCrazy »

I managed to figure that out for the bar placement but not for movement.
Oh well.

Anywho.
I've finished the mechanics of the bar... I just can't test the volume at the moment.
My desktop computer does not appear to have a native master volume slider, seeing as it has external speakers. Unless someone can find/provide the .exe for this I'm done until the 12th. That's when I should get my laptop back.
I'll work on some aesthetics until then.

Here's the semi-final code for all to see:

Code: Select all

[Rainmeter]
Author=JpsCrazy, original scroll bar code by Smurfier from RSS Scroller
Update=200
BackgroundMode=2
SolidColor=50,50,50,100

;Variables===============================================
[Variables]
;Path to NirCmd (uneccesary to change if in \Windows directory)
NirCmdPath=NirCmd.exe

;How many pixels the bar moves by
line.amount=9

;Variable for volume
var=0
;Maximum var
mult=15

;Here and below you should not change unless you want to change the size of the volume bar. It's all guess and check.
;Starting Y value for strings
S.H=0
;Starting Y value for bar
start.value=143

;Just used for measuring the height/width of things
Max=10
Tot=10

;Don't mess with these ones at all
Num=1
Move=0

;Calculate the change in Volume================================
[msVolume]
Measure=Calc
Formula=#var#*(65535/#mult#)

;Scrollbar and Buttons =======================================
[mtUp]
Meter=Image
ImageName=Arrow.png
ImageFlip=Vertical
AntiAlias=1
LeftMouseUpAction=!Execute [!RainmeterSetVariable Move 0]["#NirCmdPath#" changesysvolume [msVolume]][!RainmeterSetVariable Var [msVarUp]]

[msVarUp]
Measure=Calc
Formula=((#Var#+1) > 15) ? 15 : #Var#+1
DynamicVariables=1

[msBarPlace]
Measure=Calc
Formula=(#start.value#+((-#var#)*#line.amount#) > 8) ? #start.value#+((-#var#)*#line.amount#) : 8
DynamicVariables=1

[mtBar]
Meter=Image
ImageName=Circle.png
W=10
H=10
Y=[msBarPlace]
X=3
DynamicVariables=1

[mtDown]
Meter=Image
ImageName=Arrow.png
Y=((#Max#*15)+25+(#S.H#-20))
LeftMouseUpAction=!Execute [!RainmeterSetVariable Move 0]["#NirCmdPath#" changesysvolume -[msVolume]][!RainmeterSetVariable Var [msVarDown]]
AntiAlias=1
DynamicVariables=1

[msVarDown]
Measure=Calc
Formula=((#Var#-1) <0) ? 0 : #Var#-1
DynamicVariables=1
The temporary circle.png used.
Smurfier's arrow.png used. (Which is white on a white background... Just look for it very top left.)
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider

Post by JpsCrazy »

Fixed the volume.
Created my own images for the buttons, slider, and background.

Here's the next-semi-final code:

Code: Select all

[Rainmeter]
Author=JpsCrazy, original scroll bar code by Smurfier from RSS Scroller
Update=200
BackgroundMode=0
SolidColor=50,50,50,100

;Variables===============================================
[Variables]
;Path to NirCmd (uneccesary to change if in \Windows directory)
NirCmdPath=NirCmd.exe

;How many pixels the bar moves by
line.amount=9

;Variable for volume
var=0
;Maximum var
mult=15

;Here and below you should not change unless you want to change the size of the volume bar. It's all guess and check.
;Starting Y value for strings
S.H=0
;Starting Y value for bar
start.value=143

;Just used for measuring the height/width of things
Max=10
Tot=10

;Don't mess with these ones at all
Num=1
Move=0

;Calculate the change in Volume================================
[msVolume]
Measure=Calc
Formula=(65535/#mult#)
DynamicVariables=1

;Background Image==========================================
[mtBackground]
Meter=Image
ImageName=SliderBackgroundRound.png
Antialias=1
H=((#Max#*15)+25+(#S.H#-20))
X=6
Y=3

;Scrollbar and Buttons=======================================
[msBarPlace]
Measure=Calc
Formula=(#start.value#+((-#var#)*#line.amount#) > 8) ? #start.value#+((-#var#)*#line.amount#) : 8
DynamicVariables=1

[mtBar]
Meter=Image
ImageName=Circle.png
X=4
Y=[msBarPlace]
W=10
H=10
DynamicVariables=1

[mtUp]
Meter=Image
ImageName=Arrow.png
AntiAlias=1
X=2
Y=0
LeftMouseUpAction=!Execute [!RainmeterSetVariable Move 0]["#NirCmdPath#" changesysvolume [MsVolume]][!RainmeterSetVariable Var [msVarUp]]

[msVarUp]
Measure=Calc
Formula=((#Var#+1) > 15) ? 15 : #Var#+1
DynamicVariables=1

[mtDown]
Meter=Image
ImageName=Arrow.png
ImageFlip=Vertical
X=2
Y=((#Max#*15)+25+(#S.H#-20))
LeftMouseUpAction=!Execute [!RainmeterSetVariable Move 0]["#NirCmdPath#" changesysvolume -[MsVolume]][!RainmeterSetVariable Var [msVarDown]]
AntiAlias=1
DynamicVariables=1

[msVarDown]
Measure=Calc
Formula=((#Var#-1) <0) ? 0 : #Var#-1
DynamicVariables=1

[mtUnmute]
Meter=Image
ImageName=VolumeUnmute.png
Antialias=
X=2
Y=((#Max#*15)+35+(#S.H#-20))
W=15
H=15
LeftMouseUpAction=!Execute ["#NirCmdPath#" mutesysvolume 2][!RainmeterHideMeter mtUnmute][!RainmeterShowMeter mtMute]
Hidden=0

[mtMute]
Meter=Image
ImageName=VolumeMute.png
Antialias=
X=2
Y=((#Max#*15)+35+(#S.H#-20))
W=15
H=15
LeftMouseUpAction=!Execute ["#NirCmdPath#" mutesysvolume 2][!RainmeterHideMeter mtMute][!RainmeterShowMeter mtUnmute]
Hidden=1
Images are not completely finished, but at least they're not somebody else's now.
The only reason it's not final is because I think I could make the code cleaner/more convenient and the images aren't completely finished. Also, the placement in parts of the code may not work well, specifically the mute/unmute button. And finally, for the skin to appear correctly it's assumed you have 0 volume and you're not muted.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Volume Slider

Post by smurfier »

I figured that I would point out that you no longer need to move variable. It was a workaround for the bar-background actions which you removed.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider

Post by JpsCrazy »

Thank you. :P
I never quite figured out what it did.
And until very recently, I (think I) still had a few equations of yours which included the move variable.

Told you the code could be better. Ahaa.

Edited out now.
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider [Solved!]

Post by JpsCrazy »

I've been cleaning up the code a lot, and I still have the Max=10 you had.
My calc's are as such: H=((#Max#*15)+5)
Should I just change it to a regular number? Or leave it with the variable?
Either way I don't think it's a big deal, I just like opinions of what's best.
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Volume Slider [Solved!]

Post by Chewtoy »

JpsCrazy wrote:I've been cleaning up the code a lot, and I still have the Max=10 you had.
My calc's are as such: H=((#Max#*15)+5)
Should I just change it to a regular number? Or leave it with the variable?
Either way I don't think it's a big deal, I just like opinions of what's best.
What's best is that you make the code in a way that's easy for you to understand and easy to work with (but still having a working code).
If you plan on having people look at the code, comments!
In the aspect of resources, it's no difference. Or at least no difference to be noticed.
So do as you wish. :)
I don't think, therefore I'm not.
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider [Solved!]

Post by JpsCrazy »

Eh, very true.
There's a comment saying what it does, and I think I'll keep it.
I just have to make everything work in according to that.

I posted the actual skin: Volume Slider