gocui: more spacing logic

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-26 00:07:09 -05:00
parent 97079e936b
commit d8a1c53757
8 changed files with 31 additions and 28 deletions

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -17,26 +17,26 @@ 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
// 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)
// set the gocui view.Frame = true by default
w.frame = true
if (w.frame) {
w.realHeight += me.FramePadH
w.gocuiSize.height += me.FramePadH
}
if w.widgetType == toolkit.Root {
log(logInfo, "setupWidget() FOUND ROOT w.id =", w.id, "w.parent", w.parent, "ParentId =", a.ParentId)

View File

@ -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) {

View File

@ -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 (

View File

@ -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

View File

@ -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)