public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v2 widget-toolkit 1/3] Buttons: add AltText
@ 2022-03-28 13:07 Matthias Heiserer
  2022-03-28 13:07 ` [pve-devel] [PATCH v2 widget-toolkit 2/3] Makefile: " Matthias Heiserer
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Matthias Heiserer @ 2022-03-28 13:07 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 button.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
---
changes from v1:
move into separate class
rename vars to something a little bit nicer
move comment above function
reorder some statements

Note: Because it's now guaranteed that the function is called at render time,
I think we can leave out the extra logic to test which text is currently set.


 src/button/AltText.js | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 src/button/AltText.js

diff --git a/src/button/AltText.js b/src/button/AltText.js
new file mode 100644
index 0000000..e74d042
--- /dev/null
+++ b/src/button/AltText.js
@@ -0,0 +1,22 @@
+Ext.define('Proxmox.button.AltText', {
+    extend: 'Proxmox.button.Button',
+    xtype: 'proxmoxAltTextButton',
+
+    defaultText: "",
+    altText: "",
+
+    listeners: {
+	// HACK: calculate the max button width on first render to avoid toolbar glitches
+	render: function(button) {
+	    let me = this;
+
+	    button.setText(me.altText);
+	    let altWidth = button.getSize().width;
+
+	    button.setText(me.defaultText);
+	    let defaultWidth = button.getSize().width;
+
+	    button.setWidth(defaultWidth > altWidth ? defaultWidth : altWidth);
+	},
+    },
+});
-- 
2.30.2





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

end of thread, other threads:[~2022-04-27 16:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 13:07 [pve-devel] [PATCH v2 widget-toolkit 1/3] Buttons: add AltText Matthias Heiserer
2022-03-28 13:07 ` [pve-devel] [PATCH v2 widget-toolkit 2/3] Makefile: " Matthias Heiserer
2022-03-28 13:07 ` [pve-devel] [PATCH v2 widget-toolkit 3/3] apt repos: use new AltText button Matthias Heiserer
2022-03-28 13:07 ` [pve-devel] [PATCH v2 manager] ui: tree-wide: " Matthias Heiserer
2022-04-07 10:46 ` [pve-devel] [PATCH v2 widget-toolkit 1/3] Buttons: add AltText Dominik Csapak
2022-04-07 10:50 ` Dominik Csapak
2022-04-27 16:55 ` [pve-devel] applied: " 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