Overlapping Views

  • Hi,

    Im been working in Carbon for a number of years & am currently
    investigating the possibility of writting some apps in Cocoa.

    In IB whenever I have overlapping views I get warnings about illegal
    geometry & views overlapping other views. Does this mean that Cocoa
    doesn't really support overlapping views? If so, do views generally
    composite properly when overlapping?

    TIA,
    David Alger

    --
    David Alger,
    Software Engineer
    Family Friendly Software, LLC
    http://www.familyfriendlysoftware.com
  • On Nov 22, 2007, at 9:49 PM, David Alger wrote:

    > Im been working in Carbon for a number of years & am currently
    > investigating the possibility of writting some apps in Cocoa.
    >
    > In IB whenever I have overlapping views I get warnings about illegal
    > geometry & views overlapping other views. Does this mean that Cocoa
    > doesn't really support overlapping views? If so, do views generally
    > composite properly when overlapping?

    This is a FAQ.  Short answer is no.  For the long answer, read up
    documentation and search the archives.

    ___________________________________________________________
    Ricky A. Sharp        mailto:<rsharp...>
    Instant Interactive(tm)  http://www.instantinteractive.com
  • Hey David -

    NSView fully supports overlapping sibling views on Leopard and later.

    Jon Hess

    On Nov 22, 2007, at 7:49 PM, David Alger <dev-lists...>
    > wrote:

    > Hi,
    >
    > Im been working in Carbon for a number of years & am currently
    > investigating the possibility of writting some apps in Cocoa.
    >
    > In IB whenever I have overlapping views I get warnings about illegal
    > geometry & views overlapping other views. Does this mean that Cocoa
    > doesn't really support overlapping views? If so, do views generally
    > composite properly when overlapping?
    >
    > TIA,
    > David Alger
    >
    >
    > --
    > David Alger,
    > Software Engineer
    > Family Friendly Software, LLC
    > http://www.familyfriendlysoftware.com
  • On Nov 22, 2007, at 11:02 PM, Ricky Sharp wrote:

    >
    > On Nov 22, 2007, at 9:49 PM, David Alger wrote:
    >
    >> Im been working in Carbon for a number of years & am currently
    >> investigating the possibility of writting some apps in Cocoa.
    >>
    >> In IB whenever I have overlapping views I get warnings about
    >> illegal geometry & views overlapping other views. Does this mean
    >> that Cocoa doesn't really support overlapping views? If so, do
    >> views generally composite properly when overlapping?
    >
    > This is a FAQ.  Short answer is no.  For the long answer, read up
    > documentation and search the archives.

    Well, actually now the short answer is "it depends on the target system"

    it should work fine on 10.5. I that restriction was lifted for
    Leopard. Have a look at the CocoaSlides example for evidence of this.

    Before 10.5 it wasn't supported.
  • Thanks to all who responded. As to using Leopard only stuff, I can't
    since I'll be supporting at least back to Tiger (haven't decided on
    whether I'll support Panther yet).

    --David Alger

    On Nov 23, 2007, at 1:09 AM, Jon Hess wrote:

    > Hey David -
    >
    > NSView fully supports overlapping sibling views on Leopard and later.
    >
    > Jon Hess
    >
    > On Nov 22, 2007, at 7:49 PM, David Alger <dev-lists...>
    >> wrote:
    >
    >> Hi,
    >>
    >> Im been working in Carbon for a number of years & am currently
    >> investigating the possibility of writting some apps in Cocoa.
    >>
    >> In IB whenever I have overlapping views I get warnings about
    >> illegal geometry & views overlapping other views. Does this mean
    >> that Cocoa doesn't really support overlapping views? If so, do
    >> views generally composite properly when overlapping?
    >>
    >> TIA,
    >> David Alger
    >>
    >>
    >> --
    >> David Alger,
    >> Software Engineer
    >> Family Friendly Software, LLC
    >> http://www.familyfriendlysoftware.com

    ********************
    Ron Paul for President 2008
    http://ronpaul2008.com/

    RESTORE THE REPUBLIC & RETAIN YOUR RIGHTS
  • On Nov 23, 2007, at 2:06 AM, Scott Anguish wrote:

    >
    > On Nov 22, 2007, at 11:02 PM, Ricky Sharp wrote:
    >
    >>
    >> On Nov 22, 2007, at 9:49 PM, David Alger wrote:
    >>
    >>> Im been working in Carbon for a number of years & am currently
    >>> investigating the possibility of writting some apps in Cocoa.
    >>>
    >>> In IB whenever I have overlapping views I get warnings about
    >>> illegal geometry & views overlapping other views. Does this mean
    >>> that Cocoa doesn't really support overlapping views? If so, do
    >>> views generally composite properly when overlapping?
    >>
    >> This is a FAQ.  Short answer is no.  For the long answer, read up
    >> documentation and search the archives.
    >
    > Well, actually now the short answer is "it depends on the target
    > system"
    >
    > it should work fine on 10.5. I that restriction was lifted for
    > Leopard. Have a look at the CocoaSlides example for evidence of this.
    >
    > Before 10.5 it wasn't supported.

    I had thought that only views put into Core Animation layers could be
    overlapped.  Thus, I didn't extend this CA capability to views in
    general.  Very nice if any view can now be overlapped whether using CA
    or not.

    ___________________________________________________________
    Ricky A. Sharp        mailto:<rsharp...>
    Instant Interactive(tm)  http://www.instantinteractive.com
  • On 23 Nov 2007, at 07:09, Jon Hess wrote:

    > NSView fully supports overlapping sibling views on Leopard and later.

    I know it's been a common request for ages on the list, but I've never
    quite been sure why people are so keen on being able to have
    overlapping sibling views.  If one is completely contained within the
    other, the parent-child relationship seems cleaner (and has always
    worked); and if that isn't possible then surely in most cases it's
    going to look ugly?

    So, out of interest, David, what were you trying to achieve that
    needed overlapping views?

    Kind regards,

    Alastair.

    --
    http://alastairs-place.net
  • On Nov 23, 2007, at 10:01 AM, Alastair Houghton wrote:

    > On 23 Nov 2007, at 07:09, Jon Hess wrote:
    >
    >> NSView fully supports overlapping sibling views on Leopard and later.
    >
    > I know it's been a common request for ages on the list, but I've
    > never quite been sure why people are so keen on being able to have
    > overlapping sibling views.  If one is completely contained within
    > the other, the parent-child relationship seems cleaner (and has
    > always worked); and if that isn't possible then surely in most cases
    > it's going to look ugly?
    >
    > So, out of interest, David, what were you trying to achieve that
    > needed overlapping views?

    This particular app would be a full-screen app. The main window,
    covering most if not all of the screen, would have a background image
    with other controls directly on top of it. They would be customized to
    the extent I could in IB & sub-classed if necessary, which I know that
    I will have to do to achieve the behavior & appearance I want in some.
    Since the NSImage view doesn't support sub-views (I'm assuming it
    doesn't since IB won't let me put any in it), I was trying to have the
    NSImage view behind the other views so I wouldn't have to customize a
    NSView & draw the image manually.

    This will be my very first app written in Cocoa/Obj-C, and I'm very
    used to having compositing views in Carbon. I won't be overlapping
    views like this though if it isn't really supported, since I don't
    want my app to possibly have erratic drawing/refresh behavior.

    Regards,
    David Alger

    ********************
    Ron Paul for President 2008
    http://ronpaul2008.com/

    RESTORE THE REPUBLIC & RETAIN YOUR RIGHTS
  • On Nov 23, 2007, at 11:03 AM, David Alger wrote:

    >
    > On Nov 23, 2007, at 10:01 AM, Alastair Houghton wrote:
    >
    >> On 23 Nov 2007, at 07:09, Jon Hess wrote:
    >>
    >>> NSView fully supports overlapping sibling views on Leopard and
    >>> later.
    >>
    >> I know it's been a common request for ages on the list, but I've
    >> never quite been sure why people are so keen on being able to have
    >> overlapping sibling views.  If one is completely contained within
    >> the other, the parent-child relationship seems cleaner (and has
    >> always worked); and if that isn't possible then surely in most
    >> cases it's going to look ugly?
    >>
    >> So, out of interest, David, what were you trying to achieve that
    >> needed overlapping views?
    >
    > This particular app would be a full-screen app. The main window,
    > covering most if not all of the screen, would have a background
    > image with other controls directly on top of it. They would be
    > customized to the extent I could in IB & sub-classed if necessary,
    > which I know that I will have to do to achieve the behavior &
    > appearance I want in some. Since the NSImage view doesn't support
    > sub-views (I'm assuming it doesn't since IB won't let me put any in
    > it), I was trying to have the NSImage view behind the other views so
    > I wouldn't have to customize a NSView & draw the image manually.
    >
    > This will be my very first app written in Cocoa/Obj-C, and I'm very
    > used to having compositing views in Carbon. I won't be overlapping
    > views like this though if it isn't really supported, since I don't
    > want my app to possibly have erratic drawing/refresh behavior.

    In this specific case, it is trivial to do what you want with subviews.

    Drag in a custom view which will serve as your background view.  IB
    knows that custom views are contain views and thus you can put
    anything you want inside.  Subclass NSView and specify that class for
    your custom view.  It's drawRect: will draw whatever image you want.

    Building upon that, you could always put your NSView subclass into an
    IB Plug-In (if using IB 3.x) or a palette (IB 2.x).  That's the
    approach I went with.  I thus had a container view with a single
    'background image' attribute that I could set at design time within
    IB.  IB also displayed the selected image to include when running
    under the simulator.

    ___________________________________________________________
    Ricky A. Sharp        mailto:<rsharp...>
    Instant Interactive(tm)  http://www.instantinteractive.com
  • On 23 Nov 2007, at 17:03, David Alger wrote:

    > This particular app would be a full-screen app. The main window,
    > covering most if not all of the screen, would have a background
    > image with other controls directly on top of it. They would be
    > customized to the extent I could in IB & sub-classed if necessary,
    > which I know that I will have to do to achieve the behavior &
    > appearance I want in some. Since the NSImage view doesn't support
    > sub-views (I'm assuming it doesn't since IB won't let me put any in
    > it), I was trying to have the NSImage view behind the other views so
    > I wouldn't have to customize a NSView & draw the image manually.

    Ah, I see.  IB may not let you put subviews inside it, but I think
    you'll find that you can add them programmatically, in which case the
    normal view machinery will work just fine.

    Another (probably easier) way to achieve something similar would be to
    use a custom view, set its class to NSImageView, then initialise it
    from your -awakeFromNib routine in your application's controller
    object.  IB *will* let you put views inside a custom view.

    I think that should solve the problem for you without needing any
    support for overlapped sibling views.

    > This will be my very first app written in Cocoa/Obj-C, and I'm very
    > used to having compositing views in Carbon. I won't be overlapping
    > views like this though if it isn't really supported, since I don't
    > want my app to possibly have erratic drawing/refresh behavior.

    As I say, child views are pretty much always supported, even though IB
    might not let you create them in some cases.

    Kind regards,

    Alastair.

    --
    http://alastairs-place.net
  • >
    > This particular app would be a full-screen app. The main window,
    > covering most if not all of the screen, would have a background
    > image with other controls directly on top of it. They would be
    > customized to the extent I could in IB & sub-classed if necessary,
    > which I know that I will have to do to achieve the behavior &
    > appearance I want in some. Since the NSImage view doesn't support
    > sub-views (I'm assuming it doesn't since IB won't let me put any in
    > it), I was trying to have the NSImage view behind the other views
    > so I wouldn't have to customize a NSView & draw the image manually.
    >
    > This will be my very first app written in Cocoa/Obj-C, and I'm very
    > used to having compositing views in Carbon. I won't be overlapping
    > views like this though if it isn't really supported, since I don't
    > want my app to possibly have erratic drawing/refresh behavior.
    >
    >
    > Regards,
    > David Alger

    Assumption are evil. AFAK Image view should support subview.
    IB will not let you add subview, but you can replace your image view
    by a custom view. Set the class of the custom view to NSImageView,
    and set the image you want to display in -awakeFromNib.
    That's the easiest way i see to workaround this IB limitation.

    Jean-Daniel
  • On Nov 23, 2007, at 11:16 AM, Jean-Daniel Dupas wrote:

    >>
    >> This particular app would be a full-screen app. The main window,
    >> covering most if not all of the screen, would have a background
    >> image with other controls directly on top of it. They would be
    >> customized to the extent I could in IB & sub-classed if necessary,
    >> which I know that I will have to do to achieve the behavior &
    >> appearance I want in some. Since the NSImage view doesn't support
    >> sub-views (I'm assuming it doesn't since IB won't let me put any in
    >> it), I was trying to have the NSImage view behind the other views
    >> so I wouldn't have to customize a NSView & draw the image manually.
    >>
    >> This will be my very first app written in Cocoa/Obj-C, and I'm very
    >> used to having compositing views in Carbon. I won't be overlapping
    >> views like this though if it isn't really supported, since I don't
    >> want my app to possibly have erratic drawing/refresh behavior.
    >>
    >>
    >> Regards,
    >> David Alger
    >
    > Assumption are evil.

    Yeah, I hold to that in most cases as well. :-) What I meant was that
    it doesn't support it in IB. Since I'm new in Cocoa, I couldn't have
    told you if it would in code.

    > AFAK Image view should support subview.
    > IB will not let you add subview, but you can replace your image view
    > by a custom view. Set the class of the custom view to NSImageView,
    > and set the image you want to display in -awakeFromNib.
    > That's the easiest way i see to workaround this IB limitation.

    Thanks, I'll probably try and go this route, if it works. It is
    definitely worth a try.

    Thanks,
    David Alger

    ********************
    Ron Paul for President 2008
    http://ronpaul2008.com/

    RESTORE THE REPUBLIC & RETAIN YOUR RIGHTS
  • Hey David -

    All NSNiews support subviews. IB just limits view containment to what
    the user would find natural.

    Feel free to inject subviews in code.

    Good luck -
    Jon Hess

    On Nov 23, 2007, at 9:03 AM, David Alger <dev-lists...>
    > wrote:

    >
    > On Nov 23, 2007, at 10:01 AM, Alastair Houghton wrote:
    >
    >> On 23 Nov 2007, at 07:09, Jon Hess wrote:
    >>
    >>> NSView fully supports overlapping sibling views on Leopard and
    >>> later.
    >>
    >> I know it's been a common request for ages on the list, but I've
    >> never quite been sure why people are so keen on being able to have
    >> overlapping sibling views.  If one is completely contained within
    >> the other, the parent-child relationship seems cleaner (and has
    >> always worked); and if that isn't possible then surely in most
    >> cases it's going to look ugly?
    >>
    >> So, out of interest, David, what were you trying to achieve that
    >> needed overlapping views?
    >
    > This particular app would be a full-screen app. The main window,
    > covering most if not all of the screen, would have a background
    > image with other controls directly on top of it. They would be
    > customized to the extent I could in IB & sub-classed if necessary,
    > which I know that I will have to do to achieve the behavior &
    > appearance I want in some. Since the NSImage view doesn't support
    > sub-views (I'm assuming it doesn't since IB won't let me put any in
    > it), I was trying to have the NSImage view behind the other views so
    > I wouldn't have to customize a NSView & draw the image manually.
    >
    > This will be my very first app written in Cocoa/Obj-C, and I'm very
    > used to having compositing views in Carbon. I won't be overlapping
    > views like this though if it isn't really supported, since I don't
    > want my app to possibly have erratic drawing/refresh behavior.
    >
    >
    > Regards,
    > David Alger
    >
    > ********************
    > Ron Paul for President 2008
    > http://ronpaul2008.com/
    >
    > RESTORE THE REPUBLIC & RETAIN YOUR RIGHTS
    >
  • On Nov 23, 2007, at 12:16 PM, Alastair Houghton wrote:

    >> This will be my very first app written in Cocoa/Obj-C, and I'm very
    >> used to having compositing views in Carbon. I won't be overlapping
    >> views like this though if it isn't really supported, since I don't
    >> want my app to possibly have erratic drawing/refresh behavior.
    >
    > As I say, child views are pretty much always supported, even though
    > IB might not let you create them in some cases.

    To put a small bit of additional info on this...

    The views that don't support children are typically the ones that rely
    on hardware acceleration.. QCComposer, OpenGL, QT Movies.. I think
    that hits the big ones.  WebKit may not support it either, but for
    different reasons.
  • Am 23.11.2007 um 18:16 schrieb Ricky Sharp:
    > Drag in a custom view which will serve as your background view.  IB
    > knows that custom views are contain views and thus you can put
    > anything you want inside.  Subclass NSView and specify that class
    > for your custom view.  It's drawRect: will draw whatever image you
    > want.

      IIRC you can actually put subviews in an NSImageView, IB just
    doesn't let you. Try setting the custom view's class to NSImageView
    and set it up in code.

      And in any way, file a bug with Apple. The image view *should*
    really allow subviews.

    Cheers,
    -- M. Uli Kusterer
    "The Witnesses of TeachText are everywhere..."
    http://www.zathras.de
  • Am 23.11.2007 um 18:16 schrieb Jean-Daniel Dupas:
    > Assumption are evil. AFAK Image view should support subview.

      Well, but even though we all think it should support subviews, and
    we all use it that way, we're all making an assumption that this will
    stay true. What if Apple eventually releases a GPU-accelerated
    NSImageView that breaks all this? >:)

      Assumptions may be evil, but lecturing people about assumptions and
    not noticing one's own really isn't much better. :-p

    Cheers,
    -- M. Uli Kusterer
    "The Witnesses of TeachText are everywhere..."
    http://www.zathras.de
  • On Nov 24, 2007, at 5:29 AM, Uli Kusterer wrote:

    > Well, but even though we all think it should support subviews, and
    > we all use it that way, we're all making an assumption that this
    > will stay true. What if Apple eventually releases a GPU-accelerated
    > NSImageView that breaks all this? >:)

    that would cause so many regressions that I doubt it would ever happen.
  • Am 24.11.2007 um 23:47 schrieb Scott Anguish:
    > On Nov 24, 2007, at 5:29 AM, Uli Kusterer wrote:
    >> Well, but even though we all think it should support subviews, and
    >> we all use it that way, we're all making an assumption that this
    >> will stay true. What if Apple eventually releases a GPU-accelerated
    >> NSImageView that breaks all this? >:)
    >
    > that would cause so many regressions that I doubt it would ever
    > happen.

    I'm not good at guessing where Apple's going, but they've had three
    major revisions of Interface Builder to make image views embeddable,
    and they didn't. So, I doubt many people even found out NSImageView
    can be used as an embedder.

    Considering that, I'd say "so many regressions" are probably not much
    higher than the collateral damage done by the latest Speech Synthesis
    changes...

    Cheers,
    -- M. Uli Kusterer
    "The Witnesses of TeachText are everywhere..."
    http://www.zathras.de
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today