瀏覽代碼

simplified style definition

danaugrs 7 年之前
父節點
當前提交
6acf18ec62
共有 4 個文件被更改,包括 317 次插入819 次删除
  1. 7 7
      gui/dropdown.go
  2. 6 6
      gui/folder.go
  3. 295 791
      gui/style_light.go
  4. 9 15
      gui/table.go

+ 7 - 7
gui/dropdown.go

@@ -34,10 +34,10 @@ type DropDownStyle struct {
 
 // DropDown list styles
 type DropDownStyles struct {
-	Normal   *DropDownStyle
-	Over     *DropDownStyle
-	Focus    *DropDownStyle
-	Disabled *DropDownStyle
+	Normal   DropDownStyle
+	Over     DropDownStyle
+	Focus    DropDownStyle
+	Disabled DropDownStyle
 }
 
 // NewDropDown creates and returns a pointer to a new drop down widget with the specified width.
@@ -264,16 +264,16 @@ func (dd *DropDown) recalc() {
 func (dd *DropDown) update() {
 
 	if dd.overDropdown || dd.overList {
-		dd.applyStyle(dd.styles.Over)
+		dd.applyStyle(&dd.styles.Over)
 		dd.list.ApplyStyle(StyleOver)
 		return
 	}
 	if dd.focus {
-		dd.applyStyle(dd.styles.Focus)
+		dd.applyStyle(&dd.styles.Focus)
 		dd.list.ApplyStyle(StyleFocus)
 		return
 	}
-	dd.applyStyle(dd.styles.Normal)
+	dd.applyStyle(&dd.styles.Normal)
 	dd.list.ApplyStyle(StyleNormal)
 }
 

+ 6 - 6
gui/folder.go

@@ -29,10 +29,10 @@ type FolderStyle struct {
 }
 
 type FolderStyles struct {
-	Normal   *FolderStyle
-	Over     *FolderStyle
-	Focus    *FolderStyle
-	Disabled *FolderStyle
+	Normal   FolderStyle
+	Over     FolderStyle
+	Focus    FolderStyle
+	Disabled FolderStyle
 }
 
 // NewFolder creates and returns a pointer to a new folder widget
@@ -139,10 +139,10 @@ func (f *Folder) onCursor(evname string, ev interface{}) {
 func (f *Folder) update() {
 
 	if f.cursorOver {
-		f.applyStyle(f.styles.Over)
+		f.applyStyle(&f.styles.Over)
 		return
 	}
-	f.applyStyle(f.styles.Normal)
+	f.applyStyle(&f.styles.Normal)
 }
 
 // applyStyle applies the specified style

文件差異過大導致無法顯示
+ 295 - 791
gui/style_light.go


+ 9 - 15
gui/table.go

@@ -123,12 +123,6 @@ type TableRowStyle struct {
 	FgColor     math32.Color
 }
 
-// TableRowStyles describes all styles for the table row
-type TableRowStyles struct {
-	Normal   TableRowStyle
-	Selected TableRowStyle
-}
-
 // TableStatusStyle describes the style of the table status line panel
 type TableStatusStyle struct {
 	Border      RectBounds
@@ -148,13 +142,13 @@ type TableResizerStyle struct {
 
 // TableStyles describes all styles of the table header and rows
 type TableStyles struct {
-	Header    *TableHeaderStyle
-	RowEven   *TableRowStyle
-	RowOdd    *TableRowStyle
-	RowCursor *TableRowStyle
-	RowSel    *TableRowStyle
-	Status    *TableStatusStyle
-	Resizer   *TableResizerStyle
+	Header    TableHeaderStyle
+	RowEven   TableRowStyle
+	RowOdd    TableRowStyle
+	RowCursor TableRowStyle
+	RowSel    TableRowStyle
+	Status    TableStatusStyle
+	Resizer   TableResizerStyle
 }
 
 // TableClickEvent describes a mouse click event over a table
@@ -1569,7 +1563,7 @@ func (t *Table) calcMaxFirst() int {
 func (t *Table) updateRowStyle(ri int) {
 
 	row := t.rows[ri]
-	var trs *TableRowStyle
+	var trs TableRowStyle
 	if ri == t.rowCursor {
 		trs = t.styles.RowCursor
 	} else if row.selected {
@@ -1581,7 +1575,7 @@ func (t *Table) updateRowStyle(ri int) {
 			trs = t.styles.RowOdd
 		}
 	}
-	t.applyRowStyle(row, trs)
+	t.applyRowStyle(row, &trs)
 }
 
 // applyHeaderStyle applies style to the specified table header