It is currently October 26th, 2021, 12:45 pm

Mouse plugin from NighthawkSLO

Plugins and Addons popular with the Community
bravo-lemur
Posts: 24
Joined: August 20th, 2020, 8:49 pm

Re: Mouse plugin from NighthawkSLO

Post by bravo-lemur »

Awesome, thanks for the tip! This is the final code I'm using, which seems to be working perfectly:

Code: Select all

[Variables]
@include=#@#Variables.inc

ScaleLowLimit=0.5
ScaleHighLimit=3

SysSliderM=65
SysSliderW=250
SysSliderH=5
SysSizeX=((#SysSliderW#/(#ScaleHighLimit#-#ScaleLowLimit#))*(#SysScale#-#ScaleLowLimit#))+#SysSliderM#

[SysSizeText]
Meter=String
MeterStyle=SettingsLabelStyle
Y=25R
Text=System rings size

[SysSizeSliderBg]
Meter=Shape
X=65
Y=R
Shape=Rectangle 0,0,#SysSliderW#,#SysSliderH#,1,1 | Fill Color 255,255,255,100 | StrokeWidth 0

[SysSizeSliderBar]
Meter=Shape
X=r
Y=r
Shape=Rectangle 0,0,(#SysSizeX#-#SysSliderM#),#SysSliderH#,2,2 | Fill Color #GlowColor2#,150 | StrokeWidth 0
DynamicVariables=1
Group=SysSizeSliderGroup

[SysSizeSliderBlob]
Meter=Shape
X=r
Y=r
Shape=Rectangle (#SysSizeX#-#SysSliderM#),(-#SysSliderH#/2),#SysSliderH#,(#SysSliderH#*2) | Fill Color #GlowColor1# | StrokeWidth 0
LeftMouseDownAction=[!CommandMeasure SysSizeMouse "Start"]
DynamicVariables=1
Group=SysSizeSliderGroup

[SysSizeSliderText]
Meter=String
X=(30+#SysSliderW#)r
Y=r
Text=#SysTempScale#
StringAlign=CenterCenter
FontFace=Segoe UI
FontColor=#White#
FontSize=10
StringAlign=CenterCenter
UpdateDivider=-1
DynamicVariables=1
AntiAlias=1
Group=SysSizeSliderGroup
MouseActionCursor=1
LeftMouseUpAction=[!WriteKeyValue Variables SysScale 1.0 "#@#Variables.inc"][!Refresh *]

[SysSizeSliderPercent]
Measure=Calc
Formula=((#SysSizeX#-#SysSliderM#)*((#ScaleHighLimit#-#ScaleLowLimit#)/#SysSliderW#))+#ScaleLowLimit#
OnUpdateAction=[!SetVariable "SysTempScale" "[#CURRENTSECTION#]"]
DynamicVariables=1
UpdateDivider=-1

[SysSizeMouse]
Measure=Plugin
Plugin=Mouse
LeftMouseDragAction=[!SetVariable SysSizeX "clamp($MouseX$,#SysSliderM#,(#SysSliderM#+#SysSliderW#))"][!UpdateMeasure SysSizeSliderPercent][!UpdateMeasure #CURRENTSECTION#][!UpdateMeterGroup SysSizeSliderGroup][!Redraw]
LeftMouseUpAction=[!CommandMeasure SysSizeMouse "Stop"][!WriteKeyValue Variables SysScale #SysTempScale# "#@#Variables.inc"][!Refresh *]
RelativeToSkin=1
RequireDragging=1
DynamicVariables=1
Ta very much for all the help!
User avatar
balala
Rainmeter Sage
Posts: 13346
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

bravo-lemur wrote: July 6th, 2021, 12:51 am Awesome, thanks for the tip! This is the final code I'm using, which seems to be working perfectly:
Glad to help, however I have a comment.
In my opinion it's not alright to refresh everything when you click the slider or the string (through the [!Refresh *] bangs of the LeftMouseUpAction options of the [SysSizeMouse] measure and the [SysSizeSliderText] meter). Refreshes have to be seen extremely sceptic, especially when you refresh everything. There is not needed to refresh every activated skin, because the refresh is a quite distructive operation and should be avoided as much as possible.
So, I'd replace the the above mentioned [!Refresh *] bangs with [!SetVariable SysScale "#SysTempScale#"][!UpdateMeter "SysSizeSliderBar"][!UpdateMeter "SysSizeSliderBlob"][!UpdateMeasure "SysSizeSliderPercent"][!Redraw]. Something like this:

Code: Select all

[SysSizeSliderText]
...
LeftMouseUpAction=[!WriteKeyValue Variables SysScale "1.0" "#@#Variables.inc"][!SetVariable SysScale "1"][!UpdateMeter "SysSizeSliderBar"][!UpdateMeter "SysSizeSliderBlob"][!UpdateMeasure "SysSizeSliderPercent"][!Redraw]

...

[SysSizeMouse]
...
LeftMouseUpAction=[!CommandMeasure SysSizeMouse "Stop"][!WriteKeyValue Variables SysScale "#SysTempScale#" "#@#Variables.inc"][!SetVariable SysScale "#SysTempScale#"][!UpdateMeter "SysSizeSliderBar"][!UpdateMeter "SysSizeSliderBlob"][!UpdateMeasure "SysSizeSliderPercent"][!Redraw]
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Mouse plugin from NighthawkSLO

Post by death.crafter »

balala wrote: July 6th, 2021, 6:34 am Glad to help, however I have a comment.
In my opinion it's not alright to refresh everything when you click the slider or the string (through the [!Refresh *] bangs of the LeftMouseUpAction options of the [SysSizeMouse] measure and the [SysSizeSliderText] meter). Refreshes have to be seen extremely sceptic, especially when you refresh everything. There is not needed to refresh every activated skin, because the refresh is a quite distructive operation and should be avoided as much as possible.
So, I'd replace the the above mentioned [!Refresh *] bangs with [!SetVariable SysScale "#SysTempScale#"][!UpdateMeter "SysSizeSliderBar"][!UpdateMeter "SysSizeSliderBlob"][!UpdateMeasure "SysSizeSliderPercent"][!Redraw]. Something like this:

Code: Select all

[SysSizeSliderText]
...
LeftMouseUpAction=[!WriteKeyValue Variables SysScale "1.0" "#@#Variables.inc"][!SetVariable SysScale "1"][!UpdateMeter "SysSizeSliderBar"][!UpdateMeter "SysSizeSliderBlob"][!UpdateMeasure "SysSizeSliderPercent"][!Redraw]

...

[SysSizeMouse]
...
LeftMouseUpAction=[!CommandMeasure SysSizeMouse "Stop"][!WriteKeyValue Variables SysScale "#SysTempScale#" "#@#Variables.inc"][!SetVariable SysScale "#SysTempScale#"][!UpdateMeter "SysSizeSliderBar"][!UpdateMeter "SysSizeSliderBlob"][!UpdateMeasure "SysSizeSliderPercent"][!Redraw]
Actually it is a settings for his suite(latest post in suites). So instead of !Refresh he could use !RefreshGroup. But refresh would be necessary.
from the Realm of Death
My Current Desktop
User avatar
balala
Rainmeter Sage
Posts: 13346
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

death.crafter wrote: July 6th, 2021, 6:43 am Actually it is a settings for his suite(latest post in suites). So instead of !Refresh he could use !RefreshGroup. But refresh would be necessary.
If that's related to a suite, then yes, probably the refresh is indeed needed. However as you said, including the skins of the suite into a group and refreshing the group would be much better.
To shortly describe to bravo-lemur how to do this, it's pretty simple: Add a Group=MyGroup option to the [Rainmeter] section of each skin you want to belong to the group (obviously you can name the group as you want, MyGroup is just an example), then replace the [!Refresh *] bang with [!RefreshGroup "MyGroup"]. This way when the refresh is applied, it refreshes only the skins belonging to MyGroup, not all activated skins. This is a good idea even if you're using only skins belonging to the group, because if you later will want to distribute your work, probably many people will use it and will have loaded many other skins, not belonging to the group. In such cases avoiding the refresh of those skins is desirable.
User avatar
Active Colors
Moderator
Posts: 875
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Mouse plugin from NighthawkSLO

Post by Active Colors »

balala,

I have just noticed at the beginning of the thread you mentioned that it is possible to create a slider without any plugins. If you mean that the slider would be draggable, could your share your solution, if you already have one?

All the solutions I've seen are either either wonky, or require adding a lot of meters for every step of the slider. I came to a conclusion that it is rather impossible to make an elegant draggable slider without any plugins.

At the moment this is not a very important thing but if you know how to make one easily I will appreciate it very much!
User avatar
balala
Rainmeter Sage
Posts: 13346
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

Active Colors wrote: July 6th, 2021, 9:32 am balala,

I have just noticed at the beginning of the thread you mentioned that it is possible to create a slider without any plugins. If you mean that the slider would be draggable, could your share your solution, if you already have one?

All the solutions I've seen are either either wonky, or require adding a lot of meters for every step of the slider. I came to a conclusion that it is rather impossible to make an elegant draggable slider without any plugins.

At the moment this is not a very important thing but if you know how to make one easily I will appreciate it very much!
Sorry being late, but finally here is a NOT extremely accurate solution. I (hope at least) didn't say the solution not requiring a plugin would be simple or short. It isn't neither simple and definitely isn't nor short. As you said there are required many - many (11 in the following code) Image meters. I used only 11, but definitely for an accurate work at least 100 would be needed. I didn't add so many for an example skin, but if needed, obviously further such meters can be added. If you add those meters, making them much narrower, the slider will work much better.
Many - many years ago, when the Mouse (or some similar) plugin wasn't yet published, I worked with this implementation and as far as I remember, I got it working pretty well. In meantime the plugins came out and obviously I renounced to use this method (wasn't justified anymore, as you probably figured it out), so after all these years I don't have anymore the code(s) I worked with then.

Code: Select all

[Rainmeter]
Update=1000
LeftMouseDownAction=[!SetVariable Enabled "1"][!UpdateMeasure "MeasureEnabled"]
LeftMouseUpAction=[!SetVariable Enabled "0"][!UpdateMeasure "MeasureEnabled"]
MouseLeaveAction=[!SetVariable Enabled "0"][!UpdateMeasure "MeasureEnabled"]
BackgroundMode=2
SolidColor=0,0,0,100

[Variables]
Color=0,0,0,1
ToSet=5
Enabled=0

[MeasureEnabled]
Measure=Calc
Formula=#Enabled#
IfCondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!EnableMouseActionGroup "MouseOverAction" "Slider"][!UpdateMeterGroup "Slider"]
IfFalseAction=[!DisableMouseActionGroup "MouseOverAction" "Slider"][!UpdateMeterGroup "Slider"]
DynamicVariables=1

[SliderBackgroundStyle]
SolidColor=#Color#
X=0R
Y=0r
W=20
H=50
Group=Slider

[MeterS]
Meter=Image
MeterStyle=SliderBackgroundStyle
X=0
Y=0

[Meter0]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "0"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter1]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "1"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter2]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "2"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter3]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "3"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter4]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "4"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter5]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "5"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter6]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "6"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter7]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "7"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter8]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "8"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter9]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "9"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter10]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "10"][!UpdateMeterGroup "Slider"][!Redraw]

