From 7eca9f5d8bf443443a630217eaced8e49f1c029b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 14 Jan 2024 02:23:15 -0600 Subject: [PATCH] pad() code cleanup Signed-off-by: Jeff Carr --- andlabs/action.go | 70 ++++++++--------------------------------------- 1 file changed, 12 insertions(+), 58 deletions(-) diff --git a/andlabs/action.go b/andlabs/action.go index 0e4791d..e9b5c04 100644 --- a/andlabs/action.go +++ b/andlabs/action.go @@ -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: