Received: from mail.senf.fr (mail.senf.fr [45.154.60.74]) by mail.sr.ht (Postfix) with ESMTPS id 298E6402E4 for <~eliasnaur/gio-patches@lists.sr.ht>; Thu, 2 Jan 2020 16:13:53 +0000 (UTC) Authentication-Results: mail.sr.ht; dkim=pass (1024-bit key) header.d=alt.tf header.i=@alt.tf header.b=X0qbpr1w Received: from sibeal.alt.tf (unknown [IPv6:2a01:e35:2ecb:5850:d634:bcc7:fec7:85]) (using TLSv1.2 with cipher DHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mail.senf.fr (Postfix) with ESMTPSA id B43777F08B; Thu, 2 Jan 2020 17:13:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alt.tf; s=default; t=1577981629; bh=3UuowWb5tsI7qfkB5+/hO2mLloI878+hBIHW5mZQgzw=; h=From:To:Cc:Subject:Date:From; b=X0qbpr1w+HFsrH73e0ZW/MvrojJHY2yE4VvD9ePzgBJ3hQbzEMrduZgAKJL63DYpX aGJE/z96NfgrZp1flXhqEEfOX52dy50vJAZuGTGr1DbLvhJek3RWK/5iN4IAfmglxE 6Nr4W34G5DskC1U5UfV8DFM/sgwLltVXts0hYEz8= From: manur To: ~eliasnaur/gio-patches@lists.sr.ht Cc: manur Subject: [PATCH] widget/material: add the possiblility to change button text alignement Date: Thu, 2 Jan 2020 17:13:41 +0100 Message-Id: <20200102161341.847818-1-dever@alt.tf> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable By adding a public variable to the Button struct will allow user to set t= he direction of the text within the button User will be able to define them depending on there need instead of only = centered text Signed-off-by: manur --- widget/material/button.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/widget/material/button.go b/widget/material/button.go index b1a440d..d630805 100644 --- a/widget/material/button.go +++ b/widget/material/button.go @@ -20,11 +20,12 @@ import ( type Button struct { Text string // Color is the text color. - Color color.RGBA - Font text.Font - Background color.RGBA - CornerRadius unit.Value - shaper *text.Shaper + Color color.RGBA + Font text.Font + Background color.RGBA + CornerRadius unit.Value + shaper *text.Shaper + TextAlignement layout.Direction } =20 type IconButton struct { @@ -43,7 +44,8 @@ func (t *Theme) Button(txt string) Button { Font: text.Font{ Size: t.TextSize.Scale(14.0 / 16.0), }, - shaper: t.Shaper, + shaper: t.Shaper, + TextAlignement: layout.Center, } } =20 @@ -80,7 +82,7 @@ func (b Button) Layout(gtx *layout.Context, button *wid= get.Button) { layout.Stacked(func() { gtx.Constraints.Width.Min =3D hmin gtx.Constraints.Height.Min =3D vmin - layout.Align(layout.Center).Layout(gtx, func() { + layout.Align(b.TextAlignement).Layout(gtx, func() { layout.Inset{Top: unit.Dp(10), Bottom: unit.Dp(10), Left: unit.Dp(12= ), Right: unit.Dp(12)}.Layout(gtx, func() { paint.ColorOp{Color: col}.Add(gtx.Ops) widget.Label{}.Layout(gtx, b.shaper, b.Font, b.Text) --=20 2.24.1