It is currently March 28th, 2024, 11:11 pm

can bar meter has dynamic width ?

Get help with creating, editing & fixing problems with skins
ronzino
Posts: 22
Joined: June 4th, 2020, 4:41 pm

can bar meter has dynamic width ?

Post by ronzino »

I have a vertical bar meter (i.e. it expands-reduces on Y axis) and I would like to modify its width according to a dynamic measure.

But it seems not to work (code example follows). I am sure (but not tried yet) that a workaround should be using rectangle shape...


Code: Select all


[dbgBar_Calc]
Measure=calc
Formula= 100
MinValue=0
MaxValue=100
DynamicVariables=1

[dbgBarW_Calc]
Measure=calc
Formula= (Random)
UpdateRandom=1
LowBound=2
HighBound=10
DynamicVariables=1

[dbgBar]
Meter=Bar
X=300
Y=50
H=100
W=dbgBarW_Calc
MeasureName=dbgBar_Calc
BarColor=255,0,0,255
DynamicVariables=1
UpdateDivider=1

User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: can bar meter has dynamic width ?

Post by eclectic-tech »

ronzino wrote: January 12th, 2022, 1:08 am I have a vertical bar meter (i.e. it expands-reduces on Y axis) and I would like to modify its width according to a dynamic measure.

But it seems not to work (code example follows). I am sure (but not tried yet) that a workaround should be using rectangle shape...
Here are some examples using an image meter (top), followed by a shape meter, and 2 bar meters.

Code: Select all

[Rainmeter]
Update=500

[dbgBarW_Calc]
Measure=calc
Formula=Random
UpdateRandom=1
LowBound=2
HighBound=20
DynamicVariables=1
MinValue=0
MaxValue=100

[dbgBar]
Meter=Image
X=300
Y=50
H=100
W=(100-[dbgBarW_Calc:])
SolidColor=255,0,0,255
DynamicVariables=1

[MeterShapeRectangle]
Meter=Shape
X=300
Y=160
; Shape=Rectangle X,Y,W,H,{Rx},{Ry} | StrokeWidth 2 | Stroke Color 0,0,0,255 | Fill Color 255,255,255,255
Shape=Rectangle 0,0,(100-[dbgBarW_Calc:]),100,0 | Fill Color 255,0,0,255 | StrokeWidth 1 | StrokeColor 47,47,47,100
; Documentation: https://docs.rainmeter.net/manual-beta/meters/shape/#Rectangle
DynamicVariables=1

[MeterBar]
Meter=Bar
MeasureName=dbgBarW_Calc
X=300
Y=270
W=100
H=100
BarColor=255,0,0,255
BarOrientation=Horizontal
; BarImage=
; BarBorder=
Flip=1
SolidColor=47,47,47,100
; Documentation: https://docs.rainmeter.net/manual-beta/meters/bar/

[MeterBar2]
Meter=Bar
MeasureName=dbgBarW_Calc
X=300
Y=380
W=100
H=100
BarColor=255,0,0,255
BarOrientation=Horizontal
; BarImage=
; BarBorder=
Flip=0
SolidColor=47,47,47,100
; Documentation: https://docs.rainmeter.net/manual-beta/meters/bar/
bars4.gif
Any of these should give you a horizontally expanding bar... feel free to ask if you have questions.
You do not have the required permissions to view the files attached to this post.
ronzino
Posts: 22
Joined: June 4th, 2020, 4:41 pm

Re: can bar meter has dynamic width ?

Post by ronzino »

eclectic-tech wrote: January 12th, 2022, 2:38 am Here are some examples using an image meter (top), followed by a shape meter, and 2 bar meters.
thanks for your answer, but probably my question was not so clear. let me explain better.


let's speak about the case of Bar meter. The extension of a bar meter is driven by "MeasureName" and its movement direction is defined by "BarOrientation".

Now let's say that i want a vertical bar so BarOrientation=Vertical and MeasureName=A.
The vertical expansion and contraction is driven by A value.

IN THE MEANWHILE, I would like to drive the width of the Bar meter with another value lets say B. Doing so the implementation of Bar meter will make automatically the movment vertically (Y axis), and I will drive width with B.

BUT it seems to me that is not allowed by rain meter to dynamically change the width of a bar meter (when of course the choosen BarOrientation=Vertical). I other words, if rainmeter drives the BarOrientation=vertical (Y axis enlargement) i am not allowed to modify the width even if it is not touched by the automatic movment implementation.

is it correct ?
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: can bar meter has dynamic width ?

Post by CodeCode »

Bar meters can be dynamic if there is a variable that allows the value to be changed on the fly.

The way to do this would be to add DynamicVariables=1 to your bar meter, and any measure that has a variable in it as well.

Variables can take several forms. Look here for more info.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
ronzino
Posts: 22
Joined: June 4th, 2020, 4:41 pm

Re: can bar meter has dynamic width ?

Post by ronzino »

CodeCode wrote: January 12th, 2022, 9:25 am Bar meters can be dynamic if there is a variable that allows the value to be changed on the fly.

The way to do this would be to add DynamicVariables=1 to your bar meter, and any measure that has a variable in it as well.

Variables can take several forms. Look here for more info.
and it is exactly what i did DynamicVariables=1 or I hope so....but it does not work

Code: Select all

