mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
ui/input/system: introduce package for system events
And add ProfileOp and ProfileEvent for registering and receiving profile data. Remove the Profiling field and Timings method from app.Window. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
// Package system contain ops and types for
|
||||
// system events.
|
||||
package system
|
||||
|
||||
import (
|
||||
"gioui.org/ui"
|
||||
"gioui.org/ui/input"
|
||||
"gioui.org/ui/internal/ops"
|
||||
)
|
||||
|
||||
// ProfileOp registers a handler for receiving
|
||||
// ProfileEvents.
|
||||
type ProfileOp struct {
|
||||
Key input.Key
|
||||
}
|
||||
|
||||
// ProfileEvent contain profile data from a single
|
||||
// rendered frame.
|
||||
type ProfileEvent struct {
|
||||
// String with timings. Very likely to change.
|
||||
Timings string
|
||||
}
|
||||
|
||||
func (p ProfileOp) Add(o *ui.Ops) {
|
||||
data := make([]byte, ops.TypeProfileLen)
|
||||
data[0] = byte(ops.TypeProfile)
|
||||
o.Write(data, p.Key)
|
||||
}
|
||||
|
||||
func (p *ProfileOp) Decode(d []byte, refs []interface{}) {
|
||||
if ops.OpType(d[0]) != ops.TypeProfile {
|
||||
panic("invalid op")
|
||||
}
|
||||
*p = ProfileOp{
|
||||
Key: refs[0].(input.Key),
|
||||
}
|
||||
}
|
||||
|
||||
func (p ProfileEvent) ImplementsInputEvent() {}
|
||||
Reference in New Issue
Block a user