Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a new theme size name for rounded scrollbar corners #4839

Merged
merged 12 commits into from
Jun 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="74x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="74x3"/>
<rectangle fillColor="scrollbar" radius="3" size="74x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="71x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="71x3"/>
<rectangle fillColor="scrollbar" radius="3" size="71x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="260x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="212x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="212x3"/>
<rectangle fillColor="scrollbar" radius="3" size="212x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/hover_all_tabs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="70x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="31x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="31x3"/>
<rectangle fillColor="scrollbar" radius="3" size="31x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/hover_create_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="70x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="31x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="31x3"/>
<rectangle fillColor="scrollbar" radius="3" size="31x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/hover_first.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</widget>
<widget pos="0,30" size="70x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="31x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="31x3"/>
<rectangle fillColor="scrollbar" radius="3" size="31x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/hover_first_close.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="70x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="31x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="31x3"/>
<rectangle fillColor="scrollbar" radius="3" size="31x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/hover_none.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="70x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="31x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="31x3"/>
<rectangle fillColor="scrollbar" radius="3" size="31x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/hover_second.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</widget>
<widget pos="0,30" size="70x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="31x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="31x3"/>
<rectangle fillColor="scrollbar" radius="3" size="31x3"/>
</widget>
</widget>
</widget>
Expand Down
Binary file modified container/testdata/doctabs/desktop/single_custom_theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/tab_location_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</widget>
<widget pos="0,30" size="32x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="16x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="16x3"/>
<rectangle fillColor="scrollbar" radius="3" size="16x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</widget>
<widget pos="66,0" size="6x32" type="*widget.scrollBarArea">
<widget pos="3,0" size="3x16" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="3x16"/>
<rectangle fillColor="scrollbar" radius="3" size="3x16"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/tab_location_top.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</widget>
<widget pos="0,30" size="32x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="16x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="16x3"/>
<rectangle fillColor="scrollbar" radius="3" size="16x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</widget>
<widget pos="66,0" size="6x32" type="*widget.scrollBarArea">
<widget pos="3,0" size="3x16" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="3x16"/>
<rectangle fillColor="scrollbar" radius="3" size="3x16"/>
</widget>
</widget>
</widget>
Expand Down
4 changes: 2 additions & 2 deletions container/testdata/doctabs/desktop/tapped_all_tabs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="220x6" type="*widget.scrollBarArea">
<widget pos="77,3" size="142x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="142x3"/>
<rectangle fillColor="scrollbar" radius="3" size="142x3"/>
</widget>
</widget>
</widget>
Expand Down Expand Up @@ -85,7 +85,7 @@
</widget>
<widget pos="91,0" size="6x98" type="*widget.scrollBarArea">
<widget pos="3,0" size="3x63" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="3x63"/>
<rectangle fillColor="scrollbar" radius="3" size="3x63"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/desktop/tapped_create_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="220x6" type="*widget.scrollBarArea">
<widget pos="77,3" size="142x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="142x3"/>
<rectangle fillColor="scrollbar" radius="3" size="142x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</widget>
<widget pos="0,30" size="220x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="203x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="203x3"/>
<rectangle fillColor="scrollbar" radius="3" size="203x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</widget>
<widget pos="0,30" size="220x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="203x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="203x3"/>
<rectangle fillColor="scrollbar" radius="3" size="203x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</widget>
<widget pos="0,30" size="220x6" type="*widget.scrollBarArea">
<widget pos="16,3" size="203x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="203x3"/>
<rectangle fillColor="scrollbar" radius="3" size="203x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="74x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="74x3"/>
<rectangle fillColor="scrollbar" radius="3" size="74x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="71x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="71x3"/>
<rectangle fillColor="scrollbar" radius="3" size="71x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/mobile/change_label_initial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</widget>
<widget pos="0,30" size="260x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="212x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="212x3"/>
<rectangle fillColor="scrollbar" radius="3" size="212x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/mobile/hover_none.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
<rectangle fillColor="scrollbar" radius="3" size="77x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/mobile/tab_location_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</widget>
<widget pos="0,30" size="32x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="16x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="16x3"/>
<rectangle fillColor="scrollbar" radius="3" size="16x3"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/mobile/tab_location_top.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</widget>
<widget pos="0,30" size="32x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="16x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="16x3"/>
<rectangle fillColor="scrollbar" radius="3" size="16x3"/>
</widget>
</widget>
</widget>
Expand Down
4 changes: 2 additions & 2 deletions container/testdata/doctabs/mobile/tapped_all_tabs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</widget>
<widget pos="0,30" size="300x6" type="*widget.scrollBarArea">
<widget pos="34,3" size="265x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="265x3"/>
<rectangle fillColor="scrollbar" radius="3" size="265x3"/>
</widget>
</widget>
</widget>
Expand Down Expand Up @@ -97,7 +97,7 @@
</widget>
<widget pos="91,0" size="6x98" type="*widget.scrollBarArea">
<widget pos="3,0" size="3x63" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="3x63"/>
<rectangle fillColor="scrollbar" radius="3" size="3x63"/>
</widget>
</widget>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion container/testdata/doctabs/mobile/tapped_create_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</widget>
<widget pos="0,30" size="300x6" type="*widget.scrollBarArea">
<widget pos="34,3" size="265x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="265x3"/>
<rectangle fillColor="scrollbar" radius="3" size="265x3"/>
</widget>
</widget>
</widget>
Expand Down
Binary file modified container/testdata/doctabs/mobile/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 internal/painter/software/testdata/draw_gradient_clipped.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 internal/painter/software/testdata/draw_image_clipped.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 internal/painter/software/testdata/draw_rect_clipped.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 internal/painter/software/testdata/draw_text_clipped.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions internal/widget/scroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (r *scrollBarRenderer) MinSize() fyne.Size {

func (r *scrollBarRenderer) Refresh() {
r.background.FillColor = theme.Color(theme.ColorNameScrollBar)
r.background.CornerRadius = theme.Size(theme.SizeNameScrollBarRadius)
r.background.Refresh()
}

Expand All @@ -68,6 +69,7 @@ type scrollBar struct {

func (b *scrollBar) CreateRenderer() fyne.WidgetRenderer {
background := canvas.NewRectangle(theme.Color(theme.ColorNameScrollBar))
background.CornerRadius = theme.Size(theme.SizeNameScrollBarRadius)
r := &scrollBarRenderer{
scrollBar: b,
background: background,
Expand Down
5 changes: 4 additions & 1 deletion test/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func NewTheme() fyne.Theme {
theme.SizeNameInputBorder: float32(5),
theme.SizeNameInputRadius: float32(2),
theme.SizeNameSelectionRadius: float32(6),
theme.SizeNameScrollBarRadius: float32(2),
},
}
}
Expand Down Expand Up @@ -140,6 +141,7 @@ func Theme() fyne.Theme {
theme.SizeNameInputBorder: float32(2),
theme.SizeNameInputRadius: float32(4),
theme.SizeNameSelectionRadius: float32(4),
theme.SizeNameScrollBarRadius: float32(3),
},
}
}
Expand Down Expand Up @@ -176,8 +178,9 @@ func (t *configurableTheme) Icon(n fyne.ThemeIconName) fyne.Resource {
}

