Renamed Control.apply() to Control.make().

This commit is contained in:
Pietro Gagliardi 2014-02-14 11:12:08 -05:00
parent 8407bfb0cb
commit 80f43a613a
5 changed files with 8 additions and 8 deletions

View File

@ -35,7 +35,7 @@ func (b *Button) SetText(text string) (err error) {
return nil
}
func (b *Button) apply(window *sysData) error {
func (b *Button) make(window *sysData) error {
b.lock.Lock()
defer b.lock.Unlock()

View File

@ -47,7 +47,7 @@ func (c *Checkbox) Checked() bool {
return check
}
func (c *Checkbox) apply(window *sysData) error {
func (c *Checkbox) make(window *sysData) error {
c.lock.Lock()
defer c.lock.Unlock()

View File

@ -8,6 +8,6 @@ import (
// A Control represents an UI control. Note that Control contains unexported members; this has the consequence that you can't build custom controls that interface directly with the system-specific code (fo rinstance, to import an unsupported control), or at least not without some hackery. If you want to make your own controls, embed Area and provide its necessities.
type Control interface {
apply(window *sysData) error
make(window *sysData) error
setRect(x int, y int, width int, height int) error
}

View File

@ -33,9 +33,9 @@ func NewStack(o Orientation, controls ...Control) *Stack {
}
// TODO adorn errors with which stage failed
func (s *Stack) apply(window *sysData) error {
func (s *Stack) make(window *sysData) error {
for _, c := range s.controls {
err := c.apply(window)
err := c.make(window)
if err != nil {
return err
}

View File

@ -74,7 +74,7 @@ func (w *Window) Open(control Control) (err error) {
}
if control != nil {
w.sysData.resize = control.setRect
err = control.apply(w.sysData)
err = control.make(w.sysData)
if err != nil {
return err
}
@ -95,8 +95,8 @@ func (w *Window) Hide() (err error) {
// These satisfy the Control interface, allowing a window to own a control. As a consequence, Windows are themselves Controls. THIS IS UNDOCUMENTED AND UNSUPPORTED. I can make it supported in the future, but for now, no. You shouldn't be depending on the internals of the library to develop your programs: if the documentation is incomplete and/or wrong, get the person responsible to fix it, as the documentation, not the implementation, is your contract to what you can or cannot do. Don't worry, this package is in good company: Go itself was designed spec-first for this reason.
// If I decide not to support windows as controls, a better way to deal with controls would be in order. Perhaps separate interfaces...? Making Windows Controls seems the cleanest option for now (and with correct usage of the library costs nothing).
func (w *Window) apply(window *sysData) error {
panic("Window.apply() should never be called")
func (w *Window) make(window *sysData) error {
panic("Window.make() should never be called")
}
func (w *Window) setRect(x int, y int, width int, height int) error {
panic("Window.setRect() should never be called")