本文整理汇总了Golang中github.com/google/gxui.Theme类的典型用法代码示例。如果您正苦于以下问题:Golang Theme类的具体用法?Golang Theme怎么用?Golang Theme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Theme类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: buildMoon
func buildMoon(theme gxui.Theme, center math.Point, radius float32) gxui.Image {
c := 40
p := make(gxui.Polygon, c*2)
for i := 0; i < c; i++ {
frac := float32(i) / float32(c)
α := math.Lerpf(math.Pi*1.2, math.Pi*-0.2, frac)
p[i] = gxui.PolygonVertex{
Position: math.Point{
X: center.X + int(radius*math.Sinf(α)),
Y: center.Y + int(radius*math.Cosf(α)),
},
RoundedRadius: 0,
}
}
for i := 0; i < c; i++ {
frac := float32(i) / float32(c)
α := math.Lerpf(math.Pi*-0.2, math.Pi*1.2, frac)
r := math.Lerpf(radius, radius*0.5, math.Sinf(frac*math.Pi))
p[i+c] = gxui.PolygonVertex{
Position: math.Point{
X: center.X + int(r*math.Sinf(α)),
Y: center.Y + int(r*math.Cosf(α)),
},
RoundedRadius: 0,
}
}
image := theme.CreateImage()
image.SetPolygon(p, gxui.CreatePen(3, gxui.Gray80), gxui.CreateBrush(gxui.Gray40))
return image
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:30,代码来源:main.go
示例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)
}
开发者ID:linux-mac,项目名称:gxui,代码行数:34,代码来源:drop_down_list.go
示例3: 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
}
开发者ID:henrylee2cn,项目名称:gxui,代码行数:31,代码来源:tree.go
示例4: CreateExpandButton
func (t *Tree) CreateExpandButton(theme gxui.Theme, node *TreeInternalNode) gxui.Button {
btn := theme.CreateButton()
btn.SetMargin(math.Spacing{L: 2, R: 2, T: 1, B: 1})
btn.OnClick(func(ev gxui.MouseEvent) {
if ev.Button == gxui.MouseButtonLeft {
if node.IsExpanded() {
node.Collapse()
} else {
node.Expand()
}
}
})
node.OnExpandedChanged(func(e bool) {
if e {
btn.SetText("-")
} else {
btn.SetText("+")
}
})
if node.IsExpanded() {
btn.SetText("-")
} else {
btn.SetText("+")
}
return btn
}
开发者ID:linux-mac,项目名称:gxui,代码行数:26,代码来源:tree.go
示例5: 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
}
开发者ID:langxj,项目名称:gxui,代码行数:25,代码来源:main.go
示例6: drawWalkPath
//画行走路线
func drawWalkPath(window gxui.Window, theme gxui.Theme, driver gxui.Driver, x1, y1, x2, y2 int64) {
ps, isWalk := nm.FindPath(nmastar, x1, y1, x2, y2)
if !isWalk {
return
}
canvas := driver.CreateCanvas(math.Size{W: int(nmj.Width), H: int(nmj.Heigth)})
var polys []gxui.PolygonVertex
for i := 0; i < len(ps); i++ {
polys = append(polys,
gxui.PolygonVertex{
Position: math.Point{
int(ps[i].X),
int(ps[i].Y),
}})
}
canvas.DrawLines(polys, gxui.CreatePen(2, gxui.Green))
canvas.Complete()
image := theme.CreateImage()
image.SetCanvas(canvas)
window.AddChild(image)
}
开发者ID:gbember,项目名称:gt,代码行数:26,代码来源:main.go
示例7: 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
}
开发者ID:langxj,项目名称:gxui,代码行数:34,代码来源:main.go
示例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)
}
}
开发者ID:langxj,项目名称:gxui,代码行数:8,代码来源:draw_paint.go
示例9: Createsebaris
func Createsebaris(Theme gxui.Theme, S data.Setoran) UISetoran {
var TB UISetoran
TB.TBJumlah = Theme.CreateTextBox()
TB.TBCatatan = Theme.CreateTextBox()
TB.TBJumlah.SetText(strconv.Itoa(S.Jumlah))
TB.TBCatatan.SetText(S.Catatan)
return TB
}
开发者ID:jonysugianto,项目名称:adminkost,代码行数:8,代码来源:setoran.go
示例10: Create
func (d directory) Create(theme gxui.Theme, index int) gxui.Control {
path := d.subdirs[index]
_, name := filepath.Split(path)
l := theme.CreateLabel()
l.SetText(name)
l.SetColor(directoryColor)
return l
}
开发者ID:linux-mac,项目名称:gxui,代码行数:9,代码来源:main.go
示例11: Createsebaris
func Createsebaris(Theme gxui.Theme, Data data.Anakkost) UISewa {
var TB UISewa
TB.TBNama = Theme.CreateTextBox()
TB.TBSewa = Theme.CreateTextBox()
TB.TBCatatan = Theme.CreateTextBox()
TB.TBNama.SetText(Data.Nama)
TB.TBSewa.SetText(strconv.Itoa(Data.Sewa))
TB.TBCatatan.SetText(Data.Catatan)
return TB
}
开发者ID:jonysugianto,项目名称:adminkost,代码行数:10,代码来源:sewabulanan.go
示例12: 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
}
开发者ID:melanxolikpofigist,项目名称:gokr,代码行数:14,代码来源:kr.go
示例13: CreateLine
// mixins.TextBox overrides
func (t *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, t, index)
layout := theme.CreateLinearLayout()
layout.SetDirection(gxui.LeftToRight)
layout.AddChild(lineNumber)
layout.AddChild(line)
return line, layout
}
开发者ID:langxj,项目名称:gxui,代码行数:15,代码来源:code_editor.go
示例14: Init
func (d *DrawPaint) Init(outer DrawPaintOuter, theme gxui.Theme) {
d.outer = outer
d.driver = theme.Driver()
outer.OnDetach(func() {
if d.canvas != nil {
d.canvas.Release()
d.canvas = nil
}
})
if debugVerifyDetachOnGC {
runtime.SetFinalizer(d.outer, verifyDetach)
}
}
开发者ID:nulijiabei,项目名称:gxui,代码行数:14,代码来源:draw_paint.go
示例15: 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+" Tout"), name+" Tous mes fichiers")
holder.AddPanel(label(name+" Cours"), name+" Mes cours")
holder.AddPanel(label(name+" Musique"), name+" Ma musique")
holder.AddPanel(label(name+" Photos"), name+" Mes photos")
holder.AddPanel(label(name+" Vidéos"), name+" Mes vidéos")
return holder
}
开发者ID:adrien3d,项目名称:gobox,代码行数:16,代码来源:gui.go
示例16: 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)
}
开发者ID:liulnn,项目名称:gxui,代码行数:15,代码来源:panel_holder.go
示例17: CreateIcon
// CreateIcon is create icon control
func CreateIcon(theme gxui.Theme, icon rune, size int) gxui.Label {
if theme == nil || size < 0 {
return nil
}
control := theme.CreateLabel()
font, ok := MaterialIconFonts[size]
if !ok {
var err error
font, err = theme.Driver().CreateFont(MaterialIcon, size)
if err != nil {
return nil
}
MaterialIconFonts[size] = font
}
control.SetFont(font)
control.SetText(string(icon))
return control
}
开发者ID:aoisensi,项目名称:gxui-material-icon,代码行数:19,代码来源:gxui-material-icon.go
示例18: buildStar
func buildStar(theme gxui.Theme, center math.Point, radius, rotation float32, points int) gxui.Image {
p := make(gxui.Polygon, points*2)
for i := 0; i < points*2; i++ {
frac := float32(i) / float32(points*2)
α := frac*math.TwoPi + rotation
r := []float32{radius, radius / 2}[i&1]
p[i] = gxui.PolygonVertex{
Position: math.Point{
X: center.X + int(r*math.Cosf(α)),
Y: center.Y + int(r*math.Sinf(α)),
},
RoundedRadius: []float32{0, 50}[i&1],
}
}
image := theme.CreateImage()
image.SetPolygon(p, gxui.CreatePen(3, gxui.Red), gxui.CreateBrush(gxui.Yellow))
return image
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:18,代码来源:main.go
示例19: Create
func (a TreeToListAdapter) Create(theme gxui.Theme, index int) gxui.Control {
n, i, d := a.root.FindByIndex(index)
child := n.Child(i)
toggle := a.createExpandButton(theme, child)
toggle.SetVisible(!child.IsLeaf())
child.OnExpandedChanged(func(e bool) {
a.DataChanged()
})
control := n.node.Create(theme, i)
layout := theme.CreateLinearLayout()
layout.SetPadding(math.Spacing{L: d * 16})
layout.SetDirection(gxui.LeftToRight)
layout.AddChild(toggle)
layout.AddChild(control)
return layout
}
开发者ID:linux-mac,项目名称:gxui,代码行数:19,代码来源:tree_to_list_adapter.go
示例20: Init
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)
}
开发者ID:langxj,项目名称:gxui,代码行数:21,代码来源:scroll_layout.go
注:本文中的github.com/google/gxui.Theme类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论