forked from google/gxui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scroll_bar.go
41 lines (37 loc) · 1.21 KB
/
scroll_bar.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dark
import (
"github.com/google/gxui"
"github.com/google/gxui/mixins"
)
type ScrollBar struct {
mixins.ScrollBar
}
func CreateScrollBar(theme *Theme) gxui.ScrollBar {
s := &ScrollBar{}
s.ScrollBar.Init(s, theme)
s.SetBarBrush(theme.ScrollBarBarDefaultStyle.Brush)
s.SetBarPen(theme.ScrollBarBarDefaultStyle.Pen)
s.SetRailBrush(theme.ScrollBarRailDefaultStyle.Brush)
s.SetRailPen(theme.ScrollBarRailDefaultStyle.Pen)
updateColors := func() {
switch {
case s.IsMouseOver():
s.SetBarBrush(theme.ScrollBarBarOverStyle.Brush)
s.SetBarPen(theme.ScrollBarBarOverStyle.Pen)
s.SetRailBrush(theme.ScrollBarRailOverStyle.Brush)
s.SetRailPen(theme.ScrollBarRailOverStyle.Pen)
default:
s.SetBarBrush(theme.ScrollBarBarDefaultStyle.Brush)
s.SetBarPen(theme.ScrollBarBarDefaultStyle.Pen)
s.SetRailBrush(theme.ScrollBarRailDefaultStyle.Brush)
s.SetRailPen(theme.ScrollBarRailDefaultStyle.Pen)
}
s.Redraw()
}
s.OnMouseEnter(func(gxui.MouseEvent) { updateColors() })
s.OnMouseExit(func(gxui.MouseEvent) { updateColors() })
return s
}