It is currently March 29th, 2024, 2:59 pm

Can I "center" my download rate with the «.» ?

Get help with creating, editing & fixing problems with skins
User avatar
Rambytes
Posts: 27
Joined: August 30th, 2017, 10:36 pm

Can I "center" my download rate with the «.» ?

Post by Rambytes »

Hello and good morning,
Ok... I will try to explain with my "excellent" english (nah, i'm bad with).

I have a network meter, but the download/upload rate is center with:

Code: Select all

StringAlign=CENTER
But it's always "moving" because the rate is changing.
Image
Image
Image
What I want to do is try to center to the decimal point. So if my X=250 it will not the "/s" or the number but the decimal point at 250.

Very hard to explain in english for me.... Sorry!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can I "center" my download rate with the «.» ?

Post by jsmorley »

I don't know of any good way to do this. While it would not be difficult to "center" the decimal place character, and then have the "trunc" portion of the value right-justified to it, and the "frac" portion of the value left-justified to it, the problem is going to be that you would then lose the "scale" identifiers, which are not a part of the numeric value, but are created by the String meter when AutoScale is used. You would in fact lose the ability to AutoScale at all.

In order to tear the value apart into "trunc" "." "frac" components that can be separately positioned, you simply can't also do AutoScale, and that is going to be an unacceptable result.

The trouble for this is that the "k/M/G/T" and such scale identifiers that are added by AutoScale are not part of any "value" that you can get hold of and deal with as separate entities. They are added to the string value of the measure during the update of the String meter. Since what you would want to AutoScale would be the "trunc" portion of the number, the scale identifier would be added to that, and you would end up with something like 400 k.7 /s. Not good...

While you can use RegExpSubstitute / Substitute on a numeric measure like a Net measure, and that can be used to alter the final string output of the "string" value of the measure when used in a String meter, that can only impact the string value of the measure, and about the best you could do is strip off the scale identifiers, which would also be not good...

Maybe someone can come up with some clever idea I have not thought of, but I can't see it in native Rainmeter.

Maybe something in Lua. Do all the auto-scaling and string formatting there. Then use SKIN:Bang('!SetOption',...) to send back the Text option values for the two distinctly positioned String meters. One on the left of the decimal and one on the right.

https://docs.rainmeter.net/snippets/autoscale/
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Can I "center" my download rate with the «.» ?

Post by SilverAzide »

jsmorley wrote:I don't know of any good way to do this.
Welp, I know of a bad way... :)

Take the string output of the measure, say "386.9 k/s" like in your screenshot. Use two string measures to split the string on the decimal, so you have something like "386" and ".9 k/s" as the two resulting strings. Now to display the result, you need 2 string meters. The first meter shows the integer portion, with right-justification. The second meter is left justified and relatively-positioned to follow the first, showing the decimal portion. Kind of like this 386.9 k/s. The end result will be that the decimal point does not move. Not sure it is worth that much effort, but it's one way that works. (If you don't want the scale to move either, split the string into 3 parts...)
Last edited by SilverAzide on August 8th, 2018, 3:54 pm, edited 1 time in total.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can I "center" my download rate with the «.» ?

Post by jsmorley »

SilverAzide wrote:Welp, I know of a bad way... :)

Take the string output of the measure, say "386.9 k/s" like in your screenshot. Use two string measures to split the string on the decimal, so you have something like "386" and ".9 k/s" as the two resulting strings. Now to display the result, you need 2 string meters. The first meter shows the integer portion, with right-justification. The second meter is left justified and relatively-positioned to follow the first, showing the decimal portion. Kind of like this 386.9 k/s. The end result will be that the decimal point does not move. Not sure it is worth that much effort, but it's one way that works.
I'm pretty sure the String measure is not going to have the AutoScale applied to it.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Can I "center" my download rate with the «.» ?

Post by SilverAzide »

jsmorley wrote:I'm pretty sure the String measure is not going to have the AutoScale applied to it.
Oh yeah, forgot about that. I know a way to do it with Lua, but after that I'm out of ideas.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can I "center" my download rate with the «.» ?

Post by jsmorley »

SilverAzide wrote:Oh yeah, forgot about that. I know a way to do it with Lua, but after that I'm out of ideas.
I think it would have to be done in Lua, getting the raw number value of the Net measure, applying auto-scaling and decimal places defining in Lua, stripping off and remembering the scale postfix, breaking the scaled number into "trunc" and "frac" as strings, adding the scale posfix to the "frac" string, and sending both as Text options to the two String meters.

A lot of work indeed, but doable...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can I "center" my download rate with the «.» ?

Post by jsmorley »

The problem with any "native Rainmeter" approach to this is the logical, but pretty non-intuitive way that Substitute works when applied to a measure.

The Substitute is applied not by the measure, but by whatever is "asking for the string value" at any point. So in this case, it is the String meter that triggers the Substitute, and that is done after the AutoScale is applied. But only in the context of the String meter that has the AutoScale on it.

AutoScale on a String meter does not "change" the string value of the measure. Now, here is the non-intuitive bit... Substitute also does not "change" the string value of the measure. What happens is that the String meter gets the raw string value, then applies AutoScale, then checks for and executes any Substitute on the measure. That is the final string output of the String meter.

You might say, "But wait, Substitute does change the string value of the measure, it shows up in the About/Skins dialog with the substitution applied!" Nope. It's just that the About/Skins output works the same way any other request for the string value does. It gets the raw string value, and then checks for and applies any Substitute. That is the final string output in the dialog. Substitute never, ever changes the actual value of a measure.

Any String measure that asks for the string value of the original measure will be getting the raw string value of the number, with no AutoScale applied, and the Substitute, whether on the original measure or the String measure, will fail.
User avatar
Rambytes
Posts: 27
Joined: August 30th, 2017, 10:36 pm

Re: Can I "center" my download rate with the «.» ?

Post by Rambytes »

If I can do it with LUA, Rainmeter support LUA right? If it's too complicated to do with the "native" rainmeter meter, I can try with lua.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Can I "center" my download rate with the «.» ?

Post by SilverAzide »

jsmorley wrote:...Any String measure that asks for the string value of the original measure will be getting the raw string value of the number, with no AutoScale applied, and the Substitute, whether on the original measure or the String measure, will fail.
Yep, I think that pretty much means Lua is his only option.
Last edited by SilverAzide on August 9th, 2018, 10:32 pm, edited 1 time in total.
Gadgets Wiki GitHub More Gadgets...
User avatar
Rambytes
Posts: 27
Joined: August 30th, 2017, 10:36 pm

Re: Can I "center" my download rate with the «.» ?

Post by Rambytes »

I've read twice the answer of jsmorley and i'm not sure to understand how to split in two meter.... :-(