It is currently February 22nd, 2024, 8:55 pm

Positioning a meter relatively to its center

Report bugs with the Rainmeter application and suggest features.
User avatar
Posts: 39
Joined: July 3rd, 2010, 10:47 am
Location: Canosa di Puglia, Italy

Positioning a meter relatively to its center

Post by kami »

Normally, X and Y coordinates for meters determine the position relatively to its top-left corner.
It would be great the possibility to choose another point of the image relatively to which position a meter (for example it's center) without using offsets in X and Y parameters of a meter.
User avatar
Posts: 22620
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Positioning a meter relatively to its center

Post by jsmorley »

While the underlying intent is laudable enough, this is just not going to work in the context of how Rainmeter functions.

A meter is not actually the "contents" of the meter, be it an image, a string, a button or a bar, but is a square or rectangular "container" object that is created by either specific W and H options or automatically based on the size of the contents. The contents are just drawn "inside" this container.

The position of the meter in the skin is always based on the X (left) and Y (top) corner of this container, and it wouldn't make sense to have it be anything else.

You can't set the X and Y to the "center" of the meter, that doesn't even make sense. The X and Y MUST define where to "start" drawing the meter in the context of the skin. X and Y have nothing to do with where the contents of the meter are drawn, but only where the meter container is drawn. That just has to have a known "top-left" attribute, and any attempt to base the position on the center of the contents can only, and must only, "change" the actual values of X and Y to move them in the appropriate directions.

There is just no way that Rainmeter can start drawing a meter at some X and Y and draw it "out" in all directions from there based on some definition of "origin" and the meter contents. It's just not how this can ever work. The entire definition of a meter, how absolutely everything in Rainmeter interacts with the meter is based on X (left), Y (top), W (width) and H (height) in the Cartesian plane.

Don't be confused by meters like RoundLine that use the "center" of the contents as a part of the functionality when drawing the meter. The meter itself is still positioned based on X (left) and Y (top) and there is no consideration of the "contents" when this is done. What meters like this do is then draw the "contents" inside that meter, based on some relative size and position of the contents with the meter, not based on some relative size and position of the contents with the overall skin.

That's not to say you can't use the "center" of your meter in a calculation of where X and Y should be to position things as you want. However, what you have to do is calculate where X and Y must be in order to accomplish this, and set them. You can't just redefine what X and Y actually mean. X means left, Y means top. Always.