func (inst instanceNode) Create(theme gxui.Theme) gxui.Control { label := theme.CreateLabel() label.SetText(inst.Name()) if inst.tooltips != nil { inst.tooltips.AddToolTip(label, 0.25, func(point math.Point) gxui.Control { tip := theme.CreateLabel() tip.SetText("Class: " + inst.ClassName) return tip }) } if len(Data.Icons) == 0 { return label } texture, ok := Data.Icons[inst.ClassName] if !ok { texture = Data.Icons[""] } icon := theme.CreateImage() icon.SetMargin(math.Spacing{3, 0, 0, 0}) icon.SetTexture(texture) layout := theme.CreateLinearLayout() layout.SetDirection(gxui.LeftToRight) layout.SetHorizontalAlignment(gxui.AlignLeft) layout.SetVerticalAlignment(gxui.AlignMiddle) layout.AddChild(icon) layout.AddChild(label) return layout }
func CreateDialog(theme gxui.Theme) Dialog { c := new(dialog) c.actions = make(map[int]*dialogAction, 4) c.newButton = theme.CreateButton c.newLabel = theme.CreateLabel c.title = theme.CreateLabel() container := theme.CreateLinearLayout() container.SetDirection(gxui.TopToBottom) container.SetHorizontalAlignment(gxui.AlignLeft) container.SetVerticalAlignment(gxui.AlignTop) container.SetPadding(math.Spacing{L: 10, T: 10, R: 10, B: 10}) c.container = container actionContainer := theme.CreateLinearLayout() actionContainer.SetDirection(gxui.LeftToRight) actionContainer.SetVerticalAlignment(gxui.AlignMiddle) actionContainer.SetHorizontalAlignment(gxui.AlignCenter) c.actionContainer = actionContainer layout := theme.CreateLinearLayout() layout.SetBackgroundBrush(gxui.Brush{Color: gxui.Color{0.2, 0.2, 0.2, 1}}) layout.SetDirection(gxui.TopToBottom) layout.SetHorizontalAlignment(gxui.AlignCenter) layout.AddChild(c.title) layout.AddChild(container) layout.AddChild(actionContainer) c.control = layout return c }
func (root rootAdapter) Create(theme gxui.Theme, index int) gxui.Control { if root.Root == nil { return nil } l := theme.CreateLabel() l.SetText(root.Instances[index].Name()) return l }
func (a FormatAdapter) Create(theme gxui.Theme, index int) gxui.Control { l := theme.CreateLabel() text := Format(index).String() if text == "" { text = "None" } l.SetText(text) return l }
func (p propsAdapter) Create(theme gxui.Theme, index int) gxui.Control { pr := p.props[index] l := theme.CreateLabel() prop := pr.inst.Properties[pr.name] v := prop.String() if len(v) < 128 { l.SetText(pr.name + " (" + prop.Type().String() + ") = " + prop.String()) } else { l.SetText(pr.name + " (" + prop.Type().String() + ") = <long value>") } return l }
// Create returns a Control visualizing the item at the specified index. func (l *classList) Create(theme gxui.Theme, index int) gxui.Control { class := l.list[index] label := theme.CreateLabel() label.SetText(class.Name) return label }