11 Commits

Author SHA1 Message Date
2ab920eb26 Store role in Boxes 2024-06-03 21:13:18 -04:00
d8ae20d739 Update Tomo API 2024-06-03 21:10:20 -04:00
06561bb671 Scrollbar, ScrollContainer use ContentObject now 2024-05-27 16:28:48 -04:00
a71d81af48 Checkbox uses CheckboxUnchecked icon when unchecked 2024-05-27 15:59:24 -04:00
bd9dbb762d Update Tomo API 2024-05-27 15:22:18 -04:00
6389556199 Updated all objects to new API 2024-05-26 17:21:58 -04:00
06d99b2790 Update Tomo API 2024-05-26 17:13:40 -04:00
6ab689b5c1 Renamed input.go to textinput.go 2024-05-20 02:23:07 -04:00
6497da69ed LabelCheckbox no longer expands vertically
It should in theory valign to middle this way, but grid layout
suffers from #1
2024-05-18 14:18:02 -04:00
34794f4c77 Make the dialog API more normal
It was very nice but inconsistent with literally everything else,
and never in my life have I seen someone else make a constructor
that way.
2024-05-18 14:16:57 -04:00
25625e9a99 Add dialog boxes 2024-05-18 13:25:06 -04:00
17 changed files with 185 additions and 71 deletions

View File

