Store role in Boxes
This commit is contained in:
parent
d8ae20d739
commit
2ab920eb26
@ -28,7 +28,8 @@ func NewButton (text string) *Button {
|
|||||||
ContainerBox: tomo.NewContainerBox(),
|
ContainerBox: tomo.NewContainerBox(),
|
||||||
label: NewLabel(text),
|
label: NewLabel(text),
|
||||||
}
|
}
|
||||||
tomo.Apply(box, 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)
|
||||||
|
@ -18,7 +18,8 @@ func NewCheckbox (value bool) *Checkbox {
|
|||||||
box := &Checkbox {
|
box := &Checkbox {
|
||||||
Box: tomo.NewBox(),
|
Box: tomo.NewBox(),
|
||||||
}
|
}
|
||||||
tomo.Apply(box, 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)
|
||||||
|
@ -27,7 +27,8 @@ func newContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
|||||||
// window, tab pane, etc.
|
// window, tab pane, etc.
|
||||||
func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||||
this := newContainer(layout, children...)
|
this := newContainer(layout, children...)
|
||||||
tomo.Apply(this, tomo.R("objects", "Container", "outer"))
|
this.SetRole(tomo.R("objects", "Container", "outer"))
|
||||||
|
tomo.Apply(this)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,14 +36,16 @@ func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container
|
|||||||
// around it. It is meant to be used as a root container for a ScrollContainer.
|
// around it. It is meant to be used as a root container for a ScrollContainer.
|
||||||
func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||||
this := newContainer(layout, children...)
|
this := newContainer(layout, children...)
|
||||||
tomo.Apply(this, tomo.R("objects", "Container", "sunken"))
|
this.SetRole(tomo.R("objects", "Container", "sunken"))
|
||||||
|
tomo.Apply(this)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInnerContainer creates a new container that has no padding around it.
|
// NewInnerContainer creates a new container that has no padding around it.
|
||||||
func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||||
this := newContainer(layout, children...)
|
this := newContainer(layout, children...)
|
||||||
tomo.Apply(this, tomo.R("objects", "Container", "inner"))
|
this.SetRole(tomo.R("objects", "Container", "inner"))
|
||||||
|
tomo.Apply(this)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,8 @@ func NewHeading (level int, text string) *Heading {
|
|||||||
if level < 0 { level = 0 }
|
if level < 0 { level = 0 }
|
||||||
if level > 2 { level = 2 }
|
if level > 2 { level = 2 }
|
||||||
this := &Heading { TextBox: tomo.NewTextBox() }
|
this := &Heading { TextBox: tomo.NewTextBox() }
|
||||||
tomo.Apply(this, 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
|
||||||
}
|
}
|
||||||
|
6
icon.go
6
icon.go
@ -15,7 +15,8 @@ func NewIcon (id tomo.Icon, size tomo.IconSize) *Icon {
|
|||||||
this := &Icon {
|
this := &Icon {
|
||||||
Box: tomo.NewBox(),
|
Box: tomo.NewBox(),
|
||||||
}
|
}
|
||||||
tomo.Apply(this, 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
|
||||||
}
|
}
|
||||||
@ -25,7 +26,8 @@ func NewMimeIcon (mime data.Mime, size tomo.IconSize) *Icon {
|
|||||||
this := &Icon {
|
this := &Icon {
|
||||||
Box: tomo.NewBox(),
|
Box: tomo.NewBox(),
|
||||||
}
|
}
|
||||||
tomo.Apply(this, 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
|
||||||
}
|
}
|
||||||
|
3
label.go
3
label.go
@ -10,7 +10,8 @@ type Label struct {
|
|||||||
// NewLabel creates a new text label.
|
// NewLabel creates a new text label.
|
||||||
func NewLabel (text string) *Label {
|
func NewLabel (text string) *Label {
|
||||||
this := &Label { TextBox: tomo.NewTextBox() }
|
this := &Label { TextBox: tomo.NewTextBox() }
|
||||||
tomo.Apply(this, tomo.R("objects", "Label", ""))
|
this.SetRole(tomo.R("objects", "Label", ""))
|
||||||
|
tomo.Apply(this)
|
||||||
this.SetText(text)
|
this.SetText(text)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@ func NewLabelCheckbox (value bool, text string) *LabelCheckbox {
|
|||||||
checkbox: NewCheckbox(value),
|
checkbox: NewCheckbox(value),
|
||||||
label: NewLabel(text),
|
label: NewLabel(text),
|
||||||
}
|
}
|
||||||
tomo.Apply(box, 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)
|
||||||
|
@ -28,7 +28,8 @@ func NewNumberInput (value float64) *NumberInput {
|
|||||||
increment: NewButton(""),
|
increment: NewButton(""),
|
||||||
decrement: NewButton(""),
|
decrement: NewButton(""),
|
||||||
}
|
}
|
||||||
tomo.Apply(box, 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)
|
||||||
|
@ -45,8 +45,11 @@ func newScrollbar (orient string) *Scrollbar {
|
|||||||
this.OnMouseUp(this.handleMouseUp)
|
this.OnMouseUp(this.handleMouseUp)
|
||||||
this.OnMouseMove(this.handleMouseMove)
|
this.OnMouseMove(this.handleMouseMove)
|
||||||
this.OnScroll(this.handleScroll)
|
this.OnScroll(this.handleScroll)
|
||||||
tomo.Apply(this.handle, tomo.R("objects", "SliderHandle", orient))
|
|
||||||
tomo.Apply(this, tomo.R("objects", "Slider", orient))
|
this.handle.SetRole(tomo.R("objects", "SliderHandle", orient))
|
||||||
|
tomo.Apply(this.handle)
|
||||||
|
this.SetRole(tomo.R("objects", "Slider", orient))
|
||||||
|
tomo.Apply(this)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,8 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer {
|
|||||||
}
|
}
|
||||||
this.CaptureScroll(true)
|
this.CaptureScroll(true)
|
||||||
this.OnScroll(this.handleScroll)
|
this.OnScroll(this.handleScroll)
|
||||||
tomo.Apply(this, 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
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ func NewSeparator () *Separator {
|
|||||||
this := &Separator {
|
this := &Separator {
|
||||||
Box: tomo.NewBox(),
|
Box: tomo.NewBox(),
|
||||||
}
|
}
|
||||||
tomo.Apply(this, tomo.R("objects", "Separator", ""))
|
this.SetRole(tomo.R("objects", "Separator", ""))
|
||||||
|
tomo.Apply(this)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,11 @@ func newSlider (orient string, value float64) *Slider {
|
|||||||
this.OnMouseUp(this.handleMouseUp)
|
this.OnMouseUp(this.handleMouseUp)
|
||||||
this.OnMouseMove(this.handleMouseMove)
|
this.OnMouseMove(this.handleMouseMove)
|
||||||
this.OnScroll(this.handleScroll)
|
this.OnScroll(this.handleScroll)
|
||||||
tomo.Apply(this.handle, tomo.R("objects", "SliderHandle", orient))
|
|
||||||
tomo.Apply(this, tomo.R("objects", "Slider", orient))
|
this.handle.SetRole(tomo.R("objects", "SliderHandle", orient))
|
||||||
|
tomo.Apply(this.handle)
|
||||||
|
this.SetRole(tomo.R("objects", "Slider", orient))
|
||||||
|
tomo.Apply(this)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@ type TextInput struct {
|
|||||||
// NewTextInput creates a new text input containing the specified text.
|
// NewTextInput creates a new text input containing the specified text.
|
||||||
func NewTextInput (text string) *TextInput {
|
func NewTextInput (text string) *TextInput {
|
||||||
this := &TextInput { TextBox: tomo.NewTextBox() }
|
this := &TextInput { TextBox: tomo.NewTextBox() }
|
||||||
tomo.Apply(this, 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)
|
||||||
|
@ -11,7 +11,8 @@ type TextView struct {
|
|||||||
// NewTextView creates a new text view.
|
// NewTextView creates a new text view.
|
||||||
func NewTextView (text string) *TextView {
|
func NewTextView (text string) *TextView {
|
||||||
this := &TextView { TextBox: tomo.NewTextBox() }
|
this := &TextView { TextBox: tomo.NewTextBox() }
|
||||||
tomo.Apply(this, 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