figuring a way of having a clean internal interface for the data and other stuff I reckon. I forgot
This commit is contained in:
@@ -59,7 +59,7 @@ func NewLayoutTreeView() *LayoutTreeView {
|
||||
return view
|
||||
}
|
||||
|
||||
func (lt *LayoutTreeView) AddWindow(idx int16, win *cdashdisplay.UIWindow) error {
|
||||
func (lt *LayoutTreeView) AddWindow(win *cdashdisplay.DesktopUIWindow) error {
|
||||
root := lt.Tree.GetRoot()
|
||||
if root == nil {
|
||||
return fmt.Errorf("unable to get root of treeview")
|
||||
@@ -67,8 +67,8 @@ func (lt *LayoutTreeView) AddWindow(idx int16, win *cdashdisplay.UIWindow) error
|
||||
|
||||
// Create this new node
|
||||
newWindow := tview.NewTreeNode(
|
||||
windowInfoPageTitle(idx, win.Title.String()),
|
||||
).SetReference(idx)
|
||||
windowInfoPageTitle(win.UIData.IDX, win.Title.String()),
|
||||
).SetReference(win.UIData.IDX)
|
||||
|
||||
root.AddChild(newWindow)
|
||||
|
||||
@@ -126,14 +126,16 @@ func NewLayoutToolView() *LayoutToolView {
|
||||
return view
|
||||
}
|
||||
|
||||
func (ltv *LayoutToolView) WindowCreatedSuccessfuly(idx int16, win *cdashdisplay.UIWindow) error {
|
||||
func (ltv *LayoutToolView) WindowCreatedSuccessfuly(
|
||||
win *cdashdisplay.DesktopUIWindow,
|
||||
) error {
|
||||
updateWindowForm := NewWindowFormView(win)
|
||||
|
||||
// Update the pages ID
|
||||
ltv.LayoutActions.Pages.RemovePage(LayoutToolNewWindowID)
|
||||
AddAndShowPage(
|
||||
ltv.LayoutActions.Pages,
|
||||
windowInfoPageID(idx),
|
||||
windowInfoPageID(win.UIData.IDX),
|
||||
updateWindowForm.Form.Form,
|
||||
)
|
||||
|
||||
@@ -141,10 +143,10 @@ func (ltv *LayoutToolView) WindowCreatedSuccessfuly(idx int16, win *cdashdisplay
|
||||
ltv.LayoutActions.CreateWindowView = nil
|
||||
|
||||
// Add this form thing to the quick access map
|
||||
ltv.FormQuickAccess[idx] = updateWindowForm
|
||||
ltv.FormQuickAccess[win.UIData.IDX] = updateWindowForm
|
||||
|
||||
// Add it to the tree view
|
||||
return ltv.LayoutTree.AddWindow(idx, win)
|
||||
return ltv.LayoutTree.AddWindow(win)
|
||||
}
|
||||
|
||||
func (ltv *LayoutToolView) ShowCreateWindowForm() {
|
||||
@@ -178,7 +180,7 @@ func (ltv *LayoutToolView) DeleteWindowByNode(node *tview.TreeNode) {
|
||||
// Did we delete everything ???
|
||||
}
|
||||
|
||||
func (ltv *LayoutToolView) UpdateFormView(idx int16, win *cdashdisplay.UIWindow) {
|
||||
func (ltv *LayoutToolView) UpdateFormView(idx int16, win *cdashdisplay.DesktopUIWindow) {
|
||||
// Update the form view
|
||||
ltv.FormQuickAccess[idx].SetValues(win)
|
||||
|
||||
|
||||
@@ -4,22 +4,24 @@ import (
|
||||
"fmt"
|
||||
|
||||
"esdi/cdashdisplay"
|
||||
"esdi/telemetry"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type CDashDisplayWindowFormView struct {
|
||||
Form *tview.Form
|
||||
X *tview.InputField
|
||||
Y *tview.InputField
|
||||
Width *tview.InputField
|
||||
Height *tview.InputField
|
||||
Title *tview.InputField
|
||||
PreviewValue *tview.InputField
|
||||
ShowID *tview.Checkbox
|
||||
WinType *tview.DropDown
|
||||
TitleSize *tview.DropDown
|
||||
TextSize *tview.DropDown
|
||||
Form *tview.Form
|
||||
X *tview.InputField
|
||||
Y *tview.InputField
|
||||
Width *tview.InputField
|
||||
Height *tview.InputField
|
||||
Title *tview.InputField
|
||||
PreviewValue *tview.InputField
|
||||
ShowID *tview.Checkbox
|
||||
WinType *tview.DropDown
|
||||
TitleSize *tview.DropDown
|
||||
TextSize *tview.DropDown
|
||||
TelemetryField *tview.DropDown
|
||||
}
|
||||
|
||||
func NewCDashDisplayWindowFormView() *CDashDisplayWindowFormView {
|
||||
@@ -35,6 +37,7 @@ func NewCDashDisplayWindowFormView() *CDashDisplayWindowFormView {
|
||||
view.WinType = tview.NewDropDown().SetLabel("type").
|
||||
SetOptions([]string{"string", "bar"}, func(s string, id int) {}).
|
||||
SetCurrentOption(0)
|
||||
|
||||
view.TitleSize = tview.NewDropDown().SetLabel("Title Size").SetCurrentOption(0)
|
||||
for k := range 20 {
|
||||
view.TitleSize.AddOption(fmt.Sprintf("%d", k+1), blankDropdownOptionCallback)
|
||||
@@ -47,6 +50,12 @@ func NewCDashDisplayWindowFormView() *CDashDisplayWindowFormView {
|
||||
}
|
||||
view.TextSize.SetCurrentOption(0)
|
||||
|
||||
view.TelemetryField = tview.NewDropDown().SetLabel("Telemetry Field")
|
||||
for _, fieldName := range telemetry.FieldNames {
|
||||
view.TelemetryField.AddOption(fieldName, blankDropdownOptionCallback)
|
||||
}
|
||||
view.TelemetryField.SetCurrentOption(0)
|
||||
|
||||
view.Form = tview.NewForm().
|
||||
AddFormItem(view.X).
|
||||
AddFormItem(view.Y).
|
||||
@@ -87,13 +96,16 @@ func NewCreateWindowFormView() *CreateWindowFormView {
|
||||
|
||||
type WindowFormView struct {
|
||||
Form *CDashDisplayWindowFormView
|
||||
WinID int16
|
||||
UpdateBtn *tview.Button
|
||||
}
|
||||
|
||||
func NewWindowFormView(win *cdashdisplay.UIWindow) *WindowFormView {
|
||||
func NewWindowFormView(win *cdashdisplay.DesktopUIWindow) *WindowFormView {
|
||||
view := &WindowFormView{
|
||||
Form: NewCDashDisplayWindowFormView(),
|
||||
Form: NewCDashDisplayWindowFormView(),
|
||||
WinID: win.UIData.IDX,
|
||||
}
|
||||
view.Form.Form.SetTitle(windowEditFormTitle(win.UIData.IDX, win.Title.String()))
|
||||
|
||||
view.UpdateBtn = tview.NewButton("Update")
|
||||
// Need to inject the button functionality later
|
||||
@@ -106,7 +118,7 @@ func NewWindowFormView(win *cdashdisplay.UIWindow) *WindowFormView {
|
||||
return view
|
||||
}
|
||||
|
||||
func (fv *WindowFormView) SetValues(win *cdashdisplay.UIWindow) {
|
||||
func (fv *WindowFormView) SetValues(win *cdashdisplay.DesktopUIWindow) {
|
||||
fv.Form.X.SetText(fmt.Sprintf("%d", win.Dims.X0))
|
||||
fv.Form.Y.SetText(fmt.Sprintf("%d", win.Dims.Y0))
|
||||
fv.Form.Width.SetText(fmt.Sprintf("%d", win.Dims.Width))
|
||||
@@ -117,6 +129,12 @@ func (fv *WindowFormView) SetValues(win *cdashdisplay.UIWindow) {
|
||||
fv.Form.WinType.SetCurrentOption(0) // NOTE: this needs to set the correct option
|
||||
fv.Form.TitleSize.SetCurrentOption(int(win.Decor.TitleSize))
|
||||
fv.Form.TextSize.SetCurrentOption(int(win.Decor.TextSize))
|
||||
|
||||
telemFieldID, ok := telemetry.GetFieldID(win.UIData.TelemetryField)
|
||||
if !ok {
|
||||
telemFieldID = 0
|
||||
}
|
||||
fv.Form.TelemetryField.SetCurrentOption(int(telemFieldID))
|
||||
}
|
||||
|
||||
func windowInfoPageID(idx int16) string {
|
||||
@@ -126,3 +144,7 @@ func windowInfoPageID(idx int16) string {
|
||||
func windowInfoPageTitle(idx int16, title string) string {
|
||||
return fmt.Sprintf("%s [%02d]", title, idx)
|
||||
}
|
||||
|
||||
func windowEditFormTitle(idx int16, title string) string {
|
||||
return fmt.Sprintf("[%2d] %s", idx, title)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user