From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D8BE6B84C for ; Thu, 7 Apr 2022 12:46:26 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CD83F3BD9 for ; Thu, 7 Apr 2022 12:46:26 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 4412E3BCC for ; Thu, 7 Apr 2022 12:46:26 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1C77446F37; Thu, 7 Apr 2022 12:46:26 +0200 (CEST) Message-ID: <7145eefb-5962-65f1-0e10-53da5d164528@proxmox.com> Date: Thu, 7 Apr 2022 12:46:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Thunderbird/99.0 Content-Language: en-US To: Proxmox VE development discussion , Matthias Heiserer References: <20220328130737.2961451-1-m.heiserer@proxmox.com> From: Dominik Csapak In-Reply-To: <20220328130737.2961451-1-m.heiserer@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 1.581 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -2.873 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH v2 widget-toolkit 1/3] Buttons: add AltText X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Apr 2022 10:46:26 -0000 patches LGTM, 2/3 could be squashed into 1/3 so that we have the new code in the same commit as the Makefile change, or what do you think @thomas? do you prefer those things to be split into 2 patches? on an additional note, we could even add more functionality to the button, namely a simple 'setTextVariant' (or similar) so that the caller can easily change between the normal and alt text. Also a getter (like 'isAltText' or 'isNormalText') would be nice for now the users of this button always access the 'altText' and 'text' property directly which doesn't seem that nice if we already have a special class for it but this could be done later too, so no hard feelings On 3/28/22 15:07, Matthias Heiserer wrote: > 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 > --- > 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); > + }, > + }, > +});