[Openmcl-devel] easygui design: view size and position
rich at richsutton.com
Sat Jun 7 18:33:13 EDT 2008
this is a question about the design of easygui. i am trying to
understand it a bit better so that can build on it effectively.
an easygui view is a CLOS object with instance variables for the size
and position of (i believe) the view's frame. here is the definition:
(defclass view (easy-cocoa-object)
((position :initarg :position :reader view-position)
(size :initarg :size :reader view-size)
(frame-inited-p :initform nil)))
a fourth instance variable (inherited from easy-cocoa-object) is a
reference to the actual cocoa object for the view (the NSView). and
this leads to my question about the size and position instance
variables, because the cocoa NSView also contains size and position
information about the view's frame. the question is: What is the
intended relationship between the size and position variables stored
in the CLOS object and those stored in the cocoa object? i can
imagine several possibilities:
1. they are meant always to be the same, and the code should try to
maintain the match whenever either changes.
2. the CLOS variables are a convenience for initializing the frame of
a view. we try to initialize the cocoa view from them, but we don't
rely on any relationship between them after that.
3. we need to keep both sets of frame information distinct to handle
some cases that are not apparent to me right now.
to me, naively, it would seem best to store the frame information only
once, in the cocoa NSView, and to provide accessor functions for
conveniently reading and writing it. then the information would be
only in one place and could not get out of synch.
please let me know if you have any insight into this.
More information about the Openmcl-devel