[MeterE]
Meter=Image
MeterStyle=SliderBackgroundStyle

[MeterPath]
Meter=Image
SolidColor=220,220,220
X=20
Y=35
W=[Meter9:XW]
H=3
DynamicVariables=1
Group=Slider

[MeterSlider]
Meter=Image
SolidColor=0,0,0
X=((#ToSet#/10)*[MeterPath:W]+[MeterPath:X]-2)
Y=([MeterPath:Y]-5)
W=5
H=16
DynamicVariables=1
bravo-lemur
Posts: 24
Joined: August 20th, 2020, 8:49 pm

Re: Mouse plugin from NighthawkSLO

Post by bravo-lemur »

balala wrote: July 6th, 2021, 8:10 am If that's related to a suite, then yes, probably the refresh is indeed needed. However as you said, including the skins of the suite into a group and refreshing the group would be much better.
To shortly describe to bravo-lemur how to do this, it's pretty simple: Add a Group=MyGroup option to the [Rainmeter] section of each skin you want to belong to the group (obviously you can name the group as you want, MyGroup is just an example), then replace the [!Refresh *] bang with [!RefreshGroup "MyGroup"]. This way when the refresh is applied, it refreshes only the skins belonging to MyGroup, not all activated skins. This is a good idea even if you're using only skins belonging to the group, because if you later will want to distribute your work, probably many people will use it and will have loaded many other skins, not belonging to the group. In such cases avoiding the refresh of those skins is desirable.
That's a great shout - I've implemented that now. Still learning a lot, so thanks for all the advice :)
User avatar
balala
Rainmeter Sage
Posts: 13346
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

bravo-lemur wrote: July 6th, 2021, 9:46 pm That's a great shout - I've implemented that now.
Glad if you succeeded implementing it.
bravo-lemur wrote: July 6th, 2021, 9:46 pm Still learning a lot, so thanks for all the advice :)
We all do all the time.
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Mouse plugin from NighthawkSLO

