leonsal 8 lat temu
rodzic
commit
13c5490f81
2 zmienionych plików z 34 dodań i 40 usunięć
  1. 19 30
      gui/style.go
  2. 15 10
      gui/table.go

+ 19 - 30
gui/style.go

@@ -753,37 +753,26 @@ func setupDefaultStyle() {
 			BgColor:     math32.Color{0.7, 0.7, 0.7},
 			FgColor:     fgColor,
 		},
-		RowEven: &TableRowStyles{
-			Normal: TableRowStyle{
-				Border:      BorderSizes{0, 1, 1, 0},
-				Paddings:    BorderSizes{2, 2, 2, 2},
-				BorderColor: math32.Color4{0.6, 0.6, 0.6, 1},
-				BgColor:     math32.Color{0.85, 0.85, 0.85},
-				FgColor:     fgColor,
-			},
-			Selected: TableRowStyle{
-				Border:      BorderSizes{0, 1, 1, 0},
-				Paddings:    BorderSizes{2, 2, 2, 2},
-				BorderColor: math32.Color4{0.6, 0.6, 0.6, 1},
-				BgColor:     math32.Color{0.7, 0.7, 0.7},
-				FgColor:     fgColor,
-			},
+		RowEven: &TableRowStyle{
+			Border:      BorderSizes{0, 1, 1, 0},
+			Paddings:    BorderSizes{2, 2, 2, 2},
+			BorderColor: math32.Color4{0.6, 0.6, 0.6, 1},
+			BgColor:     math32.Color{0.85, 0.85, 0.85},
+			FgColor:     fgColor,
 		},
-		RowOdd: &TableRowStyles{
-			Normal: TableRowStyle{
-				Border:      BorderSizes{0, 1, 1, 0},
-				Paddings:    BorderSizes{2, 2, 2, 2},
-				BorderColor: math32.Color4{0.6, 0.6, 0.6, 1},
-				BgColor:     math32.Color{0.82, 0.82, 0.82},
-				FgColor:     fgColor,
-			},
-			Selected: TableRowStyle{
-				Border:      BorderSizes{0, 1, 1, 0},
-				Paddings:    BorderSizes{2, 2, 2, 2},
-				BorderColor: math32.Color4{0.6, 0.6, 0.6, 1},
-				BgColor:     math32.Color{0.7, 0.7, 0.7},
-				FgColor:     fgColor,
-			},
+		RowOdd: &TableRowStyle{
+			Border:      BorderSizes{0, 1, 1, 0},
+			Paddings:    BorderSizes{2, 2, 2, 2},
+			BorderColor: math32.Color4{0.6, 0.6, 0.6, 1},
+			BgColor:     math32.Color{0.82, 0.82, 0.82},
+			FgColor:     fgColor,
+		},
+		RowSel: &TableRowStyle{
+			Border:      BorderSizes{0, 1, 1, 0},
+			Paddings:    BorderSizes{2, 2, 2, 2},
+			BorderColor: math32.Color4{0.6, 0.6, 0.6, 1},
+			BgColor:     math32.Color{0.7, 0.7, 0.7},
+			FgColor:     fgColor,
 		},
 		Status: &TableStatusStyle{
 			Border:      BorderSizes{1, 0, 0, 0},

+ 15 - 10
gui/table.go

@@ -132,11 +132,21 @@ type TableResizerStyle struct {
 	BgColor     math32.Color4
 }
 
+//// TableStyles describes all styles of the table header and rows
+//type TableStyles struct {
+//	Header  *TableHeaderStyle
+//	RowEven *TableRowStyles
+//	RowOdd  *TableRowStyles
+//	Status  *TableStatusStyle
+//	Resizer *TableResizerStyle
+//}
+
 // TableStyles describes all styles of the table header and rows
 type TableStyles struct {
 	Header  *TableHeaderStyle
-	RowEven *TableRowStyles
-	RowOdd  *TableRowStyles
+	RowEven *TableRowStyle
+	RowOdd  *TableRowStyle
+	RowSel  *TableRowStyle
 	Status  *TableStatusStyle
 	Resizer *TableResizerStyle
 }
@@ -843,7 +853,6 @@ func (t *Table) onMouse(evname string, ev interface{}) {
 			cx, _ := t.ContentCoords(e.Xpos, e.Ypos)
 			c := t.header.cols[t.resizeCol]
 			width := cx - c.xl
-			log.Error("width:%v", width)
 			t.SetColWidth(c.id, width)
 		}
 	default:
@@ -1349,16 +1358,12 @@ func (t *Table) updateRowStyle(ri int) {
 	row := t.rows[ri]
 	var trs *TableRowStyle
 	if row.selected {
-		if ri%2 == 0 {
-			trs = &t.styles.RowEven.Selected
-		} else {
-			trs = &t.styles.RowOdd.Selected
-		}
+		trs = t.styles.RowSel
 	} else {
 		if ri%2 == 0 {
-			trs = &t.styles.RowEven.Normal
+			trs = t.styles.RowEven
 		} else {
-			trs = &t.styles.RowOdd.Normal
+			trs = t.styles.RowOdd
 		}
 	}
 	t.applyRowStyle(row, trs)