It is currently April 26th, 2024, 2:41 pm

Volume bar not working?

Get help with creating, editing & fixing problems with skins
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

Re: Volume bar not working?

Post by deXxterlab97 »

jsmorley wrote:It is really not. Not easily anyway. You can use TransformationMatrix to rotate the Image meter and the Bar meter, but that is going to screw up the "hit target" of the mouse, since the hit target will be based on the original un-rotated meter container.

I can't even imagine a way right off, that isn't going to be a hideous challenge, to get the $MouseY:%$ value to be anything close to correct on a rotated meter.
When I mute the volume it shows -1
I Want to simply replace it with OFF

There is something here missing

It works almost fine

When the volume is muted and I click on the bar it will go up to that volume as intended
But when it is already unmuted and I click on the bar everything works except the output number in the [Volume]

I think it has something to do with IfFalseAction

Code: Select all

[Rainmeter]
Update=1000

[Variables]
@Include=#@#Variables.inc

[Metadata]
Name=Life is Rainmeter
Author=deXxterlab97 
Information=Music progress bar, clickable to seek track (fast forward).
License=to kill
Version=1.1 (beta)

[MusicVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

[MeasureChangeVolume]
Measure=Calc
OnChangeAction=[!CommandMeasure MusicVolume "SetVolume [MeasureChangeVolume]"][!UpdateMeasure MusicVolume][!UpdateMeter *][!Redraw]
IfCondition=MusicVolume = -1
IfTrueAction=[!SetOption Volume Text "Off"][!Redraw]
OnUpdateAction=[!UpdateMeter Volume][!Redraw]
IfFalseAction=[!SetOption Volume Text "[MusicVolume:]"][!Redraw]


[BarBackground]
Meter=Image
X=0
Y=0
H=700
W=5
SolidColor=200,200,200,100
LeftMouseUpAction=[!SetOption MeasureChangeVolume Formula "(100-$MouseY:%$)"][!UpdateMeasure MeasureChangeVolume]
DynamicVariables=1
ImageRotate=10



[MeterBar]
Meter=Bar
MeasureName=MusicVolume
X=0
Y=0
H=700
W=5
BarColor=255,255,255
ImageRotate=10



[Volume]
Meter=String
MeasureName=MusicVolume
FontColor=#FC#
FontSize=#FS#
FontFace=#FF#
DynamicVariables=1
AntiAlias=1
X=10
Y=650
deXxterlab97
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Volume bar not working?

Post by balala »

deXxterlab97 wrote:lastly, is it possible to rotate bars and image with rainmeter or not?
As jsmorley said, if you don't need to make the rotated meter clickable, it's easy, but making it clickable to set the appropriate volume level, is much harder.
To simply rotate a meter, you have to do the followings:
  • Add the following variables to the [Variables] section:

    Code: Select all

    [Variables]
    ...
    Angle=45
    X=5
    Y=500
    From these variables, Angle is the rotation angle (and be careful, positive values mean clockwise rotation, while negative ones mean anticlockwise rotation), and X and Y are the coordinates of the rotation center (the meter will be rotated around this point).
  • Now add the following option to the meter which you'd like to rotate: TransformationMatrix=(Cos(Rad(-#Angle#)));(-Sin(Rad(-#Angle#)));(Sin(Rad(-#Angle#)));(Cos(Rad(-#Angle#)));(#X#-#X#*Cos(Rad(-#Angle#))-#Y#*Sin(Rad(-#Angle#)));(#Y#+#X#*Sin(Rad(-#Angle#))-#Y#*Cos(Rad(-#Angle#))).
This is the easiest part of the rotation. I also can't imagine a same easy way to make this rotated meter to be clickable in the same way as the un-rotated is.
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Volume bar not working?

Post by balala »

deXxterlab97 wrote:When the volume is muted and I click on the bar it will go up to that volume as intended
But when it is already unmuted and I click on the bar everything works except the output number in the [Volume]

I think it has something to do with IfFalseAction
No, it has not. Just add an IfConditionMode=1 option to the [MeasureChangeVolume] measure. Problem was caused by the fact that without this option, any of the IfTrueAction / IfFalseAction option is executed just once, not each time when the volume changes (unless in the meantime you don't mute, then unmute the volume). So, when the value is changing, the IfFalseAction isn't executed once again. The IfConditionMode=1 option makes it to be executed on each update cycle.

And one more: actually you don't need the [BarBackground] meter. Remove it and add a SolidColor=200,200,200,100 option to the [MeterBar] meter.
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

Re: Volume bar not working?

Post by deXxterlab97 »

balala wrote:As jsmorley said, if you don't need to make the rotated meter clickable, it's easy, but making it clickable to set the appropriate volume level, is much harder.
To simply rotate a meter, you have to do the followings:
  • Add the following variables to the [Variables] section:

    Code: Select all

    [Variables]
    ...
    Angle=45
    X=5
    Y=500
    From these variables, Angle is the rotation angle (and be careful, positive values mean clockwise rotation, while negative ones mean anticlockwise rotation), and X and Y are the coordinates of the rotation center (the meter will be rotated around this point).
  • Now add the following option to the meter which you'd like to rotate: TransformationMatrix=(Cos(Rad(-#Angle#)));(-Sin(Rad(-#Angle#)));(Sin(Rad(-#Angle#)));(Cos(Rad(-#Angle#)));(#X#-#X#*Cos(Rad(-#Angle#))-#Y#*Sin(Rad(-#Angle#)));(#Y#+#X#*Sin(Rad(-#Angle#))-#Y#*Cos(Rad(-#Angle#))).
This is the easiest part of the rotation. I also can't imagine a same easy way to make this rotated meter to be clickable in the same way as the un-rotated is.
What changes would I have to make if my bar is almost horizontal? (Just around 10 degrees clockwise from the horizontal position).The above code seems to work only when the bar is rotated from vertical position by a certain degree.
deXxterlab97
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Volume bar not working?

Post by balala »

deXxterlab97 wrote:What changes would I have to make if my bar is almost horizontal? (Just around 10 degrees clockwise from the horizontal position).The above code seems to work only when the bar is rotated from vertical position by a certain degree.
Changes for what? What would you like to achieve? You'd like to make it horizontal?
If you would, obviously first you have to change the Angle to 90 degrees (but I think you did this, right?): Angle=90.
Also you can try to remove the ImageRotate option of the [MeterBar] meter.
Is it now horizontal?
If not, please post the current code (again, please).
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

Re: Volume bar not working?

Post by deXxterlab97 »

balala wrote:Changes for what? What would you like to achieve? You'd like to make it horizontal?
If you would, obviously first you have to change the Angle to 90 degrees (but I think you did this, right?): Angle=90.
Also you can try to remove the ImageRotate option of the [MeterBar] meter.
Is it now horizontal?
If not, please post the current code (again, please).

Code: Select all

[Variables]
@Include=#@#Variables.inc
Angle=10
X=100
Y=100

[MeterBar]
Meter=Bar
MeasureName=MusicVolume
TransformationMatrix=(Cos(Rad(-#Angle#)));(-Sin(Rad(-#Angle#)));(Sin(Rad(-#Angle#)));(Cos(Rad(-#Angle#)));(#X#-#X#*Cos(Rad(-#Angle#))-#Y#*Sin(Rad(-#Angle#)));(#Y#+#X#*Sin(Rad(-#Angle#))-#Y#*Cos(Rad(-#Angle#)))
BarColor=255,255,255
SolidColor=200,200,200,100
H=100
W=500
So the bar fills up vertically not horizontally across like I would want to.
deXxterlab97
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Volume bar not working?

Post by balala »

deXxterlab97 wrote:So the bar fills up vertically not horizontally across like I would want to.
H=100 and W=500 on the [MeterBar] meter mean that the bar is 500 pixels wide and 100 pixels high. And you're rotating this bar around the point with the X=100 and Y=100 coordinates, with 10 degrees.
Try to replace the size of the bar meter with W=100 and H=500 and rotate it with 80 or 100 degrees.
If there's needed, you also can set a width and a height for the skin itself, with the SkinWidth and SkinHeight options, placed into the [Rainmeter] section.
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

Re: Volume bar not working?

Post by deXxterlab97 »

balala wrote:H=100 and W=500 on the [MeterBar] meter mean that the bar is 500 pixels wide and 100 pixels high. And you're rotating this bar around the point with the X=100 and Y=100 coordinates, with 10 degrees.
Try to replace the size of the bar meter with W=100 and H=500 and rotate it with 80 or 100 degrees.
If there's needed, you also can set a width and a height for the skin itself, with the SkinWidth and SkinHeight options, placed into the [Rainmeter] section.
Now I am kinda lost with transformation matrix

It creates a very weird shape instead

I want to make a 5 pixel high bar that is approximately 700-800 pixel long rotated to 10 degree (or equivalent of 80 or something degree from the vertical position)

So far I am testing different combination of W and H and so far H=500 and W=100 gives me a near square shape that works almost as it should, apart from the weird shape

I will post the entire code just in case

Code: Select all

[Rainmeter]
Update=1000

[Variables]
@Include=#@#Variables.inc
Angle=100
X=100
Y=100

[Metadata]
Name=Life is Rainmeter
Author=deXxterlab97 
Information=Music progress bar, clickable to seek track (fast forward).
License=to kill
Version=1.1 (beta)

[MusicVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

[MeasureChangeVolume]
Measure=Calc
OnChangeAction=[!CommandMeasure MusicVolume "SetVolume [MeasureChangeVolume]"][!UpdateMeasure MusicVolume][!UpdateMeter *][!Redraw]

IfConditionMode=1
IfCondition=MusicVolume = -1
IfTrueAction=[!SetOption Volume Text "Off"][!Redraw]
OnUpdateAction=[!UpdateMeter Volume][!Redraw]
IfFalseAction=[!SetOption Volume Text "[MeasureChangeVolume:]"][!Redraw]

[MeterBar]
Meter=Bar
MeasureName=MusicVolume
TransformationMatrix=(Cos(Rad(-#Angle#)));(-Sin(Rad(-#Angle#)));(Sin(Rad(-#Angle#)));(Cos(Rad(-#Angle#)));(#X#-#X#*Cos(Rad(-#Angle#))-#Y#*Sin(Rad(-#Angle#)));(#Y#+#X#*Sin(Rad(-#Angle#))-#Y#*Cos(Rad(-#Angle#)))
BarColor=255,255,255
SolidColor=200,200,200,100
H=500
W=100


[Volume]
Meter=String
MeasureName=MusicVolume
FontColor=#FC#
FontSize=#FS#
FontFace=#FF#
DynamicVariables=1
AntiAlias=1
X=10
Y=650
Hidden=1
deXxterlab97
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Volume bar not working?

Post by jsmorley »

Sounds to me like this would be easier if you started with BarOrientation=Horizontal.
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Volume bar not working?

Post by balala »

jsmorley wrote:Sounds to me like this would be easier if you started with BarOrientation=Horizontal.
Definitely.
deXxterlab97 wrote:I want to make a 5 pixel high bar that is approximately 700-800 pixel long rotated to 10 degree (or equivalent of 80 or something degree from the vertical position)
I can't really understand if you'd like "a 5 pixel high bar that is approximately 700-800 pixel long", why have you set its width and height to 100 and 500 respectively.
So, first set appropriately the width and height of the bar meter:

Code: Select all

[MeterBar]
...
W=700
H=5
Then add to the same meter the option to have a horizontal bar: BarOrientation=Horizontal.
And now finally you can set parameters of the TransformationMatrix, to rotate this bar with 10 degrees:

Code: Select all

[Variables]
...
Angle=10
X=0
Y=0
As I said, these values will probably require to set the size of the skin, through the SkinWidth and SkinHeight options:

Code: Select all

[Rainmeter]
...
SkinWidth=700
SkinHeight=140