fix interface a bit

This commit is contained in:
Vladimir Markelov 2015-10-27 17:47:53 -07:00
parent 17a8932085
commit 303b14ab7c
3 changed files with 19 additions and 5 deletions

View File

@ -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

View File

@ -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)

View File

@ -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) {