本文整理匯總了Golang中github.com/nelsam/gxui.Theme.CreateLinearLayout方法的典型用法代碼示例。如果您正苦於以下問題:Golang Theme.CreateLinearLayout方法的具體用法?Golang Theme.CreateLinearLayout怎麽用?Golang Theme.CreateLinearLayout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nelsam/gxui.Theme
的用法示例。
在下文中一共展示了Theme.CreateLinearLayout方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Create
func (defaultTreeControlCreator) Create(theme gxui.Theme, control gxui.Control, node *TreeToListNode) gxui.Control {
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: 2, R: 2, T: 1, B: 1})
btn.OnClick(func(ev gxui.MouseEvent) {
if ev.Button == gxui.MouseButtonLeft {
node.ToggleExpanded()
}
})
update := func() {
btn.SetVisible(!node.IsLeaf())
if node.IsExpanded() {
btn.SetText("-")
} else {
btn.SetText("+")
}
}
update()
gxui.WhileAttached(btn, node.OnChange, update)
ll.AddChild(btn)
ll.AddChild(control)
ll.SetPadding(math.Spacing{L: 16 * node.Depth()})
return ll
}
示例2: colorPicker
// Color picker uses the customAdapter for driving a list
func colorPicker(theme gxui.Theme) gxui.Control {
layout := theme.CreateLinearLayout()
layout.SetDirection(gxui.TopToBottom)
label0 := theme.CreateLabel()
label0.SetText("Color palette:")
layout.AddChild(label0)
adapter := &customAdapter{}
list := theme.CreateList()
list.SetAdapter(adapter)
list.SetOrientation(gxui.Horizontal)
layout.AddChild(list)
label1 := theme.CreateLabel()
label1.SetMargin(math.Spacing{T: 30})
label1.SetText("Selected color:")
layout.AddChild(label1)
selected := theme.CreateImage()
selected.SetExplicitSize(math.Size{W: 32, H: 32})
layout.AddChild(selected)
list.OnSelectionChanged(func(item gxui.AdapterItem) {
if item != nil {
control := list.ItemControl(item)
selected.SetBackgroundBrush(control.(gxui.Image).BackgroundBrush())
}
})
return layout
}
示例3: numberPicker
// Number picker uses the gxui.DefaultAdapter for driving a list
func numberPicker(theme gxui.Theme, overlay gxui.BubbleOverlay) gxui.Control {
items := []string{
"zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen", "twenty",
}
adapter := gxui.CreateDefaultAdapter()
adapter.SetItems(items)
layout := theme.CreateLinearLayout()
layout.SetDirection(gxui.TopToBottom)
label0 := theme.CreateLabel()
label0.SetText("Numbers:")
layout.AddChild(label0)
dropList := theme.CreateDropDownList()
dropList.SetAdapter(adapter)
dropList.SetBubbleOverlay(overlay)
layout.AddChild(dropList)
list := theme.CreateList()
list.SetAdapter(adapter)
list.SetOrientation(gxui.Vertical)
layout.AddChild(list)
label1 := theme.CreateLabel()
label1.SetMargin(math.Spacing{T: 30})
label1.SetText("Selected number:")
layout.AddChild(label1)
selected := theme.CreateLabel()
layout.AddChild(selected)
dropList.OnSelectionChanged(func(item gxui.AdapterItem) {
if list.Selected() != item {
list.Select(item)
}
})
list.OnSelectionChanged(func(item gxui.AdapterItem) {
if dropList.Selected() != item {
dropList.Select(item)
}
selected.SetText(fmt.Sprintf("%s - %d", item, adapter.ItemIndex(item)))
})
return layout
}
示例4: CreateLine
func (e *editor) CreateLine(theme gxui.Theme, index int) (mixins.TextBoxLine, gxui.Control) {
lineNumber := theme.CreateLabel()
lineNumber.SetText(fmt.Sprintf("%4d", index+1))
line := &mixins.CodeEditorLine{}
line.Init(line, theme, &e.CodeEditor, index)
layout := theme.CreateLinearLayout()
layout.SetDirection(gxui.LeftToRight)
layout.AddChild(lineNumber)
layout.AddChild(line)
return line, layout
}
示例5: CreateLine
// mixins.TextBox overrides
func (e *CodeEditor) CreateLine(theme gxui.Theme, index int) (TextBoxLine, gxui.Control) {
lineNumber := theme.CreateLabel()
lineNumber.SetText(fmt.Sprintf("%.4d", index+1)) // Displayed lines start at 1
line := &CodeEditorLine{}
line.Init(line, theme, e, index)
layout := theme.CreateLinearLayout()
layout.SetDirection(gxui.LeftToRight)
layout.AddChild(lineNumber)
layout.AddChild(line)
return line, layout
}
示例6: Init
func (p *PanelHolder) Init(outer PanelHolderOuter, theme gxui.Theme) {
p.Container.Init(outer, theme)
p.outer = outer
p.theme = theme
p.tabLayout = theme.CreateLinearLayout()
p.tabLayout.SetDirection(gxui.LeftToRight)
p.Container.AddChild(p.tabLayout)
p.SetMargin(math.Spacing{L: 1, T: 2, R: 1, B: 1})
p.SetMouseEventTarget(true) // For drag-drop targets
// Interface compliance test
_ = gxui.PanelHolder(p)
}
示例7: Init
func (n *genericNode) Init(outer mixins.LinearLayoutOuter, driver gxui.Driver, theme gxui.Theme, name string, color gxui.Color) {
n.LinearLayout.Init(outer, theme)
n.driver = driver
n.theme = theme
n.SetDirection(gxui.TopToBottom)
n.button = newTreeButton(driver, theme.(*basic.Theme), name)
n.button.Label().SetColor(color)
n.LinearLayout.AddChild(n.button)
n.children = theme.CreateLinearLayout()
n.children.SetDirection(gxui.TopToBottom)
n.children.SetMargin(math.Spacing{L: 10})
}
示例8: 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
}
示例9: Create
// Create implements gxui.TreeNode.
func (n *node) Create(theme gxui.Theme) gxui.Control {
layout := theme.CreateLinearLayout()
layout.SetDirection(gxui.LeftToRight)
label := theme.CreateLabel()
label.SetText(n.name)
textbox := theme.CreateTextBox()
textbox.SetText(n.name)
textbox.SetPadding(math.ZeroSpacing)
textbox.SetMargin(math.ZeroSpacing)
addButton := theme.CreateButton()
addButton.SetText("+")
addButton.OnClick(func(gxui.MouseEvent) { n.add("<new>") })
edit := func() {
layout.RemoveAll()
layout.AddChild(textbox)
layout.AddChild(addButton)
gxui.SetFocus(textbox)
}
commit := func() {
n.name = textbox.Text()
label.SetText(n.name)
layout.RemoveAll()
layout.AddChild(label)
layout.AddChild(addButton)
}
// When the user clicks the label, replace it with an editable text-box
label.OnClick(func(gxui.MouseEvent) { edit() })
// When the text-box loses focus, replace it with a label again.
textbox.OnLostFocus(commit)
layout.AddChild(label)
layout.AddChild(addButton)
return layout
}