本文整理匯總了Golang中github.com/nelsam/gxui.Theme.Driver方法的典型用法代碼示例。如果您正苦於以下問題:Golang Theme.Driver方法的具體用法?Golang Theme.Driver怎麽用?Golang Theme.Driver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nelsam/gxui.Theme
的用法示例。
在下文中一共展示了Theme.Driver方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
func (d *DrawPaint) Init(outer DrawPaintOuter, theme gxui.Theme) {
d.outer = outer
d.driver = theme.Driver()
if debugVerifyDetachOnGC {
runtime.SetFinalizer(d.outer, verifyDetach)
}
}
示例2: Create
func (treeControlCreator) Create(theme gxui.Theme, control gxui.Control, node *mixins.TreeToListNode) gxui.Control {
img := theme.CreateImage()
imgSize := math.Size{W: 10, H: 10}
ll := theme.CreateLinearLayout()
ll.SetDirection(gxui.LeftToRight)
btn := theme.CreateButton()
btn.SetBackgroundBrush(gxui.TransparentBrush)
btn.SetBorderPen(gxui.CreatePen(1, gxui.Gray30))
btn.SetMargin(math.Spacing{L: 1, R: 1, T: 1, B: 1})
btn.OnClick(func(ev gxui.MouseEvent) {
if ev.Button == gxui.MouseButtonLeft {
node.ToggleExpanded()
}
})
btn.AddChild(img)
update := func() {
expanded := node.IsExpanded()
canvas := theme.Driver().CreateCanvas(imgSize)
btn.SetVisible(!node.IsLeaf())
switch {
case !btn.IsMouseDown(gxui.MouseButtonLeft) && expanded:
canvas.DrawPolygon(expandedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray70))
case !btn.IsMouseDown(gxui.MouseButtonLeft) && !expanded:
canvas.DrawPolygon(collapsedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray70))
case expanded:
canvas.DrawPolygon(expandedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray30))
case !expanded:
canvas.DrawPolygon(collapsedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray30))
}
canvas.Complete()
img.SetCanvas(canvas)
}
btn.OnMouseDown(func(gxui.MouseEvent) { update() })
btn.OnMouseUp(func(gxui.MouseEvent) { update() })
update()
gxui.WhileAttached(btn, node.OnChange, update)
ll.AddChild(btn)
ll.AddChild(control)
ll.SetPadding(math.Spacing{L: 16 * node.Depth()})
return ll
}
示例3: Init
func (l *Layoutable) Init(outer LayoutableOuter, theme gxui.Theme) {
l.outer = outer
l.driver = theme.Driver()
}