From 3d104d5b4a61ca4d32956c771f8882a215574515 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 6 Feb 2025 21:25:51 -0600 Subject: [PATCH] dragging and window placement is still messed up --- color.go | 9 +++++++++ eventBindings.go | 5 ++++- place.go | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/color.go b/color.go index fb712ac..6861d45 100644 --- a/color.go +++ b/color.go @@ -99,6 +99,15 @@ var colorButton colorT = colorT{ name: "normal button", } +var colorButtonDense colorT = colorT{ + frame: none, + fg: none, + bg: gocui.ColorGreen, + selFg: none, + selBg: gocui.ColorWhite, + name: "normal button", +} + var colorDropdown colorT = colorT{ frame: gocui.ColorYellow, fg: none, diff --git a/eventBindings.go b/eventBindings.go index 16d5549..d51e061 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -141,7 +141,10 @@ func tabCycleWindows(g *gocui.Gui, v *gocui.View) error { return nil } tk.makeWindowActive() - tk.doWidgetClick(tk.gocuiSize.w0, tk.gocuiSize.h0) + w, h := g.MousePosition() + me.downW = w + me.downH = h + tk.doWindowClick() return nil } diff --git a/place.go b/place.go index 20d7759..4d6aad5 100644 --- a/place.go +++ b/place.go @@ -142,6 +142,13 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) { newH = newH - startH // tk.dumpWidget(fmt.Sprintf("PlaceGroup(%d,%d)", maxW, newH)) return maxW, newH + case widget.Button: + if tk.isWindowDense() && tk.isInGrid() { + tk.frame = false + tk.color = &colorButtonDense + } + tk.gocuiSetWH(startW, startH) + return tk.gocuiSize.Width(), tk.gocuiSize.Height() default: tk.gocuiSetWH(startW, startH) return tk.gocuiSize.Width(), tk.gocuiSize.Height() @@ -159,6 +166,16 @@ func (tk *guiWidget) isWindowDense() bool { return tk.parent.isWindowDense() } +func (tk *guiWidget) isInGrid() bool { + if tk.node.WidgetType == widget.Grid { + return true + } + if tk.parent == nil { + return true + } + return tk.parent.isInGrid() +} + func (w *guiWidget) placeGrid(startW int, startH int) (int, int) { // w.showWidgetPlacement("grid0:") if w.node.WidgetType != widget.Grid {