It is currently October 26th, 2021, 11:27 am

[solved] Calc Max Value incorrect ?

Help with creating, editing & fixing problems with skins
User avatar
Duschmoll
Posts: 26
Joined: May 5th, 2021, 6:08 pm

[solved] Calc Max Value incorrect ?

Post by Duschmoll »

Hello,

I'm using a Max value to get the witdh of a container.

Code: Select all

    [...]
    
    [MeasureTotalDisk]
    Measure=FreeDiskSpace
    Drive=C:
    Total=1
    UpdateDivider=5

    [MeasureFreeDisk]
    Measure=FreeDiskSpace
    Drive=C:
    UpdateDivider=5

    [MeasureUsedDisk]
    Measure=FreeDiskSpace
    Drive=C:
    InvertMeasure=1
    UpdateDivider=5
        
    [CDriveContainerWide]
    Measure=Calc
    DynamicVariables=1
    Formula=Max([CDriveMeterDiskFree:W], [CDriveMeterDiskInfo:W])

    [CDriveDetailsContainerV]
    Meter=Image
    W=[CDriveContainerWide]
    H=([CDriveMeterDiskInfo:H])
    X=R
    SolidColor=150,150,150,150

    DynamicVariables=1

    [...]
    
    [CDriveMeterDiskFree]
    Meter=STRING
    MeasureName=MeasureFreeDisk
    MeasureName2=MeasureTotalDisk
    Group=CDriveDetails

    Text="- %1B / %2B"
    [CDriveMeterDiskInfo]
    Meter=STRING
    MeasureName=MeasureUsedDisk
    MeasureName2=MeasureTotalDisk
    Group=CDriveDetails
    
    Text="%1B / %2B"

The Calc measure as an oupout of 105 at refresh of the skin than come to the proper max value of 140.
The Width of the both Meter are 140 and 131
Image
What is causing this issue ? I can't seem to put my mind around it.
Last edited by Duschmoll on September 3rd, 2021, 5:19 am, edited 2 times in total.
User avatar
CodeCode
Posts: 708
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Calc Max Value incorrect ?

Post by CodeCode »

Are you trying to have a dynamic width of the skin, or is the max value something else that isn't showing properly?

If the width is your goal, then the measure or meter section variable should get what you want from the form: [MeterTextA:W].

Of dynamic text size then that is a bit more complicated.

Ok read more of your code there. But that does not really specify your need.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Calc Max Value incorrect ?

Post by death.crafter »

After the values are retrieved, you need to immediately update the meters, and then the container.

So something like,

Code: Select all

[Rainmeter]
...
OnRefreshAction=[!Update]
or

Code: Select all

[MeasureDiskSpace]
...
OnChangeAction=[!UpdateMeter FreeSpace][!UpdateMeter UsedSpace][!UpdateMeter Container][!Redraw]
oughta do it.
from the Realm of Death
My Current Desktop
User avatar
Duschmoll
Posts: 26
Joined: May 5th, 2021, 6:08 pm

Re: Calc Max Value incorrect ?

Post by Duschmoll »

@CodeCode

[CDriveMeterDiskFree] and [CDriveMeterDiskInfo] are the two string that I want to show on my container. (the gray bar) I'm making them slide up and down when the mouse is over the container.

Since the two meter are not and will not be always of the same wide, I'm using the Calc with a max(,) formula to get the wider meter wide.
But the formula at the start is returning me 105 instead of the 140 which is the max between value the both.
Resulting in the container being smaller at start and for whatever reason the Calc then return the right value of 140 which result in the right size of the container.

I don't get it why the Calc is returning me a false value at first for then after returning me the right one without any change of the both meter wide in betweem.

Here is the full code if you want to try it :

