This repository has been archived by the owner on Jul 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.go
80 lines (62 loc) · 2.89 KB
/
app.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
// Copyright (c) 2018, Randall C. O'Reilly. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// based on golang.org/x/exp/shiny:
// 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 oswin
import (
"image"
)
// TheApp is the current oswin App -- only ever one in effect
var TheApp App
// App represents the overall OS GUI hardware, and creates Images, Textures
// and Windows, appropriate for that hardware / OS, and maintains data about
// the physical screen(s)
type App interface {
// Name is the overall name of the application -- used for specifying an
// application-specific preferences directory, etc
Name() string
// SetName sets the application name -- defaults to GoGi if not otherwise set
SetName(name string)
// NScreens returns the number of different logical and/or physical
// screens managed under this overall screen hardware
NScreens() int
// Screen returns screen for given screen number, or nil if not a
// valid screen number
Screen(scrN int) *Screen
// NWindows returns the number of windows open for this app
NWindows() int
// Window returns given window in list of windows opened under this screen
// -- list is not in any guaranteed order, but typically in order of
// creation (see also WindowByName) -- returns nil for invalid index
Window(win int) Window
// WindowByName returns given window in list of windows opened under this
// screen, by name -- nil if not found
WindowByName(name string) Window
// NewWindow returns a new Window for this screen. A nil opts is valid and
// means to use the default option values.
NewWindow(opts *NewWindowOptions) (Window, error)
// NewImage returns a new Image for this screen. Images can be drawn upon
// directly using image and other packages, and have an accessable []byte
// slice holding the image data
NewImage(size image.Point) (Image, error)
// NewTexture returns a new Texture for the given window. Textures are opaque
// and could be non-local, but very fast for rendering to windows --
// typically create a texture of each window and render to that texture,
// then Draw that texture to the window when it is time to update (call
// Publish on window after drawing)
NewTexture(win Window, size image.Point) (Texture, error)
// PrefsDir returns the OS-specific preferences directory: Mac: ~/Library,
// Linux: ~/.config, Windows: ?
PrefsDir() string
// GoGiPrefsDir returns the GoGi preferences directory: PrefsDir + GoGi --
// ensures that the directory exists first
GoGiPrefsDir() string
// AppPrefsDir returns the application-specific preferences directory:
// PrefsDir + App.Name --ensures that the directory exists first
AppPrefsDir() string
// FontPaths returns the default system font paths
FontPaths() []string
}