It is currently March 28th, 2024, 11:57 pm

Check Snap Orientation with if condition

Get help with creating, editing & fixing problems with skins
Fatty-Do-Do
Posts: 15
Joined: October 29th, 2022, 12:32 pm

Check Snap Orientation with if condition

Post by Fatty-Do-Do »

Hey there,

with the second iteration of my skin https://www.deviantart.com/fatty-do-do/art/CSM-Circular-System-Monitor-1-0-917128155 my goal was to make setup way easier. So far I've been able to automate registry readout with the IfMatch function, have made dedicated Variable and Stylesheets that are read out from all seperate skins and made the User able to rename their components/put in required values via the InputText Plugin.

However I cannot think of a solution for reading out the orientation of the Skin.
If that would be possible I'd use Bangs to change my skins style and switch the orientation of my Meters in relation to the edge the skin is snapped to.

For example. This Style is for the CPU Readout in snapped to the left side of the Desktop:

Code: Select all

[StyleRoundlineMeterBackground]
X=30
W=120
H=120
StartAngle=(Rad(110))
RotationAngle=(Rad(-220))
LineStart=50
LineLength=35
LineColor=255,255,255,20
Solid=1
AntiAlias=1
And this is for the right:

Code: Select all

[StyleRoundlineMeterBackground]
X=0
W=120
H=120
StartAngle=(Rad(70))
RotationAngle=(Rad(220))
LineStart=50
LineLength=35
LineColor=255,255,255,20
Solid=1
AntiAlias=1
The way I would set up the Style is by first creating a Parent, that has all the Values that stay the same for the orientations and then creating two children for left and right in which I can change the Values dynamicly depending on the Snap Orientation with the !SetOption Bang.
I had something like this in mind:

Code: Select all

IfCondition=SkinOrientation = left
IfTrueAction=!SetOption ...
Of course I can work that function into some mouse action or into another IfCondition as well (e.g. Flip on right click), but reading out the snap orientation would be the more elegant solution.

Thanks in Advance
Last edited by Fatty-Do-Do on November 3rd, 2022, 8:23 am, edited 2 times in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Check Snap Orientation with if condition

Post by balala »

Fatty-Do-Do wrote: October 29th, 2022, 1:01 pm The way I would set up the Style is by first creating a Parent, that has all the Values that stay the same for the orientations and then creating two children for left and right in which I can change the Values dynamicly depending on the Snap Orientation with the !SetOption Bang.
I had something like this in mind:

Code: Select all