@@ -1,7 +1,6 @@
package objects
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/objects/layouts"
@@ -29,7 +28,8 @@ func NewButton (text string) *Button {
ContainerBox: tomo.NewContainerBox(),
label: NewLabel(text),
}
theme.Apply(box, theme.R("objects", "Button", ""))
box.SetRole(tomo.R("objects", "Button", ""))
tomo.Apply(box)
box.label.SetAlign(tomo.AlignMiddle, tomo.AlignMiddle)
box.SetLayout(buttonLayout)
box.SetText(text)
@@ -49,7 +49,7 @@ func NewButton (text string) *Button {
func (this *Button) SetText (text string) {
this.label.SetText(text)
if this.labelActive && text == "" {
this.Delete(this.label)
this.Remove(this.label)
this.labelActive = false
}
if !this.labelActive && text != "" {
@@ -61,11 +61,11 @@ func (this *Button) SetText (text string) {
// SetIcon sets an icon for this button. Setting the icon to IconUnknown will
// remove it.
func (this *Button) SetIcon (id theme.Icon) {
if this.icon != nil { this.Delete(this.icon) }
func (this *Button) SetIcon (id tomo.Icon) {
if this.icon != nil { this.Remove(this.icon) }
var icon *Icon; if id != theme.IconUnknown {
icon = NewIcon(id, theme.IconSizeSmall)
var icon *Icon; if id != tomo.IconUnknown {
icon = NewIcon(id, tomo.IconSizeSmall)
}
this.icon = icon

View File

@@ -1,7 +1,6 @@
package objects
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
@@ -19,7 +18,8 @@ func NewCheckbox (value bool) *Checkbox {
box := &Checkbox {
Box: tomo.NewBox(),
}
theme.Apply(box, theme.R("objects", "Checkbox", ""))
box.SetRole(tomo.R("objects", "Checkbox", ""))
tomo.Apply(box)
box.SetValue(false)
box.OnMouseUp(box.handleMouseUp)
@@ -32,11 +32,9 @@ func NewCheckbox (value bool) *Checkbox {
func (this *Checkbox) SetValue (value bool) {
this.value = value
if this.value {
// TODO perhaps have IconStatusOkay/Cancel in actions, and have
// a status icon for checked checkboxes.
this.SetTexture(theme.IconStatusOkay.Texture(theme.IconSizeSmall))
this.SetTextureCenter(tomo.IconCheckboxChecked.Texture(tomo.IconSizeSmall))
} else {
this.SetTexture(nil)
this.SetTextureCenter(tomo.IconCheckboxUnchecked.Texture(tomo.IconSizeSmall))
}
}

View File

@@ -1,7 +1,6 @@
package objects
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
// Container is an object that can contain other objects. It can be used as a
// primitive for building more complex layouts. It has two variants: an outer
@@ -28,7 +27,8 @@ 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...)
theme.Apply(this, theme.R("objects", "Container", "outer"))
this.SetRole(tomo.R("objects", "Container", "outer"))
tomo.Apply(this)
return this
}
@@ -36,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.
func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container {
this := newContainer(layout, children...)
theme.Apply(this, theme.R("objects", "Container", "sunken"))
this.SetRole(tomo.R("objects", "Container", "sunken"))
tomo.Apply(this)
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...)
theme.Apply(this, theme.R("objects", "Container", "inner"))
this.SetRole(tomo.R("objects", "Container", "inner"))
tomo.Apply(this)
return this
}

100
dialog.go Normal file
View File

@@ -0,0 +1,100 @@
package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/objects/layouts"
// DialogKind defines the semantic role of a dialog window.
type DialogKind int; const (
DialogInformation DialogKind = iota
DialogQuestion
DialogWarning
DialogError
)
// Dialog is a modal dialog window.
type Dialog struct {
tomo.Window
controlRow tomo.ContainerBox
}
type clickable interface {
OnClick (func ()) event.Cookie
}
// NewDialog creates a new dialog window given a dialog kind.
func NewDialog (kind DialogKind, parent tomo.Window, title, message string, options ...tomo.Object) (*Dialog, error) {
if title == "" {
switch kind {
case DialogInformation: title = "Information"
case DialogQuestion: title = "Question"
case DialogWarning: title = "Warning"
case DialogError: title = "Error"
}
}
dialog := &Dialog { }
if parent == nil {
window, err := tomo.NewWindow(image.Rectangle { })
if err != nil { return nil, err }
dialog.Window = window
} else {
window, err := parent.NewModal(image.Rectangle { })
if err != nil { return nil, err }
dialog.Window = window
}
var iconId tomo.Icon
switch kind {
case DialogInformation: iconId = tomo.IconDialogInformation
case DialogQuestion: iconId = tomo.IconDialogQuestion
case DialogWarning: iconId = tomo.IconDialogWarning
case DialogError: iconId = tomo.IconDialogError
}
dialog.SetTitle(title)
icon := NewIcon(iconId, tomo.IconSizeLarge)
messageText := NewLabel(message)
messageText.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
for _, option := range options {
if option, ok := option.(clickable); ok {
option.OnClick(dialog.Close)
}
}
dialog.controlRow = NewInnerContainer(layouts.ContractHorizontal, options...)
dialog.controlRow.SetAlign(tomo.AlignEnd, tomo.AlignEnd)
dialog.SetRoot(NewOuterContainer (
layouts.NewGrid([]bool { true }, []bool { true, false }),
NewInnerContainer(layouts.ContractHorizontal, icon, messageText),
dialog.controlRow))
return dialog, nil
}
// NewDialogOk creates a new dialog window with an OK option.
func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
okButton := NewButton("OK")
okButton.SetIcon(tomo.IconDialogOkay)
okButton.OnClick(func () {
if onOk != nil { onOk() }
})
okButton.SetFocused(true)
return NewDialog(kind, parent, title, message, okButton)
}
// NewDialogOkCancel creates a new dialog window with OK and Cancel options.
func NewDialogOkCancel (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
cancelButton := NewButton("Cancel")
cancelButton.SetIcon(tomo.IconDialogCancel)
okButton := NewButton("OK")
okButton.SetIcon(tomo.IconDialogOkay)
okButton.OnClick(func () {
if onOk != nil { onOk() }
})
okButton.SetFocused(true)
return NewDialog(kind, parent, title, message, cancelButton, okButton)
}

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.31.0
require git.tebibyte.media/tomo/tomo v0.35.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.31.0 h1:LHPpj3AWycochnC8F441aaRNS6Tq6w6WnBrp/LGjyhM=
git.tebibyte.media/tomo/tomo v0.31.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
git.tebibyte.media/tomo/tomo v0.35.0 h1:1XvcUcWg1rBZXov3KfuX6VfiuBQ2mcJHIslHMLn07no=
git.tebibyte.media/tomo/tomo v0.35.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

@@ -2,7 +2,6 @@ package objects
import "fmt"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
// Heading is a label that denotes the start of some section of content. It can
// have a level from 0 to 2, with 0 being the most prominent and 2 being the
@@ -16,7 +15,8 @@ func NewHeading (level int, text string) *Heading {
if level < 0 { level = 0 }
if level > 2 { level = 2 }
this := &Heading { TextBox: tomo.NewTextBox() }
theme.Apply(this, theme.R("objects", "Heading", fmt.Sprint(level)))
this.SetRole(tomo.R("objects", "Heading", fmt.Sprint(level)))
tomo.Apply(this)
this.SetText(text)
return this
}

15
icon.go
View File

@@ -3,7 +3,6 @@ package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/data"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/canvas"
// Icon displays a single icon.
@@ -12,27 +11,29 @@ type Icon struct {
}
// NewIcon creates a new icon from an icon ID.
func NewIcon (id theme.Icon, size theme.IconSize) *Icon {
func NewIcon (id tomo.Icon, size tomo.IconSize) *Icon {
this := &Icon {
Box: tomo.NewBox(),
}
theme.Apply(this, theme.R("objects", "Icon", size.String()))
this.SetRole(tomo.R("objects", "Icon", size.String()))
tomo.Apply(this)
this.SetTexture(id.Texture(size))
return this
}
// NewMimeIcon creates a new icon from a MIME type.
func NewMimeIcon (mime data.Mime, size theme.IconSize) *Icon {
func NewMimeIcon (mime data.Mime, size tomo.IconSize) *Icon {
this := &Icon {
Box: tomo.NewBox(),
}
theme.Apply(this, theme.R("objects", "Icon", size.String()))
this.SetTexture(theme.MimeIcon(mime, size))
this.SetRole(tomo.R("objects", "Icon", size.String()))
tomo.Apply(this)
this.SetTexture(tomo.MimeIcon(mime, size))
return this
}
func (this *Icon) SetTexture (texture canvas.Texture) {
this.Box.SetTexture(texture)
this.Box.SetTextureCenter(texture)
if texture == nil {
this.SetMinimumSize(image.Pt(0, 0))
} else {

View File

@@ -1,7 +1,6 @@
package objects
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
// Label is a simple text label.
type Label struct {
@@ -11,7 +10,8 @@ type Label struct {
// NewLabel creates a new text label.
func NewLabel (text string) *Label {
this := &Label { TextBox: tomo.NewTextBox() }
theme.Apply(this, theme.R("objects", "Label", ""))
this.SetRole(tomo.R("objects", "Label", ""))
tomo.Apply(this)
this.SetText(text)
return this
}

View File

@@ -1,7 +1,6 @@
package objects
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/objects/layouts"
@@ -21,11 +20,12 @@ func NewLabelCheckbox (value bool, text string) *LabelCheckbox {
checkbox: NewCheckbox(value),
label: NewLabel(text),
}
theme.Apply(box, theme.R("objects", "LabelCheckbox", ""))
box.SetRole(tomo.R("objects", "LabelCheckbox", ""))
tomo.Apply(box)
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
box.Add(box.checkbox)
box.Add(box.label)
box.SetLayout(layouts.NewGrid([]bool { false, true }, []bool { true }))
box.SetLayout(layouts.NewGrid([]bool { false, true }, []bool { false }))
box.OnMouseUp(box.handleMouseUp)
box.label.OnMouseUp(box.handleMouseUp)

View File

@@ -3,7 +3,6 @@ package objects
import "math"
import "strconv"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/objects/layouts"
@@ -29,13 +28,14 @@ func NewNumberInput (value float64) *NumberInput {
increment: NewButton(""),
decrement: NewButton(""),
}
theme.Apply(box, theme.R("objects", "NumberInput", ""))
box.SetRole(tomo.R("objects", "NumberInput", ""))
tomo.Apply(box)
box.Add(box.input)
box.Add(box.decrement)
box.Add(box.increment)
box.SetLayout(layouts.NewGrid([]bool { true, false, false }, []bool { true }))
box.increment.SetIcon(theme.IconActionIncrement)
box.decrement.SetIcon(theme.IconActionDecrement)
box.increment.SetIcon(tomo.IconValueIncrement)
box.decrement.SetIcon(tomo.IconValueDecrement)
box.SetValue(value)

View File

@@ -2,7 +2,6 @@ package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
@@ -46,8 +45,11 @@ func newScrollbar (orient string) *Scrollbar {
this.OnMouseUp(this.handleMouseUp)
this.OnMouseMove(this.handleMouseMove)
this.OnScroll(this.handleScroll)
theme.Apply(this.handle, theme.R("objects", "SliderHandle", orient))
theme.Apply(this, theme.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
}
@@ -61,9 +63,9 @@ func NewHorizontalScrollbar () *Scrollbar {
return newScrollbar("horizontal")
}
// Link assigns this scrollbar to a ContentBox. Closing the returned cookie will
// unlink it.
func (this *Scrollbar) Link (box tomo.ContentBox) event.Cookie {
// Link assigns this scrollbar to a ContentObject. Closing the returned cookie
// will unlink it.
func (this *Scrollbar) Link (box tomo.ContentObject) event.Cookie {
this.layout.linked = box
this.linkCookie = this.newLinkCookie (
box.OnContentBoundsChange(this.handleLinkedContentBoundsChange))
@@ -231,7 +233,7 @@ func (this *Scrollbar) fallbackDragOffset () image.Point {
func (this *Scrollbar) pageSize () int {
if this.layout.linked == nil { return 0 }
viewport := this.layout.linked.InnerBounds()
viewport := this.layout.linked.GetBox().InnerBounds()
if this.layout.vertical {
return viewport.Dy()
} else {
@@ -241,7 +243,7 @@ func (this *Scrollbar) pageSize () int {
func (this *Scrollbar) stepSize () int {
// FIXME: this should not be hardcoded, need to get base font metrics
// from theme somehow. should be (emspace, lineheight)
// from tomo.somehow. should be (emspace, lineheight)
return 16
}
@@ -280,7 +282,7 @@ func (this *scrollbarCookie) Close () {
type scrollbarLayout struct {
vertical bool
value float64
linked tomo.ContentBox
linked tomo.ContentObject
}
func (scrollbarLayout) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
@@ -307,9 +309,10 @@ func (this scrollbarLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
handleLength := gutterLength * this.viewportContentRatio()
if handleLength < handleMin { handleLength = handleMin }
if handleLength >= gutterLength {
// just hide the handle if it isn't needed.
// TODO: we need a way to hide and show boxes, this is janky as
// fuck
// just hide the handle if it isn't needed. we are the layout
// and we shouldn't be adding and removing boxes, so this is
// really the only good way to hide things.
// TODO perhaps have a "Hidden" rectangle in the Tomo API?
boxes[0].SetBounds(image.Rect(-16, -16, 0, 0))
return
}
@@ -341,9 +344,9 @@ func (this scrollbarLayout) viewportContentRatio () float64 {
func (this scrollbarLayout) viewportLength () float64 {
if this.vertical {
return float64(this.linked.InnerBounds().Dy())
return float64(this.linked.GetBox().InnerBounds().Dy())
} else {
return float64(this.linked.InnerBounds().Dx())
return float64(this.linked.GetBox().InnerBounds().Dx())
}
}

View File

@@ -3,7 +3,6 @@ package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/tomo/theme"
// ScrollSide determines which Scrollbars are active in a ScrollContainer.
type ScrollSide int; const (
@@ -61,7 +60,8 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer {
}
this.CaptureScroll(true)
this.OnScroll(this.handleScroll)
theme.Apply(this, theme.R("objects", "ScrollContainer", sides.String()))
this.SetRole(tomo.R("objects", "ScrollContainer", sides.String()))
tomo.Apply(this)
this.SetLayout(this.layout)
return this
}
@@ -69,10 +69,10 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer {
// SetRoot sets the root child of the ScrollContainer. There can only be one at
// a time, and setting it will remove and unlink the current child if there is
// one.
func (this *ScrollContainer) SetRoot (root tomo.ContentBox) {
func (this *ScrollContainer) SetRoot (root tomo.ContentObject) {
if this.layout.root != nil {
// delete root and close cookies
this.Delete(this.layout.root)
// remove root and close cookies
this.Remove(this.layout.root)
if this.horizontalCookie != nil {
this.horizontalCookie.Close()
this.horizontalCookie = nil
@@ -135,14 +135,14 @@ func (this *ScrollContainer) handleScroll (x, y float64) {
}
type scrollContainerLayout struct {
root tomo.ContentBox
root tomo.ContentObject
horizontal *Scrollbar
vertical *Scrollbar
}
func (this *scrollContainerLayout) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
var minimum image.Point; if this.root != nil {
minimum = this.root.MinimumSize()
minimum = this.root.GetBox().MinimumSize()
}
if this.horizontal != nil {
minimum.Y += this.horizontal.MinimumSize().Y
@@ -166,7 +166,7 @@ func (this *scrollContainerLayout) Arrange (hints tomo.LayoutHints, boxes []tomo
rootBounds.Max.X -= this.vertical.MinimumSize().X
}
if this.root != nil {
this.root.SetBounds(rootBounds)
this.root.GetBox().SetBounds(rootBounds)
}
if this.horizontal != nil {
this.horizontal.SetBounds(image.Rect (

View File

@@ -1,7 +1,6 @@
package objects
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
// Separator is a line for visually separating elements.
type Separator struct {
@@ -13,6 +12,7 @@ func NewSeparator () *Separator {
this := &Separator {
Box: tomo.NewBox(),
}
theme.Apply(this, theme.R("objects", "Separator", ""))
this.SetRole(tomo.R("objects", "Separator", ""))
tomo.Apply(this)
return this
}

View File

@@ -2,7 +2,6 @@ package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
@@ -52,8 +51,11 @@ func newSlider (orient string, value float64) *Slider {
this.OnMouseUp(this.handleMouseUp)
this.OnMouseMove(this.handleMouseMove)
this.OnScroll(this.handleScroll)
theme.Apply(this.handle, theme.R("objects", "SliderHandle", orient))
theme.Apply(this, theme.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
}

View File

@@ -3,7 +3,6 @@ package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/text"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
@@ -20,7 +19,8 @@ type TextInput struct {
// NewTextInput creates a new text input containing the specified text.
func NewTextInput (text string) *TextInput {
this := &TextInput { TextBox: tomo.NewTextBox() }
theme.Apply(this, theme.R("objects", "TextInput", ""))
this.SetRole(tomo.R("objects", "TextInput", ""))
tomo.Apply(this)
this.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
this.SetText(text)
this.SetFocusable(true)
@@ -60,8 +60,8 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
sel := modifiers.Shift
changed := false
// TODO all this (except editing stuff) really should be moved into the
// backend
// TODO all dot control (movement, selection, etc) should be done in the
// backend. (editing should be done here, though)
switch {
case key == input.KeyEnter:
@@ -105,6 +105,14 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
}
}
// Type types a character at the current dot position.
func (this *TextInput) Type (char rune) {
dot := this.Dot()
this.text, dot = text.Type(this.text, dot, rune(char))
this.Select(dot)
this.SetText(string(this.text))
}
func (this *TextInput) handleScroll (x, y float64) {
this.ScrollTo(this.ContentBounds().Min.Add(image.Pt(int(x), int(y))))
}

View File

@@ -2,7 +2,6 @@ package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
// TextView is an area for displaying a large amount of multi-line text.
type TextView struct {
@@ -12,7 +11,8 @@ type TextView struct {
// NewTextView creates a new text view.
func NewTextView (text string) *TextView {
this := &TextView { TextBox: tomo.NewTextBox() }
theme.Apply(this, theme.R("objects", "TextView", ""))
this.SetRole(tomo.R("objects", "TextView", ""))
tomo.Apply(this)
this.SetFocusable(true)
this.SetSelectable(true)
this.SetText(text)