[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: doc bug



>Date: Fri, 31 Jan 92 12:39:21 CST
>From: liberte@ncsa.uiuc.edu (Daniel LaLiberte)
>To: bug-mcl@cambridge.apple.com
>Subject: doc bug
>
>The order in which subviews are displayed, pick-tested, and inserted
>with add-subviews is not fully specified.    Only in
>view-click-event-handler does it say anything.  "The first view added
>is the first one drawn but the last one to be queried during clicking."
>So does add-subviews add to the end of the subviews vector?  
>remove-subviews should leave the remaining subviews in the same order
>if the add-order condition is to remain true.

The view-click-event-handler documentation says it correctly.
Each added view is conceptually in front of the others as you
look at the screen. Hence, they are drawn in the same order as
added, so that views that are "closer" to the viewer will obscure
views that are "farther away". Hit testing needs to look at the
"closer" views first, so it looks at the list in opposite the
order added. remove-subviews does the right thing apropos view
ordering. Conclusion, add-subviews adds to the end of the
view-subviews vector.

>
>I also need a fast way to reorder all the subviews of a view without
>removing and reinserting them.  The doc for view-subviews says
>the vector of subviews should not be changed directly, but this is
>precisely what I need to do.  What dangers lurk?  [These subviews
>represent the projection of 3D objects, and rotation will change the
>back to front order in which they should be displayed.]

Actually, I doubt that you would get in any horrible trouble by
changing the vector. Fortunately, however, there are functions in MCL
to do what you want. I negelected to export them for 2.0b1, and
neglected to document them for 2.0 final, but they will be around for
a while:


CCL::VIEW-LEVEL (view simple-view)                 [Generic function]

Returns the level of the given view relative to its siblings. The
frontmost view, which is the one most recently added by add-subviews or
set-view-container, has a level of 0. The backmost view, which is the
one first added by add-subviews or set-view-container, has a level of
(1- (length (view-subviews (view-container view)))). If the view has no
container, view-level will return 0.


CCL::SET-VIEW-LEVEL (view simple-view) level       [Generic function]

Changes the level of the given view relative to its siblings. After
(set-view-level view level), (view-level view) will return level.
Signals an error unless:
  
   (<= 0 level (1- (length (view-subviews (view-container view)))))

invalidates view's container so that it will be redrawn with the
new subview ordering. set-view-level is a nop if view has no container.


CCL::VIEW-BRING-TO-FRONT (view simple-view)        [Generic function]

Same as (set-view-level view 0)


CCL::VIEW-SEND-TO-BACK (view simple-view)          [Generic function]

Same as:

(set-view-level
 view
 (1- (length (view-subviews (view-container view)))))

Except that it does nothing if view has no container.