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 (
WinTypeString uint8 = 0
WinTypeBASE uint8 = iota
WinTypeBAR
WinTypeSTRING
WinTypeTABLE
)
var WinTYPES = []string{"BASE", "BAR", "STRING", "TABLE"}
type UIDimensions struct {
X0 uint16 `yaml:"X0"`
Y0 uint16 `yaml:"Y0"`
+90 -18
View File
@@ -2,23 +2,23 @@ Windows:
1:
uiwindow:
Dims:
X0: 200
Y0: 45
Width: 151
Height: 70
X0: 142
Y0: 19
Width: 500
Height: 20
Decor:
BGColour: 4161
FGColour: 65535
TitleColour: 65535
BorderColour: 63488
TitleSize: 2
TextSize: 6
TitleSize: 1
TextSize: 2
HasBorder: 1
Padding: 0
Opts:
ShowID: 0
WinType: 0
PreviewValue: "4356"
WinType: 1
PreviewValue: "5678"
Title: TACHO
uidata:
WID: 1
@@ -26,9 +26,9 @@ Windows:
2:
uiwindow:
Dims:
X0: 50
Y0: 46
Width: 117
X0: 331
Y0: 190
Width: 116
Height: 70
Decor:
BGColour: 4161
@@ -41,7 +41,7 @@ Windows:
Padding: 0
Opts:
ShowID: 0
WinType: 0
WinType: 2
PreviewValue: "234"
Title: SPEEDO
uidata:
@@ -50,24 +50,96 @@ Windows:
3:
uiwindow:
Dims:
X0: 390
Y0: 45
Width: 50
Height: 71
X0: 354
Y0: 71
Width: 74
Height: 111
Decor:
BGColour: 4161
FGColour: 65535
TitleColour: 65535
BorderColour: 63488
TitleSize: 2
TextSize: 6
TextSize: 12
HasBorder: 1
Padding: 0
Opts:
ShowID: 0
WinType: 0
WinType: 2
PreviewValue: R
Title: Box
uidata:
WID: 3
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 (
"esdi/cdashdisplay"
helper "esdi/helpers"
"esdi/telemetry"
"esdi/tui/internal/services"
"esdi/tui/internal/views"
"fmt"
@@ -123,6 +122,11 @@ func (lc *LayoutController) parseWindowFormData(
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()
if titleSizeInputID == -1 {
return nil, fmt.Errorf("no option selected for title size")
@@ -163,7 +167,7 @@ func (lc *LayoutController) parseWindowFormData(
Height: uint16(heightValue),
},
Opts: cdashdisplay.UIWindowOpts{
WinType: cdashdisplay.WinTypeString, // NOTE: values aren't implemented yet
WinType: uint8(winTypeInputID),
ShowID: showIDValue,
PreviewValue: helper.B32(form.PreviewValue.GetText()),
},
@@ -192,14 +196,11 @@ func (lc *LayoutController) createWindow() {
return
}
lc.Messages <- fmt.Sprintf("pre update w address: %p\n", window)
window, err = lc.DevService.CreateWindow(window)
if err != nil {
lc.Messages <- "failed to create window\n"
return
}
lc.Messages <- fmt.Sprintf("post update w address: %p\n", window)
lc.Messages <- fmt.Sprintf("%+v\n", window)
err = lc.updateFormView(window)
if err != nil {
@@ -213,16 +214,8 @@ func (lc *LayoutController) createWindow() {
// the buttons for that purpuse
func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) error {
// OnSuccess we update our form to be an existing window form
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)
if err != nil {
return err
@@ -230,16 +223,15 @@ func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) er
// Set the update window button behaviour
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() {
lc.Messages <- "pressed update form button\n"
window, err := lc.parseWindowFormData(*formView.Form)
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
}
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
@@ -259,7 +251,7 @@ func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) er
return ev
})
lc.App.SetFocus(formView.Form.Form)
lc.App.SetFocus(lc.LayoutToolView.LayoutTree.Tree)
return nil
}
@@ -313,12 +305,18 @@ func (lc *LayoutController) updateWindowAction(win *cdashdisplay.DesktopUIWindow
}
func (lc *LayoutController) displayLoadedLayouts() {
lc.Logger.Debug("We want to view our layout!")
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)
if err != nil {
lc.Logger.Debug("an error happened viewing our layout")
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) {
+4 -4
View File
@@ -34,9 +34,9 @@ func NewCDashDisplayWindowFormView() *CDashDisplayWindowFormView {
view.Title = tview.NewInputField().SetLabel("title")
view.PreviewValue = tview.NewInputField().SetLabel("preview value")
view.ShowID = tview.NewCheckbox().SetLabel("show ID").SetChecked(true)
view.WinType = tview.NewDropDown().SetLabel("type").
SetOptions([]string{"string", "bar"}, func(s string, id int) {}).
SetCurrentOption(0)
view.WinType = tview.NewDropDown().SetLabel("Win Type").
SetOptions(cdashdisplay.WinTYPES, func(s string, id int) {}).
SetCurrentOption(int(cdashdisplay.WinTypeSTRING))
view.TitleSize = tview.NewDropDown().SetLabel("Title Size").SetCurrentOption(0)
for k := range 20 {
@@ -127,7 +127,7 @@ func (fv *WindowFormView) SetValues(win *cdashdisplay.DesktopUIWindow) {
fv.Form.Title.SetText(win.Title.String())
fv.Form.PreviewValue.SetText(win.Opts.PreviewValue.String())
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.TextSize.SetCurrentOption(int(win.Decor.TextSize))