Kaynağa Gözat

gui builder dev

leonsal 8 yıl önce
ebeveyn
işleme
28cb701d23
6 değiştirilmiş dosya ile 264 ekleme ve 194 silme
  1. 168 126
      gui/builder.go
  2. 8 8
      gui/builder_layout.go
  3. 50 22
      gui/builder_panel.go
  4. 17 17
      gui/hboxlayout.go
  5. 17 17
      gui/vboxlayout.go
  6. 4 4
      gui/window.go

+ 168 - 126
gui/builder.go

@@ -75,68 +75,75 @@ const (
 
 // Common attribute names
 const (
-	AttribAlignv         = "alignv"       // Align
-	AttribAlignh         = "alignh"       // Align
-	AttribAspectHeight   = "aspectheight" // float32
-	AttribAspectWidth    = "aspectwidth"  // float32
-	AttribBgColor        = "bgcolor"      // Color4
-	AttribBorders        = "borders"      // BorderSizes
-	AttribBorderColor    = "bordercolor"  // Color4
-	AttribChecked        = "checked"      // bool
-	AttribColor          = "color"        // Color4
-	AttribCols           = "cols"         // int GridLayout
-	AttribColSpan        = "colspan"      // int GridLayout
-	AttribColumns        = "columns"      // []map[string]interface{} Table
-	AttribCountStepx     = "countstepx"   // float32
-	AttribEdge           = "edge"         // int
-	AttribEnabled        = "enabled"      // bool
-	AttribExpand         = "expand"       // float32
-	AttribExpandh        = "expandh"      // bool
-	AttribExpandv        = "expandv"      // bool
-	AttribFirstx         = "firstx"       // float32
-	AttribFontColor      = "fontcolor"    // Color4
-	AttribFontDPI        = "fontdpi"      // float32
-	AttribFontSize       = "fontsize"     // float32
-	AttribFormat         = "format"       // string
-	AttribGroup          = "group"        // string
-	AttribHeight         = "height"       // float32
-	AttribIcon           = "icon"         // string
-	AttribImageFile      = "imagefile"    // string
-	AttribImageLabel     = "imagelabel"   // []map[string]interface{}
-	AttribItems          = "items"        // []map[string]interface{}
-	AttribLayout         = "layout"       // map[string]interface{}
-	AttribLayoutParams   = "layoutparams" // map[string]interface{}
-	AttribLineSpacing    = "linespacing"  // float32
-	AttribLines          = "lines"        // int
-	AttribMargin         = "margin"       // float32
-	AttribMargins        = "margins"      // BorderSizes
-	AttribMinHeight      = "minheight"    // bool
-	AttribMinWidth       = "minwidth"     // bool
-	AttribName           = "name"         // string
-	AttribPaddings       = "paddings"     // BorderSizes
-	AttribPanel0         = "panel0"       // map[string]interface{}
-	AttribPanel1         = "panel1"       // map[string]interface{}
-	AttribParentInternal = "parent_"      // string (internal attribute)
-	AttribPlaceHolder    = "placeholder"  // string
-	AttribPosition       = "position"     // []float32
-	AttribRangeAuto      = "rangeauto"    // bool
-	AttribRangeMin       = "rangemin"     // float32
-	AttribRangeMax       = "rangemax"     // float32
-	AttribRender         = "render"       // bool
-	AttribResizable      = "resizable"    // Resizable
-	AttribScaleFactor    = "scalefactor"  // float32
-	AttribScalex         = "scalex"       // map[string]interface{}
-	AttribScaley         = "scaley"       // map[string]interface{}
-	AttribShortcut       = "shortcut"     // []int
-	AttribSpacing        = "spacing"      // float32
-	AttribSplit          = "split"        // float32
-	AttribStepx          = "stepx"        // float32
-	AttribText           = "text"         // string
-	AttribTitle          = "title"        // string
-	AttribType           = "type"         // string
-	AttribWidth          = "width"        // float32
-	AttribValue          = "value"        // float32
-	AttribVisible        = "visible"      // bool
+	AttribAlignv         = "alignv"        // Align
+	AttribAlignh         = "alignh"        // Align
+	AttribAspectHeight   = "aspectheight"  // float32
+	AttribAspectWidth    = "aspectwidth"   // float32
+	AttribBgColor        = "bgcolor"       // Color4
+	AttribBorders        = "borders"       // BorderSizes
+	AttribBorderColor    = "bordercolor"   // Color4
+	AttribChecked        = "checked"       // bool
+	AttribColor          = "color"         // Color4
+	AttribCols           = "cols"          // int GridLayout
+	AttribColSpan        = "colspan"       // int GridLayout
+	AttribColumns        = "columns"       // []map[string]interface{} Table
+	AttribCountStepx     = "countstepx"    // float32
+	AttribEdge           = "edge"          // int
+	AttribEnabled        = "enabled"       // bool
+	AttribExpand         = "expand"        // float32
+	AttribExpandh        = "expandh"       // bool
+	AttribExpandv        = "expandv"       // bool
+	AttribFirstx         = "firstx"        // float32
+	AttribFontColor      = "fontcolor"     // Color4
+	AttribFontDPI        = "fontdpi"       // float32
+	AttribFontSize       = "fontsize"      // float32
+	AttribFormat         = "format"        // string
+	AttribGroup          = "group"         // string
+	AttribHeader         = "header"        // string
+	AttribHeight         = "height"        // float32
+	AttribHidden         = "hidden"        // bool Table
+	AttribId             = "id"            // string
+	AttribIcon           = "icon"          // string
+	AttribImageFile      = "imagefile"     // string
+	AttribImageLabel     = "imagelabel"    // []map[string]interface{}
+	AttribItems          = "items"         // []map[string]interface{}
+	AttribLayout         = "layout"        // map[string]interface{}
+	AttribLayoutParams   = "layoutparams"  // map[string]interface{}
+	AttribLineSpacing    = "linespacing"   // float32
+	AttribLines          = "lines"         // int
+	AttribMargin         = "margin"        // float32
+	AttribMargins        = "margins"       // BorderSizes
+	AttribMinwidth       = "minwidth"      // float32 Table
+	AttribAutoHeight     = "autoheight"    // bool
+	AttribAutoWidth      = "autowidth"     // bool
+	AttribName           = "name"          // string
+	AttribPaddings       = "paddings"      // BorderSizes
+	AttribPanel0         = "panel0"        // map[string]interface{}
+	AttribPanel1         = "panel1"        // map[string]interface{}
+	AttribParentInternal = "parent_"       // string (internal attribute)
+	AttribPlaceHolder    = "placeholder"   // string
+	AttribPosition       = "position"      // []float32
+	AttribRangeAuto      = "rangeauto"     // bool
+	AttribRangeMin       = "rangemin"      // float32
+	AttribRangeMax       = "rangemax"      // float32
+	AttribRender         = "render"        // bool
+	AttribResizeBorders  = "resizeborders" // Resizable
+	AttribResize         = "resize"        // bool Table
+	AttribScaleFactor    = "scalefactor"   // float32
+	AttribScalex         = "scalex"        // map[string]interface{}
+	AttribScaley         = "scaley"        // map[string]interface{}
+	AttribShortcut       = "shortcut"      // []int
+	AttribShowHeader     = "showheader"    // bool
+	AttribSortType       = "sorttype"      // TableSortType Table
+	AttribSpacing        = "spacing"       // float32
+	AttribSplit          = "split"         // float32
+	AttribStepx          = "stepx"         // float32
+	AttribText           = "text"          // string
+	AttribTitle          = "title"         // string
+	AttribType           = "type"          // string
+	AttribWidth          = "width"         // float32
+	AttribValue          = "value"         // float32
+	AttribVisible        = "visible"       // bool
 )
 
 const (
@@ -183,7 +190,7 @@ var mapEdgeName = map[string]int{
 }
 
 // maps resize border name (window) with parameter value
-var mapResizable = map[string]Resizable{
+var mapResizable = map[string]ResizeBorders{
 	"top":    ResizeTop,
 	"right":  ResizeRight,
 	"bottom": ResizeBottom,
@@ -191,6 +198,13 @@ var mapResizable = map[string]Resizable{
 	"all":    ResizeAll,
 }
 
+// maps table sort type to value
+var mapTableSortType = map[string]TableSortType{
+	"none":   TableSortNone,
+	"string": TableSortString,
+	"number": TableSortNumber,
+}
+
 // NewBuilder creates and returns a pointer to a new gui Builder object
 func NewBuilder() *Builder {
 
@@ -228,66 +242,74 @@ func NewBuilder() *Builder {
 	}
 	// Sets map of attribute name to check function
 	b.attribs = map[string]AttribCheckFunc{
-		AttribAlignv:       AttribCheckAlign,
-		AttribAlignh:       AttribCheckAlign,
-		AttribAspectWidth:  AttribCheckFloat,
-		AttribAspectHeight: AttribCheckFloat,
-		AttribHeight:       AttribCheckFloat,
-		AttribMargin:       AttribCheckFloat,
-		AttribMargins:      AttribCheckBorderSizes,
-		AttribBgColor:      AttribCheckColor,
-		AttribBorders:      AttribCheckBorderSizes,
-		AttribBorderColor:  AttribCheckColor,
-		AttribChecked:      AttribCheckBool,
-		AttribColor:        AttribCheckColor,
-		AttribCols:         AttribCheckInt,
-		AttribColSpan:      AttribCheckInt,
-		AttribCountStepx:   AttribCheckFloat,
-		AttribEdge:         AttribCheckEdge,
-		AttribEnabled:      AttribCheckBool,
-		AttribExpand:       AttribCheckFloat,
-		AttribExpandh:      AttribCheckBool,
-		AttribExpandv:      AttribCheckBool,
-		AttribFirstx:       AttribCheckFloat,
-		AttribFontColor:    AttribCheckColor,
-		AttribFontDPI:      AttribCheckFloat,
-		AttribFontSize:     AttribCheckFloat,
-		AttribFormat:       AttribCheckString,
-		AttribGroup:        AttribCheckString,
-		AttribIcon:         AttribCheckIcons,
-		AttribImageFile:    AttribCheckString,
-		AttribImageLabel:   AttribCheckMap,
-		AttribItems:        AttribCheckListMap,
-		AttribLayout:       AttribCheckLayout,
-		AttribLayoutParams: AttribCheckMap,
-		AttribLineSpacing:  AttribCheckFloat,
-		AttribLines:        AttribCheckInt,
-		AttribMinHeight:    AttribCheckBool,
-		AttribMinWidth:     AttribCheckBool,
-		AttribName:         AttribCheckString,
-		AttribPaddings:     AttribCheckBorderSizes,
-		AttribPanel0:       AttribCheckMap,
-		AttribPanel1:       AttribCheckMap,
-		AttribPlaceHolder:  AttribCheckString,
-		AttribPosition:     AttribCheckPosition,
-		AttribRangeAuto:    AttribCheckBool,
-		AttribRangeMin:     AttribCheckFloat,
-		AttribRangeMax:     AttribCheckFloat,
-		AttribRender:       AttribCheckBool,
-		AttribResizable:    AttribCheckResizable,
-		AttribScaleFactor:  AttribCheckFloat,
-		AttribScalex:       AttribCheckMap,
-		AttribScaley:       AttribCheckMap,
-		AttribShortcut:     AttribCheckMenuShortcut,
-		AttribSpacing:      AttribCheckFloat,
-		AttribSplit:        AttribCheckFloat,
-		AttribStepx:        AttribCheckFloat,
-		AttribText:         AttribCheckString,
-		AttribTitle:        AttribCheckString,
-		AttribType:         AttribCheckStringLower,
-		AttribValue:        AttribCheckFloat,
-		AttribVisible:      AttribCheckBool,
-		AttribWidth:        AttribCheckFloat,
+		AttribAlignv:        AttribCheckAlign,
+		AttribAlignh:        AttribCheckAlign,
+		AttribAspectWidth:   AttribCheckFloat,
+		AttribAspectHeight:  AttribCheckFloat,
+		AttribHeight:        AttribCheckFloat,
+		AttribBgColor:       AttribCheckColor,
+		AttribBorders:       AttribCheckBorderSizes,
+		AttribBorderColor:   AttribCheckColor,
+		AttribChecked:       AttribCheckBool,
+		AttribColor:         AttribCheckColor,
+		AttribCols:          AttribCheckInt,
+		AttribColSpan:       AttribCheckInt,
+		AttribColumns:       AttribCheckListMap,
+		AttribCountStepx:    AttribCheckFloat,
+		AttribEdge:          AttribCheckEdge,
+		AttribEnabled:       AttribCheckBool,
+		AttribExpand:        AttribCheckFloat,
+		AttribExpandh:       AttribCheckBool,
+		AttribExpandv:       AttribCheckBool,
+		AttribFirstx:        AttribCheckFloat,
+		AttribFontColor:     AttribCheckColor,
+		AttribFontDPI:       AttribCheckFloat,
+		AttribFontSize:      AttribCheckFloat,
+		AttribFormat:        AttribCheckString,
+		AttribGroup:         AttribCheckString,
+		AttribHeader:        AttribCheckString,
+		AttribHidden:        AttribCheckBool,
+		AttribIcon:          AttribCheckIcons,
+		AttribId:            AttribCheckString,
+		AttribImageFile:     AttribCheckString,
+		AttribImageLabel:    AttribCheckMap,
+		AttribItems:         AttribCheckListMap,
+		AttribLayout:        AttribCheckLayout,
+		AttribLayoutParams:  AttribCheckMap,
+		AttribLineSpacing:   AttribCheckFloat,
+		AttribLines:         AttribCheckInt,
+		AttribMargin:        AttribCheckFloat,
+		AttribMargins:       AttribCheckBorderSizes,
+		AttribMinwidth:      AttribCheckFloat,
+		AttribAutoHeight:    AttribCheckBool,
+		AttribAutoWidth:     AttribCheckBool,
+		AttribName:          AttribCheckString,
+		AttribPaddings:      AttribCheckBorderSizes,
+		AttribPanel0:        AttribCheckMap,
+		AttribPanel1:        AttribCheckMap,
+		AttribPlaceHolder:   AttribCheckString,
+		AttribPosition:      AttribCheckPosition,
+		AttribRangeAuto:     AttribCheckBool,
+		AttribRangeMin:      AttribCheckFloat,
+		AttribRangeMax:      AttribCheckFloat,
+		AttribRender:        AttribCheckBool,
+		AttribResizeBorders: AttribCheckResizeBorders,
+		AttribResize:        AttribCheckBool,
+		AttribScaleFactor:   AttribCheckFloat,
+		AttribScalex:        AttribCheckMap,
+		AttribScaley:        AttribCheckMap,
+		AttribShortcut:      AttribCheckMenuShortcut,
+		AttribShowHeader:    AttribCheckBool,
+		AttribSortType:      AttribCheckTableSortType,
+		AttribSpacing:       AttribCheckFloat,
+		AttribSplit:         AttribCheckFloat,
+		AttribStepx:         AttribCheckFloat,
+		AttribText:          AttribCheckString,
+		AttribTitle:         AttribCheckString,
+		AttribType:          AttribCheckStringLower,
+		AttribValue:         AttribCheckFloat,
+		AttribVisible:       AttribCheckBool,
+		AttribWidth:         AttribCheckFloat,
 	}
 	return b
 }
@@ -646,8 +668,28 @@ func (b *Builder) setLayoutParams(am map[string]interface{}, ipan IPanel) error
 	return nil
 }
 
-// AttribCheckResizable checks and converts attribute with list of window resizable borders
-func AttribCheckResizable(b *Builder, am map[string]interface{}, fname string) error {
+// AttribCheckTableSortType checks and converts attribute table column sort type
+func AttribCheckTableSortType(b *Builder, am map[string]interface{}, fname string) error {
+
+	// If attribute not found, ignore
+	v := am[fname]
+	if v == nil {
+		return nil
+	}
+	vs, ok := v.(string)
+	if !ok {
+		return b.err(am, fname, "Invalid attribute")
+	}
+	tstype, ok := mapTableSortType[vs]
+	if !ok {
+		return b.err(am, fname, "Invalid attribute")
+	}
+	am[fname] = tstype
+	return nil
+}
+
+// AttribCheckResizeBorders checks and converts attribute with list of window resizable borders
+func AttribCheckResizeBorders(b *Builder, am map[string]interface{}, fname string) error {
 
 	// If attribute not found, ignore
 	v := am[fname]
@@ -663,7 +705,7 @@ func AttribCheckResizable(b *Builder, am map[string]interface{}, fname string) e
 
 	// Each string field must be a valid resizable name
 	parts := strings.Fields(vs)
-	var res Resizable
+	var res ResizeBorders
 	for _, name := range parts {
 		v, ok := mapResizable[name]
 		if !ok {

+ 8 - 8
gui/builder_layout.go

@@ -26,13 +26,13 @@ func (bl *BuilderLayoutHBox) BuildLayout(b *Builder, am map[string]interface{})
 	}
 
 	// Sets optional minheight flag
-	if mh := am[AttribMinHeight]; mh != nil {
-		l.SetMinHeight(mh.(bool))
+	if mh := am[AttribAutoHeight]; mh != nil {
+		l.SetAutoHeight(mh.(bool))
 	}
 
 	// Sets optional minwidth flag
-	if mw := am[AttribMinWidth]; mw != nil {
-		l.SetMinWidth(mw.(bool))
+	if mw := am[AttribAutoWidth]; mw != nil {
+		l.SetAutoWidth(mw.(bool))
 	}
 	return l, nil
 }
@@ -77,13 +77,13 @@ func (bl *BuilderLayoutVBox) BuildLayout(b *Builder, am map[string]interface{})
 	}
 
 	// Sets optional minheight flag
-	if mh := am[AttribMinHeight]; mh != nil {
-		l.SetMinHeight(mh.(bool))
+	if mh := am[AttribAutoHeight]; mh != nil {
+		l.SetAutoHeight(mh.(bool))
 	}
 
 	// Sets optional minwidth flag
-	if mw := am[AttribMinWidth]; mw != nil {
-		l.SetMinWidth(mw.(bool))
+	if mw := am[AttribAutoWidth]; mw != nil {
+		l.SetAutoWidth(mw.(bool))
 	}
 	return l, nil
 }

+ 50 - 22
gui/builder_panel.go

@@ -608,8 +608,8 @@ func buildWindow(b *Builder, am map[string]interface{}) (IPanel, error) {
 	}
 
 	// Set optional resizable borders
-	if resiz := am[AttribResizable]; resiz != nil {
-		win.SetResizable(resiz.(Resizable))
+	if resiz := am[AttribResizeBorders]; resiz != nil {
+		win.SetResizable(resiz.(ResizeBorders))
 	}
 
 	// Builds window children
@@ -740,35 +740,63 @@ func buildTable(b *Builder, am map[string]interface{}) (IPanel, error) {
 	// Internal function to build a TableColumn from its attribute map
 	buildTableCol := func(b *Builder, am map[string]interface{}) (*TableColumn, error) {
 		tc := &TableColumn{}
-
+		if iv := am[AttribId]; iv != nil {
+			tc.Id = iv.(string)
+		}
+		if iv := am[AttribHeader]; iv != nil {
+			tc.Header = iv.(string)
+		}
+		if iv := am[AttribWidth]; iv != nil {
+			tc.Width = iv.(float32)
+		}
+		if iv := am[AttribMinwidth]; iv != nil {
+			tc.Minwidth = iv.(float32)
+		}
+		if iv := am[AttribHidden]; iv != nil {
+			tc.Hidden = iv.(bool)
+		}
+		if iv := am[AttribFormat]; iv != nil {
+			tc.Format = iv.(string)
+		}
+		if iv := am[AttribExpand]; iv != nil {
+			tc.Expand = iv.(float32)
+		}
+		if iv := am[AttribResize]; iv != nil {
+			tc.Resize = iv.(bool)
+		}
+		if iv := am[AttribSortType]; iv != nil {
+			tc.Sort = iv.(TableSortType)
+		}
 		return tc, nil
 	}
 
 	// Builds table columns array
-	tableCols := []*TableColumn{}
+	tableCols := []TableColumn{}
 	if iv := am[AttribColumns]; iv != nil {
 		cols := iv.([]map[string]interface{})
-		var tc *TableColumn
-		var err error
 		for _, c := range cols {
-			tc, err = buildTableCol(b, c)
+			tc, err := buildTableCol(b, c)
 			if err != nil {
 				return nil, err
 			}
+			tableCols = append(tableCols, *tc)
 		}
-		tableCols = append(tableCols, tc)
-	}
-	//Id         string          // Column id used to reference the column. Must be unique
-	//Header     string          // Column name shown in the table header
-	//Width      float32         // Initial column width in pixels
-	//Minwidth   float32         // Minimum width in pixels for this column
-	//Hidden     bool            // Hidden flag
-	//Align      Align           // Cell content alignment: AlignLeft|AlignCenter|AlignRight
-	//Format     string          // Format string for formatting the columns' cells
-	//FormatFunc TableFormatFunc // Format function (overrides Format string)
-	//Expand     float32         // Column width expansion factor (0 for no expansion)
-	//Sort       TableSortType   // Column sort type
-	//Resize     bool            // Allow column to be resized by user
-
-	return nil, nil
+	}
+
+	// Creates table and set common attributes
+	table, err := NewTable(0, 0, tableCols)
+	if err != nil {
+		return nil, err
+	}
+	err = b.setAttribs(am, table, asPANEL)
+	if err != nil {
+		return nil, err
+	}
+
+	// Sets optional show header attribute
+	if show := am[AttribShowHeader]; show != nil {
+		table.ShowHeader(show.(bool))
+	}
+
+	return table, nil
 }

+ 17 - 17
gui/hboxlayout.go

@@ -21,17 +21,17 @@ package gui
 // 	AlignWidth - Try to align the individual children with the same same space between each other.
 // 	Each individual child can be aligned vertically by SetLayoutParameters()
 //
-// If the layout method SetMinHeight(true) is called, the panel minimum content height will be the
+// If the layout method SetAutoHeight(true) is called, the panel minimum content height will be the
 // height of the child with the largest height.
 //
-// If the layout method SetMinWidth(true) is called, the panel minimum content width will be the
+// If the layout method SetAutoWidth(true) is called, the panel minimum content width will be the
 // sum of its children's widths plus the spacing.
 type HBoxLayout struct {
-	pan       IPanel
-	spacing   float32
-	alignH    Align
-	minHeight bool
-	minWidth  bool
+	pan        IPanel
+	spacing    float32
+	alignH     Align
+	autoHeight bool
+	minHeight  bool
 }
 
 // HBoxLayoutParams specify the vertical alignment of each individual child.
@@ -66,19 +66,19 @@ func (bl *HBoxLayout) SetAlignH(align Align) {
 	bl.Recalc(bl.pan)
 }
 
-// SetMinHeight sets if the panel minimum height should be the height of
+// SetAutoHeight sets if the panel minimum height should be the height of
 // the largest of its children's height.
-func (bl *HBoxLayout) SetMinHeight(state bool) {
+func (bl *HBoxLayout) SetAutoHeight(state bool) {
 
-	bl.minHeight = state
+	bl.autoHeight = state
 	bl.Recalc(bl.pan)
 }
 
-// SetMinWidth sets if the panel minimum width should be sum of its
+// SetAutoWidth sets if the panel minimum width should be sum of its
 // children's width plus the spacing
-func (bl *HBoxLayout) SetMinWidth(state bool) {
+func (bl *HBoxLayout) SetAutoWidth(state bool) {
 
-	bl.minWidth = state
+	bl.minHeight = state
 	bl.Recalc(bl.pan)
 }
 
@@ -95,9 +95,9 @@ func (bl *HBoxLayout) Recalc(ipan IPanel) {
 		return
 	}
 
-	// If minHeight is set, get the maximum height of all the panel's children
+	// If autoHeight is set, get the maximum height of all the panel's children
 	// and if the panel content height is less than this maximum, set its content height to this value.
-	if bl.minHeight {
+	if bl.autoHeight {
 		var maxHeight float32
 		for _, ichild := range parent.Children() {
 			child := ichild.(IPanel).GetPanel()
@@ -113,9 +113,9 @@ func (bl *HBoxLayout) Recalc(ipan IPanel) {
 		}
 	}
 
-	// If minWidth is set, get the sum of widths of this panel's children plus the spacings.
+	// If minHeight is set, get the sum of widths of this panel's children plus the spacings.
 	// If the panel content width is less than this width, set its content width to this value.
-	if bl.minWidth {
+	if bl.minHeight {
 		var totalWidth float32
 		for _, ichild := range parent.Children() {
 			child := ichild.(IPanel).GetPanel()

+ 17 - 17
gui/vboxlayout.go

@@ -21,17 +21,17 @@ package gui
 // 	AlignHeight - Try to align the individual children vertically with the same same space between each other.
 // 	Each individual child can be aligned horizontally by SetLayoutParameters()
 //
-// If the layout method SetMinHeight(true) is called, the panel minimum content height will be the
+// If the layout method SetAutoHeight(true) is called, the panel minimum content height will be the
 // sum of its children's heights plus the spacing.
 //
-// If the layout method SetMinWidth(true) is called, the panel minimum content width will be the
+// If the layout method SetAutoWidth(true) is called, the panel minimum content width will be the
 // width of the widest child.
 type VBoxLayout struct {
-	pan       IPanel
-	spacing   float32
-	alignV    Align
-	minHeight bool
-	minWidth  bool
+	pan        IPanel
+	spacing    float32
+	alignV     Align
+	autoHeight bool
+	autoWidth  bool
 }
 
 // VBoxLayoutParams specify the horizontal alignment of each individual child.
@@ -66,19 +66,19 @@ func (bl *VBoxLayout) SetAlignV(align Align) {
 	bl.Recalc(bl.pan)
 }
 
-// SetMinHeight sets if the panel minimum height should be the height of
+// SetAutoHeight sets if the panel minimum height should be the height of
 // the largest of its children's height.
-func (bl *VBoxLayout) SetMinHeight(state bool) {
+func (bl *VBoxLayout) SetAutoHeight(state bool) {
 
-	bl.minHeight = state
+	bl.autoHeight = state
 	bl.Recalc(bl.pan)
 }
 
-// SetMinWidth sets if the panel minimum width should be sum of its
+// SetAutoWidth sets if the panel minimum width should be sum of its
 // children's width plus the spacing
-func (bl *VBoxLayout) SetMinWidth(state bool) {
+func (bl *VBoxLayout) SetAutoWidth(state bool) {
 
-	bl.minWidth = state
+	bl.autoWidth = state
 	bl.Recalc(bl.pan)
 }
 
@@ -95,9 +95,9 @@ func (bl *VBoxLayout) Recalc(ipan IPanel) {
 		return
 	}
 
-	// If minHeight is set, get the sum of heights of this panel's children plus the spacings.
+	// If autoHeight is set, get the sum of heights of this panel's children plus the spacings.
 	// If the panel content height is less than this height, set its content height to this value.
-	if bl.minHeight {
+	if bl.autoHeight {
 		var totalHeight float32
 		for _, ichild := range parent.Children() {
 			child := ichild.(IPanel).GetPanel()
@@ -113,9 +113,9 @@ func (bl *VBoxLayout) Recalc(ipan IPanel) {
 		}
 	}
 
-	// If minWidth is set, get the maximum width of all the panel's children
+	// If autoWidth is set, get the maximum width of all the panel's children
 	// and if the panel content width is less than this maximum, set its content width to this value.
-	if bl.minWidth {
+	if bl.autoWidth {
 		var maxWidth float32
 		for _, ichild := range parent.Children() {
 			child := ichild.(IPanel).GetPanel()

+ 4 - 4
gui/window.go

@@ -34,7 +34,7 @@ type Window struct {
 	styles     *WindowStyles
 	title      *WindowTitle // internal optional title panel
 	client     Panel        // internal client panel
-	resizable  Resizable
+	resizable  ResizeBorders
 	overBorder string
 	drag       bool
 	mouseX     float32
@@ -59,10 +59,10 @@ type WindowStyles struct {
 	Disabled WindowStyle
 }
 
-type Resizable int
+type ResizeBorders int
 
 const (
-	ResizeTop = Resizable(1 << (iota + 1))
+	ResizeTop = ResizeBorders(1 << (iota + 1))
 	ResizeRight
 	ResizeBottom
 	ResizeLeft
@@ -93,7 +93,7 @@ func NewWindow(width, height float32) *Window {
 }
 
 // SetResizable set the borders which are resizable
-func (w *Window) SetResizable(res Resizable) {
+func (w *Window) SetResizable(res ResizeBorders) {
 
 	w.resizable = res
 }