Compare commits
8 Commits
v0.22.0
...
8469962c90
| Author | SHA1 | Date | |
|---|---|---|---|
| 8469962c90 | |||
| 0ccdb609ef | |||
| d1f0786043 | |||
| 73731c6201 | |||
| 7c42b7ad37 | |||
| 0fe4979483 | |||
| 155752ba78 | |||
| f4a3cb3c00 |
@@ -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))
|
||||
|
||||
@@ -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()
|
||||
|
||||
9
menu.go
9
menu.go
@@ -72,6 +72,7 @@ func (this *Menu) TearOff () {
|
||||
this.torn = true
|
||||
|
||||
window, err := this.parent.NewChild(this.bounds)
|
||||
window.SetIcon(tomo.IconListChoose)
|
||||
if err != nil { return }
|
||||
|
||||
visible := this.Window.Visible()
|
||||
@@ -91,20 +92,20 @@ func (this *Menu) newTearLine () tomo.Object {
|
||||
tearLine.SetRole(tomo.R("objects", "TearLine"))
|
||||
tearLine.SetFocusable(true)
|
||||
tearLine.OnKeyDown(func (key input.Key, numberPad bool) bool {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return false }
|
||||
if !isClickingKey(key) { return false }
|
||||
return true
|
||||
})
|
||||
tearLine.OnKeyUp(func (key input.Key, numberPad bool) bool {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return false }
|
||||
if !isClickingKey(key) { return false }
|
||||
this.TearOff()
|
||||
return true
|
||||
})
|
||||
tearLine.OnButtonDown(func (button input.Button) bool {
|
||||
if button != input.ButtonLeft { return false }
|
||||
if !isClickingButton(button) { return false }
|
||||
return true
|
||||
})
|
||||
tearLine.OnButtonUp(func (button input.Button) bool {
|
||||
if button != input.ButtonLeft { return false }
|
||||
if !isClickingButton(button) { return false }
|
||||
if tearLine.Window().MousePosition().In(tearLine.Bounds()) {
|
||||
this.TearOff()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user