-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
86 lines (76 loc) · 2.55 KB
/
main.go
File metadata and controls
86 lines (76 loc) · 2.55 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) 2023, Cogent Core. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"embed"
"cogentcore.org/core/base/errors"
"cogentcore.org/core/content"
"cogentcore.org/core/core"
"cogentcore.org/core/htmlcore"
"cogentcore.org/core/icons"
"cogentcore.org/core/styles"
"cogentcore.org/core/styles/units"
"cogentcore.org/core/tree"
)
//go:embed name.png
var resources embed.FS
//go:embed content
var econtent embed.FS
func main() {
b := core.NewBody("Cogent Core")
ct := content.NewContent(b).SetContent(econtent)
ctx := ct.Context
b.AddTopBar(func(bar *core.Frame) {
tb := core.NewToolbar(bar)
tb.Maker(ct.MakeToolbar)
tb.Maker(func(p *tree.Plan) {
tree.Add(p, func(w *core.Button) {
ctx.LinkButton(w, "https://cogentcore.org/blog")
w.SetText("Blog").SetIcon(icons.RssFeed)
})
tree.Add(p, func(w *core.Button) {
ctx.LinkButton(w, "https://youtube.com/@CogentCore")
w.SetText("Videos").SetIcon(icons.VideoLibrary)
})
tree.Add(p, func(w *core.Button) {
ctx.LinkButton(w, "https://github.com/cogentcore")
w.SetText("GitHub").SetIcon(icons.GitHub)
})
tree.Add(p, func(w *core.Button) {
ctx.LinkButton(w, "/community")
w.SetText("Community").SetIcon(icons.Forum)
})
tree.Add(p, func(w *core.Button) {
ctx.LinkButton(w, "https://github.com/sponsors/cogentcore")
w.SetText("Sponsor").SetIcon(icons.Favorite)
})
})
})
ctx.ElementHandlers["home-page"] = func(ctx *htmlcore.Context) bool {
frame := core.NewFrame(ctx.BlockParent)
frame.Styler(func(s *styles.Style) {
s.Direction = styles.Column
s.Grow.Set(1, 1)
s.CenterAll()
})
errors.Log(core.NewSVG(frame).ReadString(core.AppIcon))
img := core.NewImage(frame)
errors.Log(img.OpenFS(resources, "name.png"))
img.Styler(func(s *styles.Style) {
s.Min.X.SetCustom(func(uc *units.Context) float32 {
return min(uc.Dp(612), uc.Vw(80))
})
})
core.NewText(frame).SetType(core.TextHeadlineMedium).SetText("A free and open source software ecosystem for all platforms, built around a powerful, fast, elegant framework")
buttons := core.NewFrame(frame)
cc := core.NewButton(buttons).SetText("Core")
ctx.LinkButton(cc, "https://cogentcore.org/core")
cl := core.NewButton(buttons).SetText("Lab").SetType(core.ButtonTonal)
ctx.LinkButton(cl, "https://cogentcore.org/lab")
ca := core.NewButton(buttons).SetText("Apps").SetType(core.ButtonTonal)
ctx.LinkButton(ca, "https://cogentcore.org/cogent")
return true
}
b.RunMainWindow()
}