Compare commits

..

No commits in common. "2ab920eb2624962bebec4ba5daf3a38b4edd5330" and "06561bb671ac089933eff4b3ecd82abe1f3287a6" have entirely different histories.

16 changed files with 22 additions and 43 deletions

View File

@ -28,8 +28,7 @@ func NewButton (text string) *Button {
ContainerBox: tomo.NewContainerBox(),
label: NewLabel(text),
}
box.SetRole(tomo.R("objects", "Button", ""))
tomo.Apply(box)
tomo.Apply(box, tomo.R("objects", "Button", ""))
box.label.SetAlign(tomo.AlignMiddle, tomo.AlignMiddle)
box.SetLayout(buttonLayout)
box.SetText(text)

View File

@ -18,8 +18,7 @@ func NewCheckbox (value bool) *Checkbox {
box := &Checkbox {
Box: tomo.NewBox(),
}
box.SetRole(tomo.R("objects", "Checkbox", ""))
tomo.Apply(box)
tomo.Apply(box, tomo.R("objects", "Checkbox", ""))
box.SetValue(false)
box.OnMouseUp(box.handleMouseUp)

View File

@ -27,8 +27,7 @@ func newContainer (layout tomo.Layout, children ...tomo.Object) *Container {
// window, tab pane, etc.
func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container {
this := newContainer(layout, children...)
this.SetRole(tomo.R("objects", "Container", "outer"))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "Container", "outer"))
return this
}
@ -36,16 +35,14 @@ func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container
// around it. It is meant to be used as a root container for a ScrollContainer.
func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container {
this := newContainer(layout, children...)
this.SetRole(tomo.R("objects", "Container", "sunken"))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "Container", "sunken"))
return this
}
// NewInnerContainer creates a new container that has no padding around it.
func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container {
this := newContainer(layout, children...)
this.SetRole(tomo.R("objects", "Container", "inner"))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "Container", "inner"))
return this
}

2
go.mod
View File

@ -2,6 +2,6 @@ module git.tebibyte.media/tomo/objects
go 1.20
require git.tebibyte.media/tomo/tomo v0.35.0
require git.tebibyte.media/tomo/tomo v0.34.0
require golang.org/x/image v0.11.0 // indirect

4
go.sum
View File

@ -1,5 +1,5 @@
git.tebibyte.media/tomo/tomo v0.35.0 h1:1XvcUcWg1rBZXov3KfuX6VfiuBQ2mcJHIslHMLn07no=
git.tebibyte.media/tomo/tomo v0.35.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
git.tebibyte.media/tomo/tomo v0.34.0 h1:r5yJPks9rtzdDI2RyAUdqa1qb6BebG0QFe2cTmcFi+0=
git.tebibyte.media/tomo/tomo v0.34.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=

View File

@ -15,8 +15,7 @@ func NewHeading (level int, text string) *Heading {
if level < 0 { level = 0 }
if level > 2 { level = 2 }
this := &Heading { TextBox: tomo.NewTextBox() }
this.SetRole(tomo.R("objects", "Heading", fmt.Sprint(level)))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "Heading", fmt.Sprint(level)))
this.SetText(text)
return this
}

View File

@ -15,8 +15,7 @@ func NewIcon (id tomo.Icon, size tomo.IconSize) *Icon {
this := &Icon {
Box: tomo.NewBox(),
}
this.SetRole(tomo.R("objects", "Icon", size.String()))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "Icon", size.String()))
this.SetTexture(id.Texture(size))
return this
}
@ -26,8 +25,7 @@ func NewMimeIcon (mime data.Mime, size tomo.IconSize) *Icon {
this := &Icon {
Box: tomo.NewBox(),
}
this.SetRole(tomo.R("objects", "Icon", size.String()))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "Icon", size.String()))
this.SetTexture(tomo.MimeIcon(mime, size))
return this
}

View File

@ -10,8 +10,7 @@ type Label struct {
// NewLabel creates a new text label.
func NewLabel (text string) *Label {
this := &Label { TextBox: tomo.NewTextBox() }
this.SetRole(tomo.R("objects", "Label", ""))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "Label", ""))
this.SetText(text)
return this
}

View File

@ -20,8 +20,7 @@ func NewLabelCheckbox (value bool, text string) *LabelCheckbox {
checkbox: NewCheckbox(value),
label: NewLabel(text),
}
box.SetRole(tomo.R("objects", "LabelCheckbox", ""))
tomo.Apply(box)
tomo.Apply(box, tomo.R("objects", "LabelCheckbox", ""))
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
box.Add(box.checkbox)
box.Add(box.label)

View File

@ -28,8 +28,7 @@ func NewNumberInput (value float64) *NumberInput {
increment: NewButton(""),
decrement: NewButton(""),
}
box.SetRole(tomo.R("objects", "NumberInput", ""))
tomo.Apply(box)
tomo.Apply(box, tomo.R("objects", "NumberInput", ""))
box.Add(box.input)
box.Add(box.decrement)
box.Add(box.increment)

View File

@ -45,11 +45,8 @@ func newScrollbar (orient string) *Scrollbar {
this.OnMouseUp(this.handleMouseUp)
this.OnMouseMove(this.handleMouseMove)
this.OnScroll(this.handleScroll)
this.handle.SetRole(tomo.R("objects", "SliderHandle", orient))
tomo.Apply(this.handle)
this.SetRole(tomo.R("objects", "Slider", orient))
tomo.Apply(this)
tomo.Apply(this.handle, tomo.R("objects", "SliderHandle", orient))
tomo.Apply(this, tomo.R("objects", "Slider", orient))
return this
}

View File

@ -60,8 +60,7 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer {
}
this.CaptureScroll(true)
this.OnScroll(this.handleScroll)
this.SetRole(tomo.R("objects", "ScrollContainer", sides.String()))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "ScrollContainer", sides.String()))
this.SetLayout(this.layout)
return this
}

View File

@ -12,7 +12,6 @@ func NewSeparator () *Separator {
this := &Separator {
Box: tomo.NewBox(),
}
this.SetRole(tomo.R("objects", "Separator", ""))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "Separator", ""))
return this
}

View File

@ -51,11 +51,8 @@ func newSlider (orient string, value float64) *Slider {
this.OnMouseUp(this.handleMouseUp)
this.OnMouseMove(this.handleMouseMove)
this.OnScroll(this.handleScroll)
this.handle.SetRole(tomo.R("objects", "SliderHandle", orient))
tomo.Apply(this.handle)
this.SetRole(tomo.R("objects", "Slider", orient))
tomo.Apply(this)
tomo.Apply(this.handle, tomo.R("objects", "SliderHandle", orient))
tomo.Apply(this, tomo.R("objects", "Slider", orient))
return this
}

View File

@ -19,8 +19,7 @@ type TextInput struct {
// NewTextInput creates a new text input containing the specified text.
func NewTextInput (text string) *TextInput {
this := &TextInput { TextBox: tomo.NewTextBox() }
this.SetRole(tomo.R("objects", "TextInput", ""))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "TextInput", ""))
this.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
this.SetText(text)
this.SetFocusable(true)

View File

@ -11,8 +11,7 @@ type TextView struct {
// NewTextView creates a new text view.
func NewTextView (text string) *TextView {
this := &TextView { TextBox: tomo.NewTextBox() }
this.SetRole(tomo.R("objects", "TextView", ""))
tomo.Apply(this)
tomo.Apply(this, tomo.R("objects", "TextView", ""))
this.SetFocusable(true)
this.SetSelectable(true)
this.SetText(text)