Przeglądaj źródła

gui builder dev...

leonsal 8 lat temu
rodzic
commit
aa47b891ae
2 zmienionych plików z 44 dodań i 2 usunięć
  1. 5 2
      gui/builder.go
  2. 39 0
      gui/builder_panel.go

+ 5 - 2
gui/builder.go

@@ -66,6 +66,7 @@ const (
 	TypeMenu        = "menu"
 	TypeWindow      = "window"
 	TypeChart       = "chart"
+	TypeTable       = "table"
 	TypeHBoxLayout  = "hbox"
 	TypeVBoxLayout  = "vbox"
 	TypeGridLayout  = "grid"
@@ -83,8 +84,9 @@ const (
 	AttribBorderColor    = "bordercolor"  // Color4
 	AttribChecked        = "checked"      // bool
 	AttribColor          = "color"        // Color4
-	AttribCols           = "cols"         // int
-	AttribColSpan        = "colspan"      // int
+	AttribCols           = "cols"         // int GridLayout
+	AttribColSpan        = "colspan"      // int GridLayout
+	AttribColumns        = "columns"      // []map[string]interface{} Table
 	AttribCountStepx     = "countstepx"   // float32
 	AttribEdge           = "edge"         // int
 	AttribEnabled        = "enabled"      // bool
@@ -215,6 +217,7 @@ func NewBuilder() *Builder {
 		TypeTree:        buildTree,
 		TypeWindow:      buildWindow,
 		TypeChart:       buildChart,
+		TypeTable:       buildTable,
 	}
 	// Sets map of layout type name to layout function
 	b.layouts = map[string]IBuilderLayout{

+ 39 - 0
gui/builder_panel.go

@@ -733,3 +733,42 @@ func buildChart(b *Builder, am map[string]interface{}) (IPanel, error) {
 
 	return chart, nil
 }
+
+// buildTable builds a gui object of type: Table
+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{}
+
+		return tc, nil
+	}
+
+	// Builds table columns array
+	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)
+			if err != nil {
+				return nil, err
+			}
+		}
+		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
+}