-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathredrawrequests.go
More file actions
72 lines (63 loc) · 2.44 KB
/
redrawrequests.go
File metadata and controls
72 lines (63 loc) · 2.44 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
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2025 The Guigui Authors
package guigui
import (
"fmt"
"image"
"log/slog"
)
type redrawRequests struct {
region image.Rectangle
}
func (r *redrawRequests) reset() {
r.region = image.Rectangle{}
}
func (r *redrawRequests) empty() bool {
return r.region.Empty()
}
func (r *redrawRequests) union(region image.Rectangle) image.Rectangle {
return r.region.Union(region)
}
type requestRedrawReason int
const (
requestRedrawReasonUnknown requestRedrawReason = iota
requestRedrawReasonRebuildWidget
requestRedrawReasonStateKeyChanged
requestRedrawReasonRedrawWidget
requestRedrawReasonLayout
requestRedrawReasonFocus
requestRedrawReasonScreenSize
requestRedrawReasonScreenDeviceScale
requestRedrawReasonAppScale
requestRedrawReasonColorMode
requestRedrawReasonLocale
)
func (r *redrawRequests) add(region image.Rectangle, reason requestRedrawReason, widget Widget) {
r.region = r.region.Union(region)
if theDebugMode.showRenderingRegions {
switch reason {
case requestRedrawReasonRebuildWidget:
slog.Info("request redrawing", "reason", "rebuild widget", "requester", fmt.Sprintf("%T", widget), "at", widget.widgetState().rebuildRequestedAt, "region", region)
case requestRedrawReasonStateKeyChanged:
slog.Info("request redrawing", "reason", "state key changed", "requester", fmt.Sprintf("%T", widget), "region", region)
case requestRedrawReasonRedrawWidget:
slog.Info("request redrawing", "reason", "redraw widget", "requester", fmt.Sprintf("%T", widget), "at", widget.widgetState().redrawRequestedAt, "region", region)
case requestRedrawReasonLayout:
slog.Info("request redrawing", "reason", "layout", "region", region)
case requestRedrawReasonFocus:
slog.Info("request redrawing", "reason", "focus", "region", region)
case requestRedrawReasonScreenSize:
slog.Info("request redrawing", "reason", "screen size", "region", region)
case requestRedrawReasonScreenDeviceScale:
slog.Info("request redrawing", "reason", "screen device scale", "region", region)
case requestRedrawReasonAppScale:
slog.Info("request redrawing", "reason", "app scale", "region", region)
case requestRedrawReasonColorMode:
slog.Info("request redrawing", "reason", "color mode", "region", region)
case requestRedrawReasonLocale:
slog.Info("request redrawing", "reason", "locale", "region", region)
default:
slog.Info("request redrawing", "reason", "unknown", "region", region)
}
}
}