gc8 970 Posted February 15, 2022 Hi i am trying to center text in RscShortcutButton control but was able only to center it horizontally but how to center vertically? I have tried modifying the top value in TextPos class inside the RscShortcutButton class but I don't really understand the math so I haven't been able to modify it to have the text centered on all sizes of buttons and interface sizes (But modifying it changes the text vertical pos) class RscShortcutButton { class TextPos { left = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1) * (3/4)"; top = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 20) - (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)) / 2"; right = 0.005; bottom = 0; }; }; The horizontal alignment was easy, just edited this class (align) : class Attributes { font = "RobotoCondensed"; color = "#E5E5E5"; align = "center"; shadow = "true"; valign = "center"; // Doesn't do anything }; Any help is welcome 🙂 1 Share this post Link to post Share on other sites
alpha993 121 Posted February 17, 2022 According to this page, the attribute for valign should be "middle", not "center." class Attributes { font = "RobotoCondensed"; color = "#E5E5E5"; align = "center"; shadow = "true"; valign = "middle"; }; Let me know what happens because I've had my fair share of headaches with vertical alignment lol. Share this post Link to post Share on other sites
gc8 970 Posted February 17, 2022 8 hours ago, alpha993 said: According to this page, the attribute for valign should be "middle", not "center." oh right i tried that too but forgot to mention. It didn't work... Share this post Link to post Share on other sites
alpha993 121 Posted February 18, 2022 Seems like the only solution I've seen that somewhat works is to use something like this from the wiki: private _lineHeight = getNumber (configFile >> "RscStructuredText" >> "size"); private _linesTotal = (ctrlPosition _ctrl select 3) / _lineHeight; private _trailingSpace = ""; for "_i" from 1 to _linesTotal do { _trailingSpace = _trailingSpace + " " }; _ctrl ctrlSetStructuredText parseText format ["<t size='%1'><t size='1' align='center' valign='middle'>%2%3</t> </t>", _linesTotal, "Centered Text", _trailingSpace]; Which produces this with different control heights: However, it seems to be very unreliable, and changing the control width to anything other than 0.5 messes up the centering for some reason. Share this post Link to post Share on other sites
gc8 970 Posted February 18, 2022 Thanks for the help alpha993! 5 hours ago, alpha993 said: However, it seems to be very unreliable, and changing the control width to anything other than 0.5 messes up the centering for some reason. This is probably what you mean: https://imgur.com/a/3MJc5rA It's close but not perfect. The lowest button is also buggy because it's too small for proper rendering.. (So ignore that) 1 Share this post Link to post Share on other sites
gc8 970 Posted February 20, 2022 (edited) I found out that with right value for _lineHeight the code in the wiki works for RscShortcutButton. My magic value looks like this: private _lineHeight = 0.0425; With that the text is centered on all controls and interface sizes (Tested smaller interface size) i tried finding that magic value from the RscShortcutButton class but closest i could find was the size variable which is 0.04. Close but not good enough So not ideal but now I can finally use the control 🙂 Edited February 20, 2022 by gc8 Updated magic variable 1 Share this post Link to post Share on other sites
gc8 970 Posted May 17, 2022 back to the drawing board again with this one. The magic value only works on certain button sizes. Still need solution to always center the text vertically regardless of screen resolution and UI size and of course the controls own size any ideas? Share this post Link to post Share on other sites