diff --git a/composer.go b/composer.go index 07285b6..4c77425 100644 --- a/composer.go +++ b/composer.go @@ -203,7 +203,6 @@ func (c *Composer) resizeTopView(ev termbox.Event) bool { } w, h := view.Size() - wm, hm := view.Constraints() w1, h1 := w, h minW, minH := view.Constraints() if ev.Key == termbox.KeyArrowUp && minH < h { diff --git a/control_base.go b/control_base.go index 7823ed2..196580b 100644 --- a/control_base.go +++ b/control_base.go @@ -171,6 +171,9 @@ func (c *ControlBase) Parent() Control { return c.parent } +func (c *ControlBase) RecalculateConstraints() { +} + //---------- debug ---------------- func (c *ControlBase) Logger() *log.Logger { if c.parent == nil { diff --git a/frame.go b/frame.go index b9bc48f..920b8a3 100644 --- a/frame.go +++ b/frame.go @@ -95,6 +95,12 @@ func (f *Frame) RecalculateConstraints() { if newW != width || newH != height { f.SetConstraints(newW, newH) } + + if f.parent != nil { + f.parent.RecalculateConstraints() + } else if f.view != nil { + f.view.RecalculateConstraints() + } } func (f *Frame) AddChild(c Control, scale int) { diff --git a/interface.go b/interface.go index 4c62fde..0620dc7 100644 --- a/interface.go +++ b/interface.go @@ -59,6 +59,7 @@ type View interface { SetScale(int) TabStop() bool Colors() (term.Attribute, term.Attribute) + RecalculateConstraints() Logger() *log.Logger } @@ -86,5 +87,7 @@ type Control interface { Parent() Control Colors() (term.Attribute, term.Attribute) + RecalculateConstraints() + Logger() *log.Logger } diff --git a/label.go b/label.go index e0ad8e1..069ac82 100644 --- a/label.go +++ b/label.go @@ -23,7 +23,7 @@ func NewLabel(view View, parent Control, w, h int, title string, scale int) *Lab c.tabSkip = true c.fg = ColorWhite - c.bg = ColorBlack + c.bg = ColorBlackBold if parent != nil { parent.AddChild(c, scale) diff --git a/window.go b/window.go index 97ff844..89592dc 100644 --- a/window.go +++ b/window.go @@ -276,7 +276,9 @@ func (w *Window) ProcessEvent(ev Event) bool { if ev.Type == EventKey && (ev.Key == term.KeyTab || (ev.Mod&term.ModAlt != 0 && (ev.Key == term.KeyPgup || ev.Key == term.KeyPgdn))) { forward := ev.Key != term.KeyPgup ctrl := w.ActiveControl() - ctrl.ProcessEvent(Event{Type: EventActivate, X: 0}) + if ctrl != nil { + ctrl.ProcessEvent(Event{Type: EventActivate, X: 0}) + } ctrl = w.NextControl(ctrl, forward) if ctrl != nil { // w.Logger().Printf("Activate control: %v", ctrl)