diff --git a/control_base.go b/control_base.go index 3fe24e1..39ee185 100644 --- a/control_base.go +++ b/control_base.go @@ -79,10 +79,10 @@ func (c *ControlBase) SetPos(x, y int) { c.y = y } -// ApplyConstraints checks if the current size fits minimal size. +// applyConstraints checks if the current size fits minimal size. // Contol size is increased if its size is less than the current // contol minimal size -func (c *ControlBase) ApplyConstraints() { +func (c *ControlBase) applyConstraints() { w, h := c.Size() wM, hM := c.Constraints() @@ -110,7 +110,7 @@ func (c *ControlBase) SetConstraints(width, height int) { c.minH = height } - c.ApplyConstraints() + c.applyConstraints() } // Constraints return minimal control widht and height diff --git a/interface.go b/interface.go index 041bc98..19045ea 100644 --- a/interface.go +++ b/interface.go @@ -112,11 +112,25 @@ type View interface { } type Control interface { + // Title returns the current title or text of the control Title() string + // SetTitle changes control text or title SetTitle(string) + // Pos returns the current control position: X and Y. + // For View the position's origin is top left corner of console window, + // for other controls the origin is top left corner of View that hold + // the control Pos() (int, int) + // SetPos changes contols position. Manual call of the method does not + // make sense for any control except View because control positions + // inside of container always recalculated after View resizes SetPos(int, int) + // Size returns current control width and height Size() (int, int) + // SetSize changes control size. Constant DoNotChange can be + // used as placeholder to indicate that the control attrubute + // should be unchanged. + // Method panics if new size is less than minimal size SetSize(int, int) Scale() int SetScale(int) diff --git a/window.go b/window.go index a7a3064..1b6958b 100644 --- a/window.go +++ b/window.go @@ -67,7 +67,7 @@ func (w *Window) SetSize(width, height int) { RepositionControls(0, 0, w) } -func (w *Window) ApplyConstraints() { +func (w *Window) applyConstraints() { width, height := w.Size() wM, hM := w.Constraints() @@ -92,7 +92,7 @@ func (w *Window) SetConstraints(width, height int) { w.minH = height } - w.ApplyConstraints() + w.applyConstraints() } func (w *Window) Draw(canvas Canvas) {