Пример #1
0
func (l *List) Init(outer ListOuter, theme gxui.Theme) {
	l.outer = outer
	l.Container.Init(outer, theme)
	l.BackgroundBorderPainter.Init(outer)
	l.Focusable.Init(outer)

	l.theme = theme
	l.scrollBar = theme.CreateScrollBar()
	l.scrollBarChild = l.AddChild(l.scrollBar)
	l.scrollBarEnabled = true
	l.scrollBar.OnScroll(func(from, to int) { l.SetScrollOffset(from) })

	l.SetOrientation(gxui.Vertical)
	l.SetBackgroundBrush(gxui.TransparentBrush)
	l.SetMouseEventTarget(true)

	l.details = make(map[gxui.AdapterItem]itemDetails)

	// Interface compliance test
	_ = gxui.List(l)
}
Пример #2
0
func (l *ScrollLayout) Init(outer ScrollLayoutOuter, theme gxui.Theme) {
	l.Container.Init(outer, theme)
	l.BackgroundBorderPainter.Init(outer)

	l.outer = outer
	l.theme = theme
	l.canScrollX = true
	l.canScrollY = true
	scrollBarX := theme.CreateScrollBar()
	scrollBarX.SetOrientation(gxui.Horizontal)
	scrollBarX.OnScroll(func(from, to int) { l.SetScrollOffset(math.Point{X: from, Y: l.scrollOffset.Y}) })
	scrollBarY := theme.CreateScrollBar()
	scrollBarY.SetOrientation(gxui.Vertical)
	scrollBarY.OnScroll(func(from, to int) { l.SetScrollOffset(math.Point{X: l.scrollOffset.X, Y: from}) })
	l.scrollBarX = l.AddChild(scrollBarX)
	l.scrollBarY = l.AddChild(scrollBarY)
	l.SetMouseEventTarget(true)

	// Interface compliance test
	_ = gxui.ScrollLayout(l)
}