Code: Select all

    [Rainmeter]

    Update=1000



    [Variables]
    OffSet=0
    CDriveDetailsPlusOrMinus=+

    [MeasureTotalDisk]
    Measure=FreeDiskSpace
    Drive=C:
    Total=1
    UpdateDivider=5

    [MeasureFreeDisk]
    Measure=FreeDiskSpace
    Drive=C:
    UpdateDivider=5

    [MeasureUsedDisk]
    Measure=FreeDiskSpace
    Drive=C:
    InvertMeasure=1
    UpdateDivider=5

    [CDriveContainerWide]
    Measure=Calc
    DynamicVariables=1
    Formula=Max([CDriveMeterDiskFree:W], [CDriveMeterDiskInfo:W])

    [CDriveDetailsContainerV]
    Meter=Image
    W=[CDriveContainerWide]
    H=([CDriveMeterDiskInfo:H])
    X=R
    SolidColor=150,150,150,150

    DynamicVariables=1
    [CDriveDetailsContainer]
    Meter=Image
    W=[CDriveContainerWide]
    H=([CDriveMeterDiskInfo:H])

    SolidColor=FFFFFF

    DynamicVariables=1
    MouseOverAction=[!CommandMeasure CDriveSlider "Stop 1"][!SetVariable CDriveDetailsPlusOrMinus "-"][!CommandMeasure CDriveSlider "Execute 1"]
    MouseLeaveAction=[!CommandMeasure CDriveSlider "Stop 1"][!SetVariable CDriveDetailsPlusOrMinus "+"][!CommandMeasure CDriveSlider "Execute 1"]

    [CDriveSlider]
    Measure=Plugin
    Plugin=ActionTimer

    ActionList1= Wait 100 | Repeat SlideIn, 15, 100
    SlideIn=[!UpdateMeasure mCDriveDetailsContainerScroll] [!UpdateMeterGroup CDriveDetails] [!Redraw]
    IgnoreWarnings=1
    DynamicVariables=1

    [mCDriveDetailsContainerScroll]
    Measure=Calc

    Formula=Clamp(mCDriveDetailsContainerScroll#CDriveDetailsPlusOrMinus#1,-[CDriveMeterDiskFree:H],0)

    DynamicVariables=1
    UpdateDivider=-1

    [CDriveMeterDiskFree]
    Meter=STRING
    MeasureName=MeasureFreeDisk
    MeasureName2=MeasureTotalDisk
    Group=CDriveDetails

    Text="- %1B / %2B"

    X=0
    Y=[mCDriveDetailsContainerScroll]

    ;FontFace=#Font#
    ;FontSize=(#Scale#*#FontSize#)
    ;FontColor=#Color#

    AntiAlias=1
    StringEffect=SHADOW
    FontEffectColor=0,0,0
    ClipString=1
    AutoScale=1
    DynamicVariables=1
    Container=CDriveDetailsContainer

    [CDriveMeterDiskInfo]
    Meter=STRING
    MeasureName=MeasureUsedDisk
    MeasureName2=MeasureTotalDisk
    Group=CDriveDetails
    
    Text="%1B / %2B"

    X=([CDriveMeterDiskFree:W]-[CDriveMeterDiskInfo:W])
    Y=([CDriveMeterDiskFree:H]+[mCDriveDetailsContainerScroll])



    ;FontFace=#Font#
    ;FontSize=(#Scale#*#FontSize#)
    ;FontColor=#Color#

    AntiAlias=1
    StringEffect=SHADOW
    FontEffectColor=0,0,0
    ClipString=1
    AutoScale=1
    DynamicVariables=1
    Container=CDriveDetailsContainer

    [Debug]
    Meter=STRING
    Text=([CDriveContainerWide])(Max([CDriveMeterDiskFree:W], [CDriveMeterDiskInfo:W]))
    DynamicVariables=1
    x=R
    
    SolidColor=FFFFFF
User avatar
Duschmoll
Posts: 26
Joined: May 5th, 2021, 6:08 pm

Re: Calc Max Value incorrect ?

Post by Duschmoll »

death.crafter wrote: September 2nd, 2021, 3:51 am After the values are retrieved, you need to immediately update the meters, and then the container.

So something like,

Code: Select all

[Rainmeter]
...
OnRefreshAction=[!Update]
Thanks that seem to do the trick !
Tho adding a OnRefreshAction=[!Update] on [Rainmeter] would that risk adding more work on the processor if the skin as a lot of meters and measure ?
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Calc Max Value incorrect ?

Post by death.crafter »

Duschmoll wrote: September 2nd, 2021, 4:00 am Thanks that seem to do the trick !
Tho adding a OnRefreshAction=[!Update] on [Rainmeter] would that risk adding more work on the processor if the skin as a lot of meters and measure ?
It's a one time process, so it would hardly matter. Still, the second way is preferable if it works.
from the Realm of Death
My Current Desktop
User avatar
Duschmoll
Posts: 26
Joined: May 5th, 2021, 6:08 pm

Re: Calc Max Value incorrect ?

Post by Duschmoll »

death.crafter wrote: September 2nd, 2021, 5:09 am It's a one time process, so it would hardly matter. Still, the second way is preferable if it works.
Thanks for the info, sadly the second method doesn't seem to work.

I think it's because the Calc is puting an oupout of 105 at first, I don't understand where this number come from.
To put it simply the

Code: Select all

   
    [CDriveContainerWide]
    Measure=Calc
    DynamicVariables=1
    Formula=Max([CDriveMeterDiskFree:W], [CDriveMeterDiskInfo:W])
    is the equivalent of this =>
    [CDriveContainerWide]
    Measure=Calc
    DynamicVariables=1
    Formula=Max([140], [131])
    
The outpout of [CDriveContainerWide] is 105 then after an update is 140.
So where is this 105 coming from ?
For the purpose of this test, both 140 and 131 are the same from the begining, you can see that in the gif.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Calc Max Value incorrect ?

Post by eclectic-tech »

Use death.crafter's OnRefreshAction to solve the display issue.

The 105 happens because when first run, the value for your disk measures are zero, so the only width the formula sees is the text in those meters; Text="- %1B / %2B" and Text="%1B / %2B". Those characters provide the 105 width you initially see until the measures populate the actual drive values.

Adding OnRefreshAction=[!Update] in the [Rainmeter] section will update the meters once the skin is loaded and the measures have values.

This will not add any load to your computer as it only happens once when the skin is loaded. Your UpdateDivider on the drive measures is what will control any system load.
User avatar
Duschmoll
Posts: 26
Joined: May 5th, 2021, 6:08 pm

Re: Calc Max Value incorrect ?

Post by Duschmoll »

Thanks for both of yours input !

In the end OnChangeAction=[!UpdateMeter ] was what I needed.
I can't use OnRefreshAction=[!Update] because I'm using the same principal for the wide of text showing the Mhz of my CPU. So the value is constantly changing and the meter need to be updated when the value is changed.

Cheers for the help, without you I wouldn't have been able to do it !

Sorry for my bad explaining of the situation, my english is not the best