very bare bones layout selectable menu
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
LayoutToolTreeViewTitle = "Layout Tree"
|
||||
LayoutToolFlexID = "layout-tool-flex"
|
||||
LayoutToolTreeID = "layout-tool-tree"
|
||||
LayoutToolActionPagesID = "layout-tool-action-pages"
|
||||
@@ -30,7 +31,7 @@ func NewLayoutTreeView() *LayoutTreeView {
|
||||
|
||||
view.Tree = tview.NewTreeView()
|
||||
|
||||
view.Tree.SetBorder(true).SetTitle("Layout Tree")
|
||||
view.Tree.SetBorder(true).SetTitle(LayoutToolTreeViewTitle)
|
||||
view.Tree.SetInputCapture(view.InputCapture)
|
||||
// Inject ChangedFunc
|
||||
// Inject SelectedFunc
|
||||
@@ -61,6 +62,7 @@ func (lt *LayoutTreeView) AddWindow(win *cdashdisplay.DesktopUIWindow) error {
|
||||
type LayoutToolActionView struct {
|
||||
Pages *tview.Pages
|
||||
CreateWindowView *CreateWindowFormView
|
||||
LayoutSelection *LayoutToolLayoutsList
|
||||
}
|
||||
|
||||
func NewLayoutToolActionView() *LayoutToolActionView {
|
||||
@@ -154,6 +156,18 @@ func (ltv *LayoutToolView) ShowWindowFormByID(idx int16) {
|
||||
)
|
||||
}
|
||||
|
||||
func (ltv *LayoutToolView) ShowLayoutList() {
|
||||
AddAndShowPage(
|
||||
ltv.LayoutActions.Pages,
|
||||
"available-layouts-list",
|
||||
ltv.LayoutActions.LayoutSelection.Tree,
|
||||
)
|
||||
}
|
||||
|
||||
func (ltv *LayoutToolView) DeleteLayoutList() {
|
||||
ltv.LayoutActions.Pages.RemovePage("available-layouts-list")
|
||||
}
|
||||
|
||||
func (ltv *LayoutToolView) DeleteWindowByNode(node *tview.TreeNode) {
|
||||
root := ltv.LayoutTree.Tree.GetRoot()
|
||||
if root == nil {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package views
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type LayoutToolLayoutsList struct {
|
||||
Tree *tview.TreeView
|
||||
}
|
||||
|
||||
func NewLayoutToolLayoutsList() *LayoutToolLayoutsList {
|
||||
view := &LayoutToolLayoutsList{}
|
||||
|
||||
view.Tree = tview.NewTreeView()
|
||||
|
||||
view.Tree.SetBorder(true).SetTitle("Layout List")
|
||||
// Inject InputCapture
|
||||
// Inject ChangedFunc
|
||||
// Inject SelectedFunc
|
||||
|
||||
// Create a root element
|
||||
rootElem := tview.NewTreeNode(".")
|
||||
view.Tree.SetRoot(rootElem).SetCurrentNode(rootElem)
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
// AddEntries adds the list of files we wish the user to select from
|
||||
// For now we will send just a list of []string but in the future this should
|
||||
// receive (or have an alternative to receive) a directory structure
|
||||
func (ltll *LayoutToolLayoutsList) AddEntries(entries []os.DirEntry) {
|
||||
root := ltll.Tree.GetRoot()
|
||||
if root == nil {
|
||||
// NOTE: shouldn't happen at all
|
||||
return
|
||||
}
|
||||
|
||||
for _, e := range entries {
|
||||
node := tview.NewTreeNode(e.Name()).
|
||||
SetReference(e.Name())
|
||||
root.AddChild(node)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user