forked from guigui-gui/guigui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaultwidget.go
More file actions
81 lines (63 loc) · 1.86 KB
/
Copy pathdefaultwidget.go
File metadata and controls
81 lines (63 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2025 The Guigui Authors
package guigui
import (
"image"
"github.com/hajimehoshi/ebiten/v2"
)
type DefaultWidget struct {
s widgetState
_ noCopy
addr *DefaultWidget
}
var _ Widget = (*DefaultWidget)(nil)
func (d *DefaultWidget) copyCheck() {
if d.addr == nil {
d.addr = d
} else if d.addr != d {
panic("guigui: illegal use of DefaultWidget copied by value")
}
}
func (*DefaultWidget) Env(context *Context, key EnvKey, source *EnvSource) (any, bool) {
return nil, false
}
func (*DefaultWidget) Build(context *Context, adder *ChildAdder) error {
return nil
}
func (*DefaultWidget) Layout(context *Context, widgetBounds *WidgetBounds, layouter *ChildLayouter) {
}
func (*DefaultWidget) HandlePointingInput(context *Context, widgetBounds *WidgetBounds) HandleInputResult {
return HandleInputResult{}
}
func (*DefaultWidget) HandleButtonInput(context *Context, widgetBounds *WidgetBounds) HandleInputResult {
return HandleInputResult{}
}
func (*DefaultWidget) Tick(context *Context, widgetBounds *WidgetBounds) error {
context.setDefaultTickMethodCalledFlag()
return nil
}
func (*DefaultWidget) CursorShape(context *Context, widgetBounds *WidgetBounds) (ebiten.CursorShapeType, bool) {
return 0, false
}
func (*DefaultWidget) Draw(context *Context, widgetBounds *WidgetBounds, dst *ebiten.Image) {
}
func (*DefaultWidget) WriteStateKey(w *StateKeyWriter) {
}
func (d *DefaultWidget) Measure(context *Context, constraints Constraints) image.Point {
var s image.Point
if d.widgetState().root {
s = context.app.bounds().Size()
} else {
s = image.Pt(int(144*context.Scale()), int(144*context.Scale()))
}
if w, ok := constraints.FixedWidth(); ok {
s.X = w
}
if h, ok := constraints.FixedHeight(); ok {
s.Y = h
}
return s
}
func (d *DefaultWidget) widgetState() *widgetState {
return &d.s
}