Update code for objects
This commit is contained in:
parent
5d2a366a62
commit
460733c8f3
@ -29,7 +29,6 @@ func NewButton (text string) *Button {
|
|||||||
label: NewLabel(text),
|
label: NewLabel(text),
|
||||||
}
|
}
|
||||||
box.SetRole(tomo.R("objects", "Button", ""))
|
box.SetRole(tomo.R("objects", "Button", ""))
|
||||||
tomo.Apply(box)
|
|
||||||
box.label.SetAlign(tomo.AlignMiddle, tomo.AlignMiddle)
|
box.label.SetAlign(tomo.AlignMiddle, tomo.AlignMiddle)
|
||||||
box.SetLayout(buttonLayout)
|
box.SetLayout(buttonLayout)
|
||||||
box.SetText(text)
|
box.SetText(text)
|
||||||
|
@ -19,7 +19,6 @@ func NewCheckbox (value bool) *Checkbox {
|
|||||||
Box: tomo.NewBox(),
|
Box: tomo.NewBox(),
|
||||||
}
|
}
|
||||||
box.SetRole(tomo.R("objects", "Checkbox", ""))
|
box.SetRole(tomo.R("objects", "Checkbox", ""))
|
||||||
tomo.Apply(box)
|
|
||||||
box.SetValue(false)
|
box.SetValue(false)
|
||||||
|
|
||||||
box.OnMouseUp(box.handleMouseUp)
|
box.OnMouseUp(box.handleMouseUp)
|
||||||
|
@ -16,7 +16,6 @@ func NewHeading (level int, text string) *Heading {
|
|||||||
if level > 2 { level = 2 }
|
if level > 2 { level = 2 }
|
||||||
this := &Heading { TextBox: tomo.NewTextBox() }
|
this := &Heading { TextBox: tomo.NewTextBox() }
|
||||||
this.SetRole(tomo.R("objects", "Heading", fmt.Sprint(level)))
|
this.SetRole(tomo.R("objects", "Heading", fmt.Sprint(level)))
|
||||||
tomo.Apply(this)
|
|
||||||
this.SetText(text)
|
this.SetText(text)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
2
icon.go
2
icon.go
@ -16,7 +16,6 @@ func NewIcon (id tomo.Icon, size tomo.IconSize) *Icon {
|
|||||||
Box: tomo.NewBox(),
|
Box: tomo.NewBox(),
|
||||||
}
|
}
|
||||||
this.SetRole(tomo.R("objects", "Icon", size.String()))
|
this.SetRole(tomo.R("objects", "Icon", size.String()))
|
||||||
tomo.Apply(this)
|
|
||||||
this.SetTexture(id.Texture(size))
|
this.SetTexture(id.Texture(size))
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@ -27,7 +26,6 @@ func NewMimeIcon (mime data.Mime, size tomo.IconSize) *Icon {
|
|||||||
Box: tomo.NewBox(),
|
Box: tomo.NewBox(),
|
||||||
}
|
}
|
||||||
this.SetRole(tomo.R("objects", "Icon", size.String()))
|
this.SetRole(tomo.R("objects", "Icon", size.String()))
|
||||||
tomo.Apply(this)
|
|
||||||
this.SetTexture(tomo.MimeIcon(mime, size))
|
this.SetTexture(tomo.MimeIcon(mime, size))
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
1
label.go
1
label.go
@ -11,7 +11,6 @@ type Label struct {
|
|||||||
func NewLabel (text string) *Label {
|
func NewLabel (text string) *Label {
|
||||||
this := &Label { TextBox: tomo.NewTextBox() }
|
this := &Label { TextBox: tomo.NewTextBox() }
|
||||||
this.SetRole(tomo.R("objects", "Label", ""))
|
this.SetRole(tomo.R("objects", "Label", ""))
|
||||||
tomo.Apply(this)
|
|
||||||
this.SetText(text)
|
this.SetText(text)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ func NewLabelCheckbox (value bool, text string) *LabelCheckbox {
|
|||||||
label: NewLabel(text),
|
label: NewLabel(text),
|
||||||
}
|
}
|
||||||
box.SetRole(tomo.R("objects", "LabelCheckbox", ""))
|
box.SetRole(tomo.R("objects", "LabelCheckbox", ""))
|
||||||
tomo.Apply(box)
|
|
||||||
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
||||||
box.Add(box.checkbox)
|
box.Add(box.checkbox)
|
||||||
box.Add(box.label)
|
box.Add(box.label)
|
||||||
|
2
menu.go
2
menu.go
@ -41,7 +41,6 @@ func NewMenu (anchor tomo.Object, items ...tomo.Object) (*Menu, error) {
|
|||||||
if !menu.torn {
|
if !menu.torn {
|
||||||
menu.tearLine = tomo.NewBox()
|
menu.tearLine = tomo.NewBox()
|
||||||
menu.tearLine.SetRole(tomo.R("objects", "TearLine", ""))
|
menu.tearLine.SetRole(tomo.R("objects", "TearLine", ""))
|
||||||
tomo.Apply(menu.tearLine)
|
|
||||||
menu.tearLine.SetFocusable(true)
|
menu.tearLine.SetFocusable(true)
|
||||||
menu.tearLine.OnKeyUp(func (key input.Key, numberPad bool) {
|
menu.tearLine.OnKeyUp(func (key input.Key, numberPad bool) {
|
||||||
if key != input.KeyEnter && key != input.Key(' ') { return }
|
if key != input.KeyEnter && key != input.Key(' ') { return }
|
||||||
@ -67,7 +66,6 @@ func NewMenu (anchor tomo.Object, items ...tomo.Object) (*Menu, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
menu.rootContainer.SetRole(tomo.R("objects", "Container", "menu"))
|
menu.rootContainer.SetRole(tomo.R("objects", "Container", "menu"))
|
||||||
tomo.Apply(menu.rootContainer)
|
|
||||||
|
|
||||||
menu.Window.SetRoot(menu.rootContainer)
|
menu.Window.SetRoot(menu.rootContainer)
|
||||||
return menu, nil
|
return menu, nil
|
||||||
|
@ -26,7 +26,6 @@ func NewMenuItem (text string) *MenuItem {
|
|||||||
icon: NewIcon("", tomo.IconSizeSmall),
|
icon: NewIcon("", tomo.IconSizeSmall),
|
||||||
}
|
}
|
||||||
box.SetRole(tomo.R("objects", "MenuItem", ""))
|
box.SetRole(tomo.R("objects", "MenuItem", ""))
|
||||||
tomo.Apply(box)
|
|
||||||
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
||||||
box.SetLayout(layouts.NewGrid([]bool { false, true }, []bool { true }))
|
box.SetLayout(layouts.NewGrid([]bool { false, true }, []bool { true }))
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ func NewNumberInput (value float64) *NumberInput {
|
|||||||
decrement: NewButton(""),
|
decrement: NewButton(""),
|
||||||
}
|
}
|
||||||
box.SetRole(tomo.R("objects", "NumberInput", ""))
|
box.SetRole(tomo.R("objects", "NumberInput", ""))
|
||||||
tomo.Apply(box)
|
|
||||||
box.Add(box.input)
|
box.Add(box.input)
|
||||||
box.Add(box.decrement)
|
box.Add(box.decrement)
|
||||||
box.Add(box.increment)
|
box.Add(box.increment)
|
||||||
|
@ -47,9 +47,7 @@ func newScrollbar (orient string) *Scrollbar {
|
|||||||
this.OnScroll(this.handleScroll)
|
this.OnScroll(this.handleScroll)
|
||||||
|
|
||||||
this.handle.SetRole(tomo.R("objects", "SliderHandle", orient))
|
this.handle.SetRole(tomo.R("objects", "SliderHandle", orient))
|
||||||
tomo.Apply(this.handle)
|
|
||||||
this.SetRole(tomo.R("objects", "Slider", orient))
|
this.SetRole(tomo.R("objects", "Slider", orient))
|
||||||
tomo.Apply(this)
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer {
|
|||||||
this.CaptureScroll(true)
|
this.CaptureScroll(true)
|
||||||
this.OnScroll(this.handleScroll)
|
this.OnScroll(this.handleScroll)
|
||||||
this.SetRole(tomo.R("objects", "ScrollContainer", sides.String()))
|
this.SetRole(tomo.R("objects", "ScrollContainer", sides.String()))
|
||||||
tomo.Apply(this)
|
|
||||||
this.SetLayout(this.layout)
|
this.SetLayout(this.layout)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,5 @@ func NewSeparator () *Separator {
|
|||||||
Box: tomo.NewBox(),
|
Box: tomo.NewBox(),
|
||||||
}
|
}
|
||||||
this.SetRole(tomo.R("objects", "Separator", ""))
|
this.SetRole(tomo.R("objects", "Separator", ""))
|
||||||
tomo.Apply(this)
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,7 @@ func newSlider (orient string, value float64) *Slider {
|
|||||||
this.OnScroll(this.handleScroll)
|
this.OnScroll(this.handleScroll)
|
||||||
|
|
||||||
this.handle.SetRole(tomo.R("objects", "SliderHandle", orient))
|
this.handle.SetRole(tomo.R("objects", "SliderHandle", orient))
|
||||||
tomo.Apply(this.handle)
|
|
||||||
this.SetRole(tomo.R("objects", "Slider", orient))
|
this.SetRole(tomo.R("objects", "Slider", orient))
|
||||||
tomo.Apply(this)
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ type TextInput struct {
|
|||||||
func NewTextInput (text string) *TextInput {
|
func NewTextInput (text string) *TextInput {
|
||||||
this := &TextInput { TextBox: tomo.NewTextBox() }
|
this := &TextInput { TextBox: tomo.NewTextBox() }
|
||||||
this.SetRole(tomo.R("objects", "TextInput", ""))
|
this.SetRole(tomo.R("objects", "TextInput", ""))
|
||||||
tomo.Apply(this)
|
|
||||||
this.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
this.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
||||||
this.SetText(text)
|
this.SetText(text)
|
||||||
this.SetFocusable(true)
|
this.SetFocusable(true)
|
||||||
|
@ -12,7 +12,6 @@ type TextView struct {
|
|||||||
func NewTextView (text string) *TextView {
|
func NewTextView (text string) *TextView {
|
||||||
this := &TextView { TextBox: tomo.NewTextBox() }
|
this := &TextView { TextBox: tomo.NewTextBox() }
|
||||||
this.SetRole(tomo.R("objects", "TextView", ""))
|
this.SetRole(tomo.R("objects", "TextView", ""))
|
||||||
tomo.Apply(this)
|
|
||||||
this.SetFocusable(true)
|
this.SetFocusable(true)
|
||||||
this.SetSelectable(true)
|
this.SetSelectable(true)
|
||||||
this.SetText(text)
|
this.SetText(text)
|
||||||
|
Loading…
Reference in New Issue
Block a user