It is currently December 8th, 2021, 7:49 pm

TransformationMatrix with MouseOverAction

Report bugs with the Rainmeter application and suggest features.
F!.OW
Posts: 22
Joined: April 1st, 2018, 12:42 pm

TransformationMatrix with MouseOverAction

Post by F!.OW »

The first meter "Hover Me" works exactly how it should with the MouseOverAction.

Taking the same meter and applying the TransformationMatrix setting, it scales accordingly, but the MouseOver area does not change. It seems to remain in its original size and position. Is this a bug or the nature of how this setting works? Or am I not doing something right?
Transform.jpg
Example code to show what's happening:

Code: Select all

[Rainmeter]
Update=25
AccurateText=1
SkinWidth=300
SkinHeight=300

[Style]
FontFace=Segoe UI
FontSize=12
FontColor=255,255,255
Padding=20,15,20,15
SolidColor=0,120,215
AntiAlias=1

[Base]
Meter=String
MeterStyle=Style
Text=Hover Me
MouseOverAction=[!SetOption Base SolidColor 215,0,120]
MouseLeaveAction=[!SetOption Base SolidColor 0,120,215]
DynamicVariables=1

[Transform+]
Meter=String
MeterStyle=Style
Text=Transformed
X=r
Y=10R

[Transform]
Meter=String
MeterStyle=Style
Text=Transformed
SolidColor=0,120,215,160
MouseOverAction=[!SetOption Transform SolidColor 215,0,120,160]
MouseLeaveAction=[!SetOption Transform SolidColor 0,120,215,160]
X=r
Y=r
TransformationMatrix=1.25;0;0;1.25;0;0
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TransformationMatrix with MouseOverAction

Post by jsmorley »

It is the nature of how it works. TransformationMatrix does not alter the size and shape of the meter, and mouse actions are based on the meter.

https://docs.rainmeter.net/manual/meters/general-options/#TransformationMatrix
Also note that the even if the meter's visual location and orientation is changed by the transformation the place where it would be located without the transformation will still be used to define the window size and register the mouse clicks. This might change in the future though.
It's one of the reasons that I don't personally think TransformationMatrix is the best route for a hover effect like this. I would just make the FontSize larger, and let the meter grow to accommodate it.

A lot of folks really like TransformationMatrix. I personal find the fact that is makes mouse actions and relative positioning problematic to be pretty much a show-stopper. I think it has its uses, but they are not as general as it might seem at first glance.
User avatar
jsmorley
Developer
Posts: 22421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TransformationMatrix with MouseOverAction

Post by jsmorley »

Code: Select all

[Rainmeter]
Update=25
AccurateText=1
SkinWidth=300
SkinHeight=300

[Style]
FontFace=Segoe UI
FontSize=12
FontColor=255,255,255
Padding=20,15,20,15
SolidColor=0,120,215
AntiAlias=1

[Base]
Meter=String
MeterStyle=Style
Text=Hover Me
MouseOverAction=[!SetOption Base SolidColor 215,0,120][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption Base SolidColor 0,120,215][!UpdateMeter *][!Redraw]

[Transform]
Meter=String
MeterStyle=Style
Text=Transformed
SolidColor=0,120,215,160
MouseOverAction=[!SetOption Transform FontSize "18"][!SetOption Transform SolidColor 215,0,120,160][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption Transform FontSize ""][!SetOption Transform SolidColor 0,120,215,160][!UpdateMeter *][!Redraw]
X=r
Y=10R
GIF.gif
Might take some playing with the Padding or setting dynamic W and H on the meters to get it perfect. Using Padding to "center" text in a meter has its own issues when you dynamically change things. I think centering is better done with W and H and X and Y and StringAlign, with Padding just used for uhm... padding. Padding is a fixed number of "pixels", and FontSize has no knowable relationship with pixels. It's "points".
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TransformationMatrix with MouseOverAction

Post by jsmorley »

Code: Select all

[Rainmeter]
Update=25
AccurateText=1
SkinWidth=300
SkinHeight=300

[Style]
FontFace=Segoe UI
FontSize=12
FontColor=255,255,255
StringAlign=LeftCenter
Padding=20,15,20,15
SolidColor=0,120,215
AntiAlias=1

[Base]
Meter=String
MeterStyle=Style
Text=Hover Me
Y=25
MouseOverAction=[!SetOption Base SolidColor 215,0,120][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption Base SolidColor 0,120,215][!UpdateMeter *][!Redraw]
DynamicVariables=1

[Transform]
Meter=String
MeterStyle=Style
Text=Transformed
SolidColor=0,120,215,160
MouseOverAction=[!SetOption Transform FontSize "18"][!SetOption Transform SolidColor 215,0,120,160][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption Transform FontSize ""][!SetOption Transform SolidColor 0,120,215,160][!UpdateMeter *][!Redraw]
X=r
Y=10R
GIF.gif
StringAlign=LeftCenter
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TransformationMatrix with MouseOverAction

Post by jsmorley »

There are lots of way to skin this cat, but the long and the short of it is that TransformationMatrix might not be the best...
User avatar
SilverAzide
Rainmeter Sage
Posts: 1677
Joined: March 23rd, 2015, 5:26 pm

Re: TransformationMatrix with MouseOverAction

Post by SilverAzide »

F!.OW wrote:Taking the same meter and applying the TransformationMatrix setting, it scales accordingly, but the MouseOver area does not change. It seems to remain in its original size and position. Is this a bug or the nature of how this setting works? Or am I not doing something right?
Well, I'm one who actually likes TransformationMatrix, and I use it all the time. What JSMorley says is all true, but you can make it work and create totally scalable skins with it. The other reason I prefer it is that it scales more precisely, which is important if you have a lot of string meters tightly spaced (fonts don't scale precisely when scaling at non-integer values). The trick to making mouse events (including tooltips) work is to create transparent image meters that overlay the meter you are scaling. The mouse events and tooltips are attached to the transparent meter. This meter is not scaled but is sized to exactly fit the meter it is on top of. For example, replace your code with something like this:

Code: Select all

[Transform]
Meter=String
MeterStyle=Style
Text=Transformed
SolidColor=0,120,215,160
X=r
Y=r
TransformationMatrix=1.25;0;0;1.25;0;0

[TransformMouseRegion]
Meter=Image
Solidcolor=0,0,0,0
X=([Transform:X] * 1.25)
Y=([Transform:Y] * 1.25)
W=([Transform:W] * 1.25)
H=([Transform:H] * 1.25)
DynamicVariables=1
MouseOverAction=[!SetOption Transform SolidColor 215,0,120,160]
MouseLeaveAction=[!SetOption Transform SolidColor 0,120,215,160]
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TransformationMatrix with MouseOverAction

Post by jsmorley »

X=([Transform:X] * 1.25)

Do keep in mind that W and H and X and Y are always integers, and will be truncated, or rounded-down, if they are fractional.

Might be worth exploring using Shape meters for this, where the measurements, position and size, can be exact...

Also keep in mind that Solidcolor=0,0,0,0 will not detect the mouse...
User avatar
SilverAzide
Rainmeter Sage
Posts: 1677
Joined: March 23rd, 2015, 5:26 pm

Re: TransformationMatrix with MouseOverAction

Post by SilverAzide »

jsmorley wrote:Also keep in mind that Solidcolor=0,0,0,0 will not detect the mouse...
Actually -- strangely -- it does! I was surprised, since the docs say it should not, but for this purpose it appears to be working fine. My Gadgets suite has about 100 mouse handling meters scattered throughout, and all work perfectly. Perhaps Rainmeter itself is correcting this to "0,0,0,1"?
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TransformationMatrix with MouseOverAction

Post by jsmorley »

SilverAzide wrote:Actually -- strangely -- it does! I was surprised, since the docs say it should not, but for this purpose it appears to be working fine. My Gadgets suite has about 100 mouse handling meters scattered throughout, and all work perfectly. Perhaps Rainmeter itself is correcting this to "0,0,0,1"?
Hm.. I think it might be seeing the MouseOverAction on the entire [TransformMouseRegion] meter because although the transformation doesn't change the size of that meter container [Transform], and any mouse action on it would only see the original untransformed meter, the "result" of the transformation does make all the pixels "behind" [TransformMouseRegion] "solid", and thus the mouse actions on it are seen, even with the SolidColor=0,0,0,0.

Remember that mouse actions are best described as "is the pixel my mouse is on solid, and I don't care what made it solid, and is it within the boundaries defined by the meter this mouse action is on?" With that logic in mind, this actually makes sense.

You actually don't need the SolidColor at all on [TransformMouseRegion], it doesn't do anything and the result is the same.

The Shape meter is different, but that is another topic.

Interesting... Learn something every day with Rainmeter.
User avatar
SilverAzide
Rainmeter Sage
Posts: 1677
Joined: March 23rd, 2015, 5:26 pm

Re: TransformationMatrix with MouseOverAction

Post by SilverAzide »

jsmorley wrote:... the "result" of the transformation does make all the pixels "behind" [TransformMouseRegion] "solid", and thus the mouse actions on it are seen, even with the SolidColor=0,0,0,0.
Aha! This must be correct and the key to why it works. I found that if you have meter with a fixed width (so it is essentially like "X_____"), the mouse events will react to the blank space once the TransformationMatrix is applied, but it will act as expected otherwise.
I've long wondered why this is, but it's clear now... :)
Gadgets Wiki GitHub More Gadgets...