More ImageList removal.
This commit is contained in:
parent
62d9ae07ad
commit
dc32a0e27a
6
table.go
6
table.go
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
// Table is a Control that displays a list of like-structured data in a grid where each row represents an item and each column represents a bit of data.
|
// Table is a Control that displays a list of like-structured data in a grid where each row represents an item and each column represents a bit of data.
|
||||||
// Tables store and render a slice of struct values.
|
// Tables store and render a slice of struct values.
|
||||||
// Each field of the struct of type ImageIndex is rendered as an icon from the Table's ImageList.
|
// Each field of the struct of type *image.RGBA is rendered as an icom.
|
||||||
// Each field whose type is bool or equivalent to bool is rendered as a checkbox.
|
// Each field whose type is bool or equivalent to bool is rendered as a checkbox.
|
||||||
// All other fields are rendered as strings formatted with package fmt's %v format specifier.
|
// All other fields are rendered as strings formatted with package fmt's %v format specifier.
|
||||||
//
|
//
|
||||||
|
@ -37,10 +37,6 @@ type Table interface {
|
||||||
// Do not call this outside a Lock()..Unlock() or RLock()..RUnlock() pair.
|
// Do not call this outside a Lock()..Unlock() or RLock()..RUnlock() pair.
|
||||||
Data() interface{}
|
Data() interface{}
|
||||||
|
|
||||||
// LoadImageList loads the given ImageList into the Table.
|
|
||||||
// This function copies; changes to the ImageList made later will not be reflected by the Table.
|
|
||||||
LoadImageList(imagelist ImageList)
|
|
||||||
|
|
||||||
// Selected and Select get and set the currently selected item in the Table.
|
// Selected and Select get and set the currently selected item in the Table.
|
||||||
// Selected returns -1 if no item is selected.
|
// Selected returns -1 if no item is selected.
|
||||||
// Pass -1 to Select to deselect all items.
|
// Pass -1 to Select to deselect all items.
|
||||||
|
|
|
@ -12,15 +12,14 @@ import (
|
||||||
|
|
||||||
type icon struct {
|
type icon struct {
|
||||||
Bool bool
|
Bool bool
|
||||||
Icon ImageIndex
|
Icon *image.RGBA
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstimg *image.RGBA
|
var firstimg *image.RGBA
|
||||||
|
|
||||||
func readIcons() ([]icon, ImageList) {
|
func readIcons() []icon {
|
||||||
out := make([]icon, len(icons))
|
out := make([]icon, len(icons))
|
||||||
outil := NewImageList()
|
|
||||||
for i := range icons {
|
for i := range icons {
|
||||||
r := bytes.NewReader(icons[i].data)
|
r := bytes.NewReader(icons[i].data)
|
||||||
png, _, err := image.Decode(r)
|
png, _, err := image.Decode(r)
|
||||||
|
@ -32,11 +31,10 @@ func readIcons() ([]icon, ImageList) {
|
||||||
if firstimg == nil {
|
if firstimg == nil {
|
||||||
firstimg = img
|
firstimg = img
|
||||||
}
|
}
|
||||||
out[i].Icon = ImageIndex(i)
|
out[i].Icon = img
|
||||||
out[i].Name = icons[i].name
|
out[i].Name = icons[i].name
|
||||||
outil.Append(img)
|
|
||||||
}
|
}
|
||||||
return out, outil
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func tileImage(times int) *image.RGBA {
|
func tileImage(times int) *image.RGBA {
|
||||||
|
|
|
@ -67,7 +67,6 @@ type testwin struct {
|
||||||
openbtn Button
|
openbtn Button
|
||||||
fnlabel Label
|
fnlabel Label
|
||||||
icons []icon
|
icons []icon
|
||||||
il ImageList
|
|
||||||
icontbl Table
|
icontbl Table
|
||||||
group2 Group
|
group2 Group
|
||||||
group Group
|
group Group
|
||||||
|
@ -185,7 +184,7 @@ func (tw *testwin) make(done chan struct{}) {
|
||||||
tw.roro.SetText(tw.roenter.Text())
|
tw.roro.SetText(tw.roenter.Text())
|
||||||
})
|
})
|
||||||
tw.t.Append("Read-Only", newVerticalStack(tw.roenter, tw.roro))
|
tw.t.Append("Read-Only", newVerticalStack(tw.roenter, tw.roro))
|
||||||
tw.icons, tw.il = readIcons() // repainter uses these
|
tw.icons = readIcons() // repainter uses these
|
||||||
tw.repainter = newRepainter(15)
|
tw.repainter = newRepainter(15)
|
||||||
tw.t.Append("Repaint", tw.repainter.grid)
|
tw.t.Append("Repaint", tw.repainter.grid)
|
||||||
tw.addfe()
|
tw.addfe()
|
||||||
|
@ -194,7 +193,6 @@ func (tw *testwin) make(done chan struct{}) {
|
||||||
idq := tw.icontbl.Data().(*[]icon)
|
idq := tw.icontbl.Data().(*[]icon)
|
||||||
*idq = tw.icons
|
*idq = tw.icons
|
||||||
tw.icontbl.Unlock()
|
tw.icontbl.Unlock()
|
||||||
tw.icontbl.LoadImageList(tw.il)
|
|
||||||
tw.icontbl.OnSelected(func() {
|
tw.icontbl.OnSelected(func() {
|
||||||
s := fmt.Sprintf("%d ", tw.icontbl.Selected())
|
s := fmt.Sprintf("%d ", tw.icontbl.Selected())
|
||||||
tw.icontbl.RLock()
|
tw.icontbl.RLock()
|
||||||
|
|
Loading…
Reference in New Issue