added the wintype option to the form so more rich layouts can be created

This commit is contained in:
2026-03-13 17:20:13 +00:00
parent 6b7c09c314
commit bbc62560f3
4 changed files with 115 additions and 40 deletions
+6 -1
View File
@@ -9,9 +9,14 @@ const (
) )
const ( const (
WinTypeString uint8 = 0 WinTypeBASE uint8 = iota
WinTypeBAR
WinTypeSTRING
WinTypeTABLE
) )
var WinTYPES = []string{"BASE", "BAR", "STRING", "TABLE"}
type UIDimensions struct { type UIDimensions struct {
X0 uint16 `yaml:"X0"` X0 uint16 `yaml:"X0"`
Y0 uint16 `yaml:"Y0"` Y0 uint16 `yaml:"Y0"`
+90 -18
View File
@@ -2,23 +2,23 @@ Windows:
1: 1:
uiwindow: uiwindow:
Dims: Dims:
X0: 200 X0: 142
Y0: 45 Y0: 19
Width: 151 Width: 500
Height: 70 Height: 20
Decor: Decor:
BGColour: 4161 BGColour: 4161
FGColour: 65535 FGColour: 65535
TitleColour: 65535 TitleColour: 65535
BorderColour: 63488 BorderColour: 63488
TitleSize: 2 TitleSize: 1
TextSize: 6 TextSize: 2
HasBorder: 1 HasBorder: 1
Padding: 0 Padding: 0
Opts: Opts:
ShowID: 0 ShowID: 0
WinType: 0 WinType: 1
PreviewValue: "4356" PreviewValue: "5678"
Title: TACHO Title: TACHO
uidata: uidata:
WID: 1 WID: 1
@@ -26,9 +26,9 @@ Windows:
2: 2:
uiwindow: uiwindow:
Dims: Dims:
X0: 50 X0: 331
Y0: 46 Y0: 190
Width: 117 Width: 116
Height: 70 Height: 70
Decor: Decor:
BGColour: 4161 BGColour: 4161
@@ -41,7 +41,7 @@ Windows:
Padding: 0 Padding: 0
Opts: Opts:
ShowID: 0 ShowID: 0
WinType: 0 WinType: 2
PreviewValue: "234" PreviewValue: "234"
Title: SPEEDO Title: SPEEDO
uidata: uidata:
@@ -50,24 +50,96 @@ Windows:
3: 3:
uiwindow: uiwindow:
Dims: Dims:
X0: 390 X0: 354
Y0: 45 Y0: 71
Width: 50 Width: 74
Height: 71 Height: 111
Decor: Decor:
BGColour: 4161 BGColour: 4161
FGColour: 65535 FGColour: 65535
TitleColour: 65535 TitleColour: 65535
BorderColour: 63488 BorderColour: 63488
TitleSize: 2 TitleSize: 2
TextSize: 6 TextSize: 12
HasBorder: 1 HasBorder: 1
Padding: 0 Padding: 0
Opts: Opts:
ShowID: 0 ShowID: 0
WinType: 0 WinType: 2
PreviewValue: R PreviewValue: R
Title: Box Title: Box
uidata: uidata:
WID: 3 WID: 3
TelemetryField: Gear TelemetryField: Gear
4:
uiwindow:
Dims:
X0: 9
Y0: 413
Width: 57
Height: 57
Decor:
BGColour: 4161
FGColour: 65535
TitleColour: 65535
BorderColour: 63488
TitleSize: 2
TextSize: 4
HasBorder: 1
Padding: 0
Opts:
ShowID: 0
WinType: 2
PreviewValue: "12"
Title: ABS
uidata:
WID: 4
TelemetryField: Emtpy
5:
uiwindow:
Dims:
X0: 74
Y0: 413
Width: 57
Height: 57
Decor:
BGColour: 4161
FGColour: 65535
TitleColour: 65535
BorderColour: 63488
TitleSize: 2
TextSize: 4
HasBorder: 1
Padding: 0
Opts:
ShowID: 0
WinType: 2
PreviewValue: "12"
Title: TC
uidata:
WID: 5
TelemetryField: Emtpy
6:
uiwindow:
Dims:
X0: 140
Y0: 412
Width: 57
Height: 57
Decor:
BGColour: 4161
FGColour: 65535
TitleColour: 65535
BorderColour: 63488
TitleSize: 2
TextSize: 4
HasBorder: 1
Padding: 0
Opts:
ShowID: 0
WinType: 2
PreviewValue: "6"
Title: Thr
uidata:
WID: 6
TelemetryField: Emtpy
+15 -17
View File
@@ -3,7 +3,6 @@ package controllers
import ( import (
"esdi/cdashdisplay" "esdi/cdashdisplay"
helper "esdi/helpers" helper "esdi/helpers"
"esdi/telemetry"
"esdi/tui/internal/services" "esdi/tui/internal/services"
"esdi/tui/internal/views" "esdi/tui/internal/views"
"fmt" "fmt"
@@ -123,6 +122,11 @@ func (lc *LayoutController) parseWindowFormData(
return nil, err return nil, err
} }
winTypeInputID, _ := form.WinType.GetCurrentOption()
if winTypeInputID == -1 {
return nil, fmt.Errorf("no option selected for win type")
}
titleSizeInputID, titleSizeInput := form.TitleSize.GetCurrentOption() titleSizeInputID, titleSizeInput := form.TitleSize.GetCurrentOption()
if titleSizeInputID == -1 { if titleSizeInputID == -1 {
return nil, fmt.Errorf("no option selected for title size") return nil, fmt.Errorf("no option selected for title size")
@@ -163,7 +167,7 @@ func (lc *LayoutController) parseWindowFormData(
Height: uint16(heightValue), Height: uint16(heightValue),
}, },
Opts: cdashdisplay.UIWindowOpts{ Opts: cdashdisplay.UIWindowOpts{
WinType: cdashdisplay.WinTypeString, // NOTE: values aren't implemented yet WinType: uint8(winTypeInputID),
ShowID: showIDValue, ShowID: showIDValue,
PreviewValue: helper.B32(form.PreviewValue.GetText()), PreviewValue: helper.B32(form.PreviewValue.GetText()),
}, },
@@ -192,14 +196,11 @@ func (lc *LayoutController) createWindow() {
return return
} }
lc.Messages <- fmt.Sprintf("pre update w address: %p\n", window)
window, err = lc.DevService.CreateWindow(window) window, err = lc.DevService.CreateWindow(window)
if err != nil { if err != nil {
lc.Messages <- "failed to create window\n" lc.Messages <- "failed to create window\n"
return return
} }
lc.Messages <- fmt.Sprintf("post update w address: %p\n", window)
lc.Messages <- fmt.Sprintf("%+v\n", window)
err = lc.updateFormView(window) err = lc.updateFormView(window)
if err != nil { if err != nil {
@@ -213,16 +214,8 @@ func (lc *LayoutController) createWindow() {
// the buttons for that purpuse // the buttons for that purpuse
func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) error { func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) error {
// OnSuccess we update our form to be an existing window form // OnSuccess we update our form to be an existing window form
lc.Messages <- fmt.Sprintf("Setting up window:\n%+v\n", win) lc.Messages <- fmt.Sprintf("Setting up window:\n%+v\n", win)
telemFieldID, ok := telemetry.GetFieldID(win.UIData.TelemetryField)
if !ok {
telemFieldID = 1000
}
lc.Messages <- fmt.Sprintf("field id for: %s is %d\n", win.UIData.TelemetryField, telemFieldID)
err := lc.LayoutToolView.WindowCreatedSuccessfuly(win) err := lc.LayoutToolView.WindowCreatedSuccessfuly(win)
if err != nil { if err != nil {
return err return err
@@ -230,16 +223,15 @@ func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) er
// Set the update window button behaviour // Set the update window button behaviour
formView := lc.LayoutToolView.FormQuickAccess[win.UIData.IDX] formView := lc.LayoutToolView.FormQuickAccess[win.UIData.IDX]
lc.Messages <- fmt.Sprintf("QA FORM: %+v\n", lc.LayoutToolView.FormQuickAccess)
err = SetFormButtonCallback(formView.Form.Form, "Update", func() { err = SetFormButtonCallback(formView.Form.Form, "Update", func() {
lc.Messages <- "pressed update form button\n" lc.Messages <- "pressed update form button\n"
window, err := lc.parseWindowFormData(*formView.Form) window, err := lc.parseWindowFormData(*formView.Form)
if err != nil { if err != nil {
lc.Messages <- "failed to parse window form data " + err.Error() + "\n" // lc.Messages <- "failed to parse window form data " + err.Error() + "\n"
return return
} }
lc.Messages <- fmt.Sprintf("window data in form: %v\n", window) // lc.Messages <- fmt.Sprintf("window data in form: %v\n", window)
window.UIData.IDX = formView.WinID window.UIData.IDX = formView.WinID
@@ -259,7 +251,7 @@ func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) er
return ev return ev
}) })
lc.App.SetFocus(formView.Form.Form) lc.App.SetFocus(lc.LayoutToolView.LayoutTree.Tree)
return nil return nil
} }
@@ -313,12 +305,18 @@ func (lc *LayoutController) updateWindowAction(win *cdashdisplay.DesktopUIWindow
} }
func (lc *LayoutController) displayLoadedLayouts() { func (lc *LayoutController) displayLoadedLayouts() {
lc.Logger.Debug("We want to view our layout!")
for _, w := range lc.DevService.CDash.State.Layout.Windows { for _, w := range lc.DevService.CDash.State.Layout.Windows {
lc.Logger.Debug(fmt.Sprintf("updatinf form view for a layout: %+v", w))
err := lc.updateFormView(w) err := lc.updateFormView(w)
if err != nil { if err != nil {
lc.Logger.Debug("an error happened viewing our layout")
lc.Messages <- "failed to add window to list" lc.Messages <- "failed to add window to list"
} }
} }
lc.Logger.Debug("If we don't get here it means we somehow hanged the program earlier")
} }
func (lc *LayoutController) getCurrentTreeNodeModel() (*tview.TreeNode, int16, error) { func (lc *LayoutController) getCurrentTreeNodeModel() (*tview.TreeNode, int16, error) {
+4 -4
View File
@@ -34,9 +34,9 @@ func NewCDashDisplayWindowFormView() *CDashDisplayWindowFormView {
view.Title = tview.NewInputField().SetLabel("title") view.Title = tview.NewInputField().SetLabel("title")
view.PreviewValue = tview.NewInputField().SetLabel("preview value") view.PreviewValue = tview.NewInputField().SetLabel("preview value")
view.ShowID = tview.NewCheckbox().SetLabel("show ID").SetChecked(true) view.ShowID = tview.NewCheckbox().SetLabel("show ID").SetChecked(true)
view.WinType = tview.NewDropDown().SetLabel("type"). view.WinType = tview.NewDropDown().SetLabel("Win Type").
SetOptions([]string{"string", "bar"}, func(s string, id int) {}). SetOptions(cdashdisplay.WinTYPES, func(s string, id int) {}).
SetCurrentOption(0) SetCurrentOption(int(cdashdisplay.WinTypeSTRING))
view.TitleSize = tview.NewDropDown().SetLabel("Title Size").SetCurrentOption(0) view.TitleSize = tview.NewDropDown().SetLabel("Title Size").SetCurrentOption(0)
for k := range 20 { for k := range 20 {
@@ -127,7 +127,7 @@ func (fv *WindowFormView) SetValues(win *cdashdisplay.DesktopUIWindow) {
fv.Form.Title.SetText(win.Title.String()) fv.Form.Title.SetText(win.Title.String())
fv.Form.PreviewValue.SetText(win.Opts.PreviewValue.String()) fv.Form.PreviewValue.SetText(win.Opts.PreviewValue.String())
fv.Form.ShowID.SetChecked(win.Opts.ShowID == 1) fv.Form.ShowID.SetChecked(win.Opts.ShowID == 1)
fv.Form.WinType.SetCurrentOption(0) // NOTE: this needs to set the correct option fv.Form.WinType.SetCurrentOption(int(win.Opts.WinType)) // NOTE: this needs to set the correct option
fv.Form.TitleSize.SetCurrentOption(int(win.Decor.TitleSize)) fv.Form.TitleSize.SetCurrentOption(int(win.Decor.TitleSize))
fv.Form.TextSize.SetCurrentOption(int(win.Decor.TextSize)) fv.Form.TextSize.SetCurrentOption(int(win.Decor.TextSize))