public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH widget-toolkit 1/2] Utils: add calculate max button width hack
@ 2022-03-24 11:33 Matthias Heiserer
  2022-03-24 11:33 ` [pve-devel] [PATCH widget-toolkit 2/2] use the width-helper from utils Matthias Heiserer
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Matthias Heiserer @ 2022-03-24 11:33 UTC (permalink / raw)
  To: pve-devel

The same code is used once in widget toolkit and twice in PVE already,
so it makes sense to add it as a separate function.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
---
 src/Utils.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/Utils.js b/src/Utils.js
index 6a03057..27fcd1d 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1272,6 +1272,17 @@ utilities: {
 	    .map(val => val.charCodeAt(0)),
 	);
     },
+
+    calculateWidth: function(btn) {
+	// HACK: calculate the max button width on first render to avoid toolbar glitches
+	let defSize = btn.getSize().width;
+
+	btn.setText(btn.altText);
+	let altSize = btn.getSize().width;
+
+	btn.setText(btn.defaultText);
+	btn.setWidth(altSize > defSize ? altSize : defSize);
+    },
 },
 
     singleton: true,
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-03-28 10:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 11:33 [pve-devel] [PATCH widget-toolkit 1/2] Utils: add calculate max button width hack Matthias Heiserer
2022-03-24 11:33 ` [pve-devel] [PATCH widget-toolkit 2/2] use the width-helper from utils Matthias Heiserer
2022-03-25  8:37   ` Thomas Lamprecht
2022-03-24 11:33 ` [pve-devel] [PATCH manager] " Matthias Heiserer
2022-03-25  8:47   ` Thomas Lamprecht
2022-03-25  8:35 ` [pve-devel] [PATCH widget-toolkit 1/2] Utils: add calculate max button width hack Thomas Lamprecht
2022-03-25  8:47 ` Thomas Lamprecht
2022-03-28  9:43   ` Matthias Heiserer
2022-03-28  9:44     ` Thomas Lamprecht
2022-03-28 10:17       ` Matthias Heiserer
2022-03-28 10:27         ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal