mirror of
https://github.com/VladimirMarkelov/clui.git
synced 2025-04-28 13:48:50 +08:00
fix interface a bit
This commit is contained in:
parent
17a8932085
commit
303b14ab7c
@ -79,10 +79,10 @@ func (c *ControlBase) SetPos(x, y int) {
|
|||||||
c.y = y
|
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 size is increased if its size is less than the current
|
||||||
// contol minimal size
|
// contol minimal size
|
||||||
func (c *ControlBase) ApplyConstraints() {
|
func (c *ControlBase) applyConstraints() {
|
||||||
w, h := c.Size()
|
w, h := c.Size()
|
||||||
wM, hM := c.Constraints()
|
wM, hM := c.Constraints()
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ func (c *ControlBase) SetConstraints(width, height int) {
|
|||||||
c.minH = height
|
c.minH = height
|
||||||
}
|
}
|
||||||
|
|
||||||
c.ApplyConstraints()
|
c.applyConstraints()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constraints return minimal control widht and height
|
// Constraints return minimal control widht and height
|
||||||
|
14
interface.go
14
interface.go
@ -112,11 +112,25 @@ type View interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Control interface {
|
type Control interface {
|
||||||
|
// Title returns the current title or text of the control
|
||||||
Title() string
|
Title() string
|
||||||
|
// SetTitle changes control text or title
|
||||||
SetTitle(string)
|
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)
|
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)
|
SetPos(int, int)
|
||||||
|
// Size returns current control width and height
|
||||||
Size() (int, int)
|
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)
|
SetSize(int, int)
|
||||||
Scale() int
|
Scale() int
|
||||||
SetScale(int)
|
SetScale(int)
|
||||||
|
@ -67,7 +67,7 @@ func (w *Window) SetSize(width, height int) {
|
|||||||
RepositionControls(0, 0, w)
|
RepositionControls(0, 0, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) ApplyConstraints() {
|
func (w *Window) applyConstraints() {
|
||||||
width, height := w.Size()
|
width, height := w.Size()
|
||||||
wM, hM := w.Constraints()
|
wM, hM := w.Constraints()
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ func (w *Window) SetConstraints(width, height int) {
|
|||||||
w.minH = height
|
w.minH = height
|
||||||
}
|
}
|
||||||
|
|
||||||
w.ApplyConstraints()
|
w.applyConstraints()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Draw(canvas Canvas) {
|
func (w *Window) Draw(canvas Canvas) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user