-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.go
74 lines (60 loc) · 2 KB
/
window.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
package impress
import (
"image"
"image/color"
"github.com/codeation/impress/driver"
)
// Window represents inner window
type Window struct {
painter driver.Painter
}
// NewWindow creates new inner window with a specified size and background color
func (app *Application) NewWindow(rect image.Rectangle, background color.Color) *Window {
return app.frame.NewWindow(rect, background)
}
// NewWindow creates new frame window with a specified size and background color
func (f *Frame) NewWindow(rect image.Rectangle, background color.Color) *Window {
return &Window{
painter: f.framer.NewWindow(rect, background),
}
}
// Drop deletes window.
// Note that a dropped window can no longer be used
func (w *Window) Drop() {
w.painter.Drop()
w.painter = nil // TODO notice when the window is dropped
}
// Size changes window size and position
func (w *Window) Size(rect image.Rectangle) {
w.painter.Size(rect)
}
// Clear clears current window
func (w *Window) Clear() {
w.painter.Clear()
}
// Fill draws a rectangle with specified size and foreground color
func (w *Window) Fill(rect image.Rectangle, foreground color.Color) {
w.painter.Fill(rect, foreground)
}
// Line draws a color line connecting two specified points
func (w *Window) Line(from image.Point, to image.Point, foreground color.Color) {
w.painter.Line(from, to, foreground)
}
// Image draws a image into specified rectangle.
// Specify a different rectangle size to scale the image
func (w *Window) Image(rect image.Rectangle, img *Image) {
w.painter.Image(rect, img.imager)
}
// Text draws a text at specified location using a specified font and foreground color
func (w *Window) Text(text string, font *Font, from image.Point, foreground color.Color) {
w.painter.Text(text, font.fonter, from, foreground)
}
// Show sends the contents of the window to the screen.
// Note that a drawings are not visible until Show
func (w *Window) Show() {
w.painter.Show()
}
// Raise brings the window to the forefront
func (w *Window) Raise() {
w.painter.Raise()
}