Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core.Tabs.NewTab returns the tab, to allow for customization #344

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions canvas/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ func (cv *Canvas) Init() {
})
tree.AddChildAt(w, "tabs", func(w *core.Tabs) {
w.SetType(core.FunctionalTabs)
pt := w.NewTab("Paint")
pt, _ := w.NewTab("Paint")
NewPaintView(pt).SetCanvas(cv)
at := w.NewTab("Align")
at, _ := w.NewTab("Align")
NewAlignView(at).SetCanvas(cv)
cv.EditState.Text.Defaults()
tt := w.NewTab("Text")
tt, _ := w.NewTab("Text")
core.NewForm(tt).SetStruct(&cv.EditState.Text)
})
})
Expand Down
8 changes: 4 additions & 4 deletions clock/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func main() {
}

func clock(ts *core.Tabs) {
cl := ts.NewTab("Clock")
cl, _ := ts.NewTab("Clock")
cl.Styler(func(s *styles.Style) {
s.CenterAll()
})
Expand All @@ -41,19 +41,19 @@ type timer struct {
}

func timers(ts *core.Tabs) {
tr := ts.NewTab("Timers")
tr, _ := ts.NewTab("Timers")
trd := 15 * time.Minute
trv := core.NewValue(&trd, "")
tr.AddChild(trv)
core.NewButton(tr).SetText("Start")
}

func stopwatches(ts *core.Tabs) {
sw := ts.NewTab("Stopwatches")
sw, _ := ts.NewTab("Stopwatches")
core.NewButton(sw).SetText("Start")
}

func alarms(ts *core.Tabs) {
al := ts.NewTab("Alarms")
al, _ := ts.NewTab("Alarms")
core.NewButton(al).SetText("Create")
}
17 changes: 9 additions & 8 deletions code/debugpanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func (dv *DebugPanel) InitTabs() {
if w.NumTabs() > 0 {
return
}
ctv := texteditor.NewEditor(w.NewTab(DebugTabConsole))
dtab, _ := w.NewTab(DebugTabConsole)
ctv := texteditor.NewEditor(dtab)
ctv.SetName("dbg-console")
ConfigOutputTextEditor(ctv)
dv.State.BlankState()
Expand All @@ -147,7 +148,7 @@ func (dv *DebugPanel) InitTabs() {
dv.OutputBuffer.Options.LineNumbers = false
ctv.SetBuffer(dv.OutputBuffer)

bv := w.NewTab(DebugTabBreaks)
bv, _ := w.NewTab(DebugTabBreaks)
tree.AddChild(bv, func(w *core.Table) {
w.SetSlice(&dv.State.Breaks)
w.OnDoubleClick(func(e events.Event) {
Expand All @@ -168,7 +169,7 @@ func (dv *DebugPanel) InitTabs() {
})
})

sv := w.NewTab(DebugTabStack)
sv, _ := w.NewTab(DebugTabStack)
tree.AddChild(sv, func(w *core.Table) {
w.SetReadOnly(true)
w.SetSlice(&dv.State.Stack)
Expand All @@ -181,7 +182,7 @@ func (dv *DebugPanel) InitTabs() {
})

if dv.Known == fileinfo.Go { // dv.Dbg.HasTasks() { // todo: not avail here yet
tv := w.NewTab(DebugTabTasks)
tv, _ := w.NewTab(DebugTabTasks)
tree.AddChild(tv, func(w *core.Table) {
w.SetReadOnly(true)
w.SetSlice(&dv.State.Tasks)
Expand All @@ -199,7 +200,7 @@ func (dv *DebugPanel) InitTabs() {
})
}

tv := w.NewTab(DebugTabThreads)
tv, _ := w.NewTab(DebugTabThreads)
tree.AddChild(tv, func(w *core.Table) {
w.SetReadOnly(true)
w.SetSlice(&dv.State.Threads)
Expand All @@ -216,7 +217,7 @@ func (dv *DebugPanel) InitTabs() {
})
})

vv := w.NewTab(DebugTabVars)
vv, _ := w.NewTab(DebugTabVars)
tree.AddChild(vv, func(w *core.Table) {
w.SetReadOnly(true)
w.SetSlice(&dv.State.Vars)
Expand All @@ -226,7 +227,7 @@ func (dv *DebugPanel) InitTabs() {
})
})

ff := w.NewTab(DebugTabFrames)
ff, _ := w.NewTab(DebugTabFrames)
tree.AddChild(ff, func(w *core.Table) {
w.SetReadOnly(true)
w.SetSlice(&dv.State.FindFrames)
Expand All @@ -239,7 +240,7 @@ func (dv *DebugPanel) InitTabs() {
})
})

gv := w.NewTab(DebugTabGlobals)
gv, _ := w.NewTab(DebugTabGlobals)
tree.AddChild(gv, func(w *core.Table) {
w.SetReadOnly(true)
w.SetSlice(&dv.State.GlobalVars)
Expand Down
2 changes: 1 addition & 1 deletion code/piv/piview.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func (pv *PiView) RecycleMainTab(label string, typ reflect.Type, sel bool) core.
}
return widg
}
widg = tv.NewTab(typ, label)
widg, _ = tv.NewTab(typ, label)
if sel {
tv.SelectTabByName(label)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module cogentcore.org/cogent
go 1.22

require (
cogentcore.org/core v0.3.3-0.20240822231726-6385e4c9fc1f
cogentcore.org/core v0.3.3-0.20240825182959-fe4840922a21
github.com/aandrew-me/tgpt/v2 v2.7.2
github.com/alecthomas/chroma/v2 v2.13.0
github.com/bogdanfinn/fhttp v0.5.27
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cogentcore.org/core v0.3.3-0.20240822231726-6385e4c9fc1f h1:ia/D6kJ5nhFzyYyRZHe7LmXTPpIh+dDO+Jm8GQzUmGQ=
cogentcore.org/core v0.3.3-0.20240822231726-6385e4c9fc1f/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4=
cogentcore.org/core v0.3.3-0.20240825182959-fe4840922a21 h1:tffR0tewNHVE36GpZE7ZjTSE4KYoRfbdeL9btV8UmbU=
cogentcore.org/core v0.3.3-0.20240825182959-fe4840922a21/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4=
github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4 h1:6lx9xzJAhdjq0LvVfbITeC3IH9Fzvo1aBahyPu2FuG8=
github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4/go.mod h1:FChzXi1izqzdPb6BiNZmcZLGyTYiT61iGx9Rxx9GNeI=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down
4 changes: 2 additions & 2 deletions numbers/cmd/numbers/numbers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ func Interactive(c *Config) error {

ts := core.NewTabs(b)

db := ts.NewTab("Data browser")
db, _ := ts.NewTab("Data browser")
core.NewText(db).SetType(core.TextTitleLarge).SetText("Use your terminal to enter data browser commands.")

rt := ts.NewTab("Random")
rt, _ := ts.NewTab("Random")
tb := core.NewToolbar(rt)
rd := random.NewRandom(rt)
tb.Maker(rd.MakeToolbar)
Expand Down
1 change: 1 addition & 0 deletions numbers/imports/cogentcore_org-core-tensor-stats-simat.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions numbers/imports/cogentcore_org-core-tensor-stats-split.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions numbers/imports/cogentcore_org-core-tensor-stats-stats.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions numbers/imports/cogentcore_org-core-tensor-tensorcore.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 26 additions & 78 deletions numbers/imports/cogentcore_org-core-tensor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading