This repository has been archived by the owner on Nov 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
/
viewport.go
109 lines (81 loc) · 3.67 KB
/
viewport.go
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gxui
import (
"github.com/google/gxui/math"
)
type Viewport interface {
// SizeDips returns the size of the viewport in device-independent pixels.
// The ratio of pixels to DIPs is based on the screen density and scale
// adjustments made with the SetScale method.
SizeDips() math.Size
// SetSizeDips sets the size of the viewport in device-independent pixels.
// The ratio of pixels to DIPs is based on the screen density and scale
// adjustments made with the SetScale method.
SetSizeDips(math.Size)
// SizePixels returns the size of the viewport in pixels.
SizePixels() math.Size
// Scale returns the display scaling for this viewport.
// A scale of 1 is unscaled, 2 is twice the regular scaling.
Scale() float32
// SetScale alters the display scaling for this viewport.
// A scale of 1 is unscaled, 2 is twice the regular scaling.
SetScale(float32)
// Fullscreen returns true if the viewport was created full-screen.
Fullscreen() bool
// Title returns the title of the window.
// This is usually the text displayed at the top of the window.
Title() string
// SetTitle changes the title of the window.
SetTitle(string)
// Position returns position of the window.
Position() math.Point
// SetPosition changes position of the window.
SetPosition(math.Point)
// Show makes the window visible.
Show()
// Hide makes the window invisible.
Hide()
// Close destroys the window.
// Once the window is closed, no further calls should be made to it.
Close()
// SetCanvas changes the displayed content of the viewport to the specified
// Canvas. As canvases are immutable once completed, every visual update of a
// viewport will require a call to SetCanvas.
SetCanvas(Canvas)
// OnClose subscribes f to be called when the viewport closes.
OnClose(f func()) EventSubscription
// OnResize subscribes f to be called whenever the viewport changes size.
OnResize(f func()) EventSubscription
// OnMouseMove subscribes f to be called whenever the mouse cursor moves over
// the viewport.
OnMouseMove(f func(MouseEvent)) EventSubscription
// OnMouseEnter subscribes f to be called whenever the mouse cursor enters the
// viewport.
OnMouseEnter(f func(MouseEvent)) EventSubscription
// OnMouseEnter subscribes f to be called whenever the mouse cursor leaves the
// viewport.
OnMouseExit(f func(MouseEvent)) EventSubscription
// OnMouseDown subscribes f to be called whenever a mouse button is pressed
// while the cursor is inside the viewport.
OnMouseDown(f func(MouseEvent)) EventSubscription
// OnMouseUp subscribes f to be called whenever a mouse button is released
// while the cursor is inside the viewport.
OnMouseUp(f func(MouseEvent)) EventSubscription
// OnMouseScroll subscribes f to be called whenever the mouse scroll wheel
// turns while the cursor is inside the viewport.
OnMouseScroll(f func(MouseEvent)) EventSubscription
// OnKeyDown subscribes f to be called whenever a keyboard key is pressed
// while the viewport has focus.
OnKeyDown(f func(KeyboardEvent)) EventSubscription
// OnKeyUp subscribes f to be called whenever a keyboard key is released
// while the viewport has focus.
OnKeyUp(f func(KeyboardEvent)) EventSubscription
// OnKeyRepeat subscribes f to be called whenever a keyboard key-repeat event
// is raised while the viewport has focus.
OnKeyRepeat(f func(KeyboardEvent)) EventSubscription
// OnKeyStroke subscribes f to be called whenever a keyboard key-stroke event
// is raised while the viewport has focus.
OnKeyStroke(f func(KeyStrokeEvent)) EventSubscription
}