It is currently March 28th, 2024, 8:10 pm

"SOLVED" Hiding storage meters (it is generally a USB skin)

Get help with creating, editing & fixing problems with skins
Unatomic
Posts: 33
Joined: October 23rd, 2012, 7:37 pm

"SOLVED" Hiding storage meters (it is generally a USB skin)

Post by Unatomic »

Hello forum,

I created a USB skin. It works fine and gets the job done. It starts from the drive letter "E:" up to "H:" and measures total, free and used disk space as a normal USB skin we see regularly. All drives appear in the same skin.

I tried to hide the meters that are not used, so when (for example) letter "F:" is not used, it is hidden from the skin.

Now... I used "Y=r" and "Y=R" method to make the next letter go up and no space is created in the skin.

A picture will explain the situation better:
example.png
I think, the way I wrote the code it should behave like picture C) when I remove drive"F:", but picture B) is what happens and the next letter "G:" does not take the exact place of the unused letter "F:". I can not find what I am missing. In theory (as long as I understand) the next measure should take exactly the place of the previous one. If needed I will post the whole skin code.



TLDR: Look the picture and then the code. Thanx in advance


The code is exactly the same with the other letters E, G and H

Code: Select all

;DRIVE F==================================

[MeasureTotalF]
Measure=FreeDiskSpace
Drive=F:
IgnoreRemovable=0
IfBelowValue=1
IfEqualAction=!execute [!HideMeter MeterDriveLabelF] [!HideMeter MeterTotalFText][!HideMeter MeterTotalFBar][!HideMeter MeterUsedFBar] [!HideMeter MeterUsedFText] [!HideMeter MeterFreeFText][!Redraw]
IfAboveValue=1
IfAboveAction=!execute [!ShowMeter MeterDriveLabelF] [!ShowMeter MeterTotalFText][!ShowMeter MeterTotalFBar][!ShowMeter MeterUsedFBar] [!ShowMeter MeterUsedFText] [!ShowMeter MeterFreeFText][!Redraw]

[MeasureLabelF]
Measure=FreeDiskSpace
Drive=F:
Label=1
IgnoreRemovable=0
UpdateDivider=2

[MeasureFreeF]
Measure=FreeDiskSpace
Drive=F:
IgnoreRemovable=0
UpdateDivider=4

[MeasureUsedF]
Measure=FreeDiskSpace
Drive=F:
IgnoreRemovable=0
InvertMeasure=1
UpdateDivider=2
Substitute="1.0":"Removed"

;==================================

[MeterDriveLabelF]
Meter=STRING
MeasureName=MeasureLabelF
MeterStyle=StringStyle
StringStyle=bolditalic
StringAlign=Center
X=115
Y=60r
Text="%1"

[MeterTotalFText]
MeasureName=MeasureTotalF
Meter=STRING
MeterStyle=StringStyle
StringAlign=RIGHT
X=308
Y=r
Text="F: %1"
AutoScale=1

[MeterTotalFBar]
Meter=Image
SolidColor=255, 255,255,50
X=12
Y=-5R
W=295
H=20
LeftMouseUpAction=!execute ["F:"]
DynamicVariables  = 1

[MeterUsedFBar]
MeasureName=MeasureUsedF
Meter=BAR
BarColor=0, 125,255,200
X=12
Y=r
W=295
H=20
BarOrientation=HORIZONTAL

[MeterUsedFText]
MeasureName=MeasureUsedF
Meter=STRING
MeterStyle=StringStyle
X=12
Y=-5r
Text="%1"
AutoScale=1

[MeterFreeFText]
MeasureName=MeasureFreeF
Meter=STRING
MeterStyle=StringStyle
StringAlign=RIGHT
X=308
Y=r
Text="%1"
AutoScale=1
You do not have the required permissions to view the files attached to this post.
Last edited by Unatomic on November 12th, 2017, 2:32 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hiding storage meters (it is generally a USB skin)

Post by balala »

The problem is that a meter, even hidden, is still placed to its normal position, where it is when is shown. The relatively positioned meters with the r parameter, are placed so many pixels below the previous one, as many is indicated by the Y=XXr parameter. So, when the meters belonging to drive F: are hidden, they stay at their own place, but their size is reduced to 0. This is why when the F: drive is hidden, the next one (in this case the drive G:) is placed not 60 pixels below the meters of drive E:, but 60 + 60 pixels.
The simplest solution to fix this is to place the first meter of each drive using not the r parameter, but the R and even this is a way to use Y=0R, otherwise you can't achieve what you want.
So, replace the Y=60r option of the [MeterDriveLabelF] (the next one, below the meters of drive E, but obviously you have to do the same with the following ones too), with Y=0R. This will make the meters of the groups (drives) to be much more closer one of each other. To farther them, place another, invisible meter after the last meter of each drive. Eg add after the last meter of each drive (in this case after [MeterFreeFText]) the following meter:

Code: Select all

