-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkspaceRegistry.go
More file actions
43 lines (34 loc) · 1.19 KB
/
WorkspaceRegistry.go
File metadata and controls
43 lines (34 loc) · 1.19 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
package main
import (
"runtime"
workspace "github.com/cowsed/PrettyMath/Workspaces"
_ "github.com/cowsed/PrettyMath/Workspaces/2DPlotter"
_ "github.com/cowsed/PrettyMath/Workspaces/Attractor2D"
_ "github.com/cowsed/PrettyMath/Workspaces/ModelViewer"
// _ "github.com/cowsed/PrettyMath/Workspaces/OpenCL" //Doesn't work currently
_ "github.com/cowsed/PrettyMath/Workspaces/OpenGL"
g "github.com/AllenDang/giu"
"github.com/AllenDang/giu/imgui"
)
//NewWorkspace is an empty struct (to fulfill g.Widget)for a page that allows the creation of workspaces
type NewWorkspace struct {
}
//Build builds the page full of options for workspaces to create
func (NWS *NewWorkspace) Build() {
//Build the creation tab
g.TabItem("Create New").Layout(
g.Label("New Page: "),
g.Custom(func() {
for _, ws := range workspace.RegisteredWorkspaces {
if imgui.Button("Create " + ws.Name) {
CurrentWorkspaces = append(CurrentWorkspaces, ws.InitFunc(onClose, AddProcess))
}
}
}),
).Build()
}
//The closing function that gets passed to workspaces to remove themselves and replace themselves with the creation tab
func onClose() {
CurrentWorkspaces = []g.Widget{&NewWorkspace{}}
runtime.GC()
}