本文整理匯總了Golang中github.com/nelsam/gxui.Theme類的典型用法代碼示例。如果您正苦於以下問題:Golang Theme類的具體用法?Golang Theme怎麽用?Golang Theme使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Theme類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewProjectOpener
func NewProjectOpener(theme gxui.Theme, projPane gxui.Control) *ProjectOpener {
return &ProjectOpener{
statusKeeper: statusKeeper{theme: theme},
name: theme.CreateTextBox(),
projPane: projPane,
}
}
示例2: Init
func (l *DropDownList) Init(outer DropDownListOuter, theme gxui.Theme) {
l.outer = outer
l.Container.Init(outer, theme)
l.BackgroundBorderPainter.Init(outer)
l.Focusable.Init(outer)
l.theme = theme
l.list = theme.CreateList()
l.list.OnSelectionChanged(func(item gxui.AdapterItem) {
l.outer.RemoveAll()
adapter := l.list.Adapter()
if item != nil && adapter != nil {
l.selected = l.AddChild(adapter.Create(l.theme, adapter.ItemIndex(item)))
} else {
l.selected = nil
}
l.Relayout()
})
l.list.OnItemClicked(func(gxui.MouseEvent, gxui.AdapterItem) {
l.HideList()
})
l.list.OnKeyPress(func(ev gxui.KeyboardEvent) {
switch ev.Key {
case gxui.KeyEnter, gxui.KeyEscape:
l.HideList()
}
})
l.list.OnLostFocus(l.HideList)
l.OnDetach(l.HideList)
l.SetMouseEventTarget(true)
// Interface compliance test
_ = gxui.DropDownList(l)
}
示例3: Init
func (t *TextBox) Init(outer TextBoxOuter, driver gxui.Driver, theme gxui.Theme, font gxui.Font) {
t.List.Init(outer, theme)
t.Focusable.Init(outer)
t.outer = outer
t.driver = driver
t.font = font
t.onRedrawLines = gxui.CreateEvent(func() {})
t.controller = gxui.CreateTextBoxController()
t.adapter = &TextBoxAdapter{TextBox: t}
t.desiredWidth = 100
t.SetScrollBarEnabled(false) // Defaults to single line
t.OnGainedFocus(func() { t.onRedrawLines.Fire() })
t.OnLostFocus(func() { t.onRedrawLines.Fire() })
t.horizScroll = theme.CreateScrollBar()
t.horizScrollChild = t.AddChild(t.horizScroll)
t.horizScroll.SetOrientation(gxui.Horizontal)
t.horizScroll.OnScroll(func(from, to int) {
t.SetHorizOffset(from)
})
t.controller.OnTextChanged(func([]gxui.TextBoxEdit) {
t.onRedrawLines.Fire()
t.List.DataChanged(false)
})
t.controller.OnSelectionChanged(func() {
t.onRedrawLines.Fire()
})
t.List.SetAdapter(t.adapter)
// Interface compliance test
_ = gxui.TextBox(t)
}
示例4: Create
func (a *customAdapter) Create(theme gxui.Theme, index int) gxui.Control {
phase := float32(index) / 1000
c := gxui.Color{
R: 0.5 + 0.5*math.Sinf(math.TwoPi*(phase+0.000)),
G: 0.5 + 0.5*math.Sinf(math.TwoPi*(phase+0.333)),
B: 0.5 + 0.5*math.Sinf(math.TwoPi*(phase+0.666)),
A: 1.0,
}
i := theme.CreateImage()
i.SetBackgroundBrush(gxui.CreateBrush(c))
i.SetMargin(math.Spacing{L: 3, T: 3, R: 3, B: 3})
i.OnMouseEnter(func(ev gxui.MouseEvent) {
i.SetBorderPen(gxui.CreatePen(2, gxui.Gray80))
})
i.OnMouseExit(func(ev gxui.MouseEvent) {
i.SetBorderPen(gxui.TransparentPen)
})
i.OnMouseDown(func(ev gxui.MouseEvent) {
i.SetBackgroundBrush(gxui.CreateBrush(c.MulRGB(0.7)))
})
i.OnMouseUp(func(ev gxui.MouseEvent) {
i.SetBackgroundBrush(gxui.CreateBrush(c))
})
return i
}
示例5: 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
}
示例6: 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
}
示例7: createIconButton
func createIconButton(driver gxui.Driver, theme gxui.Theme, iconPath string) gxui.Button {
button := theme.CreateButton()
button.SetType(gxui.PushButton)
fileBytes, err := assets.Asset(iconPath)
if err != nil {
log.Printf("Error: Failed to read asset %s: %s", iconPath, err)
return button
}
f := bytes.NewBuffer(fileBytes)
src, _, err := image.Decode(f)
if err != nil {
log.Printf("Error: Failed to decode image %s: %s", iconPath, err)
return button
}
src = resize.Resize(24, 24, src, resize.Bilinear)
rgba := image.NewRGBA(src.Bounds())
draw.Draw(rgba, src.Bounds(), src, image.ZP, draw.Src)
texture := driver.CreateTexture(rgba, 1)
icon := theme.CreateImage()
icon.SetTexture(texture)
button.AddChild(icon)
return button
}
示例8: Init
func (d *DrawPaint) Init(outer DrawPaintOuter, theme gxui.Theme) {
d.outer = outer
d.driver = theme.Driver()
if debugVerifyDetachOnGC {
runtime.SetFinalizer(d.outer, verifyDetach)
}
}
示例9: newCompletionLabel
func newCompletionLabel(theme gxui.Theme, color gxui.Color) *completionLabel {
l := &completionLabel{}
l.Init(l, theme, theme.DefaultMonospaceFont(), color)
l.SetMargin(math.Spacing{
T: 3,
R: 3,
})
l.SetHorizontalAlignment(gxui.AlignCenter)
l.padding = completionPadding
return l
}
示例10: NewProjectsPane
func NewProjectsPane(driver gxui.Driver, theme gxui.Theme, projFrame gxui.Control) *Projects {
pane := &Projects{
theme: theme,
projectFrame: projFrame,
button: createIconButton(driver, theme, "projects.png"),
projects: theme.CreateList(),
projectsAdapter: gxui.CreateDefaultAdapter(),
}
pane.projectsAdapter.SetItems(settings.Projects())
pane.projects.SetAdapter(pane.projectsAdapter)
return pane
}
示例11: panelHolder
// Create a PanelHolder with a 3 panels
func panelHolder(name string, theme gxui.Theme) gxui.PanelHolder {
label := func(text string) gxui.Label {
label := theme.CreateLabel()
label.SetText(text)
return label
}
holder := theme.CreatePanelHolder()
holder.AddPanel(label(name+" 0 content"), name+" 0 panel")
holder.AddPanel(label(name+" 1 content"), name+" 1 panel")
holder.AddPanel(label(name+" 2 content"), name+" 2 panel")
return holder
}
示例12: 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
}
示例13: 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
}
示例14: 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)
}
示例15: newCommandBox
func newCommandBox(driver gxui.Driver, theme gxui.Theme, controller Controller) *commandBox {
box := &commandBox{
driver: driver,
controller: controller,
}
box.label = theme.CreateLabel()
box.label.SetColor(cmdColor)
box.LinearLayout.Init(box, theme)
box.SetDirection(gxui.LeftToRight)
box.AddChild(box.label)
box.Clear()
return box
}