Allow dialogues to be hidden or shown
To do this, MENU and SUBMENU are split into two types (at last), and a Widget type is introduced. This should allow lots of code to be removed at some point.
This commit is contained in:
43
internal/ui/events.go
Normal file
43
internal/ui/events.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package ui
|
||||
|
||||
func (d *Driver) hoverStartEvent(h hoverable, inBounds bool) {
|
||||
if inBounds && !h.hoverState() {
|
||||
//log.Printf("hoverable false -> true")
|
||||
h.setHoverState(true)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Driver) hoverEndEvent(h hoverable, inBounds bool) {
|
||||
if !inBounds && h.hoverState() {
|
||||
//log.Printf("hoverable true -> false")
|
||||
h.setHoverState(false)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Driver) mouseDownEvent(c clickable, inBounds, wasDown, isDown bool) {
|
||||
if inBounds && !wasDown && isDown {
|
||||
//log.Printf("mouse down false -> true")
|
||||
c.setMouseDownState(true)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Driver) mouseClickEvent(c clickable, inBounds, wasDown, isDown bool) {
|
||||
if inBounds && wasDown && !isDown {
|
||||
//log.Printf("mouse click")
|
||||
c.registerMouseClick()
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Driver) mouseUpEvent(c clickable, inBounds, wasDown, isDown bool) {
|
||||
if inBounds {
|
||||
if wasDown && !isDown {
|
||||
//log.Printf("mouse down true -> false")
|
||||
c.setMouseDownState(false)
|
||||
}
|
||||
} else {
|
||||
if wasDown {
|
||||
//log.Printf("mouse down true -> false")
|
||||
c.setMouseDownState(false)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user