Post by Yincognito »

balala wrote: July 6th, 2021, 6:37 pmMany - many years ago, when the Mouse (or some similar) plugin wasn't yet published, I worked with this implementation and as far as I remember, I got it working pretty well. In meantime the plugins came out and obviously I renounced to use this method (wasn't justified anymore, as you probably figured it out), so after all these years I don't have anymore the code(s) I worked with then.
Nice trick though. :thumbup: It certainly works, and it works even better if you have a lower skin update value.
That being said, apart from this plugin being really great and all, I still wonder why folks seem a bit reluctant to use scrolling instead of dragging to control a slider of any kind. No plugin required, yields the mouse variables, adjusting the incrementing / decrementing step can be done easily either through an additional slider or using the mouse variables to control the "speed" of that scrolling, and so on.
User avatar
Active Colors
Moderator
Posts: 875
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Mouse plugin from NighthawkSLO

Post by Active Colors »

balala wrote: July 6th, 2021, 6:37 pm Sorry being late, but finally here is a NOT extremely accurate solution. I (hope at least) didn't say the solution not requiring a plugin would be simple or short. It isn't neither simple and definitely isn't nor short. As you said there are required many - many (11 in the following code) Image meters. I used only 11, but definitely for an accurate work at least 100 would be needed. I didn't add so many for an example skin, but if needed, obviously further such meters can be added. If you add those meters, making them much narrower, the slider will work much better.
Many - many years ago, when the Mouse (or some similar) plugin wasn't yet published, I worked with this implementation and as far as I remember, I got it working pretty well. In meantime the plugins came out and obviously I renounced to use this method (wasn't justified anymore, as you probably figured it out), so after all these years I don't have anymore the code(s) I worked with then.

