Reimplemented Control.containerShow()/Control.containerHide(). Will be needed to fully move Tab on Windows away from container.
This commit is contained in:
parent
ca39a32a90
commit
335480db7c
15
control.go
15
control.go
|
@ -8,6 +8,11 @@ type Control interface {
|
|||
preferredSize(d *sizing) (width, height int)
|
||||
resize(x int, y int, width int, height int, d *sizing)
|
||||
nTabStops() int // used by the Windows backend
|
||||
|
||||
// these are provided for Tab on Windows, where we have to show and hide the individual tab pages manually
|
||||
// if we ever get something like a SidebarStack of some sort, we'll need to implement this everywhere
|
||||
containerShow() // show if and only if programmer said to show
|
||||
containerHide() // hide regardless of whether programmer said to hide
|
||||
}
|
||||
|
||||
type controlbase struct {
|
||||
|
@ -15,6 +20,8 @@ type controlbase struct {
|
|||
fpreferredSize func(d *sizing) (width, height int)
|
||||
fresize func(x int, y int, width int, height int, d *sizing)
|
||||
fnTabStops func() int
|
||||
fcontainerShow func()
|
||||
fcontainerHide func()
|
||||
}
|
||||
|
||||
// children should not use the same name as these, otherwise weird things will happen
|
||||
|
@ -34,3 +41,11 @@ func (c *controlbase) resize(x int, y int, width int, height int, d *sizing) {
|
|||
func (c *controlbase) nTabStops() int {
|
||||
return c.fnTabStops()
|
||||
}
|
||||
|
||||
func (c *controlbase) containerShow() {
|
||||
c.fcontainerShow()
|
||||
}
|
||||
|
||||
func (c *controlbase) containerHide() {
|
||||
c.fcontainerHide()
|
||||
}
|
||||
|
|
|
@ -25,6 +25,12 @@ func newControlSingleHWND(hwnd C.HWND) *controlSingleHWND {
|
|||
// most controls count as one tab stop
|
||||
return 1
|
||||
},
|
||||
fcontainerShow: func() {
|
||||
C.ShowWindow(c.hwnd, C.SW_SHOW)
|
||||
},
|
||||
fcontainerHide: func() {
|
||||
C.ShowWindow(c.hwnd, C.SW_HIDE)
|
||||
},
|
||||
}
|
||||
c.hwnd = hwnd
|
||||
return c
|
||||
|
|
12
grid.go
12
grid.go
|
@ -178,6 +178,18 @@ func (g *grid) setParent(p *controlParent) {
|
|||
g.container.setParent(p)
|
||||
}
|
||||
|
||||
func (g *grid) containerShow() {
|
||||
for _, c := range g.controls {
|
||||
c.control.containerShow()
|
||||
}
|
||||
}
|
||||
|
||||
func (g *grid) containerHide() {
|
||||
for _, c := range g.controls {
|
||||
c.control.containerHide()
|
||||
}
|
||||
}
|
||||
|
||||
// builds the topological cell grid; also makes colwidths and rowheights
|
||||
func (g *grid) mkgrid() (gg [][]int, colwidths []int, rowheights []int) {
|
||||
gg = make([][]int, g.ymax)
|
||||
|
|
|
@ -124,6 +124,22 @@ func (g *simpleGrid) setParent(parent *controlParent) {
|
|||
g.container.setParent(parent)
|
||||
}
|
||||
|
||||
func (g *simpleGrid) containerShow() {
|
||||
for _, cc := range g.controls {
|
||||
for _, c := range cc {
|
||||
c.containerShow()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (g *simpleGrid) containerHide() {
|
||||
for _, cc := range g.controls {
|
||||
for _, c := range cc {
|
||||
c.containerHide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (g *simpleGrid) resize(x int, y int, width int, height int, d *sizing) {
|
||||
max := func(a int, b int) int {
|
||||
if a > b {
|
||||
|
|
12
stack.go
12
stack.go
|
@ -85,6 +85,18 @@ func (s *stack) setParent(parent *controlParent) {
|
|||
s.container.setParent(parent)
|
||||
}
|
||||
|
||||
func (s *stack) containerShow() {
|
||||
for _, c := range s.controls {
|
||||
c.containerShow()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *stack) containerHide() {
|
||||
for _, c := range s.controls {
|
||||
c.containerHide()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *stack) resize(x int, y int, width int, height int, d *sizing) {
|
||||
var stretchywid, stretchyht int
|
||||
|
||||
|
|
Loading…
Reference in New Issue