mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
ui/app: implement Command for system events
And add CommandBack for the Android back button. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+19
-4
@@ -10,6 +10,10 @@ import (
|
||||
"gioui.org/ui"
|
||||
)
|
||||
|
||||
type Event interface {
|
||||
ImplementsEvent()
|
||||
}
|
||||
|
||||
type Draw struct {
|
||||
Config *ui.Config
|
||||
Size image.Point
|
||||
@@ -23,12 +27,16 @@ type ChangeStage struct {
|
||||
Stage Stage
|
||||
}
|
||||
|
||||
type Stage uint8
|
||||
|
||||
type Event interface {
|
||||
ImplementsEvent()
|
||||
// Command is a system event.
|
||||
type Command struct {
|
||||
Type CommandType
|
||||
// Suppress the default action of the command.
|
||||
Cancel bool
|
||||
}
|
||||
|
||||
type Stage uint8
|
||||
type CommandType uint8
|
||||
|
||||
type Input interface {
|
||||
ImplementsInput()
|
||||
}
|
||||
@@ -39,6 +47,12 @@ const (
|
||||
StageVisible
|
||||
)
|
||||
|
||||
const (
|
||||
// CommandBack is the command for a back action
|
||||
// such as the Android back button.
|
||||
CommandBack CommandType = iota
|
||||
)
|
||||
|
||||
const (
|
||||
inchPrDp = 1.0 / 160
|
||||
mmPrDp = 25.4 / 160
|
||||
@@ -98,6 +112,7 @@ func (l Stage) String() string {
|
||||
|
||||
func (_ Draw) ImplementsEvent() {}
|
||||
func (_ ChangeStage) ImplementsEvent() {}
|
||||
func (_ *Command) ImplementsEvent() {}
|
||||
|
||||
func init() {
|
||||
args := strings.Split(extraArgs, "|")
|
||||
|
||||
Reference in New Issue
Block a user