Example #1
0
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
}