Compare commits

..

No commits in common. "6089dd3ff1f31acc8b3d5bb524e70b3643afd944" and "2b354979aab08336c426e3e7454fab26b5b3cd13" have entirely different histories.

4 changed files with 14 additions and 68 deletions

View File

@ -33,7 +33,7 @@ func (this *Label) SetFocused (focused bool) {
this.box.SetFocused(focused) this.box.SetFocused(focused)
} }
// SetText sets the text content of the label. // SetText sets the text content of the heading.
func (this *Label) SetText (text string) { func (this *Label) SetText (text string) {
this.box.SetText(text) this.box.SetText(text)
} }

View File

@ -75,13 +75,13 @@ func (this *NumberInput) Dot () text.Dot {
// Value returns the value of the input. // Value returns the value of the input.
func (this *NumberInput) Value () float64 { func (this *NumberInput) Value () float64 {
value, _ := strconv.ParseFloat(this.input.Value(), 64) value, _ := strconv.ParseFloat(this.input.Text(), 64)
return value return value
} }
// SetValue sets the value of the input. // SetValue sets the value of the input.
func (this *NumberInput) SetValue (value float64) { func (this *NumberInput) SetValue (value float64) {
this.input.SetValue(strconv.FormatFloat(value, 'g', -1, 64)) this.input.SetText(strconv.FormatFloat(value, 'g', -1, 64))
} }
// OnValueChange specifies a function to be called when the user edits the input // OnValueChange specifies a function to be called when the user edits the input

View File

@ -55,7 +55,7 @@ func (this *TextInput) Dot () text.Dot {
return this.box.Dot() return this.box.Dot()
} }
// SetAlign sets the X and Y alignment of the text input. // SetAlign sets the X and Y alignment of the label.
func (this *TextInput) SetAlign (x, y tomo.Align) { func (this *TextInput) SetAlign (x, y tomo.Align) {
this.box.SetAttr(tomo.AAlign(x, y)) this.box.SetAttr(tomo.AAlign(x, y))
} }

View File

@ -2,77 +2,23 @@ package objects
import "image" import "image"
import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/text"
import "git.tebibyte.media/tomo/tomo/event"
var _ tomo.Object = new(TabbedContainer)
// TextView is an area for displaying a large amount of multi-line text. // TextView is an area for displaying a large amount of multi-line text.
type TextView struct { type TextView struct {
box tomo.TextBox tomo.TextBox
} }
// NewTextView creates a new text view. // NewTextView creates a new text view.
func NewTextView (text string) *TextView { func NewTextView (text string) *TextView {
textView := &TextView { box: tomo.NewTextBox() } this := &TextView { TextBox: tomo.NewTextBox() }
textView.box.SetRole(tomo.R("objects", "TextView")) this.SetRole(tomo.R("objects", "TextView"))
textView.box.SetFocusable(true) this.SetFocusable(true)
textView.box.SetSelectable(true) this.SetSelectable(true)
textView.SetText(text) this.SetText(text)
textView.box.SetAttr(tomo.AOverflow(false, true)) this.SetAttr(tomo.AOverflow(false, true))
textView.box.SetAttr(tomo.AWrap(true)) this.SetAttr(tomo.AWrap(true))
textView.box.OnScroll(textView.handleScroll) this.OnScroll(this.handleScroll)
return textView return this
}
// GetBox returns the underlying box.
func (this *TextView) GetBox () tomo.Box {
return this.box
}
// SetFocused sets whether or not this text view has keyboard focus. If set to
// true, this method will steal focus away from whichever object currently has
// focus.
func (this *TextView) SetFocused (focused bool) {
this.box.SetFocused(focused)
}
// Select sets the text cursor or selection.
func (this *TextView) Select (dot text.Dot) {
this.box.Select(dot)
}
// Dot returns the text cursor or selection.
func (this *TextView) Dot () text.Dot {
return this.box.Dot()
}
// SetAlign sets the X and Y alignment of the text view.
func (this *TextView) SetAlign (x, y tomo.Align) {
this.box.SetAttr(tomo.AAlign(x, y))
}
// ContentBounds returns the bounds of the inner content of the text view
// relative to the text view's InnerBounds.
func (this *TextView) ContentBounds () image.Rectangle {
return this.box.ContentBounds()
}
// ScrollTo shifts the origin of the text view's content to the origin of the
// text view's InnerBounds, offset by the given point.
func (this *TextView) ScrollTo (position image.Point) {
this.box.ScrollTo(position)
}
// OnContentBoundsChange specifies a function to be called when the text view's
// ContentBounds or InnerBounds changes.
func (this *TextView) OnContentBoundsChange (callback func ()) event.Cookie {
return this.box.OnContentBoundsChange(callback)
}
// SetText sets the text content of the view.
func (this *TextView) SetText (text string) {
this.box.SetText(text)
} }
func (this *TextView) handleScroll (x, y float64) bool { func (this *TextView) handleScroll (x, y float64) bool {