(w, h int)
| 4012 | } |
| 4013 | |
| 4014 | func (td *TableData) Resize(w, h int) { |
| 4015 | |
| 4016 | if td.Width == w && td.Height == h { |
| 4017 | return |
| 4018 | } |
| 4019 | |
| 4020 | for len(td.RowHeadings) < h { |
| 4021 | hori := NewDraggableLabel("Row "+strconv.Itoa(len(td.RowHeadings)+1), td) |
| 4022 | hori.Label.OnChange = func() { |
| 4023 | td.Changed = true |
| 4024 | } |
| 4025 | td.RowHeadings = append(td.RowHeadings, hori) |
| 4026 | } |
| 4027 | |
| 4028 | for len(td.ColumnHeadings) < w { |
| 4029 | vert := NewDraggableLabel("Col "+strconv.Itoa(len(td.ColumnHeadings)+1), td) |
| 4030 | vert.Vertical = true |
| 4031 | vert.Label.OnChange = func() { |
| 4032 | td.Changed = true |
| 4033 | } |
| 4034 | td.ColumnHeadings = append(td.ColumnHeadings, vert) |
| 4035 | } |
| 4036 | |
| 4037 | td.Width = w |
| 4038 | td.Height = h |
| 4039 | |
| 4040 | // Data |
| 4041 | |
| 4042 | for y := 0; y < h; y++ { |
| 4043 | |
| 4044 | if len(td.Data) < h { |
| 4045 | td.Data = append(td.Data, make([]*TableDataContents, 0, w)) |
| 4046 | } |
| 4047 | |
| 4048 | for x := 0; x < w; x++ { |
| 4049 | |
| 4050 | if len(td.Data[y]) >= w { |
| 4051 | break |
| 4052 | } |
| 4053 | |
| 4054 | tdc := &TableDataContents{TableData: td} |
| 4055 | |
| 4056 | button := NewIconButton(0, 0, &sdl.FRect{0, 488, 24, 24}, globals.GUITexture, true, func() { |
| 4057 | tdc.OnClick(false) |
| 4058 | }) |
| 4059 | button.OnRightClickPressed = func() { |
| 4060 | tdc.OnClick(true) |
| 4061 | } |
| 4062 | button.Highlighter.HighlightMode = HighlightRing |
| 4063 | button.BGIconSrc = &sdl.FRect{0, 488, 24, 24} |
| 4064 | button.FadeOnInactive = false |
| 4065 | |
| 4066 | tdc.Button = button |
| 4067 | |
| 4068 | td.Data[y] = append(td.Data[y], tdc) |
| 4069 | |
| 4070 | } |
| 4071 | } |
no test coverage detected