It is currently October 13th, 2024, 7:49 am

Mouse plugin from NighthawkSLO

Plugins and Addons popular with the Community
cthunsthrall
Posts: 11
Joined: December 2nd, 2020, 3:51 pm

Re: Mouse plugin from NighthawkSLO

Post by cthunsthrall »

balala wrote: December 29th, 2020, 2:52 pm Yep, it is enabled for me.
Well like I said before, the skins don't work with hardware acceleration enabled anymore. Not sure what caused that. But as of today, I finally managed to get it to work with hardware acceleration enabled. (at least for myself) So see if this one works for you:
Volume&Backlight_502.rmskin
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

cthunsthrall wrote: January 2nd, 2021, 7:53 am So see if this one works for you:
Volume&Backlight_502.rmskin
Yep, it does. Good work, congrats.
bravo-lemur
Posts: 24
Joined: August 20th, 2020, 8:49 pm

Re: Mouse plugin from NighthawkSLO

Post by bravo-lemur »

I'm trying to use this plugin to make a slider where the minimum value is 0.5, maximum is 3.0 and default value is 1.0, but I can't figure out how to make the minimum value >0. Can anyone advise?

Thanks in advance!
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

bravo-lemur wrote: July 4th, 2021, 6:10 pm I'm trying to use this plugin to make a slider where the minimum value is 0.5, maximum is 3.0 and default value is 1.0, but I can't figure out how to make the minimum value >0. Can anyone advise?
No, I suppose no one can, because it's not very clear what you want to do. What you mean by "slider" and how the plugin can help? Do you have a code? If you do, please post it.
bravo-lemur
Posts: 24
Joined: August 20th, 2020, 8:49 pm

Re: Mouse plugin from NighthawkSLO

Post by bravo-lemur »

balala wrote: July 4th, 2021, 6:29 pm No, I suppose no one can, because it's not very clear what you want to do. What you mean by "slider" and how the plugin can help? Do you have a code? If you do, please post it.
I mean a slider as in a line with a draggable element that goes back and forth to set a value along the line, like the volume slider demonstrated in the first post of this thread.

What I want to do is make a slider to allow a user to adjust the size of a skin, based on a default size of 1.0, and I don't want the scale to go lower than 0.5 or higher than 3.0 (i.e. I don't want to the skin to go smaller than 0.5x original size or greater than 3.0x original size). In all the examples I've seen, the sliders controlled by Mouse Plugin always go down to 0 as a minimum value, and I'm not sure how to set the minimum value to be 0.5 instead of 0.

My question is: is it possible to set a minimum value of >0 on a slider using Mouse Plugin?
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

bravo-lemur wrote: July 4th, 2021, 7:10 pm My question is: is it possible to set a minimum value of >0 on a slider using Mouse Plugin?
It definitely is, but do you have a code you're working with? I suppose you have, so please post it.
bravo-lemur
Posts: 24
Joined: August 20th, 2020, 8:49 pm

Re: Mouse plugin from NighthawkSLO

Post by bravo-lemur »

I'm currently using the following code that I "borrowed" from another skin:

Code: Select all

