From aaebb4c5d993aafe8b290055296c9aaa1fb1ea93 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 25 Mar 2025 09:31:40 -0500 Subject: [PATCH] table headers identified. ready for sorting --- color.go | 21 +++++++++++++++++++++ eventMouseClick.go | 8 ++++++++ widgetAdd.go | 20 +++++++++++--------- widgetDraw.go | 7 +------ 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/color.go b/color.go index a27d7fe..0df88e8 100644 --- a/color.go +++ b/color.go @@ -186,6 +186,27 @@ func (tk *guiWidget) setColorLabel() { tk.updateColor() } +func (tk *guiWidget) setColorLabelTable() { + if tk.color == nil { + tk.color = new(colorT) + } + if me.dark { + tk.color.frame = gocui.AttrNone + tk.color.fg = gocui.ColorWhite + tk.color.bg = gocui.ColorBlack + tk.color.selFg = gocui.ColorWhite + tk.color.selBg = gocui.AttrNone + } else { + tk.color.frame = gocui.AttrNone + tk.color.fg = gocui.ColorBlack + tk.color.bg = gocui.AttrNone + tk.color.selFg = gocui.AttrNone + tk.color.selBg = gocui.ColorGreen + } + + tk.updateColor() +} + func (tk *guiWidget) setColorButtonDense() { if tk.color == nil { tk.color = new(colorT) diff --git a/eventMouseClick.go b/eventMouseClick.go index 0dfa7e4..0d46216 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -109,6 +109,14 @@ func doMouseClick(w int, h int) { case widget.Textbox: tk.prepTextbox() return + case widget.Label: + if tk.node.InTable() { + if tk.node.State.AtH == 0 { + log.Log(NOW, "todo: sort by column here") + tk.dumpWidget("sort") + } + } + return default: // TODO: enable the GUI debugger in gocui // tk.dumpWidget("undef click()") // enable this to debug widget clicks diff --git a/widgetAdd.go b/widgetAdd.go index 6bb459b..0686c86 100644 --- a/widgetAdd.go +++ b/widgetAdd.go @@ -41,17 +41,14 @@ func addWidget(n *tree.Node) { switch n.WidgetType { case widget.Root: log.Log(INFO, "setStartWH() rootNode w.id =", n.WidgetId, "w.name", n.String()) - // tk.color = &colorRoot setFake(n) return case widget.Flag: - // tk.color = &colorFlag setFake(n) return case widget.Window: tk.frame = false tk.labelN = tk.GetText() + " X" - // tk.setColor(&colorWindow) me.newWindowTrigger <- tk redoWindows(0, 0) return @@ -62,7 +59,6 @@ func addWidget(n *tree.Node) { tk.isFake = true return case widget.Tab: - // tk.color = &colorTab return case widget.Button: tk.setColorButton() @@ -81,20 +77,16 @@ func addWidget(n *tree.Node) { case widget.Textbox: n.State.Label = "" tk.labelN = " " - // tk.color = &colorDropdown tk.setColorInput() return case widget.Combobox: - // tk.color = &colorCombobox tk.setColorInput() return case widget.Box: - // tk.color = &colorBox tk.isFake = true setFake(n) return case widget.Grid: - // tk.color = &colorGrid tk.isFake = true setFake(n) return @@ -103,7 +95,17 @@ func addWidget(n *tree.Node) { tk.frame = false return case widget.Label: - tk.setColorLabel() + if tk.node.InTable() { + if tk.node.State.AtH == 0 { + // this is the table header + tk.setColorLabelTable() + } else { + // todo: highlight the whole table row + tk.setColorLabel() + } + } else { + tk.setColorLabel() + } tk.frame = false return default: diff --git a/widgetDraw.go b/widgetDraw.go index d678678..6da9fcd 100644 --- a/widgetDraw.go +++ b/widgetDraw.go @@ -223,17 +223,12 @@ func (tk *guiWidget) drawView() { log.Log(INFO, "drawView() END") } +// redraw the widget tree starting at this location func (w *guiWidget) DrawAt(offsetW, offsetH int) { - // w.setColor(&colorActiveW) w.placeWidgets(offsetW, offsetH) // compute the sizes & places for each widget // w.dumpWidget(fmt.Sprintf("DrawAt(%d,%d)", offsetW, offsetH)) } -func (w *guiWidget) simpleDrawAt(offsetW, offsetH int) { - // w.setColor(&colorActiveW) - w.dumpWidget("simpleDrawAt()") -} - // display the widgets in the binary tree func (w *guiWidget) drawTree(draw bool) { if w == nil {