It is currently April 27th, 2024, 11:23 pm

Issues with re-appearing Meters after using HideMeter

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Issues with re-appearing Meters after using HideMeter

Post by jsmorley »

The issue is sort of a bug and sort of not. The problem is that the way you are doing this, you have a MouseLeave on a meter that you then hide when you left click it. However, when you hide the meter, that fires the MouseLeave action, in which you just show the meter again. So you are in a vicious loop that you can't get out of.

I could argue that the MouseLeave action should not be fired when the meter is hidden, but I could also argue that it should. The long and the short of it is that it always has worked that way, and I'd be afraid of backwards compatibility issues if we change it.

Having said that, I think there is a much better way to attack your skin functionality that does not cause this problem.

Code: Select all

[Rainmeter]
Update=1000
Author= Chrotesque | comamind.deviantart.com, chrotesque.com, comamind.de

[Metadata]
Name=Chrotesquian | Middle Bar (C-Sign)
Version=1.0
License=Creative Commons BY-NC-ND 3.0 (http://creativecommons.org/licenses/by-nc-nd/3.0/)

[Variables]
@include1=_vars.ini

;----------------------------------------------------------------> [ START ]

[icon_start]
Meter=IMAGE
ImageName=start.png
Path="#ROOTCONFIGPATH#\img\"
X=114
Y=0
LeftMouseDownAction=!Execute [!HideMeter icon_start][!ShowMeterGroup BarIcons][!Update]

;----------------------------------------------------------------> [ BAR ] 

[bar]
Group=BarIcons
Meter=IMAGE
ImageName=bar.png
Path="#ROOTCONFIGPATH#\img\"
X=0
Y=0
Hidden=1

;----------------------------------------------------------------> [ ICONS ] 

[icon_collapse]
Group=BarIcons
Meter=IMAGE
ImageName=arrow.png
Path="#ROOTCONFIGPATH#\img\"
X=128
Y=0
Hidden=1
MouseOverAction=!Execute [!SetOption icon_collapse ImageName arrow_h.png][!Update]
MouseLeaveAction=!Execute [!SetOption icon_collapse ImageName arrow.png][!Update]
LeftMouseDownAction=!Execute [!HideMeterGroup BarIcons][!HideMeterGroup BarIcons_hover][!ShowMeter icon_start][!Update]
RightMouseUpAction=!Execute [!HideMeter icon_collapse][!ShowMeter icon_config][!Update]

[icon_config]
Meter=IMAGE
ImageName=config.png
Path="#ROOTCONFIGPATH#\img\"
X=131
Y=5
Hidden=1
MouseOverAction=!Execute [!SetOption icon_config ImageName config_h.png][!Update]
MouseLeaveAction=!Execute [!SetOption icon_config ImageName config.png][!Update]
LeftMouseDownAction=[]
RightMouseUpAction=!Execute [!HideMeter icon_config][!ShowMeter icon_collapse][!Update]

[icon_system]
Group=BarIcons
Meter=IMAGE
ImageName=system.png
Path="#ROOTCONFIGPATH#\img\"
X=25
Y=1
Hidden=1
MouseOverAction=!Execute [!SetOption icon_system ImageName system_h.png][!Update]
MouseLeaveAction=!Execute [!SetOption icon_system ImageName system.png][!Update]
LeftMouseDownAction=[]

[icon_apps]
Group=BarIcons
Meter=IMAGE
ImageName=apps.png
Path="#ROOTCONFIGPATH#\img\"
X=60
Y=3
Hidden=1
MouseOverAction=!Execute [!SetOption icon_apps ImageName apps_h.png][!Update]
MouseLeaveAction=!Execute [!SetOption icon_apps ImageName apps.png][!Update]
LeftMouseDownAction=[]

[icon_weather]
Group=BarIcons
Meter=IMAGE
ImageName=weather.png
Path="#ROOTCONFIGPATH#\img\"
X=195
Y=2
Hidden=1
MouseOverAction=!Execute [!SetOption icon_weather ImageName weather_h.png][!Update]
MouseLeaveAction=!Execute [!SetOption icon_weather ImageName weather.png][!Update]
LeftMouseDownAction=[]

[icon_notepad]
Group=BarIcons
Meter=IMAGE
ImageName=notepad.png
Path="#ROOTCONFIGPATH#\img\"
X=250
Y=1
Hidden=1
MouseOverAction=!Execute [!SetOption icon_notepad ImageName notepad_h.png][!Update]
MouseLeaveAction=!Execute [!SetOption icon_notepad ImageName notepad.png][!Update]
LeftMouseDownAction=[]
What I am doing is using !SetOption to just change the images from the "off" to the "over" versions on MouseOver/MouseLeave. Doing this instead of all that "hiding" and "showing" of meters avoids our issue, and saves a lot of code by eliminating all those extra meters entirely.

I am also changing the overall Update rate of the skin to 1000, then adding !Update bangs to the ends of the mouse actions, so overall the skin will use a bit less CPU, while still being very responsive. Using Update in [Rainmeter] to control mouse action responsiveness is generally not needed and not very efficient.

As you are aware, you have some positioning issues with the different versions of the images that you were correcting in a brute force way before with X and Y on the various meters, and you will need to address that in the image itself with this approach. (or again use !SetOption on the mouse actions to change the X and Y on the meters, but It would be cleaner to just have the images corrected)

I would change to this approach for your skin if I were you, as I'm not sure yet where we are going with any change to the application, and this IMHO is more efficient anyway.
User avatar
Chrotesque
Posts: 6
Joined: May 31st, 2012, 10:55 pm
Location: France

Re: Issues with re-appearing Meters after using HideMeter

Post by Chrotesque »

What I am doing is using !SetOption to just change the images from the "off" to the "over" versions on MouseOver/MouseLeave. Doing this instead of all that "hiding" and "showing" of meters avoids our issue, and saves a lot of code by eliminating all those extra meters entirely.
Which sounds great, I am new to all this so any help in reducing unnecessary code is welcome. :)
I am also changing the overall Update rate of the skin to 1000, then adding !Update bangs to the ends of the mouse actions, so overall the skin will use a bit less CPU, while still being very responsive. Using Update in [Rainmeter] to control mouse action responsiveness is generally not needed and not very efficient.
I used that to get a fast hover effect to be honest but I'll check out your solution and see whether or not this works just as well.
As you are aware, you have some positioning issues with the different versions of the images that you were correcting in a brute force way before with X and Y on the various meters, and you will need to address that in the image itself with this approach. (or again use !SetOption on the mouse actions to change the X and Y on the meters, but It would be cleaner to just have the images corrected)
I can't quite follow you on this one. There was one positioning issue with the icon_config but that was due to laziness. Other than that I didn't create the icons and the hover effects for those icons with the same image sizes which forced me to use different X & Y coordinates. Again, laziness. I will clean that one up, of course. (One might argue that creating image & hover image with the same dimensions would take less time than adjusting X&Y every time ... :P)
I would change to this approach for your skin if I were you, as I'm not sure yet where we are going with any change to the application, and this IMHO is more efficient anyway.
I am quite sure it is, I completely trust you on this one and as soon as I've got a few hours I'll get back to the project.

Again, thanks for your help! :)