Splitting Panels
This commit is contained in:
parent
eb8142ea8e
commit
cf5803c464
4
main.go
4
main.go
@ -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() {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user