[Variables]
SliderM=140
SizeSliderVar=(#Size#/3*#SliderW#+#SliderM#)
SliderW=200
SliderH=5

[SizeText]
Meter=String
Y=500
X=35
MeterStyle=RegularText
Text=Size

[SizeSlider]
Meter=Shape
X=#SliderM#
Y=r
Shape=Rectangle 0,-1,#SliderW#,#SliderH#,(1),(1) | Fill Color 255,255,255,50 | StrokeWidth 0
Shape2=Rectangle 0,-1,(#SizeSliderVar#-#SliderM#),#SliderH#,(2*1),(2*1) | Fill Color 255,255,255,50 | StrokeWidth 0
Shape3=Rectangle 0,(-#SliderH#*3),#SliderW#,(#SliderH#*6) | Fill Color 0,0,0,1 | StrokeWidth 0
LeftMouseDownAction=[!CommandMeasure SizeMouse "Start"]
DynamicVariables=1
UpdateDivider=-1
Group=SizeSliderGroup

[SizeSliderText]
Meter=String
X=(30+#SliderW#)r
Y=r
Text=#Size#
FontSize=10
StringAlign=CenterCenter
UpdateDivider=-1
DynamicVariables=1
MeterStyle=RegularText
Group=SizeSliderGroup
MouseActionCursor=1
LeftMouseUpAction=[!WriteKeyValue Variables Size 1.00 "#@#Vars.inc"][!Refresh]

[SizeSliderPercent]
Measure=Calc
Formula=((#SizeSliderVar#-(#SliderM#))*3/(((#SliderM#)+#SliderW#)-(#SliderM#)))
OnUpdateAction=[!SetVariable "Size" "[#CURRENTSECTION#:2]"]
DynamicVariables=1
Disabled=1
Group=NoUpdateOnLoad
UpdateDivider=-1

[SizeMouse]
Measure=Plugin
Plugin=Mouse
LeftMouseDragAction=[!SetVariable SizeSliderVar "(Clamp(($MouseX$),(#SliderM#),((#SliderM#)+#SliderW#)))"][!UpdateMeasure SizeSliderPercent][!UpdateMeasure #CURRENTSECTION#][!UpdateMeterGroup SizeSliderGroup][!Redraw]
LeftMouseUpAction=[!CommandMeasure SizeMouse "Stop"][!WriteKeyValue Variables Size #Size# "#@#Vars.inc"]
RelativeToSkin=1
RequireDragging=1
DynamicVariables=1
In the original skin where I found this code, the slider goes from 0 to 3.00 (in #@#Vars.inc, Size=3.00).
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

bravo-lemur wrote: July 4th, 2021, 7:31 pm I'm currently using the following code that I "borrowed" from another skin:
This is perfectly alright, there is nothing wrong with this procedure.
However there are a few things you should fix / correct on this code:
  • Neither the Size variable isn't included into the [Variables] section, nor a @Include=#@#Vars.inc (the file where the Size variable resides, I guess) option isn't added. The skin doesn't know the Size variable and accordingly can't use it (the variables don't have a "default" value). So add the @Include=#@#Vars.inc option to the BEGINNIG (it is extremely important to place it before the first variable, or in fact before the SizeSliderVar variable - it is much simpler to place it at the beginning of the section) of the [Variables] section (AGAIN, if my above guess related to the place where the Size variable is declared is correct - if it's not add the appropriate file).
  • Since the SizeSliderVar variable is using both, the SliderM and the SliderW variable, is important to have these variables before SizeSliderVar. So move the SliderW variable before SizeSliderVar.
  • Don't disable the [SizeSliderPercent] measure. If you disable it there is nothing which could re-enable it, so accordingly it doesn't work. So remove its Disabled=1 option (or modify it to Disabled=0).
  • Even if practically this is not a mistake, I recomment to get rid of so many parenthesis as possible. For instance in the first !SetVariable bang of the LeftMouseDragAction option of the [SizeMouse] measure remove the following red marked parentheses: [!SetVariable SizeSliderVar "(Clamp(($MouseX$),(#SliderM#),((#SliderM#)+#SliderW#)))"], getting this: [!SetVariable SizeSliderVar "(Clamp($MouseX$,#SliderM#,(#SliderM#+#SliderW#)))"]. When there is one single variable, without calculations, there is not needed to include it into parentheses. If a calculation is done yes, but the simple variable doesn't require them.
  • Finally to get what you want (so to restrict the value of the Size variable between 0.5 and 3) modify the Formula option of the [SizeSliderPercent] measure to Formula=(0.5+(#SizeSliderVar#-#SliderM#)*2.5/#SliderW#). Note here that I reduced the 3 constant in the middle of the formula to 2.5 and added a 0.5 to the calculated value.
With the above modifications your code will look this way:

Code: Select all

[Variables]
@Include=#@#Vars.inc
SliderM=140
SliderW=200
SizeSliderVar=(#Size#/3*#SliderW#+#SliderM#)
SliderH=5

[SizeText]
Meter=String
Y=500
X=35
MeterStyle=RegularText
FontColor=220,220,220
Text=Size

[SizeSlider]
Meter=Shape
X=#SliderM#
Y=r
Shape=Rectangle 0,-1,#SliderW#,#SliderH#,(1),(1) | Fill Color 255,255,255,50 | StrokeWidth 0
Shape2=Rectangle 0,-1,(#SizeSliderVar#-#SliderM#),#SliderH#,(2*1),(2*1) | Fill Color 255,255,255,50 | StrokeWidth 0
Shape3=Rectangle 0,(-#SliderH#*3),#SliderW#,(#SliderH#*6) | Fill Color 0,0,0,1 | StrokeWidth 0
LeftMouseDownAction=[!CommandMeasure SizeMouse "Start"]
DynamicVariables=1
UpdateDivider=-1
Group=SizeSliderGroup

[SizeSliderText]
Meter=String
X=(30+#SliderW#)r
Y=r
Text=#Size#
FontSize=10
StringAlign=CenterCenter
UpdateDivider=-1
DynamicVariables=1
MeterStyle=RegularText
FontColor=220,220,220
Group=SizeSliderGroup
MouseActionCursor=1
LeftMouseUpAction=[!WriteKeyValue Variables Size 1.00 "#@#Vars.inc"][!Refresh]

[SizeSliderPercent]
Measure=Calc
Formula=(0.5+(#SizeSliderVar#-#SliderM#)*2.5/#SliderW#)
OnUpdateAction=[!SetVariable "Size" "[#CURRENTSECTION#:2]"]
DynamicVariables=1
Disabled=0
Group=NoUpdateOnLoad
UpdateDivider=-1

[SizeMouse]
Measure=Plugin
Plugin=Mouse
LeftMouseDragAction=[!SetVariable SizeSliderVar "(Clamp($MouseX$,#SliderM#,(#SliderM#+#SliderW#)))"][!UpdateMeasure SizeSliderPercent][!UpdateMeasure #CURRENTSECTION#][!UpdateMeterGroup SizeSliderGroup][!Redraw]
LeftMouseUpAction=[!CommandMeasure SizeMouse "Stop"][!WriteKeyValue Variables Size #Size# "#@#Vars.inc"]
RelativeToSkin=1
RequireDragging=1
DynamicVariables=1
bravo-lemur
Posts: 24
Joined: August 20th, 2020, 8:49 pm

Re: Mouse plugin from NighthawkSLO

Post by bravo-lemur »

That's great, the slider is going from 0.5 to 3 now - thank you very much!
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

bravo-lemur wrote: July 4th, 2021, 9:33 pm That's great, the slider is going from 0.5 to 3 now - thank you very much!
Glad to help.
One more thing: to can extremely easily set the limits (if anytime later you'll have to change them) add the following two variables into the [Variables] section (beside the existing variables):

Code: Select all

[Variables]
...
LowLimit=0.5
HighLimit=3
Now use these variables into the Formula option of the [SizeSliderPercent] neasure: Formula=(#LowLimit#+(#SizeSliderVar#-#SliderM#)*(#HighLimit#-#LowLimit#)/#SliderW#).
Whenever you want to change the limits, you have to only replace the values of the two variables. The only thing you have to keep in mind is to have the LowLimit variable lower then HighLimit. In fact this isn't true either. If HighLimit is lower than LowLimit, the slider works "in the oposite direction": On its left side will be the variable set to its higher limit, wile on right to its lower limit (so will incres when you drag it to left and decrease when you drag it to right).