summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-26 00:07:09 -0500
committerJeff Carr <[email protected]>2023-04-26 00:07:09 -0500
commit4b9b381bcf02c212d72f55d4738943941e843250 (patch)
tree60932c0fe675d477357318eb3d2de5e2b3a5c09d
parent435b75b6e841ae981f6a98d2a0aaaafaedc2e170 (diff)
gocui: more spacing logic
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--grid.go4
-rw-r--r--redraw.go4
-rw-r--r--toolkit/andlabs/window.go2
-rw-r--r--toolkit/gocui/common.go22
-rw-r--r--toolkit/gocui/place.go7
-rw-r--r--toolkit/gocui/structs.go2
-rw-r--r--toolkit/widget.go10
-rw-r--r--window.go4
8 files changed, 29 insertions, 26 deletions
diff --git a/grid.go b/grid.go
index 0a6e0ce..4ece4d2 100644
--- a/grid.go
+++ b/grid.go
@@ -27,8 +27,8 @@ func (n *Node) NewGrid(name string, w int, h int) *Node {
a.Text = name
a.X = w
a.Y = h
- a.Width = w
- a.Height = h
+ // a.Width = w
+ // a.Height = h
newNode.X = w
newNode.Y = h
newNode.NextX = 1
diff --git a/redraw.go b/redraw.go
index 9eb3c86..dee535a 100644
--- a/redraw.go
+++ b/redraw.go
@@ -32,8 +32,8 @@ func (n *Node) redo(plug *aplug) {
a.WidgetId = n.id
// used for new Windows
- a.Width = n.Width
- a.Height = n.Height
+// a.Width = n.Width
+// a.Height = n.Height
// used for anything that needs a range
a.X = n.X
diff --git a/toolkit/andlabs/window.go b/toolkit/andlabs/window.go
index 34245d8..42a2baa 100644
--- a/toolkit/andlabs/window.go
+++ b/toolkit/andlabs/window.go
@@ -23,7 +23,7 @@ func newWindow(a toolkit.Action) {
newt.wId = a.WidgetId
// menubar bool is if the OS defined border on the window should be used
- win := ui.NewWindow(a.Name, a.Width, a.Height, menubar)
+ win := ui.NewWindow(a.Name, a.X, a.Y, menubar)
win.SetBorderless(canvas)
win.SetMargined(margin)
win.OnClosing(func(*ui.Window) bool {
diff --git a/toolkit/gocui/common.go b/toolkit/gocui/common.go
index 09c58f0..9f10e94 100644
--- a/toolkit/gocui/common.go
+++ b/toolkit/gocui/common.go
@@ -17,27 +17,27 @@ func makeWidget(a *toolkit.Action) *cuiWidget {
w.s = a.S
w.x = a.X
w.y = a.Y
- w.width = a.Width
- w.height = a.Height
+
t := len(w.text)
- w.realWidth = t + me.buttonPadding
- w.realHeight = me.DefaultHeight
- w.gocuiSize.width = t + me.buttonPadding
- w.gocuiSize.height = me.DefaultHeight
+ w.gocuiSize.width = t + me.PadW
+ w.gocuiSize.height = me.DefaultHeight + me.PadH
+
+ w.realWidth = w.gocuiSize.width
+ w.realHeight = w.gocuiSize.height
- w.widgetType = a.WidgetType
- w.id = a.WidgetId
- // set the name used by gocui to the id
- w.cuiName = strconv.Itoa(w.id)
// set the gocui view.Frame = true by default
w.frame = true
-
if (w.frame) {
w.realHeight += me.FramePadH
w.gocuiSize.height += me.FramePadH
}
+ w.widgetType = a.WidgetType
+ w.id = a.WidgetId
+ // set the name used by gocui to the id
+ w.cuiName = strconv.Itoa(w.id)
+
if w.widgetType == toolkit.Root {
log(logInfo, "setupWidget() FOUND ROOT w.id =", w.id, "w.parent", w.parent, "ParentId =", a.ParentId)
w.id = 0
diff --git a/toolkit/gocui/place.go b/toolkit/gocui/place.go
index 2ff791a..50e3b6f 100644
--- a/toolkit/gocui/place.go
+++ b/toolkit/gocui/place.go
@@ -48,13 +48,13 @@ func (w *cuiWidget) placeBox() {
w.showWidgetPlacement(logNow, "boxE()")
}
+/*
func (w *cuiWidget) getGroupWH() {
p := w.parent // the parent must be a group widget
// update parent gocuiSize
- p.realWidth = 0
- p.realHeight = 0
- p.realHeight += me.buttonPadding // pad height for the group label
+ // p.realWidth =
+ // p.realHeight += me.DefaultHeight + me.PadH + me.FramePadH
for _, child := range p.children {
p.realWidth += child.realWidth
p.realHeight += child.realHeight
@@ -71,6 +71,7 @@ func (w *cuiWidget) getGroupWH() {
}
return
}
+*/
func (w *cuiWidget) placeWidgets() {
if (w == nil) {
diff --git a/toolkit/gocui/structs.go b/toolkit/gocui/structs.go
index 78ca36d..b3c780f 100644
--- a/toolkit/gocui/structs.go
+++ b/toolkit/gocui/structs.go
@@ -69,7 +69,7 @@ type config struct {
// horizontalPadding int
// groupPadding int `default:"6" dense:"2"` // this is supposed to be how far to indent to the left
- buttonPadding int `default:"4" dense:"3"` // if 3, buttons slightly overlap
+ // buttonPadding int `default:"4" dense:"3"` // if 3, buttons slightly overlap
}
var (
diff --git a/toolkit/widget.go b/toolkit/widget.go
index 1a5a45f..51fe8b5 100644
--- a/toolkit/widget.go
+++ b/toolkit/widget.go
@@ -34,14 +34,16 @@ type Action struct {
A any // switch to this or deprecate this? pros/cons?
- // This GUI is intended for simple things
- // We are not laying out PDF's here
// This is used for things like a slider(0,100)
- Width int
- Height int
X int
Y int
+ // This GUI is intended for simple things
+ // Is having an option like 640x480 really a good idea?
+ // TODO: remove Width & Height measured in pixels?
+// Width int
+// Height int
+
// Put space around elements to improve look & feel
Margin bool
diff --git a/window.go b/window.go
index 558e782..ebf4a85 100644
--- a/window.go
+++ b/window.go
@@ -17,8 +17,8 @@ func (n *Node) NewWindow(title string) *Node {
var a toolkit.Action
a.ActionType = toolkit.Add
- a.Width = Config.Width
- a.Height = Config.Height
+ a.X = Config.Width
+ a.Y = Config.Height
a.Name = title
a.Text = title
newaction(&a, newNode, n)