It is currently April 25th, 2024, 3:40 pm

Placing a skin in the center of screen

Get help with creating, editing & fixing problems with skins
User avatar
Senzai
Posts: 10
Joined: May 17th, 2012, 3:51 am

Placing a skin in the center of screen

Post by Senzai »

Here's my skin so far, I've been trying to follow the Tips and Tricks http://docs.rainmeter.net/tips/screen-position-variables but my skin just sits in the top left left hand corner no matter what I do.

Code: Select all

[Background]
Meter=Image
ImageName=bg.png
W=729
H=729
ImageAlpha=150
WindowX=((#SCREENAREAWIDTH# / 2) - 365) 
WindowY=((#SCREENAREAHEIGHT# / 2) - 365)
Here's bg.png if it helps http://i.imgur.com/aC4OBXg.png it's just a red circle.
Right-clicking on the skin and saying refresh would show changes to the WindowX and WindowY properties and reposition the skin right?
Last edited by Senzai on March 18th, 2013, 1:32 am, edited 1 time in total.
Creation is a matter of thought.
User avatar
ScoobSTi
Posts: 127
Joined: September 12th, 2012, 10:49 pm

Re: Placing a skin in the center of screen

Post by ScoobSTi »

WindowX and WindowY only apply to Rainmeter.ini, which contains info on the current loaded skins. They don't belong in the skin's code itself, which is why it isn't working. So now you have two choices, either placing the skin in the center by using the skin's code or by Rainmeter.ini.

Personally, I'd do it in the skin's code, so that it'll always be centered. To do that, change "WindowX" to just "X" and "WindowY" to just "Y".
Image
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Placing a skin in the center of screen

Post by jsmorley »

Senzai wrote:Here's my skin so far, I've been trying to follow the Tips and Tricks http://docs.rainmeter.net/tips/screen-position-variables but my skin just sits in the top left left hand corner no matter what I do.

Code: Select all

[Background]
Meter=Image
ImageName=bg.png
W=729
H=729
ImageAlpha=150
WindowX=((#SCREENAREAWIDTH# / 2) - 365) 
WindowY=((#SCREENAREAHEIGHT# / 2) - 365)
Here's bg.png if it helps http://i.imgur.com/aC4OBXg.png it's just a red circle.
Right-clicking on the skin and saying refresh would show changes to the WindowX and WindowY properties and reposition the skin right?
You can't use WindowX and WindowY in a skin. Those are settings that are contained in Rainmeter.ini, and for the most part are controlled automatically when you drag a skin on the screen. You also don't want to use the X and Y of a meter to try and set the position of a skin on the screen. However, what you can in the skin is:

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!Move (#SCREENAREAWIDTH#/2)-100 (#SCREENAREAHEIGHT#/2)-50]

[MeterBackground]
Meter=Image
W=200
H=100
SolidColor=255,0,0,255
Note that there are NO spaces in the formulas in the OnRefreshAction. Bangs are sensitive to spaces in things, unless they are strings and enclosed in quotes. If you really want the prettier formatting for the formulas, you could use:

OnRefreshAction=[!Move "(#SCREENAREAWIDTH# / 2) - 100" "(#SCREENAREAHEIGHT# / 2) - 50"]

http://docs.rainmeter.net/manual/bangs#Move
http://docs.rainmeter.net/manual/skins/rainmeter-section#OnRefreshAction
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Placing a skin in the center of screen

Post by jsmorley »

ScoobSTi wrote:Personally, I'd do it in the skin's code, so that it'll always be centered. To do that, change "WindowX" to just "X" and "WindowY" to just "Y".
That would be a mistake. The entire skin would "grow" to accommodate the meter being set at an X and Y position in the context of the entire skin, and would in any case only be in the middle of the screen as long as the entire skin was positioned in the absolute top left corner of the screen.

Don't forget, X and Y in a meter are relative to the skin, not relative to the screen.

This skin demonstrates what you would get using X and Y in the meter:

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,100

[MeterBackground]
Meter=Image
W=200
H=100
X=(#SCREENAREAWIDTH#/2)-100
Y=(#SCREENAREAHEIGHT#/2)-50
SolidColor=255,0,0,255
3-17-2013 9-05-16 PM.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Senzai
Posts: 10
Joined: May 17th, 2012, 3:51 am

Re: Placing a skin in the center of screen

Post by Senzai »

jsmorley wrote: You can't use WindowX and WindowY in a skin. Those are settings that are contained in Rainmeter.ini. You also don't want to use the X and Y of a meter to try and set the position of a skin on the screen. What you can in the skin is:

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!Move (#SCREENAREAWIDTH#/2)-100 (#SCREENAREAHEIGHT#/2)-50]

[MeterBackground]
Meter=Image
W=200
H=100
SolidColor=255,0,0,255
Note that there are NO spaces in the formulas in the OnRefreshAction. Bangs and Actions are sensitive to spaces in things, unless they are strings and enclosed in quotes. If you really want the prettier formatting for the formulas, you could use:

OnRefreshAction=[!Move "(#SCREENAREAWIDTH# / 2) - 100" "(#SCREENAREAHEIGHT# / 2) - 50"]

http://docs.rainmeter.net/manual/bangs#Move
http://docs.rainmeter.net/manual/skins/rainmeter-section#OnRefreshAction
Thank you for the links to the documentation, that works perfectly :D
I really should've seen that WindowX and WindowY were for Rainmeter.ini
Is there any reason that I would need Update=1000 if it's literally just a background image and nothing else?
Creation is a matter of thought.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Placing a skin in the center of screen

Post by jsmorley »

Senzai wrote: Thank you for the links to the documentation, that works perfectly :D
I really should've seen that WindowX and WindowY were for Rainmeter.ini
Is there any reason that I would need Update=1000 if it's literally just a background image and nothing else?
Update=1000 is the default, I just always add it due to force of habit more than anything else. I just always add:

[Rainmeter]
Update=1000

to all skins when I start them, as when I am scrolling around later in the skin in my editor, it gives me a nice visual indication that I am at the top.

Anyway, what you really want if the entire skin is just that one meter is Update=-1. That way the skin will only update once when loaded or refreshed and then just sit there minding its own business and using no resources at all.
User avatar
ScoobSTi
Posts: 127
Joined: September 12th, 2012, 10:49 pm

Re: Placing a skin in the center of screen

Post by ScoobSTi »

jsmorley wrote:That would be a mistake. The entire skin would "grow" to accommodate the meter being set at an X and Y position in the context of the entire skin, and would in any case only be in the middle of the screen as long as the entire skin was positioned in the absolute top left corner of the screen.

Don't forget, X and Y in a meter are relative to the skin, not relative to the screen.
Oh right, forgot about that. :oops:
Image
rabitailleow
Posts: 1
Joined: December 12th, 2021, 1:06 pm

Re: Placing a skin in the center of screen

Post by rabitailleow »

Hello, I am new to this... But what do all of you mean by skin code?

EDIT: Nevermind. I got it.
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Placing a skin in the center of screen

Post by CodeCode »

rabitailleow wrote: December 12th, 2021, 1:10 pm Hello, I am new to this... But what do all of you mean by skin code?

EDIT: Nevermind. I got it.
This might help: https://docs.rainmeter.net/manual/bangs/#SetWindowPosition

Code: Select all

[Raonmeter]
Update=1000
OnRefreshAction=[!SetWindowPosition "50%" "50%" "0%" "0%"]
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Placing a skin in the center of screen

Post by balala »

CodeCode wrote: December 12th, 2021, 2:05 pm This might help: https://docs.rainmeter.net/manual/bangs/#SetWindowPosition

Code: Select all

[Raonmeter]
Update=1000
OnRefreshAction=[!SetWindowPosition "50%" "50%" "0%" "0%"]
In fact with this OnRefreshAction the skin isn't placed exactly to the center of screen. This way the upper left corner of the skin will be in the center of screen. To move it in center, replace the last two parameters of 0% (AnchorX and AnchorY) with 50%: OnRefreshAction=[!SetWindowPosition "50%" "50%" "50%" "50%"]. This way you get the center of skin in the center of screen.