[MeterDistE]
Meter=Image
SolidColor=0,0,0,1
X=0r
Y=0R
W=10
H=30
This meter is not visible, even if it is shown, being practically transparent (its color is 0,0,0,1)
After this you have to show / hide this meter, together with the others of the same drive. Just add the [!HideMeter MeterDistE] / [!ShowMeter MeterDistE] bangs to the IfBelowAction / IfAboveAction options of the [MeasureTotalE] measure (just mention here that there's a typo in the posted code, the IfEqualAction option should be IfBelowAction):

Code: Select all

[MeasureTotalE]
Measure=FreeDiskSpace
Drive=E:
IgnoreRemovable=0
IfBelowValue=1
IfBelowAction=!execute [!HideMeter MeterDriveLabelE] [!HideMeter MeterTotalEText][!HideMeter MeterTotalEBar][!HideMeter MeterUsedEBar] [!HideMeter MeterUsedEText] [!HideMeter MeterFreeEText][!HideMeter MeterDistE][!Redraw]
IfAboveValue=1
IfAboveAction=!execute [!ShowMeter MeterDriveLabelE] [!ShowMeter MeterTotalEText][!ShowMeter MeterTotalEBar][!ShowMeter MeterUsedEBar] [!ShowMeter MeterUsedEText] [!ShowMeter MeterFreeEText][!ShowMeter MeterDistE][!Redraw]
Do all this with all drives of your code.
Remarks about the posted code:
  • !execute is a deprecated bang and should not be used anymore. Remove it.
  • In such cases, when the code is working with more drives, would be a very good idea to post the code of all drives, even if the appropriate sections are the same. It would be much easier for us to help you, so help us, to can help you.
  • Instead of hiding / showing the meters of certain drive one by one (in the IfBelowAction (or IfEqualAction) / IfAboveAction options of the [MeasureTotalE] measure), I'd create groups of meters for each drive and would hide / show the group, instead of the meters. If you want to try this possibility, add the Group=DriveE option to each meter of your code (and obviously modify accordingly this option when you add it to the meters of another drive), then replace the mentioned options of the [MeasureTotalE] measure with the following one:

    Code: Select all

    [MeasureTotalE]
    Measure=FreeDiskSpace
    Drive=E:
    IgnoreRemovable=0
    IfBelowValue=1
    IfBelowAction=[!HideMeterGroup DriveE][!Redraw]
    IfAboveValue=1
    IfAboveAction=[!ShowMeterGroup DriveE][!Redraw]
    I think this is much simpler solution, plus if you'd did this before the [MeterDistE] meter (and the others) was added, AND you also include the Group=DriveE option to the [MeterDistE] meter, you don't have to modify the [MeasureTotalE] measure, it would do its job perfectly.
Unatomic
Posts: 33
Joined: October 23rd, 2012, 7:37 pm

Re: Hiding storage meters (it is generally a USB skin)

Post by Unatomic »

That is a fast reply!!!

I understand now how R and r works. Thank you for pointing out that "60" remains in the code after hiding the meters.

I thought about grouping but I knew it worked both ways so I wanted to sort it out before cleaning the skin.

Another solution: now I think about removing the hard-coded "60r" and replace it with a variable with the value of 60 which will change to 0 when the meter hides.
Something like:

Code: Select all


distanceDriveE=60

Y=(#distanceDriveE#)r

IfBelowValue=1
IfBelowAction=[!HideMeterGroup DriveE!][SetVariable distanceDriveE "0"][!Redraw]
IfAboveValue=1
IfAboveAction=[!ShowMeterGroup DriveE][SetVariable distanceDriveE "60"][!Redraw]
I will try to edit the skin and post how it goes
Really thank you for the detailed reply.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hiding storage meters (it is generally a USB skin)

Post by balala »

Unatomic wrote:I thought about grouping but I knew it worked both ways so I wanted to sort it out before cleaning the skin.
I think those groups can simplify the code. But how are you writing your skin, with or without creating group, depends entirely on you, the author.
Unatomic wrote:Another solution: now I think about removing the hard-coded "60r" and replace it with a variable with the value of 60 which will change to 0 when the meter hides.
Yeah, this is another good solution, which also has the advantage that it doesn't require to add further meters. But instead of creating a (or rather more) new variable(s), I'd modify the position of the meter through some !SetOption bangs. But again, both solutions (with variables or with the !SetOption bang) are good and any of them will work. Depends on you which one do you choose.
Check them and let me know which one seem better.
Unatomic
Posts: 33
Joined: October 23rd, 2012, 7:37 pm

Re: Hiding storage meters (it is generally a USB skin)

Post by Unatomic »

Yes! It works perfectly!Thank you for the help.

By setting a variable and changing it every time the meter hides and shows does the trick.

I also cleaned the code and grouped the drives and corrected the If actions as you said.

PS. I just saw your last reply about the setoption bang. maybe I will mess with it on another skin or later. Right now Im very happy about how the skin works.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hiding storage meters (it is generally a USB skin)

Post by balala »

Unatomic wrote:I also cleaned the code and grouped the drives and corrected the If actions as you said.
Actually I'd replace those IfActions with IfConditions, which are much more versatile, but finally the IfActions are still good...
But I'm glad if I helped.