I want to create a small skin that requires me to have the bar be segmented, and act as segments, as opposed to one contiguous image, as in if CPU utilization is between X% and Y% load segment #1; if CPU utilization is between Y% and Z%, keep segment #1 loaded and also load #2.
I hope I made enough sense.
It is currently March 29th, 2024, 8:32 am
Segmented Bar Measure
-
- Posts: 7
- Joined: June 1st, 2020, 7:26 pm
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Segmented Bar Measure
Yep, you definitely made...xFluing wrote: ↑June 1st, 2020, 7:36 pm I want to create a small skin that requires me to have the bar be segmented, and act as segments, as opposed to one contiguous image, as in if CPU utilization is between X% and Y% load segment #1; if CPU utilization is between Y% and Z%, keep segment #1 loaded and also load #2.
I hope I made enough sense.
There are more possible solutions, here is one of them. I used (only) four Image meters, to create the bar, but if needed (and desired), further ones can be added. The limits (X, Y, Z and so on) are from 0% to 25% (first segment), from 26% to 50% (second segment), from 51% to 75% (third segment) and respectively from 76% to 100% (fourth - last - segment),
Please try out the following code and let me know if it meets your needs:
Code: Select all
[Rainmeter]
Update=1000
[Variables]
[MeasureCPU]
Measure=CPU
IfCondition=(#CURRENTSECTION#<=25)
IfTrueAction=[!ShowMeter "Meter0-25"][!HideMeter "Meter25-50"][!HideMeter "Meter50-75"][!HideMeter "Meter75-100"][!Redraw]
IfCondition2=((#CURRENTSECTION#>25)&&(#CURRENTSECTION#<=50))
IfTrueAction2=[!ShowMeter "Meter0-25"][!ShowMeter "Meter25-50"][!HideMeter "Meter50-75"][!HideMeter "Meter75-100"][!Redraw]
IfCondition3=((#CURRENTSECTION#>50)&&(#CURRENTSECTION#<=75))
IfTrueAction3=[!ShowMeter "Meter0-25"][!ShowMeter "Meter25-50"][!ShowMeter "Meter50-75"][!HideMeter "Meter75-100"][!Redraw]
IfCondition4=(#CURRENTSECTION#>75)
IfTrueAction4=[!ShowMeter "Meter0-25"][!ShowMeter "Meter25-50"][!ShowMeter "Meter50-75"][!ShowMeter "Meter75-100"][!Redraw]
[Meter0-25]
Meter=Image
SolidColor=0,255,0
X=0
Y=75
W=30
H=25
Hidden=1
[Meter25-50]
Meter=Image
SolidColor=255,240,0
X=0r
Y=-25r
W=30
H=25
Hidden=1
[Meter50-75]
Meter=Image
SolidColor=255,127,40
X=0r
Y=-25r
W=30
H=25
Hidden=1
[Meter75-100]
Meter=Image
SolidColor=255,0,0
X=0r
Y=-25r
W=30
H=25
Hidden=1
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Segmented Bar Measure
Another solution of the same question. In my above code IfConditions have been added to the [MeasureCPU] measure, to get shown / hidden the appropriate meters. But the same thing can be done with properly written Hidden options on the Image meters:
This time there are no Ifconditions on the [MeasureCPU] measure, but Hidden options have been added to each of the [Meter25-50], [Meter50-75] and [Meter75-100] meters, to get the same result.
Code: Select all
[Rainmeter]
Update=1000
[Variables]
[MeasureCPU]
Measure=CPU
[Meter0-25]
Meter=Image
SolidColor=0,255,0
X=0
Y=75
W=30
H=25
Hidden=0
[Meter25-50]
Meter=Image
SolidColor=255,240,0
X=0r
Y=-25r
W=30
H=25
Hidden=([MeasureCPU]<=25)
DynamicVariables=1
[Meter50-75]
Meter=Image
SolidColor=255,127,40
X=0r
Y=-25r
W=30
H=25
Hidden=([MeasureCPU]<=50)
DynamicVariables=1
[Meter75-100]
Meter=Image
SolidColor=255,0,0
X=0r
Y=-25r
W=30
H=25
Hidden=([MeasureCPU]<=75)
DynamicVariables=1
-
- Posts: 7
- Joined: June 1st, 2020, 7:26 pm
Re: Segmented Bar Measure
Yeah thanks I like the second method better, seems more simple.balala wrote: ↑June 1st, 2020, 8:41 pm Another solution of the same question. In my above code IfConditions have been added to the [MeasureCPU] measure, to get shown / hidden the appropriate meters. But the same thing can be done with properly written Hidden options on the Image meters:
-snip-
This time there are no Ifconditions on the [MeasureCPU] measure, but Hidden options have been added to each of the [Meter25-50], [Meter50-75] and [Meter75-100] meters, to get the same result.
However I still have to ask, from a "programming" point of view which one would be better to use? Both in terms of execution speed and resource usage. I don't want my skin to use more resources than it should.
Also are you really from Romania? Because I'd have my mind blown to have met another romanian on this forum.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Segmented Bar Measure
I don't think any of the two methods is simpler, but this depends on your preferences as well.
Don't really think any of them would be better (or worse) from any point of view. I believe you can use any of them, with no fear.
Yep, I am. You too?
-
- Posts: 7
- Joined: June 1st, 2020, 7:26 pm
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania