buttons in dense mode line up correctly

This commit is contained in:
Jeff Carr 2025-02-08 13:57:31 -06:00
parent c4f9bac85e
commit 5827b9ace2
3 changed files with 26 additions and 4 deletions

View File

@ -99,10 +99,10 @@ func (tk *guiWidget) setColorButtonDense() {
return return
} }
tk.color.frame = gocui.AttrNone tk.color.frame = gocui.AttrNone
tk.color.fg = gocui.ColorBlue tk.color.fg = gocui.ColorWhite
tk.color.bg = gocui.AttrNone tk.color.bg = gocui.ColorBlue
tk.color.selFg = gocui.ColorWhite tk.color.selFg = gocui.ColorBlue
tk.color.selBg = gocui.ColorBlue tk.color.selBg = gocui.AttrNone
} }
func (tk *guiWidget) setColorButton() { func (tk *guiWidget) setColorButton() {

View File

@ -148,6 +148,9 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
tk.color = nil tk.color = nil
tk.defaultColor = nil tk.defaultColor = nil
tk.setColorButtonDense() tk.setColorButtonDense()
// if tk.full.Height() > 0 {
tk.full.h1 = tk.full.h0
// }
} }
tk.gocuiSetWH(startW, startH) tk.gocuiSetWH(startW, startH)
return tk.gocuiSize.Width(), tk.gocuiSize.Height() return tk.gocuiSize.Width(), tk.gocuiSize.Height()

19
size.go
View File

@ -79,6 +79,11 @@ func (tk *guiWidget) Size() (int, int) {
return len(tk.String()) + 10, 3 // TODO: compute this based on 'window dense' return len(tk.String()) + 10, 3 // TODO: compute this based on 'window dense'
case widget.Checkbox: case widget.Checkbox:
return len(tk.String()) + 2, 3 // TODO: compute this based on 'window dense' return len(tk.String()) + 2, 3 // TODO: compute this based on 'window dense'
case widget.Button:
if tk.isWindowDense() {
return len(tk.String()) + 2, 0
}
return len(tk.String()) + 2, 3 // TODO: compute this based on 'window dense'
} }
if tk.isFake { if tk.isFake {
return 0, 0 return 0, 0
@ -249,6 +254,14 @@ func (tk *guiWidget) setFullSize() bool {
tk.full.h1 = r.h1 tk.full.h1 = r.h1
changed = true changed = true
} }
if tk.node.WidgetType == widget.Button {
tk.full.h1 = tk.full.h0 + 1
}
if tk.isWindowDense() && tk.isInGrid() {
// if tk.full.Height() > 0 {
tk.full.h1 = tk.full.h0
// }
}
if changed { if changed {
tk.dumpWidget(fmt.Sprintf("setFullSize(changed)")) tk.dumpWidget(fmt.Sprintf("setFullSize(changed)"))
} }
@ -310,6 +323,12 @@ func (tk *guiWidget) buttonFullSize() rectType {
tk.full.h0 = r.h0 tk.full.h0 = r.h0
tk.full.h1 = r.h1 tk.full.h1 = r.h1
// total hack. fix this somewhere eventually correctly
if tk.isWindowDense() { // total hack. fix this somewhere eventually correctly
tk.full.h0 += 1 // total hack. fix this somewhere eventually correctly
tk.full.h1 = tk.full.h0 // total hack. fix this somewhere eventually correctly
}
return r return r
} }