Skip to content

Commit

Permalink
Splitting Panels
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewilson2002 committed Apr 5, 2021
1 parent eb8142e commit cf5803c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ func main() {
}}, &ui.ItemSeparator{}, &ui.ItemEntry{Name: "Split Top", QuickChar: 6, Callback: func() {

}}, &ui.ItemEntry{Name: "Split Bottom", QuickChar: 6, Callback: func() {

panelContainer.SplitSelected(ui.SplitVertical, ui.NewTabContainer(&theme))
}}, &ui.ItemEntry{Name: "Split Left", QuickChar: 6, Callback: func() {

}}, &ui.ItemEntry{Name: "Split Right", QuickChar: 6, Callback: func() {

panelContainer.SplitSelected(ui.SplitHorizontal, ui.NewTabContainer(&theme))
}}, &ui.ItemSeparator{}, &ui.ItemEntry{Name: "Move", Shortcut: "Ctrl+M", Callback: func() {

}}, &ui.ItemEntry{Name: "Resize", Shortcut: "Ctrl+R", Callback: func() {
Expand Down
7 changes: 7 additions & 0 deletions ui/panelcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,19 @@ func (c *PanelContainer) SplitSelected(kind SplitKind, item Component) {
}

// It should be asserted that whatever is selected is either PanelKindEmpty or PanelKindSingle

(**c.selected).Left = &Panel{Parent: *c.selected, Left: (**c.selected).Left, Kind: PanelKindSingle}
if item == nil {
(**c.selected).Right = &Panel{Parent: *c.selected, Kind: PanelKindEmpty}
} else {
(**c.selected).Right = &Panel{Parent: *c.selected, Left: item, Kind: PanelKindSingle}
}
(**c.selected).Kind = PanelKind(kind)
if kind == SplitVertical {
(**c.selected).SplitAt = (**c.selected).height / 2
} else {
(**c.selected).SplitAt = (**c.selected).width / 2
}
(*c.selected).UpdateSplits()
(*c.selected).SetFocused(false)
panel := (**c.selected).Left.(*Panel) // TODO: watch me... might be a bug lurking in a hidden copy here
Expand Down

0 comments on commit cf5803c

Please sign in to comment.