6 Commits

4 changed files with 12 additions and 11 deletions

View File

@@ -53,6 +53,7 @@ func NewDialog (kind DialogKind, parent tomo.Window, title, message string, opti
case DialogError: iconId = tomo.IconDialogError
}
dialog.SetTitle(title)
dialog.SetIcon(iconId)
icon := NewIcon(iconId, tomo.IconSizeLarge)
messageText := NewLabel(message)
messageText.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))

View File

@@ -24,6 +24,8 @@ func NewLabelSwatch (value color.Color, text string) *LabelSwatch {
box.SetRole(tomo.R("objects", "LabelSwatch"))
box.swatch.label = text
box.label.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))
box.label.SetSelectable(false)
box.label.SetFocusable(false)
box.Add(box.swatch)
box.Add(box.label)
box.SetAttr(tomo.ALayout(layouts.Row { false, true }))
@@ -61,12 +63,12 @@ func (this *LabelSwatch) OnConfirm (callback func ()) event.Cookie {
}
func (this *LabelSwatch) handleButtonDown (button input.Button) bool {
if button != input.ButtonLeft { return true }
if !isClickingButton(button) { return true }
return true
}
func (this *LabelSwatch) handleButtonUp (button input.Button) bool {
if button != input.ButtonLeft { return true }
if !isClickingButton(button) { return true }
if this.Window().MousePosition().In(this.Bounds()) {
this.swatch.SetFocused(true)
this.swatch.Choose()

View File

@@ -9,7 +9,7 @@ import "git.tebibyte.media/tomo/tomo/event"
// overflowing ContainerBox.
type Scrollbar struct {
tomo.ContainerBox
handle *SliderHandle
handle *sliderHandle
layout scrollbarLayout
dragging bool
dragOffset image.Point
@@ -24,7 +24,7 @@ type Scrollbar struct {
func newScrollbar (orient string) *Scrollbar {
this := &Scrollbar {
ContainerBox: tomo.NewContainerBox(),
handle: &SliderHandle {
handle: &sliderHandle {
Box: tomo.NewBox(),
},
layout: scrollbarLayout {
@@ -43,9 +43,9 @@ func newScrollbar (orient string) *Scrollbar {
this.OnMouseMove(this.handleMouseMove)
this.OnScroll(this.handleScroll)
this.handle.SetRole(tomo.R("objects", "SliderHandle"))
this.handle.SetRole(tomo.R("objects", "ScrollbarHandle"))
this.handle.SetTag(orient, true)
this.SetRole(tomo.R("objects", "Slider"))
this.SetRole(tomo.R("objects", "Scrollbar"))
this.SetTag(orient, true)
return this
}

View File

@@ -9,7 +9,7 @@ import "git.tebibyte.media/tomo/tomo/event"
// Slider is a control that selects a numeric value between 0 and 1.
type Slider struct {
tomo.ContainerBox
handle *SliderHandle
handle *sliderHandle
layout sliderLayout
dragging bool
dragOffset image.Point
@@ -21,16 +21,14 @@ type Slider struct {
}
}
// SliderHandle is a simple object that serves as a handle for sliders and
// scrollbars. It is completely inert.
type SliderHandle struct {
type sliderHandle struct {
tomo.Box
}
func newSlider (orient string, value float64) *Slider {
this := &Slider {
ContainerBox: tomo.NewContainerBox(),
handle: &SliderHandle {
handle: &sliderHandle {
Box: tomo.NewBox(),
},
layout: sliderLayout {