It is currently March 28th, 2024, 6:38 pm

Increase bar clicking on button image?

Get help with creating, editing & fixing problems with skins
User avatar
GioRgSaVv
Posts: 62
Joined: February 7th, 2017, 10:02 pm

Increase bar clicking on button image?

Post by GioRgSaVv »

Hello, I just want to know if it's possible to increase/decrease the bar from a skin by clicking on a button skin.

This for example:
Image

Something like "MouseUpAction=BarSkin +5%" ?? or something similar?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Increase bar clicking on button image?

Post by balala »

GioRgSaVv wrote:I just want to know if it's possible to increase/decrease the bar from a skin by clicking on a button skin.
It is. For example:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Variables]
BarWidth=200

[MeasureRandom]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=0
HighBound=100
MinValue=0
MaxValue=100

[MeterDecreaseWidth]
Meter=STRING
X=40
Y=10
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=CENTERCENTER
AntiAlias=1
Text=-
MouseOverAction=[!SetOption #CURRENTSECTION# FontColor "50,50,50"][!SetOption #CURRENTSECTION# SolidColor "220,220,220,150"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# FontColor "220,220,220"][!SetOption #CURRENTSECTION# SolidColor "0,0,0,150"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
LeftMouseUpAction=[!SetVariable BarWidth "(#BarWidth#-10)"][!UpdateMeter "MeterBar"][!UpdateMeterGroup "Buttons"][!Redraw]
DynamicVariables=1
Group=Buttons

[MeterIncreaseWidth]
Meter=STRING
X=5R
Y=0r
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=CENTERCENTER
AntiAlias=1
Text=+
MouseOverAction=[!SetOption #CURRENTSECTION# FontColor "50,50,50"][!SetOption #CURRENTSECTION# SolidColor "220,220,220,150"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# FontColor "220,220,220"][!SetOption #CURRENTSECTION# SolidColor "0,0,0,150"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
LeftMouseUpAction=[!SetVariable BarWidth "(#BarWidth#+10)"][!UpdateMeter "MeterBar"][!UpdateMeterGroup "Buttons"][!Redraw]
DynamicVariables=1
Group=Buttons

[MeterBar]
MeasureName=MeasureRandom
Meter=BAR
X=0R
Y=-10r
W=#BarWidth#
H=20
BarColor=255,240,0
SolidColor=80,80,80,150
BarOrientation=Horizontal
DynamicVariables=1
User avatar
GioRgSaVv
Posts: 62
Joined: February 7th, 2017, 10:02 pm

Re: Increase bar clicking on button image?

Post by GioRgSaVv »

No no no, not this :D
:17denial


Sorry, I wasn't clear enough, what I was trying to say is to fill the bar by clicking a button.
But thanks a lot for the code! I will save that for later, maybe it will be useful in the future :)

I actually made it tho.
Image

It is now complete, but I have only one little problem... is it possible not to refresh a skin even after when I click the "refresh all" button from rainmeter application?
I want to keep on tracking how many times I do something, like daily goals, but if I refresh all skins this will also refresh, obviously, so it will reset.

I bet I will need to use some scripts program in order to achieve that, right? :/
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Increase bar clicking on button image?

Post by jsmorley »

You just need to use !WriteKeyValue in order to make the value you set "persistent" by writing it to the skin file.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Current=27

[CurrentValue]
Measure=Calc
Formula=#Current#
DynamicVariables=1
MinValue=0
MaxValue=100

[MeterCurrent]
Meter=Bar
MeasureName=CurrentValue
W=300
H=20
BarOrientation=Horizontal
BarColor=0,255,0,255
SolidColor=47,47,47,255

[MeterIncrease]
Meter=String
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Increase
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Current "(#Current#+1)"][!WriteKeyValue Variables Current "(#Current#+1)"][!UpdateMeter *][!Redraw]
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Increase bar clicking on button image?

Post by eclectic-tech »

GioRgSaVv wrote:No no no, not this :D
:17denial


Sorry, I wasn't clear enough, what I was trying to say is to fill the bar by clicking a button.
But thanks a lot for the code! I will save that for later, maybe it will be useful in the future :)

I actually made it tho.
Image

It is now complete, but I have only one little problem... is it possible not to refresh a skin even after when I click the "refresh all" button from rainmeter application?
I want to keep on tracking how many times I do something, like daily goals, but if I refresh all skins this will also refresh, obviously, so it will reset.

I bet I will need to use some scripts program in order to achieve that, right? :/
What you need to do when you set the new value of the bars on a click, is to also use !WriteKeyValue to permanently write that value to the [Variables] section.

Without seeing your code, I can only show you a generic example. This would be used on the button meters...

Code: Select all

[PlusButton]
...
LeftmouseUpAction=[!SetVariable NumberOfBars (Clamp(#NumberOfBars#+1,0,5))][!WriteKeyValue Variables NumberOfBars (Clamp(#NumberOfBars#+1,0,5))][!UpdateMeter *][!Redraw]

[MinusButton]
...
LeftmouseUpAction=[!SetVariable NumberOfBars (Clamp(#NumberOfBars#-1,0,5))][!WriteKeyValue Variables NumberOfBars (Clamp(#NumberOfBars#-1,0,5))][!UpdateMeter *][!Redraw]

EDIT: JSMorley beat me again, but I would consider using the Clamp function so you stay within the range of possible bars. :sly:
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Increase bar clicking on button image?

Post by jsmorley »

eclectic-tech wrote: EDIT: JSMorley beat me again, but I would consider using the Clamp function so you stay within the range of possible bars. :sly:
Yes, my example was the most generic of generic examples. I would also suggest that you need some kind of "reset" button on this. Having to hit minus repeatedly in order to start over didn't test well with the focus group in the Rainmeter Usability Lab.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Increase bar clicking on button image?

Post by eclectic-tech »

jsmorley wrote:Yes, my example was the most generic of generic examples. I would also suggest that you need some kind of "reset" button on this. Having to hit minus repeatedly in order to start over didn't test well with the focus group in the Usability Lab.
Yes, using this scheme, a third button would be needed to reset... :17nodding
User avatar
GioRgSaVv
Posts: 62
Joined: February 7th, 2017, 10:02 pm

Re: Increase bar clicking on button image?

Post by GioRgSaVv »

Ah it's actually a lot harder than I thought :/
In the end I just made it with... images and not as a bar meter :o

I upload it.
I just added tons of images and I completed it with a different way :/

I want to use your way in order to complete it, but I just can't make it work with the spaces, how to separate the same bar to small pieces? In my case 5 pieces, and each click on the button image will fill the bar by 1 piece, 1 box.

By the way thanks a lot for your time and your help! I appreciate it! :)
Attachments
e.zip
(4.77 KiB) Downloaded 18 times
Last edited by GioRgSaVv on May 23rd, 2018, 8:48 pm, edited 2 times in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Increase bar clicking on button image?

Post by balala »

GioRgSaVv wrote:Ah it's actually a lot harder than I thought :/
In the end I just made it with... images and not as a bar meter :o
Image and Bar meters are for completely different things. But why do you find it so hard? I think it isn't. jsmorley gave you a sample code.
User avatar
GioRgSaVv
Posts: 62
Joined: February 7th, 2017, 10:02 pm

Re: Increase bar clicking on button image?

Post by GioRgSaVv »

By the way I just found out that when I click again the "increase" button while bar is already at max it will keep "counting" but won't show it.
Each click will increase the bar by 20% so it will go 120-140-160% but it will only show the normal length of the bar, so I will need to press the decrease button 3 more times for 140-120-and 100 :P even tho minvalue is 0 and maxvalue is 100 (yes it goes bellow 0 too! :P )
Post Reply