~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH] widget/material: add the possiblility to change button text alignement

manur
Details
Message ID
<20200102161341.847818-1-dever@alt.tf>
DKIM signature
missing
Download raw message
Patch: +9 -7
By adding a public variable to the Button struct will allow user to set the 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 <dever@alt.tf>
---
 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
}

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,
	}
}

@@ -80,7 +82,7 @@ func (b Button) Layout(gtx *layout.Context, button *widget.Button) {
		layout.Stacked(func() {
			gtx.Constraints.Width.Min = hmin
			gtx.Constraints.Height.Min = 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)
-- 
2.24.1
Details
Message ID
<BZM1VNONON2G.3VDTM7VPAKV7R@testmac>
In-Reply-To
<20200102161341.847818-1-dever@alt.tf> (view parent)
DKIM signature
missing
Download raw message
On Thu Jan 2, 2020 at 5:13 PM, manur wrote:
> By adding a public variable to the Button struct will allow user to set
> the direction of the text within the button
> User will be able to define them depending on there need instead of only
> centered text
>

Thanks. What is the use case for the feature? I don't think I've
encountered material design buttons with text not aligned to the center.

> 
> Signed-off-by: manur <dever@alt.tf>
> ---
> 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

TextAlignement => TextAlignment.

[PATCH] Typo fix

manur
Details
Message ID
<20200103193617.977989-1-dever@alt.tf>
In-Reply-To
<BZM1VNONON2G.3VDTM7VPAKV7R@testmac> (view parent)
DKIM signature
missing
Download raw message
Patch: +9 -9
Signed-off-by: manur <dever@alt.tf>
---

This will allow to use button material in larger widget and be able to set alignment of text
In my case i've used the button to avoid rewriting the layout/click visual response for a file explorer (used in a list , the button will take all available space but centering it doesn't look good)



 widget/material/button.go | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/widget/material/button.go b/widget/material/button.go
index d630805..86ccd59 100644
--- a/widget/material/button.go
+++ b/widget/material/button.go
@@ -20,12 +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
	TextAlignement layout.Direction
	Color         color.RGBA
	Font          text.Font
	Background    color.RGBA
	CornerRadius  unit.Value
	shaper        *text.Shaper
	TextAlignment layout.Direction
}

type IconButton struct {
@@ -44,8 +44,8 @@ func (t *Theme) Button(txt string) Button {
		Font: text.Font{
			Size: t.TextSize.Scale(14.0 / 16.0),
		},
		shaper:         t.Shaper,
		TextAlignement: layout.Center,
		shaper:        t.Shaper,
		TextAlignment: layout.Center,
	}
}

@@ -82,7 +82,7 @@ func (b Button) Layout(gtx *layout.Context, button *widget.Button) {
		layout.Stacked(func() {
			gtx.Constraints.Width.Min = hmin
			gtx.Constraints.Height.Min = vmin
			layout.Align(b.TextAlignement).Layout(gtx, func() {
			layout.Align(b.TextAlignment).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)
-- 
2.24.1

Re: [PATCH] Typo fix

Details
Message ID
<BZMGVY6OM8SA.1EEU07957BFEW@toolbox>
In-Reply-To
<20200103193617.977989-1-dever@alt.tf> (view parent)
DKIM signature
missing
Download raw message
Please squash your fixes to previous patches.

On Fri Jan 3, 2020 at 8:36 PM, manur wrote:
> 
> This will allow to use button material in larger widget and be able to
> set alignment of text
> In my case i've used the button to avoid rewriting the layout/click
> visual response for a file explorer (used in a list , the button will
> take all available space but centering it doesn't look good)
>
>

Can you elaborate? From your description, you could either (1) use widget.Button
directly, skipping material.Buttonm or (2) use a gesture.Click listener.
Reply to thread Export thread (mbox)