From 70651db58f6ba5ea09b5f20ee5b57f51460f01c3 Mon Sep 17 00:00:00 2001 From: Jacob Alzen Date: Fri, 15 Jul 2022 21:03:52 +0200 Subject: [PATCH] Transparent background for LowImportance Button This makes sure that we don't change the background for disabled button with LowImportance. As a benefit, this makes the SelectEntry look a lot better when disabled. Fixes #3139 --- widget/button.go | 3 +++ widget/button_test.go | 14 ++++++++++++++ widget/testdata/button/low_importance.png | Bin 0 -> 1196 bytes .../testdata/button/low_importance_disabled.png | Bin 0 -> 1024 bytes .../select_entry/disableable_disabled.xml | 2 +- 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 widget/testdata/button/low_importance.png create mode 100644 widget/testdata/button/low_importance_disabled.png diff --git a/widget/button.go b/widget/button.go index 9aecfd20f0..bca840a096 100644 --- a/widget/button.go +++ b/widget/button.go @@ -337,6 +337,9 @@ func (r *buttonRenderer) applyTheme() { func (r *buttonRenderer) buttonColor() color.Color { switch { case r.button.Disabled(): + if r.button.Importance == LowImportance { + return color.Transparent + } return theme.DisabledButtonColor() case r.button.focused: return blendColor(theme.ButtonColor(), theme.FocusColor()) diff --git a/widget/button_test.go b/widget/button_test.go index aa787aec7b..96f978a9d5 100644 --- a/widget/button_test.go +++ b/widget/button_test.go @@ -121,6 +121,20 @@ func TestButton_Disabled(t *testing.T) { assert.False(t, button.Disabled()) } +func TestButton_LowImportance(t *testing.T) { + test.NewApp() + defer test.NewApp() + + b := &widget.Button{Text: "Text", Icon: theme.HomeIcon(), Importance: widget.LowImportance} + w := test.NewWindow(b) + defer w.Close() + + test.AssertImageMatches(t, "button/low_importance.png", w.Canvas().Capture()) + + b.Disable() + test.AssertImageMatches(t, "button/low_importance_disabled.png", w.Canvas().Capture()) +} + func TestButton_Hover(t *testing.T) { test.NewApp() defer test.NewApp() diff --git a/widget/testdata/button/low_importance.png b/widget/testdata/button/low_importance.png new file mode 100644 index 0000000000000000000000000000000000000000..71f28214a8b2b6c8b8663a9968e5b79e9d2aef72 GIT binary patch literal 1196 zcmV;d1XKHoP)mEdKb^oS0=a-77ZBtEf?Pn53kY%nK`tQ31q8W(AQuqi0)kvX+UY{JM;jMB zVcOs9aSJCNoU%q@fd-g1j;|7BvnM~$#xpt&?qOe;3F2`Un zI2;ZP!}cQ-MScDHH5?8fG3)i~*J`!;a6A|chC-p{GGVjXd_KQgtCT)v zlgVVJr>A#!cL4wzjfTVF80aN&YNp#T8P&CO91Wipun0Jm=4A_yXz&1N#0 zhECL^3k<^?4u`>DIC_}HVj&2^>-AC;b>LE^Qel4C+1UXAY;SKDi^ct`dcEG|a^X16 z{7I7J$B!TL`Mgf2vs$gCQt8Eu7sX=H>2zwf+C(Dp>C-2l&nFg(nY#}F(A(SV_xl?= zR1>vRAP{&w9=%?FoWXLr{KkzNV`F2?nGa(!nIsZPJRYB%oMa**k?7mEZ#a(o{r=9* zPLW8YR;w>xz8nsRXJ%&Z-@kwH;zglQ$mjE|R%^Xpce~x?a+#tityT*F=&}14V|l*p1QTQ_2I(@qtUp$ynOV?bUJM`8eJ~e{wM!9+`D%V$MKbwm64H=Y&P51 z*T=Lf7K>G{*S%gZP1BDaJ$m!z4FI6KyL)MAsa!6Pj*c?ZBaz7P@NgoLX!KmI*3Nz6 z@pz$7V2a|+n>SloN-C8yKmS>Jxm>P5AgEL-v$M0IQ0VdF$3mfSVPRolV4xl8gLb+Y z92|^BqX2*h4<5AWf+;S!T<$;{s?}-$03MHb=gu7_B9qCaQfW4uZ7uh|X`72SLXsp? zHKNhz`uaK(eR9*-v$i%X?axm<2^yEeR!{AW0g_sE|Dxqu)S z5aa@aTtJWu2yy{IE+EJS1i6497ZBtEf?Pn53kY%n`F{Wa0RR8PU7$5&FenlL0000< KMNUMnLSTY)h)mi5 literal 0 HcmV?d00001 diff --git a/widget/testdata/button/low_importance_disabled.png b/widget/testdata/button/low_importance_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..943dc8b79c95198594aa0d4b1a8e5249e66e596e GIT binary patch literal 1024 zcmV+b1poVqP)i3IatUNlMM3ur%_=)R}Yc3m))%>3xf| zQC*zRm3z+4*?B%YJ9}gs=jZ1@S-}4E1bz|J1%bLCP!|O1fVn{>3$(z;0l%3IzXp;dDVNIuK(Sb~EX%K9zY~Afg`z0Bt_urvT~`#vmtnsd zAJ#=8k;rDV48!0ya^LbGe z0pRH92mtE!dbL_zDJd?UPOsDfKa(dXC#tG`=445dWLfTXI)CfHY;JBMgnGT+%gYOn z@I0^UI>&Jj3j{%kL?Q^Gr>CcGw;PYg1Azd~^Bl*eQmOfTUMvq_4Re7yw+J4uIm;G1pqibJq-qfADlTFjV>=QR~mc{Rge!t&pwRU!Pc%HW`tI=rqF@5mUg<%-&b{hcV@%Zua@mGezPm^uiZ}Oba z=U7T462XyRFo+OZb&q@x-(2_zE?WgbXt&$b=@bW9mc@?J>2xR*vTb`f9IC3C&1SE! zuNj6}?nlcVcU69)i*~zhS(YS8`Fy_9=>Wi=KYs>;!QI`RBuV%!Ua3?DgMp$b;c$3& zcemMW&So>mad@8BG|gI2uh&<)?l1kHS|}7u)8u)6X8}S8FBV+jb~>Hs=jZ8k`tb08 z%N&Fd!!VUf#dTeTP%IW>*_BgczVba4S5x?RqtO@)1^^(-^4{Ja4o)VM_iC+AO^#ti zQFL8*I-M?S{EuN-Ruo0YasFSeeD-qm+wziM`i%St)CGaMAW#ViOB5U2|RbwQvm u2-F3Ex*$*&1nPo7T@a`X!hZn(0RR7YD{}%@-mrZD0000 - +