IfCondition=SkinOrientation = left
IfTrueAction=!SetOption ...
I'm not sure I completely follow, but what is sure is that an IfConditon HAS TO BE ENTIRELY NUMERIC. So, the IfCondition=SkinOrientation = left option definitely can't work, because in the IfCondition have to have a numerical condition which can or not to be true. But SkinOrientation = left is not numeric. To deal with this kind of conditions, you have to use IfMatch. For instance by not adding the above IfCondition (which anyway doesn't work), but add the following IfMatch (and the appropriate IfMatchAction) option to the [SkinOrientation] measure (I assume [SkinOrientation] is a measure, right?):

Code: Select all

[SkinOrientation]
...
IfMatch=left
IfMatchAction=['SetOption ...]
Fatty-Do-Do
Posts: 15
Joined: October 29th, 2022, 12:32 pm

Re: Check Snap Orientation with if condition

Post by Fatty-Do-Do »

balala wrote: October 29th, 2022, 7:57 pm I'm not sure I completely follow, but what is sure is that an IfConditon HAS TO BE ENTIRELY NUMERIC. So, the IfCondition=SkinOrientation = left option definitely can't work, because in the IfCondition have to have a numerical condition which can or not to be true. But SkinOrientation = left is not numeric. To deal with this kind of conditions, you have to use IfMatch. For instance by not adding the above IfCondition (which anyway doesn't work), but add the following IfMatch (and the appropriate IfMatchAction) option to the [SkinOrientation] measure (I assume [SkinOrientation] is a measure, right?):

Code: Select all

[SkinOrientation]
...
IfMatch=left
IfMatchAction=['SetOption ...]
Hey balala,

thanks for the reply. :thumbup:
We are getting close to my question. The IfCondition being numeric would work, if a measure for the skin orientation would spit out a numeric value (e.g. if right=1, left=2).
In my original question "Skin Orientation = left" was just meant to represent the thing I am trying to achieve. What I am asking is, if there is a way to get a value for "left" built in to Rainmeter (When a non numeric string I will use IfMatch, when numeric I intend to use IfCondition). So what I tried to ask for is, if it is possible to use any Measure built into Rainmeter that is able to tell me (numeric or not), to which of its sides a skin is snapped to (e.g. I snap it to the left Desktop edge and the measure spits out any value that I can then use to change the orientation of the Meters within said skin.).

I already have the rotating and repositioning figured out so my goal is just to automate it, instead of having it require a manual mouse input.

Thanks in Advance
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Check Snap Orientation with if condition

Post by SilverAzide »

Fatty-Do-Do wrote: October 30th, 2022, 4:57 pm Hey balala,

thanks for the reply. :thumbup:
We are getting close to my question. The IfCondition being numeric would work, if a measure for the skin orientation would spit out a numeric value (e.g. if right=1, left=2).
In my original question "Skin Orientation = left" was just meant to represent the thing I am trying to achieve. What I am asking is, if there is a way to get a value for "left" built in to Rainmeter (When a non numeric string I will use IfMatch, when numeric I intend to use IfCondition). So what I tried to ask for is, if it is possible to use any Measure built into Rainmeter that is able to tell me (numeric or not), to which of its sides a skin is snapped to (e.g. I snap it to the left Desktop edge and the measure spits out any value that I can then use to change the orientation of the Meters within said skin.).

I already have the rotating and repositioning figured out so my goal is just to automate it, instead of having it require a manual mouse input.

Thanks in Advance
If that is all you need, then you can use an IfCondition on any measure to determine if your skin is at the left or right side if the screen. There are additional complications if you are using multiple monitors, or have the taskbar on the side of the screen, etc., but I'll let you worry about that. The basics are:

Code: Select all

IfCondition=(#CURRENTCONFIGX# = 0)
IfTrueAction=[!Log "Skin is at the left side of the screen." Notice]
IfCondition2=(#CURRENTCONFIGX# + #CURRENTCONFIGWIDTH# = #SCREENAREAWIDTH#)
IfTrueAction2=[!Log "Skin is at the right side of the screen." Notice]
DynamicVariables=1
I didn't try this, but that is the general gist... You might want to check this out: Built-In Variables.
Gadgets Wiki GitHub More Gadgets...
Fatty-Do-Do
Posts: 15
Joined: October 29th, 2022, 12:32 pm

Re: Check Snap Orientation with if condition

Post by Fatty-Do-Do »

SilverAzide wrote: October 30th, 2022, 7:01 pm If that is all you need, then you can use an IfCondition on any measure to determine if your skin is at the left or right side if the screen. There are additional complications if you are using multiple monitors, or have the taskbar on the side of the screen, etc., but I'll let you worry about that. The basics are:

Code: Select all

IfCondition=(#CURRENTCONFIGX# = 0)
IfTrueAction=[!Log "Skin is at the left side of the screen." Notice]
IfCondition2=(#CURRENTCONFIGX# + #CURRENTCONFIGWIDTH# = #SCREENAREAWIDTH#)
IfTrueAction2=[!Log "Skin is at the right side of the screen." Notice]
DynamicVariables=1
I didn't try this, but that is the general gist... You might want to check this out: Built-In Variables.
Thank you very much SilverAzide! :thumbup:

You have given me an Idea for a Calc measure. I'll try to use the built in variables for the Current Monitors screen size and calculate its aspect ratio to define rotation rules depending on my skins X and Y Position in relation to screen width and depth. That way I can include the Top and Bottom orientations for the skin as well.

Also Thanks for pointing out the issue with multiple Screens. One less hurdle to stumble on later. Since multiple screens are no longer adressable by such a calculations I might add the option to disable any auto-orientation measures and flip the skin manually.

I'm gonna add my final solution to this post, once I've figured something out something satisfying.

Cheers! :welcome:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Check Snap Orientation with if condition

Post by balala »

SilverAzide wrote: October 30th, 2022, 7:01 pm The basics are:

Code: Select all

IfCondition=(#CURRENTCONFIGX# = 0)
IfTrueAction=[!Log "Skin is at the left side of the screen." Notice]
IfCondition2=(#CURRENTCONFIGX# + #CURRENTCONFIGWIDTH# = #SCREENAREAWIDTH#)
IfTrueAction2=[!Log "Skin is at the right side of the screen." Notice]
DynamicVariables=1
I didn't try this, but that is the general gist...
Note that probably this approach is a little bit extreme. I think better is to use a small region on the left and right side of the screen, in which if the skin is positioned, you can get it being on the appropriate side of screen. I mean that if a skin is positioned one single pixel to right of the left edge of screen, with this approach, the IfCondition is not met, however this is skin is practically still on left side. I'd probably define a space, let's say 50 or 100 pixels (the #Offset# variable below), in which if the skins left / right edge resides, the skin is still considered being on left / right.
For instance:

Code: Select all

IfCondition=(#CURRENTCONFIGX#<#Offset#)
IfTrueAction=[!Log "Skin is at the left side of the screen." Notice]
IfCondition2=((#CURRENTCONFIGX#+#CURRENTCONFIGWIDTH#)>(#SCREENAREAWIDTH#-#Offset#))
IfTrueAction2=[!Log "Skin is at the right side of the screen." Notice]
DynamicVariables=1
To get this working, the Offset variable has to be defined in the [Variables] section of the skin.
Fatty-Do-Do
Posts: 15
Joined: October 29th, 2022, 12:32 pm

Re: Check Snap Orientation with if condition

Post by Fatty-Do-Do »

balala wrote: October 30th, 2022, 8:16 pm Note that probably this approach is a little bit extreme. I think better is to use a small region on the left and right side of the screen, in which if the skin is positioned, you can get it being on the appropriate side of screen. I mean that if a skin is positioned one single pixel to right of the left edge of screen, with this approach, the IfCondition is not met, however this is skin is practically still on left side. I'd probably define a space, let's say 50 or 100 pixels (the #Offset# variable below), in which if the skins left / right edge resides, the skin is still considered being on left / right.
For instance:

Code: Select all

IfCondition=(#CURRENTCONFIGX#<#Offset#)
IfTrueAction=[!Log "Skin is at the left side of the screen." Notice]
IfCondition2=((#CURRENTCONFIGX#+#CURRENTCONFIGWIDTH#)>(#SCREENAREAWIDTH#-#Offset#))
IfTrueAction2=[!Log "Skin is at the right side of the screen." Notice]
DynamicVariables=1
To get this working, the Offset variable has to be defined in the [Variables] section of the skin.
Thanks Balala,

thats at least in part the Idea. The code snippet will help getting me started. However I am afraid of some weird rotational behaviour when in the corners (as long as I have left and right as well as top and bottom versions of the skin). I should be able to calculate the gradient of a straight line from the top left corner of the screen and the bottom left corner to the center of my skin. The gradient of said lines can then be if conditioned to being equal, less or more than (+/-)Screenheight/Screenwidth, which allows me to determine in which quadrant of the screen the center of my skin currently is. I can then add parameters (something like your offset variable) defining "edge". Those two together should somewhat negate the Task Bar Issue as well.

Cheers! :welcome:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Check Snap Orientation with if condition

Post by balala »

Fatty-Do-Do wrote: October 30th, 2022, 10:27 pm I should be able to calculate the gradient of a straight line from the top left corner of the screen and the bottom left corner to the center of my skin. The gradient of said lines can then be if conditioned to being equal, less or more than (+/-)Screenheight/Screenwidth,
You probably meant the Tangent function, not a gradient (or Sinus, Cosinus). This can be easily done, for instance this way:

Code: Select all

[MeasureTangent]
Measure=Calc
Formula=( #SCREENAREAHEIGHT# / #SCREENAREAWIDTH# )
When you have this value, you have to use some IfConditions, to decide in which quadrant the skin resides. For instance (again):

Code: Select all

[MeasureTangent]
Measure=Calc
Formula=( #SCREENAREAHEIGHT# / #SCREENAREAWIDTH# )
IfCondition=(((#CURRENTCONFIGY#/#CURRENTCONFIGX#)<#CURRENTSECTION#)&&((#CURRENTCONFIGY#/(#SCREENAREAWIDTH#-#CURRENTCONFIGX#))<#CURRENTSECTION#))
IfTrueAction=[!SetVariable Quadrant "1"]
IfCondition2=(((#CURRENTCONFIGY#/#CURRENTCONFIGX#)<#CURRENTSECTION#)&&((#CURRENTCONFIGY#/(#SCREENAREAWIDTH#-#CURRENTCONFIGX#))>=#CURRENTSECTION#))
IfTrueAction2=[!SetVariable Quadrant "2"]
IfCondition3=(((#CURRENTCONFIGY#/#CURRENTCONFIGX#)>=#CURRENTSECTION#)&&((#CURRENTCONFIGY#/(#SCREENAREAWIDTH#-#CURRENTCONFIGX#))>=#CURRENTSECTION#))
IfTrueAction3=[!SetVariable Quadrant "3"]
IfCondition4=(((#CURRENTCONFIGY#/#CURRENTCONFIGX#)>=#CURRENTSECTION#)&&((#CURRENTCONFIGY#/(#SCREENAREAWIDTH#-#CURRENTCONFIGX#))<#CURRENTSECTION#))
IfTrueAction4=[!SetVariable Quadrant "4"]
DynamicVariables=1
This code returns the Quadrant variable, which has the following values (instead of describing it, here is a much more expresive image):
Quadrant.png
You do not have the required permissions to view the files attached to this post.
Fatty-Do-Do
Posts: 15
Joined: October 29th, 2022, 12:32 pm

Re: Check Snap Orientation with if condition

Post by Fatty-Do-Do »

balala wrote: October 31st, 2022, 7:50 pm You probably meant the Tangent function, not a gradient (or Sinus, Cosinus). This can be easily done, for instance this way:

Code: Select all

[MeasureTangent]
Measure=Calc
Formula=( #SCREENAREAHEIGHT# / #SCREENAREAWIDTH# )
When you have this value, you have to use some IfConditions, to decide in which quadrant the skin resides. For instance (again):

Code: Select all

[MeasureTangent]
Measure=Calc
Formula=( #SCREENAREAHEIGHT# / #SCREENAREAWIDTH# )
IfCondition=(((#CURRENTCONFIGY#/#CURRENTCONFIGX#)<#CURRENTSECTION#)&&((#CURRENTCONFIGY#/(#SCREENAREAWIDTH#-#CURRENTCONFIGX#))<#CURRENTSECTION#))
IfTrueAction=[!SetVariable Quadrant "1"]
IfCondition2=(((#CURRENTCONFIGY#/#CURRENTCONFIGX#)<#CURRENTSECTION#)&&((#CURRENTCONFIGY#/(#SCREENAREAWIDTH#-#CURRENTCONFIGX#))>=#CURRENTSECTION#))
IfTrueAction2=[!SetVariable Quadrant "2"]
IfCondition3=(((#CURRENTCONFIGY#/#CURRENTCONFIGX#)>=#CURRENTSECTION#)&&((#CURRENTCONFIGY#/(#SCREENAREAWIDTH#-#CURRENTCONFIGX#))>=#CURRENTSECTION#))
IfTrueAction3=[!SetVariable Quadrant "3"]
IfCondition4=(((#CURRENTCONFIGY#/#CURRENTCONFIGX#)>=#CURRENTSECTION#)&&((#CURRENTCONFIGY#/(#SCREENAREAWIDTH#-#CURRENTCONFIGX#))<#CURRENTSECTION#))
IfTrueAction4=[!SetVariable Quadrant "4"]
DynamicVariables=1
This code returns the Quadrant variable, which has the following values (instead of describing it, here is a much more expresive image):

Quadrant.png
Thanks so much!
That is exactly what I meant (English is a second language to me and especially mathematical terms I have trouble translating) :oops: . However I want to calculate the Rotation in relation to the center point of my Skin so ill try:

Code: Select all

[MeasureTangent]
Measure=Calc
Formula=( #SCREENAREAHEIGHT# / #SCREENAREAWIDTH# )
IfCondition=((((#CURRENTCONFIGY# + 0.5 * #CURRENTCONFIGHEIGHT#)/(#CURRENTCONFIGX# + 0.5 * #CURRENTCONFIGWIDTH#))<#CURRENTSECTION#)&&(((#CURRENTCONFIGY# + 0.5 * #CURRENTCONFIGHEIGHT#)/(#SCREENAREAWIDTH#-(#CURRENTCONFIGX# + 0.5 * #CURRENTCONFIGWIDTH#)))<#CURRENTSECTION#))
IfTrueAction=[!SetVariable Quadrant "1"]
IfCondition2=((((#CURRENTCONFIGY# + 0.5 * #CURRENTCONFIGHEIGHT#)/(#CURRENTCONFIGX# + 0.5 * #CURRENTCONFIGWIDTH#))<#CURRENTSECTION#)&&(((#CURRENTCONFIGY# + 0.5 * #CURRENTCONFIGHEIGHT#)/(#SCREENAREAWIDTH#-(#CURRENTCONFIGX# + 0.5 * #CURRENTCONFIGWIDTH#)))>=#CURRENTSECTION#))
IfTrueAction2=[!SetVariable Quadrant "2"]
IfCondition3=((((#CURRENTCONFIGY# + 0.5 * #CURRENTCONFIGHEIGHT#)/(#CURRENTCONFIGX# + 0.5 * #CURRENTCONFIGWIDTH#))>=#CURRENTSECTION#)&&(((#CURRENTCONFIGY# + 0.5 * #CURRENTCONFIGHEIGHT#)/(#SCREENAREAWIDTH#-(#CURRENTCONFIGX# + 0.5 * #CURRENTCONFIGWIDTH#)))>=#CURRENTSECTION#))
IfTrueAction3=[!SetVariable Quadrant "3"]
IfCondition4=((((#CURRENTCONFIGY# + 0.5 * #CURRENTCONFIGHEIGHT#)/(#CURRENTCONFIGX# + 0.5 * #CURRENTCONFIGWIDTH#))>=#CURRENTSECTION#)&&(((#CURRENTCONFIGY# + 0.5 * #CURRENTCONFIGHEIGHT#)/(#SCREENAREAWIDTH#-(#CURRENTCONFIGX# + 0.5 * #CURRENTCONFIGWIDTH#)))<#CURRENTSECTION#))
IfTrueAction4=[!SetVariable Quadrant "4"]
DynamicVariables=1
Since my Skins Height and Width will dynamically change depending on the Orientation this should hopefully allow me to get some decent corner snapping behaviour.
In addition to that I want the whole Quadrant assignment to happen only if #CURRENTCONFIGX# or #CURRENTCONFIGY# change and to keep CPU Usage minimal i would like to trigger them by using "OnChangeAction". I'd just create another measure reading those out and (de)activate the Quadrant measure OnChange. Any better way to do that?

Cheers! :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Check Snap Orientation with if condition

Post by balala »

Fatty-Do-Do wrote: November 1st, 2022, 4:15 pm (English is a second language to me
Well, in fact for me it's the third.
Fatty-Do-Do wrote: November 1st, 2022, 4:15 pm However I want to calculate the Rotation in relation to the center point of my Skin so ill try:
Yep, seems alright. Do you get the skin working as expected?
Fatty-Do-Do wrote: November 1st, 2022, 4:15 pm In addition to that I want the whole Quadrant assignment to happen only if #CURRENTCONFIGX# or #CURRENTCONFIGY# change and to keep CPU Usage minimal i would like to trigger them by using "OnChangeAction". I'd just create another measure reading those out and (de)activate the Quadrant measure OnChange. Any better way to do that?
Even if there is some way to do this, I don't think it worth, because with such a solution, you're complicating the code too much. On modern computers this kind of calculations are not a big deal. So, recommend you keep the code as you have it now and don't complicate things.
However, if you still want to do this, let me know, to get a solution. But don't recommend...