Code: Select all

[Rainmeter]
Update=1000
LeftMouseDownAction=[!SetVariable Enabled "1"][!UpdateMeasure "MeasureEnabled"]
LeftMouseUpAction=[!SetVariable Enabled "0"][!UpdateMeasure "MeasureEnabled"]
MouseLeaveAction=[!SetVariable Enabled "0"][!UpdateMeasure "MeasureEnabled"]
BackgroundMode=2
SolidColor=0,0,0,100

[Variables]
Color=0,0,0,1
ToSet=5
Enabled=0

[MeasureEnabled]
Measure=Calc
Formula=#Enabled#
IfCondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!EnableMouseActionGroup "MouseOverAction" "Slider"][!UpdateMeterGroup "Slider"]
IfFalseAction=[!DisableMouseActionGroup "MouseOverAction" "Slider"][!UpdateMeterGroup "Slider"]
DynamicVariables=1

[SliderBackgroundStyle]
SolidColor=#Color#
X=0R
Y=0r
W=20
H=50
Group=Slider

[MeterS]
Meter=Image
MeterStyle=SliderBackgroundStyle
X=0
Y=0

[Meter0]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "0"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter1]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "1"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter2]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "2"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter3]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "3"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter4]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "4"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter5]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "5"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter6]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "6"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter7]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "7"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter8]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "8"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter9]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "9"][!UpdateMeterGroup "Slider"][!Redraw]

[Meter10]
Meter=Image
MeterStyle=SliderBackgroundStyle
MouseOverAction=[!SetVariable ToSet "10"][!UpdateMeterGroup "Slider"][!Redraw]

[MeterE]
Meter=Image
MeterStyle=SliderBackgroundStyle

[MeterPath]
Meter=Image
SolidColor=220,220,220
X=20
Y=35
W=[Meter9:XW]
H=3
DynamicVariables=1
Group=Slider

[MeterSlider]
Meter=Image
SolidColor=0,0,0
X=((#ToSet#/10)*[MeterPath:W]+[MeterPath:X]-2)
Y=([MeterPath:Y]-5)
W=5
H=16
DynamicVariables=1
Thank you balala for sharing your methd. I wanted to escape "mapping" the bar but I suppose that's the only viable way to do it with the current condition of Rainmeter. I will use your way and I will think about how to optimize it.
Yincognito wrote: July 7th, 2021, 10:25 pm I still wonder why folks seem a bit reluctant to use scrolling instead of dragging to control a slider of any kind.
A regular computer user would instantly drag the knob when they see it. Besides, it is just more intuitive rather than scroll mouse, in my opinion. And it is just about human's perception based on associations. Remember this dude?
Image