func (t *configurableTheme) Size(s fyne.ThemeSizeName) float32 {
if t.sizes[s] == 0 {
if _, ok := t.sizes[s]; !ok {
fyne.LogError(fmt.Sprintf("size %s not defined in theme %s", s, t.name), nil)
return 0
}

return t.sizes[s]
Expand Down
5 changes: 5 additions & 0 deletions theme/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ const (
//
// Since: 2.4
SizeNameSelectionRadius fyne.ThemeSizeName = "selectionRadius"

// SizeNameScrollBarRadius is the name of theme lookup for the scroll bar corner radius.
//
// Since: 2.5
SizeNameScrollBarRadius = "scrollBarRadius"
)

// CaptionTextSize returns the size for caption text.
Expand Down
2 changes: 2 additions & 0 deletions theme/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ func (t *builtinTheme) Size(s fyne.ThemeSizeName) float32 {
return 5
case SizeNameSelectionRadius:
return 3
case SizeNameScrollBarRadius:
return 3
default:
return 0
}
Expand Down
2 changes: 1 addition & 1 deletion widget/testdata/entry/wrap_multi_line_truncate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</widget>
<widget pos="0,90" size="120x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="49x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="49x3"/>
<rectangle fillColor="scrollbar" radius="3" size="49x3"/>
</widget>
</widget>
</widget>
Expand Down
Loading