reimplement the color button
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
9bfabef760
commit
999a8fd199
25
button.go
25
button.go
|
@ -88,3 +88,28 @@ func CreateFontButton(box *GuiBox, action string) *GuiButton {
|
||||||
})
|
})
|
||||||
return &newGB
|
return &newGB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateColorButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
|
||||||
|
// create a 'fake' button entry for the mouse clicks
|
||||||
|
var newCB GuiButton
|
||||||
|
newCB.Name = name
|
||||||
|
newCB.CB = ui.NewColorButton()
|
||||||
|
newCB.Box = box
|
||||||
|
newCB.Custom = custom
|
||||||
|
newCB.Values = values
|
||||||
|
|
||||||
|
Data.AllButtons = append(Data.AllButtons, &newCB)
|
||||||
|
|
||||||
|
newCB.CB.OnChanged(func (*ui.ColorButton) {
|
||||||
|
log.Println("ColorButton.OnChanged() START Color Button Click")
|
||||||
|
r, g, b, a := newCB.CB.Color()
|
||||||
|
log.Println("ColorButton.OnChanged() Color() =", r, g, b, a)
|
||||||
|
if (newCB.Custom != nil) {
|
||||||
|
newCB.Custom(&newCB)
|
||||||
|
} else if (Data.MouseClick != nil) {
|
||||||
|
Data.MouseClick(&newCB)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
box.UiBox.Append(newCB.CB, false)
|
||||||
|
return &newCB
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package gui
|
||||||
|
|
||||||
|
//
|
||||||
|
// convert between 'standard' golang Color and andlabs/ui Color
|
||||||
|
//
|
||||||
|
|
||||||
|
// import "log"
|
||||||
|
// import "fmt"
|
||||||
|
import "image/color"
|
||||||
|
|
||||||
|
import "github.com/andlabs/ui"
|
||||||
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
|
func libuiColorToGOlangColor(rgba color.RGBA) ui.TableColor {
|
||||||
|
/* a hack to see if colors work differently on macos or windows
|
||||||
|
if (rgba.R == 72) {
|
||||||
|
log.Println("SETTING COLOR TO NIL")
|
||||||
|
log.Println("SETTING COLOR TO NIL")
|
||||||
|
log.Println("SETTING COLOR TO NIL")
|
||||||
|
return ui.TableColor{}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return ui.TableColor{float64(rgba.R) / 256, float64(rgba.G) / 256, float64(rgba.B) / 256, float64(rgba.A) / 256}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func golangColorGOlibuiColorTo (ui.TableColor) (rgba color.RGBA) {
|
||||||
|
color.RGBA{float64(, 100, 200, 100}
|
||||||
|
return ui.TableColor{float64(rgba.R) / 256, float64(rgba.G) / 256, float64(rgba.B) / 256, float64(rgba.A) / 256}
|
||||||
|
}
|
||||||
|
*/
|
16
debug.go
16
debug.go
|
@ -41,15 +41,9 @@ func DumpBoxes() {
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
||||||
pages := window.UiTab.NumPages()
|
pages := window.UiTab.NumPages()
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
||||||
for i := 0; i < pages; i++ {
|
// for i := 0; i < pages; i++ {
|
||||||
log.Println("gui.DumpBoxes()\t\tWindow.UiTab.Margined(", i, ") =")
|
// log.Println("gui.DumpBoxes()\t\tWindow.UiTab.Margined(", i, ") =", window.UiTab.Margined(i))
|
||||||
log.Println(window.UiTab.Margined(i))
|
// }
|
||||||
/*
|
|
||||||
if (window.UiTab.Margined(i)) {
|
|
||||||
window.UiTab.SetMargined(i, false)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
// tmp := spew.NewDefaultConfig()
|
// tmp := spew.NewDefaultConfig()
|
||||||
// tmp.MaxDepth = 2
|
// tmp.MaxDepth = 2
|
||||||
// tmp.Dump(window.UiTab)
|
// tmp.Dump(window.UiTab)
|
||||||
|
@ -60,7 +54,7 @@ func DumpBoxes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, window := range Data.Windows {
|
for i, window := range Data.Windows {
|
||||||
log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name)
|
log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name, "TabNumber =", window.TabNumber)
|
||||||
for name, abox := range window.BoxMap {
|
for name, abox := range window.BoxMap {
|
||||||
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
||||||
if (name == "MAINBOX") {
|
if (name == "MAINBOX") {
|
||||||
|
@ -74,7 +68,7 @@ func DumpBoxes() {
|
||||||
if (name == "DEBUG") {
|
if (name == "DEBUG") {
|
||||||
log.Println("\t\twatchGUI() BOX abox =", reflect.TypeOf(abox))
|
log.Println("\t\twatchGUI() BOX abox =", reflect.TypeOf(abox))
|
||||||
win := abox.Window
|
win := abox.Window
|
||||||
log.Println("\t\twatchGUI() BOX win =", reflect.TypeOf(win))
|
log.Println("\t\twatchGUI() BOX win =", reflect.TypeOf(win))
|
||||||
area := win.Area
|
area := win.Area
|
||||||
log.Println("\t\twatchGUI() BOX area =", reflect.TypeOf(area), area.UiArea)
|
log.Println("\t\twatchGUI() BOX area =", reflect.TypeOf(area), area.UiArea)
|
||||||
// spew.Dump(area.UiArea)
|
// spew.Dump(area.UiArea)
|
||||||
|
|
|
@ -64,6 +64,7 @@ type GuiWindow struct {
|
||||||
Width int
|
Width int
|
||||||
Height int
|
Height int
|
||||||
Axis int // does it add items to the X or Y axis
|
Axis int // does it add items to the X or Y axis
|
||||||
|
TabNumber int // the andlabs/ui tab index
|
||||||
|
|
||||||
// the callback function to make the window contents
|
// the callback function to make the window contents
|
||||||
MakeWindow func(*GuiWindow) *GuiBox
|
MakeWindow func(*GuiWindow) *GuiBox
|
||||||
|
@ -100,10 +101,12 @@ type GuiButton struct {
|
||||||
// a callback function for the main application
|
// a callback function for the main application
|
||||||
Custom func (*GuiButton)
|
Custom func (*GuiButton)
|
||||||
Values interface {}
|
Values interface {}
|
||||||
|
Color color.RGBA
|
||||||
|
|
||||||
// andlabs/ui abstraction mapping
|
// andlabs/ui abstraction mapping
|
||||||
B *ui.Button
|
B *ui.Button
|
||||||
FB *ui.FontButton
|
FB *ui.FontButton
|
||||||
|
CB *ui.ColorButton
|
||||||
}
|
}
|
||||||
|
|
||||||
// text entry fields
|
// text entry fields
|
||||||
|
|
|
@ -29,18 +29,6 @@ func (mh *TableData) ColumnTypes(m *ui.TableModel) []ui.TableValue {
|
||||||
return mh.generatedColumnTypes
|
return mh.generatedColumnTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
func libuiColorToGOlangColor(rgba color.RGBA) ui.TableColor {
|
|
||||||
/* a hack to see if colors work differently on macos or windows
|
|
||||||
if (rgba.R == 72) {
|
|
||||||
log.Println("SETTING COLOR TO NIL")
|
|
||||||
log.Println("SETTING COLOR TO NIL")
|
|
||||||
log.Println("SETTING COLOR TO NIL")
|
|
||||||
return ui.TableColor{}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return ui.TableColor{float64(rgba.R) / 256, float64(rgba.G) / 256, float64(rgba.B) / 256, float64(rgba.A) / 256}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Figure out why this is being called 1000 times a second (10 times for each row & column)
|
// TODO: Figure out why this is being called 1000 times a second (10 times for each row & column)
|
||||||
// Nevermind this TODO. Who gives a shit. This is a really smart way to treat the OS toolkits
|
// Nevermind this TODO. Who gives a shit. This is a really smart way to treat the OS toolkits
|
||||||
func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue {
|
func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue {
|
||||||
|
|
Loading…
Reference in New Issue