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 case DialogError: iconId = tomo.IconDialogError
} }
dialog.SetTitle(title) dialog.SetTitle(title)
dialog.SetIcon(iconId)
icon := NewIcon(iconId, tomo.IconSizeLarge) icon := NewIcon(iconId, tomo.IconSizeLarge)
messageText := NewLabel(message) messageText := NewLabel(message)
messageText.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle)) 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.SetRole(tomo.R("objects", "LabelSwatch"))
box.swatch.label = text box.swatch.label = text
box.label.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle)) box.label.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))
box.label.SetSelectable(false)
box.label.SetFocusable(false)
box.Add(box.swatch) box.Add(box.swatch)
box.Add(box.label) box.Add(box.label)
box.SetAttr(tomo.ALayout(layouts.Row { false, true })) 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 { func (this *LabelSwatch) handleButtonDown (button input.Button) bool {
if button != input.ButtonLeft { return true } if !isClickingButton(button) { return true }
return true return true
} }
func (this *LabelSwatch) handleButtonUp (button input.Button) bool { 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()) { if this.Window().MousePosition().In(this.Bounds()) {
this.swatch.SetFocused(true) this.swatch.SetFocused(true)
this.swatch.Choose() this.swatch.Choose()

View File

@@ -9,7 +9,7 @@ import "git.tebibyte.media/tomo/tomo/event"
// overflowing ContainerBox. // overflowing ContainerBox.
type Scrollbar struct { type Scrollbar struct {
tomo.ContainerBox tomo.ContainerBox
handle *SliderHandle handle *sliderHandle
layout scrollbarLayout layout scrollbarLayout
dragging bool dragging bool
dragOffset image.Point dragOffset image.Point
@@ -24,7 +24,7 @@ type Scrollbar struct {
func newScrollbar (orient string) *Scrollbar { func newScrollbar (orient string) *Scrollbar {
this := &Scrollbar { this := &Scrollbar {
ContainerBox: tomo.NewContainerBox(), ContainerBox: tomo.NewContainerBox(),
handle: &SliderHandle { handle: &sliderHandle {
Box: tomo.NewBox(), Box: tomo.NewBox(),
}, },
layout: scrollbarLayout { layout: scrollbarLayout {
@@ -43,9 +43,9 @@ func newScrollbar (orient string) *Scrollbar {
this.OnMouseMove(this.handleMouseMove) this.OnMouseMove(this.handleMouseMove)
this.OnScroll(this.handleScroll) this.OnScroll(this.handleScroll)
this.handle.SetRole(tomo.R("objects", "SliderHandle")) this.handle.SetRole(tomo.R("objects", "ScrollbarHandle"))
this.handle.SetTag(orient, true) this.handle.SetTag(orient, true)
this.SetRole(tomo.R("objects", "Slider")) this.SetRole(tomo.R("objects", "Scrollbar"))
this.SetTag(orient, true) this.SetTag(orient, true)
return this 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. // Slider is a control that selects a numeric value between 0 and 1.
type Slider struct { type Slider struct {
tomo.ContainerBox tomo.ContainerBox
handle *SliderHandle handle *sliderHandle
layout sliderLayout layout sliderLayout
dragging bool dragging bool
dragOffset image.Point dragOffset image.Point
@@ -21,16 +21,14 @@ type Slider struct {
} }
} }
// SliderHandle is a simple object that serves as a handle for sliders and type sliderHandle struct {
// scrollbars. It is completely inert.
type SliderHandle struct {
tomo.Box tomo.Box
} }
func newSlider (orient string, value float64) *Slider { func newSlider (orient string, value float64) *Slider {
this := &Slider { this := &Slider {
ContainerBox: tomo.NewContainerBox(), ContainerBox: tomo.NewContainerBox(),
handle: &SliderHandle { handle: &sliderHandle {
Box: tomo.NewBox(), Box: tomo.NewBox(),
}, },
layout: sliderLayout { layout: sliderLayout {