I don't know if this is currently possible, but it would be very handy to be able to find the "measured" width of a string in a String meter when clipping is used. By "measured", I mean the width -- in pixels -- you use internally to determine if a string needs to be clipped or wrapped (i.e., Graphics::MeasureString(), DrawText() or equivalent) within the bounding rectangle.
One use of this would be to emulate a feature that Windows often uses. If I have a string that ends up being clipped and "ellipses-ized", I could add some logic in a related measure to provide a tooltip to show the full text, whereas if the string does not end up being clipped I could remove/hide the tooltip.
Here is a simple illustration. In the Rainmeter About dialog, if the Message column is clipped, a tooltip is provided, but if you widen it enough to show the full text, the tooltip is not shown
I realize that the width property (W) can tell you the width of a string meter, but it does not work when clipping is used (you just get the width of the clipping rectangle).
I envision this feature not as a new measure or anything, but as a property of a section. You would reference this like you do the X, Y, W, H properties now, for example [MyStringMeter:Q], where "Q" (or whatever you decide) is the "measured" width in pixels. (Measured height could be useful too.) Obviously this value would be dependent on a lot of things, like if clipping is used, the H/W of the meter, the font, D2D vs. GDI+, etc. -- stuff that is nearly impossible/impractical to find out external to the app code. This feature would also be totally backward compatible with existing skins, since it is only a new property and not a new/revised measure or meter.
A boolean or enum-type property that tells you if a string is clipped or wrapped (or both or neither) could be just as useful, but providing the numeric values might provide more flexibility for skin developers.
Thanks for listening!
It is currently October 21st, 2019, 4:09 am
Report bugs with the Rainmeter application and suggest features.
3 posts • Page 1 of 1
- Posts: 592
- Joined: March 23rd, 2015, 5:26 pm
- Posts: 1343
- Joined: April 11th, 2013, 8:08 pm
- Location: Italy
- Rainmeter Sage
- Posts: 8871
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
There is a simple solution of this. According to this one you have to create two different string meters, which both show the same string. One of them have to be clipped and visible, the other unclipped and invisible (setting an almost transparent color, with Alpha set to 1). All other settings should be identical (FontSize, FontFace, StringStyle and so on) - this is very important! Now you can compare the width of these two meters. If the second one (unclipped) is wider then the first one (clipped), then means that the meter exceeded the set width and gone clipped, otherwise obviously it didn't:
You also have to be careful about the width of the skin (SkinWidth option in [Rainmeter] section), which in some cases can cause troubles.
Code: Select all
[MeterString1] Meter=STRING MeasureName=MyMeasure X=0 Y=0 W=250 H=14 ClipString=1 FontColor=220,220,220 SolidColor=0,0,0,150 FontSize=8 FontFace=Segoe UI StringStyle=BOLD StringAlign=LEFT AntiAlias=1 Text=%1 [MeterString2] Meter=STRING MeasureName=MyMeasure X=0 Y=0 FontColor=220,220,220,1 SolidColor=0,0,0,1 FontSize=8 FontFace=Segoe UI StringStyle=BOLD StringAlign=LEFT AntiAlias=1 Text=%1 [MeasureIfClipped] Measure=Calc Formula=( [MeterString1:W] = [MeterString2:W] ) IfCondition=(#CURRENTSECTION#=1) IfTrueAction=[BANGS FOR THE CASE WHEN [MeterString1] ISN'T CLIPPED] IffALSEAction=[BANGS FOR THE CASE WHEN [MeterString1] IS CLIPPED]