[dbgBar]
Meter=Bar
X=300
Y=50
H=100
W=dbgBarW_Calc
MeasureName=dbgBar_Calc
BarColor=255,0,0,255
DynamicVariables=1
UpdateDivider=1
Last edited by balala on January 12th, 2022, 11:35 am, edited 1 time in total.
Reason: Please use <code> tags whenever are posting code snippets. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: can bar meter has dynamic width ?

Post by balala »

ronzino wrote: January 12th, 2022, 9:42 am and it is exactly what i did DynamicVariables=1 or I hope so....but it does not work
Try to use the string value of the [dbgBarW_Calc] measure in the W option, replacing the W=dbgBarW_Calc option by W=[dbgBarW_Calc]
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: can bar meter has dynamic width ?

Post by CodeCode »

balala wrote: January 12th, 2022, 11:38 am Try to use the string value of the [dbgBarW_Calc] measure in the W option, replacing the W=dbgBarW_Calc option by W=[dbgBarW_Calc]
Yes. That is a section variable. Each measure is essentially a section. That is why I mentioned the manual. You could do what you are trying more than one way and have it be good. Such as using a variable in this form; #VarImg#, then declare that static variable without the # in the [Variables] section, likea dis: VarImg=[dbgBarW_Calc]. I am just illustrating the possible variations - this case using the the character variable #VarImg# is less intuitive than using the section variable [dbgBarW_Calc].

Hope you get it but if you'd prefer to stay on task, balala's suggestion should work for you.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: can bar meter has dynamic width ?

Post by eclectic-tech »

Thanks for clarifying. This will work; because you want the Image and Shape meters to increase vertically (like the Bar meter) some calculations need to be added to the meter's width and height values.
barx3.gif

Code: Select all

[Rainmeter]
Update=250

[MeasureH]
Measure=Loop
StartValue=1
EndValue=100

[MeasureW]
Measure=calc
Formula=Random
UpdateRandom=1
LowBound=2
HighBound=20
DynamicVariables=1
MinValue=0
MaxValue=100

[MeterString]
Meter=String
MeasureName=MeasureH
MeasureName2=MeasureW
X=300
Y=50
Text=MeasureH: %1 | MeasureW: 100-%2

[MeterImageString]
Meter=String
X=300
Y=2R
Text=Image Meter

[dbgBar]
Meter=Image
X=300
Y=(200-[MeasureH])
H=[MeasureH]
W=(100-[MeasureW:])
SolidColor=255,0,0,255
DynamicVariables=1

[MeterShapeString]
Meter=String
X=500
Y=65
Text=Shape Meter

[MeterShapeRectangle]
Meter=Shape
X=500
Y=200
; Shape=Rectangle X,Y,W,H,{Rx},{Ry} | StrokeWidth 2 | Stroke Color 0,0,0,255 | Fill Color 255,255,255,255
Shape=Rectangle 0,0,(100-[MeasureW:]),(-[MeasureH]),0 | Fill Color 255,0,0,255 | StrokeWidth 1 | StrokeColor 47,47,47,100
; Documentation: https://docs.rainmeter.net/manual-beta/meters/shape/#Rectangle
DynamicVariables=1

[MeterBarString]
Meter=String
X=700
Y=65
Text=Bar Meter

[MeterBar]
Meter=Bar
MeasureName=MeasureH
X=700
Y=100
W=(100-[MeasureW:])
H=100
BarColor=255,0,0,255
BarOrientation=Vertical
; BarImage=
; BarBorder=
Flip=0
; Background color optional
; SolidColor=47,47,47,100
DynamicVariables=1
; Documentation: https://docs.rainmeter.net/manual-beta/meters/bar/

You do not have the required permissions to view the files attached to this post.
ronzino
Posts: 22
Joined: June 4th, 2020, 4:41 pm

Re: can bar meter has dynamic width ?

Post by ronzino »

eclectic-tech wrote: January 12th, 2022, 4:19 pm Thanks for clarifying. This will work; because you want the Image and Shape meters to increase vertically (like the Bar meter) some calculations need to be added to the meter's width and height values.
barx3.gif
Thanks for your help I have tried and, resuming, the result (and my fault) is this one..... in the Bar meter, for W i have used dbgBarW_Calc INSTEAD of [dbgBarW_Calc] (see my first post)

NOW..... can someone enlight me why dbgBarW_Calc is a numeric value, while [dbgBarW_Calc] is the string one, and i Have to use a string value to set W in the bar meter ? S
shouldn't W be numeric in the bar meter ? It defines the width !!!

furthermore, lets look at eclectic-tech suggestion to do this

W=(100-[dbgBarW_Calc:])

here we are subtracting a string from a number (i.e. casting) casting back to assign the numeric value to W that for sure it shall be used as numeric.

Is there something I haven't understood?
Honestrly speaking is quit confusing the double value (string and numeric) managment that almost always does not trigger any error in the log like in this case.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: can bar meter has dynamic width ?

Post by eclectic-tech »

This may help to explains about Measure values. All measures return both String and Number values.

When used in MeasureName= in a String Meter, the String value will be used by default.
When a measure name is used in calculations (e.g., Calc 'Formula' or 'IfCondition' tests) the Number value will be used by default.

You can specify which measure value to use by using the measure name as a Section Variable. Using Section Variables lets you control whether the String or Number value is used.

Yeah, it can take a bit of time to understand, but eventually you will come to appreciate the control Section Variables provide.
Remember to always add DynamicVariables=1 in any section with Section Variables in it.

Hope this helps some... :)