Skip to content

Commit

Permalink
Split Padding to introduce InnerPadding and LineSpacing
Browse files Browse the repository at this point in the history
Avoiding the complexity of overusing a single variable...
  • Loading branch information
andydotxyz committed Aug 28, 2022
1 parent dc003c6 commit 5ca198e
Show file tree
Hide file tree
Showing 166 changed files with 404 additions and 374 deletions.
2 changes: 1 addition & 1 deletion container/testdata/apptabs/mobile/hover_none.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<rectangle fillColor="shadow" pos="0,43" size="150x6"/>
<rectangle fillColor="primary" pos="0,43" size="72x6"/>
<widget pos="0,49" size="150x100" type="*widget.Label">
<text pos="12,12" size="126x19">Text1</text>
<text pos="8,8" size="134x19">Text1</text>
</widget>
</widget>
</content>
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/doctabs/mobile/hover_none.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<content>
<widget size="150x150" type="*container.DocTabs">
<container size="150x44">
<widget size="100x44" type="*widget.Scroll">
<widget size="108x44" type="*widget.Scroll">
<container size="162x44">
<widget size="78x44" type="*container.tabButton">
<text bold color="primary" pos="6,12" size="66x19">Test1</text>
Expand All @@ -17,27 +17,27 @@
</widget>
</widget>
</container>
<widget pos="0,38" size="100x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="61x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="61x3"/>
<widget pos="0,38" size="108x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="72x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="72x3"/>
</widget>
</widget>
<widget pos="100,0" size="0x44" type="*widget.Shadow">
<widget pos="108,0" size="0x44" type="*widget.Shadow">
<linearGradient angle="270" endColor="shadow" pos="-8,0" size="8x44"/>
</widget>
</widget>
<container pos="106,0" size="44x44">
<widget size="44x44" type="*widget.Button">
<rectangle size="44x44"/>
<container pos="114,0" size="36x44">
<widget size="36x44" type="*widget.Button">
<rectangle size="36x44"/>
<rectangle size="0x0"/>
<image fillMode="contain" pos="12,12" rsc="more-horizontal.svg" size="iconInlineSize" themed="default"/>
<image fillMode="contain" pos="8,12" rsc="more-horizontal.svg" size="iconInlineSize" themed="default"/>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,44" size="150x6"/>
<rectangle fillColor="primary" pos="0,44" size="78x6"/>
<widget pos="0,50" size="150x100" type="*widget.Label">
<text pos="12,12" size="126x19">Text1</text>
<text pos="8,8" size="134x19">Text1</text>
</widget>
</widget>
</content>
Expand Down
Binary file modified dialog/testdata/color/dialog_expanded_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_expanded_theme_ugly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_recents_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_recents_theme_ugly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_simple_recents_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_simple_recents_theme_ugly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_simple_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_simple_theme_ugly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_theme_ugly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/dialog-custom-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/dialog-custom-ugly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/dialog-onshow-theme-changed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/dialog-onshow-theme-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/button_important.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/canvas_mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/entry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/entry_focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/label_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/label_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions layout/formlayout.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (f *formLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {

tableRow := table[row]
if _, ok := objects[i].(*canvas.Text); ok {
objects[i].Move(fyne.NewPos(theme.Padding()*2, y+theme.Padding()*2))
objects[i].Resize(fyne.NewSize(tableRow[0].Width-theme.Padding()*4, objects[i].MinSize().Height))
objects[i].Move(fyne.NewPos(theme.InnerPadding(), y+theme.InnerPadding()))
objects[i].Resize(fyne.NewSize(tableRow[0].Width-theme.InnerPadding()*2, objects[i].MinSize().Height))
} else {
objects[i].Move(fyne.NewPos(0, y))
objects[i].Resize(fyne.NewSize(tableRow[0].Width, tableRow[0].Height))
Expand Down
2 changes: 2 additions & 0 deletions test/testtheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func NewTheme() fyne.Theme {
},
sizes: map[fyne.ThemeSizeName]float32{
theme.SizeNameInlineIcon: float32(24),
theme.SizeNameInnerPadding: float32(20),
theme.SizeNameLineSpacing: float32(6),
theme.SizeNamePadding: float32(10),
theme.SizeNameScrollBar: float32(10),
theme.SizeNameScrollBarSmall: float32(2),
Expand Down
2 changes: 2 additions & 0 deletions test/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func Theme() fyne.Theme {
},
sizes: map[fyne.ThemeSizeName]float32{
theme.SizeNameInlineIcon: float32(20),
theme.SizeNameInnerPadding: float32(8),
theme.SizeNameLineSpacing: float32(4),
theme.SizeNamePadding: float32(4),
theme.SizeNameScrollBar: float32(16),
theme.SizeNameScrollBarSmall: float32(3),
Expand Down
28 changes: 28 additions & 0 deletions theme/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ const (
// Since: 2.0
SizeNameInlineIcon fyne.ThemeSizeName = "iconInline"

// SizeNameInnerPadding is the name of theme lookup for internal widget padding size.
//
// Since: 2.3
SizeNameInnerPadding fyne.ThemeSizeName = "innerPadding"

// SizeNameLineSpacing is the name of theme lookup for between text line spacing.
//
// Since: 2.3
SizeNameLineSpacing fyne.ThemeSizeName = "lineSpacing"

// SizeNamePadding is the name of theme lookup for padding size.
//
// Since: 2.0
Expand Down Expand Up @@ -313,6 +323,13 @@ func IconInlineSize() float32 {
return current().Size(SizeNameInlineIcon)
}

// InnerPadding is the standard gap between element content and the outside edge of a widget.
//
// Since: 2.3
func InnerPadding() float32 {
return current().Size(SizeNameInnerPadding)
}

// InputBackgroundColor returns the color used to draw underneath input elements.
func InputBackgroundColor() color.Color {
return current().Color(ColorNameInputBackground, currentVariant())
Expand Down Expand Up @@ -342,6 +359,13 @@ func LightTheme() fyne.Theme {
return theme
}

// LineSpacing is the default gap between multiple lines of text.
//
// Since: 2.3
func LineSpacing() float32 {
return current().Size(SizeNameLineSpacing)
}

// Padding is the standard gap between elements and the border around interface elements.
func Padding() float32 {
return current().Size(SizeNamePadding)
Expand Down Expand Up @@ -632,6 +656,10 @@ func (t *builtinTheme) Size(s fyne.ThemeSizeName) float32 {
return 1
case SizeNameInlineIcon:
return 20
case SizeNameInnerPadding:
return 8
case SizeNameLineSpacing:
return 4
case SizeNamePadding:
return 6
case SizeNameScrollBar:
Expand Down
2 changes: 1 addition & 1 deletion widget/accordion_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestAccordionRenderer_MinSize(t *testing.T) {
aih := ar.headers[0].MinSize()
aid := ai.Detail.MinSize()
assert.Equal(t, fyne.Max(aih.Width, aid.Width), min.Width)
assert.Equal(t, aih.Height+aid.Height+theme.Padding()*1, min.Height)
assert.Equal(t, aih.Height+aid.Height+theme.Padding(), min.Height)
})
t.Run("Closed", func(t *testing.T) {
ac := NewAccordion()
Expand Down
28 changes: 14 additions & 14 deletions widget/accordion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func TestAccordion_ChangeTheme(t *testing.T) {

w := test.NewWindow(ac)
defer w.Close()
w.Resize(ac.MinSize().Add(fyne.NewSize(theme.Padding()*2, theme.Padding()*2)))
w.Resize(ac.MinSize().Add(fyne.NewSize(theme.InnerPadding(), theme.InnerPadding())))

test.AssertImageMatches(t, "accordion/theme_initial.png", w.Canvas().Capture())

test.WithTestTheme(t, func() {
w.Resize(ac.MinSize().Add(fyne.NewSize(theme.Padding()*2, theme.Padding()*2)))
w.Resize(ac.MinSize().Add(fyne.NewSize(theme.InnerPadding(), theme.InnerPadding())))
ac.Refresh()
time.Sleep(100 * time.Millisecond)
test.AssertImageMatches(t, "accordion/theme_changed.png", w.Canvas().Capture())
Expand Down Expand Up @@ -219,11 +219,11 @@ func TestAccordion_Layout(t *testing.T) {

func TestAccordion_MinSize(t *testing.T) {
minSizeA := fyne.MeasureText("A", theme.TextSize(), fyne.TextStyle{})
minSizeA.Width += theme.IconInlineSize() + theme.Padding()*7
minSizeA.Height = fyne.Max(minSizeA.Height, theme.IconInlineSize()) + theme.Padding()*2
minSizeA.Width += theme.IconInlineSize() + theme.InnerPadding()*3+theme.Padding()
minSizeA.Height = fyne.Max(minSizeA.Height, theme.IconInlineSize()) + theme.InnerPadding()
minSizeB := fyne.MeasureText("B", theme.TextSize(), fyne.TextStyle{})
minSizeB.Width += theme.IconInlineSize() + theme.Padding()*7
minSizeB.Height = fyne.Max(minSizeB.Height, theme.IconInlineSize()) + theme.Padding()*2
minSizeB.Width += theme.IconInlineSize() + theme.InnerPadding()*3+theme.Padding()
minSizeB.Height = fyne.Max(minSizeB.Height, theme.IconInlineSize()) + theme.InnerPadding()
minSize1 := fyne.MeasureText("111111", theme.TextSize(), fyne.TextStyle{})
minSize1.Width += theme.Padding() * 4
minSize1.Height += theme.Padding() * 4
Expand All @@ -250,7 +250,7 @@ func TestAccordion_MinSize(t *testing.T) {
Detail: widget.NewLabel("111111"),
},
},
want: fyne.NewSize(minWidthA1, minSizeA.Height+theme.Padding()*2),
want: fyne.NewSize(minWidthA1, minSizeA.Height+theme.InnerPadding()),
},
"single_open_one_item_opened": {
items: []*widget.AccordionItem{
Expand All @@ -260,7 +260,7 @@ func TestAccordion_MinSize(t *testing.T) {
},
},
opened: []int{0},
want: fyne.NewSize(minWidthA1, minHeightA1+theme.Padding()*2),
want: fyne.NewSize(minWidthA1, minHeightA1+theme.InnerPadding()),
},
"single_open_multiple_items": {
items: []*widget.AccordionItem{
Expand All @@ -273,7 +273,7 @@ func TestAccordion_MinSize(t *testing.T) {
Detail: widget.NewLabel("2222222222"),
},
},
want: fyne.NewSize(minWidthA1B2, minSizeA.Height+minSizeB.Height+theme.Padding()*4+1),
want: fyne.NewSize(minWidthA1B2, minSizeA.Height+minSizeB.Height+theme.InnerPadding()*2+1),
},
"single_open_multiple_items_opened": {
items: []*widget.AccordionItem{
Expand All @@ -287,7 +287,7 @@ func TestAccordion_MinSize(t *testing.T) {
},
},
opened: []int{0, 1},
want: fyne.NewSize(minWidthA1B2, minSizeA.Height+minSizeB.Height+minSize2.Height+theme.Padding()*5+1),
want: fyne.NewSize(minWidthA1B2, minSizeA.Height+minSizeB.Height+minSize2.Height+theme.InnerPadding()*2+theme.Padding()+1),
},
"multiple_open_one_item": {
multiOpen: true,
Expand All @@ -297,7 +297,7 @@ func TestAccordion_MinSize(t *testing.T) {
Detail: widget.NewLabel("111111"),
},
},
want: fyne.NewSize(minWidthA1, minSizeA.Height+theme.Padding()*2),
want: fyne.NewSize(minWidthA1, minSizeA.Height+theme.InnerPadding()),
},
"multiple_open_one_item_opened": {
multiOpen: true,
Expand All @@ -308,7 +308,7 @@ func TestAccordion_MinSize(t *testing.T) {
},
},
opened: []int{0},
want: fyne.NewSize(minWidthA1, minHeightA1+theme.Padding()*2),
want: fyne.NewSize(minWidthA1, minHeightA1+theme.InnerPadding()),
},
"multiple_open_multiple_items": {
multiOpen: true,
Expand All @@ -322,7 +322,7 @@ func TestAccordion_MinSize(t *testing.T) {
Detail: widget.NewLabel("2222222222"),
},
},
want: fyne.NewSize(minWidthA1B2, minSizeA.Height+minSizeB.Height+theme.Padding()*4+1),
want: fyne.NewSize(minWidthA1B2, minSizeA.Height+minSizeB.Height+theme.InnerPadding()*2+1),
},
"multiple_open_multiple_items_opened": {
multiOpen: true,
Expand All @@ -337,7 +337,7 @@ func TestAccordion_MinSize(t *testing.T) {
},
},
opened: []int{0, 1},
want: fyne.NewSize(minWidthA1B2, minSizeA.Height+minSizeB.Height+minSize1.Height+minSize2.Height+theme.Padding()*6+1),
want: fyne.NewSize(minWidthA1B2, minSizeA.Height+minSizeB.Height+minSize1.Height+minSize2.Height+theme.InnerPadding()*3+1),
},
} {
t.Run(name, func(t *testing.T) {
Expand Down
9 changes: 3 additions & 6 deletions widget/button.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (b *Button) CreateRenderer() fyne.WidgetRenderer {
seg := &TextSegment{Text: b.Text, Style: RichTextStyleStrong}
seg.Style.Alignment = fyne.TextAlignCenter
text := NewRichText(seg)
text.inset = fyne.NewSize(theme.Padding()*2, theme.Padding()*2)
text.inset = fyne.NewSize(theme.InnerPadding(), theme.InnerPadding())

background := canvas.NewRectangle(theme.ButtonColor())
tapBG := canvas.NewRectangle(color.Transparent)
Expand Down Expand Up @@ -293,7 +293,7 @@ func (r *buttonRenderer) MinSize() (size fyne.Size) {
}

func (r *buttonRenderer) Refresh() {
r.label.inset = fyne.NewSize(theme.Padding()*2, theme.Padding()*2)
r.label.inset = fyne.NewSize(theme.InnerPadding(), theme.InnerPadding())
r.label.Segments[0].(*TextSegment).Text = r.button.Text
r.updateIconAndText()
r.applyTheme()
Expand Down Expand Up @@ -363,10 +363,7 @@ func (r *buttonRenderer) buttonColor() color.Color {
}

func (r *buttonRenderer) padding() fyne.Size {
if r.button.Text == "" {
return fyne.NewSize(theme.Padding()*4, theme.Padding()*4)
}
return fyne.NewSize(theme.Padding()*6, theme.Padding()*4)
return fyne.NewSize(theme.InnerPadding()*2, theme.InnerPadding()*2)
}

func (r *buttonRenderer) updateIconAndText() {
Expand Down
12 changes: 6 additions & 6 deletions widget/button_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func TestButtonRenderer_Layout(t *testing.T) {
render.Layout(render.MinSize())

assert.True(t, render.icon.Position().X < render.label.Position().X)
assert.Equal(t, theme.Padding()*3, render.icon.Position().X)
assert.Equal(t, theme.Padding()*3, render.MinSize().Width-render.label.Position().X-render.label.Size().Width)
assert.Equal(t, theme.InnerPadding(), render.icon.Position().X)
assert.Equal(t, theme.InnerPadding(), render.MinSize().Width-render.label.Position().X-render.label.Size().Width)
}

func TestButtonRenderer_Layout_Stretch(t *testing.T) {
Expand All @@ -162,12 +162,12 @@ func TestButtonRenderer_Layout_Stretch(t *testing.T) {

textHeight := render.label.MinSize().Height
minIconHeight := fyne.Max(theme.IconInlineSize(), textHeight)
assert.Equal(t, 50+theme.Padding()*3, render.icon.Position().X, "icon x")
assert.Equal(t, 50+theme.Padding()*2, render.icon.Position().Y, "icon y")
assert.Equal(t, 50+theme.InnerPadding(), render.icon.Position().X, "icon x")
assert.Equal(t, 50+theme.InnerPadding(), render.icon.Position().Y, "icon y")
assert.Equal(t, theme.IconInlineSize(), render.icon.Size().Width, "icon width")
assert.Equal(t, minIconHeight, render.icon.Size().Height, "icon height")
assert.Equal(t, 50+theme.Padding()*4+theme.IconInlineSize(), render.label.Position().X, "label x")
assert.Equal(t, 50+theme.Padding()*2, render.label.Position().Y, "label y")
assert.Equal(t, 50+theme.InnerPadding()+theme.Padding()+theme.IconInlineSize(), render.label.Position().X, "label x")
assert.Equal(t, 50+theme.InnerPadding(), render.label.Position().Y, "label y")
assert.Equal(t, render.label.MinSize(), render.label.Size(), "label size")
}

Expand Down
4 changes: 2 additions & 2 deletions widget/button_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func TestButton_MinSize(t *testing.T) {
button := widget.NewButton("Hi", nil)
min := button.MinSize()

assert.True(t, min.Width > theme.Padding()*2)
assert.True(t, min.Height > theme.Padding()*2)
assert.True(t, min.Width > theme.InnerPadding())
assert.True(t, min.Height > theme.InnerPadding())
}

func TestButton_SetText(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions widget/card_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestCard_Layout(t *testing.T) {

window := test.NewWindow(card)
size := card.MinSize().Max(fyne.NewSize(80, 0)) // give a little width for image only tests
window.Resize(size.Add(fyne.NewSize(theme.Padding()*2, theme.Padding()*2)))
window.Resize(size.Add(fyne.NewSize(theme.InnerPadding(), theme.InnerPadding())))
if tt.content != nil {
assert.Equal(t, float32(10), tt.content.Size().Height)
}
Expand All @@ -121,7 +121,7 @@ func TestCard_MinSize(t *testing.T) {
content := widget.NewLabel("simple")
card := &widget.Card{Content: content}

inner := card.MinSize().Subtract(fyne.NewSize(theme.Padding()*3, theme.Padding()*3)) // shadow + content pad
inner := card.MinSize().Subtract(fyne.NewSize(theme.InnerPadding()+theme.Padding(), theme.InnerPadding()+theme.Padding())) // shadow + content pad
assert.Equal(t, content.MinSize(), inner)
}

Expand Down
13 changes: 6 additions & 7 deletions widget/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ func (c *checkRenderer) MinSize() fyne.Size {

// Layout the components of the check widget
func (c *checkRenderer) Layout(size fyne.Size) {
focusIndicatorSize := fyne.NewSize(theme.IconInlineSize()+theme.Padding()*2, theme.IconInlineSize()+theme.Padding()*2)
focusIndicatorSize := fyne.NewSize(theme.IconInlineSize()+theme.InnerPadding(), theme.IconInlineSize()+theme.InnerPadding())
c.focusIndicator.Resize(focusIndicatorSize)
c.focusIndicator.Move(fyne.NewPos(theme.Padding()*0.5, (size.Height-focusIndicatorSize.Height)/2))
c.focusIndicator.Move(fyne.NewPos(theme.InputBorderSize(), (size.Height-focusIndicatorSize.Height)/2))

offset := fyne.NewSize(focusIndicatorSize.Width, 0)

labelSize := size.Subtract(offset)
xOff := focusIndicatorSize.Width + theme.InputBorderSize()*2
labelSize := size.SubtractWidthHeight(xOff, 0)
c.label.Resize(labelSize)
c.label.Move(fyne.NewPos(offset.Width+theme.Padding(), 0))
c.label.Move(fyne.NewPos(xOff, 0))

iconPos := fyne.NewPos(theme.Padding()*1.5, (size.Height-theme.IconInlineSize())/2)
iconPos := fyne.NewPos(theme.InnerPadding()/2 + theme.InputBorderSize(), (size.Height-theme.IconInlineSize())/2)
iconSize := fyne.NewSize(theme.IconInlineSize(), theme.IconInlineSize())
c.bg.Move(iconPos.AddXY(4, 4))
c.bg.Resize(iconSize.SubtractWidthHeight(8, 8))
Expand Down
7 changes: 4 additions & 3 deletions widget/check_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"github.com/stretchr/testify/assert"
)

func TestCheckSize(t *testing.T) {
check := NewCheck("Hi", nil)
min := check.MinSize()

assert.True(t, min.Width > theme.Padding()*2)
assert.True(t, min.Height > theme.Padding()*2)
assert.True(t, min.Width > theme.InnerPadding())
assert.True(t, min.Height > theme.InnerPadding())
}

func TestCheckChecked(t *testing.T) {
Expand Down
Loading

0 comments on commit 5ca198e

Please sign in to comment.