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) log.Log(INFO, "pad() on WidgetId =", n.WidgetId)
t := n.tk t := n.tk
@ -56,64 +56,18 @@ func (n *node) pad(at widget.ActionType) {
switch n.WidgetType { switch n.WidgetType {
case widget.Group: case widget.Group:
switch at { t.uiGroup.SetMargined(b)
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)
}
case widget.Tab: case widget.Tab:
switch at { tabSetMargined(t.uiTab, b)
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)
}
case widget.Window: case widget.Window:
switch at { t.uiWindow.SetMargined(b)
case widget.Margin: t.uiWindow.SetBorderless(b)
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)
}
case widget.Grid: case widget.Grid:
switch at { t.uiGrid.SetPadded(b)
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)
}
case widget.Box: case widget.Box:
switch at { t.uiBox.SetPadded(b)
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)
default: 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: case widget.AddText:
n.addText(a) n.addText(a)
case widget.Margin: case widget.Margin:
n.pad(widget.Unmargin) n.pad(true)
case widget.Unmargin: case widget.Unmargin:
n.pad(widget.Margin) n.pad(false)
case widget.Pad: case widget.Pad:
n.pad(widget.Pad) n.pad(true)
case widget.Unpad: case widget.Unpad:
n.pad(widget.Unpad) n.pad(false)
case widget.Delete: case widget.Delete:
n.Delete() n.Delete()
case widget.Move: case widget.Move: