It is currently April 19th, 2024, 4:27 am

dynamic text button in cascade menu

Get help with creating, editing & fixing problems with skins
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

dynamic text button in cascade menu

Post by pul53dr1v3r »

I'm having a trouble making a textual button in the part of the skin that hides/shows on click on another button keeping the latest state after restart. The button named "MEM:" in the video attached below, has two meters. One for OFF and another for ON (orange text) state. After minimizing the bottom part of the skin, "MEM:" button won't display until you refresh the skin manually. The function of the MEM: button is to show or hide the Graph of memory usage. "-" button shows/hides all graphs and things in graphs.

Code: Select all

[Rainmeter]
Background=#@#Background.png
BackgroundMode=3
BackgroundMargins=0,34,0,13
AccurateText=1

[Variables]

SkinState=1
MemHistState=1

[MEMHistogram]
Meter=Histogram
MeasureName=UsedVMEM
GraphStart=Left
LineWidth=1
X=11
Y=100
W=186
H=25
Autoscale=1
Antialias=1
PrimaryColor=176,196,222,150
;SolidColor=255,255,255,15
Group=Graphs

[HideMemHistogram]
Meter=String
MeterStyle=styleLeftText
FontSize=7
X=41
;Y=98
FontColor=255,140,0,100
Text="MEM"
LeftMouseUpAction=[!SetVariable MemHistState "0"][!WriteKeyValue Variables MemHistState "0"][!UpdateMeasure "MeasureMemHistState"]
Group=TButtons

[ShowMemHistogram]
Meter=String
MeterStyle=styleLeftText
FontSize=7
X=r
;Y=r
FontColor=255,255,255,50
Text="MEM"
LeftMouseUpAction=[!SetVariable MemHistState "1"][!WriteKeyValue Variables MemHistState "1"][!UpdateMeasure "MeasureMemHistState"]
Hidden=1
Group=TButtons

[MeasureMemHistState]
Measure=Calc
Formula=#MemHistState#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!HideMeter "MEMHistogram"][!ShowMeter "ShowMemHistogram"][!HideMeter "HideMemHistogram"][!Update]
IfFalseAction=[!ShowMeter "MEMHistogram"][!HideMeter "ShowMemHistogram"][!ShowMeter "HideMemHistogram"][!Update][!Redraw]
DynamicVariables=1


[meterHideGraphs]
Meter=Button
ButtonImage=#@#Images\left.png
X=185
Y=15
ImageTint=255,255,255,150
LeftMouseUpAction=[!SetVariable SkinState "0"][!WriteKeyValue Variables SkinState "0"][!UpdateMeasure "MeasureSkinState"]
TooltipText=Hide graph

[meterShowGraphs]
Meter=Button
ButtonImage=#@#Images\right.png
X=r
Y=r
ImageTint=255,255,255,150
LeftMouseUpAction=[!SetVariable SkinState "1"][!WriteKeyValue Variables SkinState "1"][!UpdateMeasure "MeasureSkinState"]
TooltipText=Show graph
Hidden=1

[MeasureSkinState]
Measure=Calc
Formula=#SkinState#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!HideMeterGroup "Graphs"][!HideMeterGroup "TButtons"][!ShowMeter "meterShowGraphs"][!HideMeter "meterHideGraphs"][!SetOptionGroup "Graphs" "Y" "0"][!SetOptionGroup "TButtons" "Y" "0"][!Update]
IfFalseAction=[!ShowMeterGroup "Graphs"][!HideMeter "meterShowGraphs"][!ShowMeter "meterHideGraphs"][!SetOption "GPUHistogram" "Y" "100"][!SetOption "MEMHistogram" "Y" "100"][!SetOption "HistogramLabelGPU" "Y" "98"][!SetOption "HistogramLabelMEM" "Y" "98"][!SetOption "HideMemHistogram" "Y" "98"][!SetOption "ShowMemHistogram" "Y" "98"][!Update][!Redraw]

DynamicVariables=1



https://youtu.be/GRgXU2Xp-RM
Last edited by pul53dr1v3r on November 7th, 2017, 7:26 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: dynamic text button in cascade menu

Post by balala »

The problem is caused by the [!HideMeterGroup "TButtons"] bang of the IfTrueAction option of the [MeasureSkinState] measure. Initially the [HideMemHistogram] meter is visible and [ShowMemHistogram] is hidden. Clicking the button will set the value of the SkinState variable to 0, which hides the TButtons group of meters (both the [HideMemHistogram] and [ShowMemHistogram] meters belong to this group, so both are hidden). But when you click again to the button, there is no bang to show again the meters / group, so they will never be shown again.
Depending on what you'd like to achieve, a first solution would be to add a [!ShowMeterGroup "TButtons"] bang to the IfFalseAction option of the [MeasureSkinState] measure. But this bang will cause both meters belonging to the TButtons group to be shown, which I think it's not ok.
Instead I suppose you'd like to show the appropriate meter, depending on the value of the MemHistState variable. Am I right? If I am, don't add the above [!ShowMeterGroup "TButtons"] bang, instead add the following two bangs to the IfTrueAction and IfFalseAction options of the [MeasureSkinState] measure, being carefully to not remove any of the existing bangs:

Code: Select all

[MeasureSkinState]
...
IfTrueAction=[!DisableMeasure "MeasureMemHistState...
IfFalseAction=[!EnableMeasure "MeasureMemHistState"]...
These bangs will disable the [MeasureMemHistState] measure when the button(s) are hidden and will re-enable it when the they should be shown. But according to the value of the MemHistState variable, the appropriate button will be shown, while the other will be hidden.
Is this what you wanted to achieve?
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: dynamic text button in cascade menu

Post by pul53dr1v3r »

Yes, that's what I want (the second solution). Just some other issue exist. As I've added the same code for the GPu button, I'll send the new code.
What's happening now is that, when buttons are OFF (grey), when I do manual refresh, both of the graphs show. The buttons work well and don't change color on refresh, just on click.

Code: Select all

SkinState=1
MemHistState=0
GpuHistState=0

Code: Select all

[MEMHistogram]
Meter=Histogram
MeasureName=UsedVMEM
GraphStart=Left
LineWidth=1
X=11
Y=100
W=186
H=25
Autoscale=1
Antialias=1
PrimaryColor=176,196,222,150
;SolidColor=255,255,255,15
Group=Graphs

[GPUHistogram]
Meter=Histogram
MeasureName=GPU1CoreUsage
GraphStart=Left
LineWidth=1
X=11
Y=100
W=186
H=25
Autoscale=1
Antialias=1
PrimaryColor=176,196,222,150
;SolidColor=255,255,255,15
Group=Graphs

[HistogramBackground]
Meter=Image
X=11
Y=100
W=186
H=25
Autoscale=1
Antialias=1
;PrimaryColor=176,196,222,150
SolidColor=255,255,255,15

;"""""""""""""""""""""""""""""""""""""""""""""""HistogramButtons
;GPU
[HideGpuHistogram]
Meter=String
MeterStyle=styleLeftText
FontSize=7
X=11
;Y=98
FontColor=255,140,0,100
Text="GPU"
LeftMouseUpAction=[!SetVariable GpuHistState "0"][!WriteKeyValue Variables GpuHistState "0"][!UpdateMeasure "MeasureGpuHistState"]
Group=TButtons

[ShowGpuHistogram]
Meter=String
MeterStyle=styleLeftText
FontSize=7
X=r
;Y=r
FontColor=255,255,255,50
Text="GPU"
LeftMouseUpAction=[!SetVariable GpuHistState "1"][!WriteKeyValue Variables GpuHistState "1"][!UpdateMeasure "MeasureGpuHistState"]
Hidden=1
Group=TButtons

[MeasureGpuHistState]
Measure=Calc
Formula=#GpuHistState#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!HideMeter "GPUHistogram"][!ShowMeter "ShowGpuHistogram"][!HideMeter "HideGpuHistogram"][!Update]
IfFalseAction=[!ShowMeter "GPUHistogram"][!HideMeter "ShowGpuHistogram"][!ShowMeter "HideGpuHistogram"][!Update][!Redraw]
DynamicVariables=1


;MEM
[HideMemHistogram]
Meter=String
MeterStyle=styleLeftText
FontSize=7
X=41
;Y=98
FontColor=255,140,0,100
Text="MEM"
LeftMouseUpAction=[!SetVariable MemHistState "0"][!WriteKeyValue Variables MemHistState "0"][!UpdateMeasure "MeasureMemHistState"]
Group=TButtons

[ShowMemHistogram]
Meter=String
MeterStyle=styleLeftText
FontSize=7
X=r
;Y=r
FontColor=255,255,255,50
Text="MEM"
LeftMouseUpAction=[!SetVariable MemHistState "1"][!WriteKeyValue Variables MemHistState "1"][!UpdateMeasure "MeasureMemHistState"]
Hidden=1
Group=TButtons

[MeasureMemHistState]
Measure=Calc
Formula=#MemHistState#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!HideMeter "MEMHistogram"][!ShowMeter "ShowMemHistogram"][!HideMeter "HideMemHistogram"][!Update]
IfFalseAction=[!ShowMeter "MEMHistogram"][!HideMeter "ShowMemHistogram"][!ShowMeter "HideMemHistogram"][!Update][!Redraw]
DynamicVariables=1

;"""""""""""""""""""""""""""""""""""""""""""""""Collapse

[meterHideGraphs]
Meter=Button
ButtonImage=#@#Images\left.png
X=185
Y=15
ImageTint=255,255,255,150
LeftMouseUpAction=[!SetVariable SkinState "0"][!WriteKeyValue Variables SkinState "0"][!UpdateMeasure "MeasureSkinState"]
TooltipText=Hide graph

[meterShowGraphs]
Meter=Button
ButtonImage=#@#Images\right.png
X=r
Y=r
ImageTint=255,255,255,150
LeftMouseUpAction=[!SetVariable SkinState "1"][!WriteKeyValue Variables SkinState "1"][!UpdateMeasure "MeasureSkinState"]
TooltipText=Show graph
Hidden=1

[MeasureSkinState]
Measure=Calc
Formula=#SkinState#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!DisableMeasure "MeasureMemHistState"][!DisableMeasure "MeasureGpuHistState"][!HideMeterGroup "Graphs"][!HideMeterGroup "TButtons"][!ShowMeter "meterShowGraphs"][!HideMeter "meterHideGraphs"][!SetOptionGroup "Graphs" "Y" "0"][!SetOptionGroup "TButtons" "Y" "0"][!HideMeter "HistogramBackground"][!Update]
IfFalseAction=[!EnableMeasure "MeasureMemHistState"][!EnableMeasure "MeasureGpuHistState"][!ShowMeterGroup "Graphs"][!HideMeter "meterShowGraphs"][!ShowMeter "meterHideGraphs"][!SetOption "GPUHistogram" "Y" "100"][!SetOption "MEMHistogram" "Y" "100"][!SetOption "HideMemHistogram" "Y" "98"][!SetOption "ShowMemHistogram" "Y" "98"][!SetOption "HideGpuHistogram" "Y" "98"][!SetOption "ShowGpuHistogram" "Y" "98"][!ShowMeter "HistogramBackground"][!Update][!Redraw]

DynamicVariables=1

https://www.youtube.com/watch?v=xI3_xRpxX_Q&feature=youtu.be
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: dynamic text button in cascade menu

Post by balala »

Pul53dr1v3r wrote:What's happening now is that, when buttons are OFF (grey), when I do manual refresh, both of the graphs show. The buttons work well and don't change color on refresh, just on click.
Just remove the [!ShowMeterGroup "Graphs"] bang from the IfFalseAction option of the [MeasureSkinState] measure.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: dynamic text button in cascade menu

Post by pul53dr1v3r »

i wonder if i have eyes at all... That0s it. Think this is the last question: I'd love to make it possible that when we click on one of the buttons on the graph, that another button and its graph gets off(button turns grey, graph is hidden). Guess there is no need for a new measure ust adding "hidemeter" or "disablemeasure" in an If command...

Edit: when one of the buttons is on and we click on another: it turns clicked ON (orange) and its graph is ON,
but to keep possibility to turn OFF the one that is ON clicking on that button.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: dynamic text button in cascade menu

Post by balala »

Pul53dr1v3r wrote:Think this is the last question: I'd love to make it possible that when we click on one of the buttons on the graph, that another button and its graph gets off(button turns grey, graph is hidden). Guess there is no need for a new measure ust adding "hidemeter" or "disablemeasure" in an If command...
I'd add some further bangs to the LeftMouseUpAction options of the [ShowGpuHistogram] and [ShowMemHistogram] meters, as it follows:

Code: Select all

[ShowGpuHistogram]
...
LeftMouseUpAction=[!SetVariable GpuHistState "1"][!SetVariable MemHistState "0"][!WriteKeyValue Variables GpuHistState "1"][!WriteKeyValue Variables MemHistState "0"][!UpdateMeasure "MeasureGpuHistState"][!UpdateMeasure "MeasureMemHistState"]

...

[ShowMemHistogram]
...
LeftMouseUpAction=[!SetVariable MemHistState "1"][!SetVariable GpuHistState "0"][!WriteKeyValue Variables MemHistState "1"][!WriteKeyValue Variables GpuHistState "0"][!UpdateMeasure "MeasureMemHistState"][!UpdateMeasure "MeasureGpuHistState"]
This way anytime when one of those meters is shown, the other is hidden. The only time when you can have both of them visible is in the first moment, after refresh, if both variables MemHistState and GpuHistState are equal to 1. If you also would like to avoid this, I think another simple Calc measure should be added:

Code: Select all

[MeasureShowGpuHistogramShowMemHistogram]
Measure=Calc
Formula=( #MemHistState# + #GpuHistState# )
IfCondition=(#CURRENTSECTION#>=2)
IfTrueAction=[!SetVariable MemHistState "0"][!WriteKeyValue Variables MemHistState "0"][!UpdateMeasure "MeasureMemHistState"]
DynamicVariables=1
The IfTrueAction option of this measure sets the MemHistState variable to zero, if both are equal to 1.
Here just mention that depending on which histogram is more important for you, you can modify the above IfTrueAction, to have hidden the [GPUHistogram] instead of [MEMHistogram], when both variables are equal to 1: LeftMouseUpAction=[!SetVariable GpuHistState "0"][!WriteKeyValue Variables GpuHistState "0"][!UpdateMeasure "MeasureGpuHistState"]
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: dynamic text button in cascade menu

Post by pul53dr1v3r »

balala wrote:

Code: Select all

[ShowGpuHistogram]
...
LeftMouseUpAction=[!SetVariable GpuHistState "1"][!SetVariable MemHistState "0"][!WriteKeyValue Variables GpuHistState "1"][!WriteKeyValue Variables MemHistState "0"][!UpdateMeasure "MeasureGpuHistState"][!UpdateMeasure "MeasureMemHistState"]

...

[ShowMemHistogram]
...
LeftMouseUpAction=[!SetVariable MemHistState "1"][!SetVariable GpuHistState "0"][!WriteKeyValue Variables MemHistState "1"][!WriteKeyValue Variables GpuHistState "0"][!UpdateMeasure "MeasureMemHistState"][!UpdateMeasure "MeasureGpuHistState"]
Seems like it works pretty well with this part of the code. Didn't succeed in getting the two graphs at the same time at all. Yes, I don't want to see two graphs at the same time because it looks unclear as I've used histograms. It could be clearer with lines, but histograms look better, in my opinion.
As so, what do you suggest about this lines, to put them in or to keep aside?

Code: Select all

[MeasureShowGpuHistogramShowMemHistogram]
Measure=Calc
Formula=( #MemHistState# + #GpuHistState# )
IfCondition=(#CURRENTSECTION#>=2)
IfTrueAction=[!SetVariable MemHistState "0"][!WriteKeyValue Variables MemHistState "0"][!UpdateMeasure "MeasureMemHistState"]
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: dynamic text button in cascade menu

Post by balala »

Pul53dr1v3r wrote:Seems like it works pretty well with this part of the code. Didn't succeed in getting the two graphs at the same time at all. Yes, I don't want to see two graphs at the same time because it looks unclear as I've used histograms. It could be clearer with lines, but histograms look better, in my opinion.
As so, what do you suggest about this lines, to put them in or to keep aside?
I think there are more possibilities:
  • Put the two histograms one below the other and show them simultaneously. If you want this solution, just have to go back to the previous code and modify the [!SetOption "GPUHistogram" "Y" "100"] bang of the IfFalseAction option of the [MeasureSkinState] measure to [!SetOption GPUHistogram Y "5R"] (or obviously should get a better value for the Y option, if this one is not good enough for you).
  • Use one single Histogram meter and add two measures to be shown on it. Eg, by modifying the [MEMHistogram], by adding a MeasureName2=GPU1CoreUsage and a SecondaryColor=255,0,0,150 option, which will make both measures to be shown there. In this case a few other options / bangs should be removed / modified to get the Histogram working as you want.
Here I have two remarks about your code:
  • The LineWidth=1 option used on both Histogram meters is not a valid option for this kind of meters, I suppose you probably experimented with Line meters, too and it remained there. Remove it.
  • Doesn't really worth to use the [!Redraw] bang along with [!Update]. It's not needed, because when you update the whole skin a redrawn is also made, so adding the [!Redraw] bang doubles the execution of this, otherwise expensive bang. Details in last paragraph here: https://forum.rainmeter.net/viewtopic.php?p=126530#p126530
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: dynamic text button in cascade menu

Post by pul53dr1v3r »

Thx for suggestions about !Redraws and LineWidth. Already thrown away that redundancies. As far as other ideas about graphs are concerned, I go with the current because it won't be only two of the graphs. I've just added one more for the temperature and all works flawlessly with the yesterdays parts of code except

Code: Select all

[MeasureShowGpuHistogramShowMemHistogram]
Measure=Calc
Formula=( #MemHistState# + #GpuHistState# )
IfCondition=(#CURRENTSECTION#>=2)
IfTrueAction=[!SetVariable MemHistState "0"][!WriteKeyValue Variables MemHistState "0"][!UpdateMeasure "MeasureMemHistState"]
DynamicVariables=1
as it's working well no that code.

I won't write Thanks to you, as it is like a poppy seed compared to a ball, at least, considering all your help... Only words aren't more than smoke, either good or bad ones.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: dynamic text button in cascade menu

Post by balala »

Finally I'm not very sure. Does or doesn't work well the [MeasureShowGpuHistogramShowMemHistogram] measure and the whole code?