Skip to content
Open
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
24 changes: 24 additions & 0 deletions core/framecol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package core

import (
"cogentcore.org/core/styles"
"cogentcore.org/core/tree"
)

func NewFrameCol(parent ...tree.Node) *Frame {
frm := NewFrame(parent...)
frm.Styler(func(s *styles.Style) {
//s.GrowWrap = false
s.Grow.Set(1, 1)
s.Direction = styles.Column
s.Grow.X = 1
s.Grow.Y = 1
s.Border.Radius = styles.BorderRadiusFull
s.Gap.Zero()
s.Align.Content = styles.Start
s.Align.Items = styles.Start
s.Overflow.Set(styles.OverflowAuto)
})
return frm
}

19 changes: 19 additions & 0 deletions core/framerow.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package core

import (
"cogentcore.org/core/styles"
"cogentcore.org/core/styles/units"
"cogentcore.org/core/tree"
)

func NewFrameRow(parent ...tree.Node) *Frame {
frm := NewFrame(parent...)
frm.Styler(func(s *styles.Style) {
s.Overflow.Set(styles.OverflowHidden) // no scrollbars!
s.Gap.Set(units.Dp(4))
s.Direction = styles.Row
s.Grow.Set(1, 0)
s.Wrap = true
})
return frm
}
21 changes: 13 additions & 8 deletions core/tabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Tabs struct {

// NewTabButton is whether to show a new tab button at the end of the list of tabs.
NewTabButton bool
NewTabButtonOnClick func(e events.Event)

// NewTabFunc is a function that will be called when the NewTabButton
// is clicked to create a new tab, with the index of this new tab.
Expand Down Expand Up @@ -159,14 +160,18 @@ func (ts *Tabs) Init() {
}
ntb := NewButton(w).SetType(ButtonAction).SetIcon(icons.Add)
ntb.SetTooltip("Add a new tab").SetName("new-tab-button")
ntb.OnClick(func(e events.Event) {
ts.NewTab("New tab")
idx := ts.NumTabs() - 1
if ts.NewTabFunc != nil {
ts.NewTabFunc(idx)
}
ts.SelectTabIndex(idx)
})
if ts.NewTabButtonOnClick == nil {
ntb.OnClick(func(e events.Event) {
ts.NewTab("New tab")
idx := ts.NumTabs() - 1
if ts.NewTabFunc != nil {
ts.NewTabFunc(idx)
}
ts.SelectTabIndex(idx)
})
} else {
ntb.OnClick(ts.NewTabButtonOnClick)
}
})
})
tree.AddAt(p, "frame", func(w *Frame) {
Expand Down