pad() code cleanup

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-14 02:23:15 -06:00
parent 31dbec2b56
commit 7eca9f5d8b
1 changed files with 12 additions and 58 deletions

View File

@ -45,7 +45,7 @@ func (n *node) enable(b bool) {
}
}
func (n *node) pad(at widget.ActionType) {
func (n *node) pad(b bool) {
log.Log(INFO, "pad() on WidgetId =", n.WidgetId)
t := n.tk
@ -56,64 +56,18 @@ func (n *node) pad(at widget.ActionType) {
switch n.WidgetType {
case widget.Group:
switch at {
case widget.Margin:
t.uiGroup.SetMargined(true)
case widget.Unmargin:
t.uiGroup.SetMargined(false)
case widget.Pad:
t.uiGroup.SetMargined(true)
case widget.Unpad:
t.uiGroup.SetMargined(false)
}
t.uiGroup.SetMargined(b)
case widget.Tab:
switch at {
case widget.Margin:
tabSetMargined(t.uiTab, true)
case widget.Unmargin:
tabSetMargined(t.uiTab, false)
case widget.Pad:
tabSetMargined(t.uiTab, true)
case widget.Unpad:
tabSetMargined(t.uiTab, false)
}
tabSetMargined(t.uiTab, b)
case widget.Window:
switch at {
case widget.Margin:
t.uiWindow.SetMargined(true)
case widget.Unmargin:
t.uiWindow.SetMargined(false)
case widget.Pad:
t.uiWindow.SetBorderless(false)
case widget.Unpad:
t.uiWindow.SetBorderless(true)
}
t.uiWindow.SetMargined(b)
t.uiWindow.SetBorderless(b)
case widget.Grid:
switch at {
case widget.Margin:
t.uiGrid.SetPadded(true)
case widget.Unmargin:
t.uiGrid.SetPadded(false)
case widget.Pad:
t.uiGrid.SetPadded(true)
case widget.Unpad:
t.uiGrid.SetPadded(false)
}
t.uiGrid.SetPadded(b)
case widget.Box:
switch at {
case widget.Margin:
t.uiBox.SetPadded(true)
case widget.Unmargin:
t.uiBox.SetPadded(false)
case widget.Pad:
t.uiBox.SetPadded(true)
case widget.Unpad:
t.uiBox.SetPadded(false)
}
case widget.Textbox:
log.Log(ERROR, "TODO: implement ActionType =", at)
t.uiBox.SetPadded(b)
default:
log.Log(ERROR, "TODO: implement pad() for", at)
log.Log(ERROR, "TODO: implement pad() for", n.WidgetType, n.progname)
}
}
@ -247,13 +201,13 @@ func rawAction(a *widget.Action) {
case widget.AddText:
n.addText(a)
case widget.Margin:
n.pad(widget.Unmargin)
n.pad(true)
case widget.Unmargin:
n.pad(widget.Margin)
n.pad(false)
case widget.Pad:
n.pad(widget.Pad)
n.pad(true)
case widget.Unpad:
n.pad(widget.Unpad)
n.pad(false)
case widget.Delete:
n.Delete()
case widget.Move: