Trouble with Leopard's newly enhanced NSSplitView

  • Right, I've decided to take the plunge and the next major release of
    my main app will be Leopard only.. as I'm going through the Leopard
    feature list, I'm trying to eliminate as much custom code with
    standard Leopard-features as at all possible and taking advantage of
    new capabilities that I now get for free.

    I've been thinking about using RBSplitView for a while, but I'm not
    keen on relying too much on third-party code after being boxed-in by
    MOKit for a while. Now the new Leopard NSSplitView is supposed to be a
    much more satisfactory implementation than the old one, so I decided
    to give it a go.

    Unfortunately, I can't figure out how to do what I need with it. The
    documentation is still a bit bare-bones, so perhaps I've overlooked
    something.

    What I want is a three view (2 vertical splitters) with the central
    view being of fixed size, e.g.

    <-->|    |<-->

    When I pull the left splitter towards the right, the left view should
    get bigger, the central view stay the same size and the right view get
    smaller, e.g.

    <--->|      |<->

    When I pull the left splitter towards the left, the left view should
    get smaller and the right view larger:

    <->|      |<--->

    At some stage when it gets too small the left view should collapse:

    |      |<------>

    The right view should have a minimum size and not collapse.

    The behavior of the right splitter should be:

    <->|    |<--->  (when dragged to the left)

    <--->|    |<->  (when dragged to the right)

    The essential thing is that the central view should "slide" around.

    I can't for the life of me figure out how to do this. The views don't
    have max and min widths, so it all comes down to implementing this in
    the NSSplitView delegate methods. The problem is that I need to move
    the position of BOTH splitters simultaneously to get the central view
    to keep a constant width. The only place I can find to do this in is
    the delegate method that gets called during the splitter drag:

    - (CGFloat)splitView:(NSSplitView *)sender constrainSplitPosition:
    (CGFloat)proposedPosition ofSubviewAt:(NSInteger)offset;

    I calculate the correct next position of the second splitter based on
    the proposedPosition of the first splitter and then set this via:

    [splitView setPosition: x ofDividerAtIndex: theOtherSplittersIndex];

    Unfortunately, this results in that same method being called for that
    second splitter and the adjustment being executed before the first
    call is finished. So by the time that the "proposedPosition" for the
    first splitter has been applied, the second splitter has already been
    changed and the views have been resized accordingly. This produces an
    offset which is taken up by the splitter itself. After the drag of the
    first splitter is finished, the second splitter has become wider and
    this can get up to 200 pixels wide :-(

    What am I doing wrong? Is this even possible with Leopard's
    NSSplitView? Can RBSplitView handle this more gracefully?

    I guess what I'd need would be some way of changing both splitters
    simultaneously instead of applying one new position after the other..

    Any insights would be much appreciated.

    Best regards,

    Frank
  • Right,

    It looks like I'm going to have to go down the RBSplitView route then..

    Best regards,

    Frank

    On 18 Dec 2007, at 10:05, Frank Reiff wrote:

    > Right, I've decided to take the plunge and the next major release of
    > my main app will be Leopard only.. as I'm going through the Leopard
    > feature list, I'm trying to eliminate as much custom code with
    > standard Leopard-features as at all possible and taking advantage of
    > new capabilities that I now get for free.
    >
    > I've been thinking about using RBSplitView for a while, but I'm not
    > keen on relying too much on third-party code after being boxed-in by
    > MOKit for a while. Now the new Leopard NSSplitView is supposed to be
    > a much more satisfactory implementation than the old one, so I
    > decided to give it a go.
    >
    > Unfortunately, I can't figure out how to do what I need with it. The
    > documentation is still a bit bare-bones, so perhaps I've overlooked
    > something.
    >
    > What I want is a three view (2 vertical splitters) with the central
    > view being of fixed size, e.g.
    >
    > <-->|    |<-->
    >
    > When I pull the left splitter towards the right, the left view
    > should get bigger, the central view stay the same size and the right
    > view get smaller, e.g.
    >
    > <--->|      |<->
    >
    > When I pull the left splitter towards the left, the left view should
    > get smaller and the right view larger:
    >
    > <->|      |<--->
    >
    > At some stage when it gets too small the left view should collapse:
    >
    > |      |<------>
    >
    > The right view should have a minimum size and not collapse.
    >
    > The behavior of the right splitter should be:
    >
    > <->|    |<--->  (when dragged to the left)
    >
    > <--->|    |<->  (when dragged to the right)
    >
    > The essential thing is that the central view should "slide" around.
    >
    > I can't for the life of me figure out how to do this. The views
    > don't have max and min widths, so it all comes down to implementing
    > this in the NSSplitView delegate methods. The problem is that I need
    > to move the position of BOTH splitters simultaneously to get the
    > central view to keep a constant width. The only place I can find to
    > do this in is the delegate method that gets called during the
    > splitter drag:
    >
    > - (CGFloat)splitView:(NSSplitView *)sender constrainSplitPosition:
    > (CGFloat)proposedPosition ofSubviewAt:(NSInteger)offset;
    >
    > I calculate the correct next position of the second splitter based
    > on the proposedPosition of the first splitter and then set this via:
    >
    > [splitView setPosition: x ofDividerAtIndex: theOtherSplittersIndex];
    >
    > Unfortunately, this results in that same method being called for
    > that second splitter and the adjustment being executed before the
    > first call is finished. So by the time that the "proposedPosition"
    > for the first splitter has been applied, the second splitter has
    > already been changed and the views have been resized accordingly.
    > This produces an offset which is taken up by the splitter itself.
    > After the drag of the first splitter is finished, the second
    > splitter has become wider and this can get up to 200 pixels wide :-(
    >
    > What am I doing wrong? Is this even possible with Leopard's
    > NSSplitView? Can RBSplitView handle this more gracefully?
    >
    > I guess what I'd need would be some way of changing both splitters
    > simultaneously instead of applying one new position after the other..
    >
    > Any insights would be much appreciated.
    >
    > Best regards,
    >
    > Frank
  • At 07:20 -0800 19/12/2007, <cocoa-dev-request...> wrote:
    > From: Frank Reiff <reiff...>
    > References: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    > In-Reply-To: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    > Date: Wed, 19 Dec 2007 10:35:29 +0100
    > Message-ID: <DEFCF398-BF7B-4CB0-9570-B1EA5CB4B98C...>
    >
    > Right,
    >
    > It looks like I'm going to have to go down the RBSplitView route then..
    >
    > On 18 Dec 2007, at 10:05, Frank Reiff wrote:
    >> What I want is a three view (2 vertical splitters) with the central view being of fixed size, e.g.
    >>
    >> <-->|    |<-->
    >>
    >> When I pull the left splitter towards the right, the left view should get bigger, the central view stay the same size and the right view get smaller, e.g.
    >>
    >> <--->|      |<->
    >>
    >> When I pull the left splitter towards the left, the left view should get smaller and the right view larger:
    >>
    >> <->|      |<--->
    >>
    >> ....
    >> The essential thing is that the central view should "slide" around.

    RBSplitView should do most of what you want; just set the min and max sizes of the central view to the same fixed number. Collapsing etc. will also work just by setting parameters in IB.

    However, the current version won't work by dragging the fixed view "behind" the mouse movement; I'll try to do this in the next version. It will allow you to push the fixed view ahead of the movement, though. Sorry about that.

    --
    Rainer Brockerhoff  <rainer...>
    Belo Horizonte, Brazil
    "In the affairs of others even fools are wise
    In their own business even sages err."
    Weblog: http://www.brockerhoff.net/bb/viewtopic.php
  • Hi Rainer,

    I just included the Library project and installed IB3 palette. Looks
    great; just the way that Apple should have done it :-)

    Thanks a lot for making this available.

    Best regards,

    Frank

    On 19 Dec 2007, at 16:56, Rainer Brockerhoff wrote:

    > At 07:20 -0800 19/12/2007, <cocoa-dev-request...> wrote:
    >> From: Frank Reiff <reiff...>
    >> References: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    >> In-Reply-To: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    >> Date: Wed, 19 Dec 2007 10:35:29 +0100
    >> Message-ID: <DEFCF398-BF7B-4CB0-9570-B1EA5CB4B98C...>
    >>
    >> Right,
    >>
    >> It looks like I'm going to have to go down the RBSplitView route
    >> then..
    >>
    >> On 18 Dec 2007, at 10:05, Frank Reiff wrote:
    >>> What I want is a three view (2 vertical splitters) with the
    >>> central view being of fixed size, e.g.
    >>>
    >>> <-->|    |<-->
    >>>
    >>> When I pull the left splitter towards the right, the left view
    >>> should get bigger, the central view stay the same size and the
    >>> right view get smaller, e.g.
    >>>
    >>> <--->|      |<->
    >>>
    >>> When I pull the left splitter towards the left, the left view
    >>> should get smaller and the right view larger:
    >>>
    >>> <->|      |<--->
    >>>
    >>> ....
    >>> The essential thing is that the central view should "slide" around.
    >
    > RBSplitView should do most of what you want; just set the min and
    > max sizes of the central view to the same fixed number. Collapsing
    > etc. will also work just by setting parameters in IB.
    >
    > However, the current version won't work by dragging the fixed view
    > "behind" the mouse movement; I'll try to do this in the next
    > version. It will allow you to push the fixed view ahead of the
    > movement, though. Sorry about that.
    >
    > --
    > Rainer Brockerhoff  <rainer...>
    > Belo Horizonte, Brazil
    > "In the affairs of others even fools are wise
    > In their own business even sages err."
    > Weblog: http://www.brockerhoff.net/bb/viewtopic.php
  • Hi again,

    I see what you mean with the splitters only working in one direction..
    You wouldn't have a provisional ETA for the next version? My apps only
    due for March-June 2008..

    Thanks again.

    Best regards,

    Frank

    On 19 Dec 2007, at 16:56, Rainer Brockerhoff wrote:

    > At 07:20 -0800 19/12/2007, <cocoa-dev-request...> wrote:
    >> From: Frank Reiff <reiff...>
    >> References: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    >> In-Reply-To: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    >> Date: Wed, 19 Dec 2007 10:35:29 +0100
    >> Message-ID: <DEFCF398-BF7B-4CB0-9570-B1EA5CB4B98C...>
    >>
    >> Right,
    >>
    >> It looks like I'm going to have to go down the RBSplitView route
    >> then..
    >>
    >> On 18 Dec 2007, at 10:05, Frank Reiff wrote:
    >>> What I want is a three view (2 vertical splitters) with the
    >>> central view being of fixed size, e.g.
    >>>
    >>> <-->|    |<-->
    >>>
    >>> When I pull the left splitter towards the right, the left view
    >>> should get bigger, the central view stay the same size and the
    >>> right view get smaller, e.g.
    >>>
    >>> <--->|      |<->
    >>>
    >>> When I pull the left splitter towards the left, the left view
    >>> should get smaller and the right view larger:
    >>>
    >>> <->|      |<--->
    >>>
    >>> ....
    >>> The essential thing is that the central view should "slide" around.
    >
    > RBSplitView should do most of what you want; just set the min and
    > max sizes of the central view to the same fixed number. Collapsing
    > etc. will also work just by setting parameters in IB.
    >
    > However, the current version won't work by dragging the fixed view
    > "behind" the mouse movement; I'll try to do this in the next
    > version. It will allow you to push the fixed view ahead of the
    > movement, though. Sorry about that.
    >
    > --
    > Rainer Brockerhoff  <rainer...>
    > Belo Horizonte, Brazil
    > "In the affairs of others even fools are wise
    > In their own business even sages err."
    > Weblog: http://www.brockerhoff.net/bb/viewtopic.php
  • At 17:41 +0100 19/12/2007, Frank Reiff wrote:
    > I see what you mean with the splitters only working in one direction.. You wouldn't have a provisional ETA for the next version? My apps only due for March-June 2008..

    Not really, sorry. I've got lots of urgent stuff to work through; it might be ready around March, but can't promise (yet). :-(

    --
    Rainer Brockerhoff  <rainer...>
    Belo Horizonte, Brazil
    "In the affairs of others even fools are wise
    In their own business even sages err."
    Weblog: http://www.brockerhoff.net/bb/viewtopic.php
  • Perhaps you should consider enhancing RBSplitView yourself. Rainer
    distributes the source under the MIT license, after all. (And then
    submit your enhancement to him!)

    --
    m-s

    On 19 Dec, 2007, at 11:41, Frank Reiff wrote:

    > Hi again,
    >
    > I see what you mean with the splitters only working in one
    > direction.. You wouldn't have a provisional ETA for the next
    > version? My apps only due for March-June 2008..
    >
    > Thanks again.
    >
    > Best regards,
    >
    > Frank
    >
    > On 19 Dec 2007, at 16:56, Rainer Brockerhoff wrote:
    >
    >> At 07:20 -0800 19/12/2007, <cocoa-dev-request...> wrote:
    >>> From: Frank Reiff <reiff...>
    >>> References: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    >>> In-Reply-To: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    >>> Date: Wed, 19 Dec 2007 10:35:29 +0100
    >>> Message-ID: <DEFCF398-BF7B-4CB0-9570-B1EA5CB4B98C...>
    >>>
    >>> Right,
    >>>
    >>> It looks like I'm going to have to go down the RBSplitView route
    >>> then..
    >>>
    >>> On 18 Dec 2007, at 10:05, Frank Reiff wrote:
    >>>> What I want is a three view (2 vertical splitters) with the
    >>>> central view being of fixed size, e.g.
    >>>>
    >>>> <-->|    |<-->
    >>>>
    >>>> When I pull the left splitter towards the right, the left view
    >>>> should get bigger, the central view stay the same size and the
    >>>> right view get smaller, e.g.
    >>>>
    >>>> <--->|      |<->
    >>>>
    >>>> When I pull the left splitter towards the left, the left view
    >>>> should get smaller and the right view larger:
    >>>>
    >>>> <->|      |<--->
    >>>>
    >>>> ....
    >>>> The essential thing is that the central view should "slide" around.
    >>
    >> RBSplitView should do most of what you want; just set the min and
    >> max sizes of the central view to the same fixed number. Collapsing
    >> etc. will also work just by setting parameters in IB.
    >>
    >> However, the current version won't work by dragging the fixed view
    >> "behind" the mouse movement; I'll try to do this in the next
    >> version. It will allow you to push the fixed view ahead of the
    >> movement, though. Sorry about that.
    >>
    >> --
    >> Rainer Brockerhoff  <rainer...>
    >> Belo Horizonte, Brazil
    >> "In the affairs of others even fools are wise
    >> In their own business even sages err."
    >> Weblog: http://www.brockerhoff.net/bb/viewtopic.php

  • Hi Michael,

    > Perhaps you should consider enhancing RBSplitView yourself. Rainer
    > distributes the source under the MIT license, after all. (And then
    > submit your enhancement to him!)

    Thanks for the suggestion. I'm not sure how Rainer feels about
    contributed code, but since he's already planning on supporting this
    in his next release I think he's probably got his own ideas on how to
    do this already.

    The other factor would of course be time. I really do need to get a
    move on for getting v8 of my app out for March 2008 and I've just kind
    of committed to a complete interface revamp after getting carried away
    with the new Leopard features :-)

    The earliest I could start working in earnest on anything more than a
    quick and dirty hack to RBSplit would be summer 2008. That being said
    it would be interesting to cooperate with Rainer and give something
    back to the community. I'm still a recovering J2EE guy at heart, so I
    could certainly learn a thing or two about Cocoa by doing this..

    Best regards,

    Frank

    >
    >
    > --
    > m-s
    >
    >
    > On 19 Dec, 2007, at 11:41, Frank Reiff wrote:
    >
    >> Hi again,
    >>
    >> I see what you mean with the splitters only working in one
    >> direction.. You wouldn't have a provisional ETA for the next
    >> version? My apps only due for March-June 2008..
    >>
    >> Thanks again.
    >>
    >> Best regards,
    >>
    >> Frank
    >>
    >> On 19 Dec 2007, at 16:56, Rainer Brockerhoff wrote:
    >>
    >>> At 07:20 -0800 19/12/2007, <cocoa-dev-request...> wrote:
    >>>> From: Frank Reiff <reiff...>
    >>>> References: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    >>>> In-Reply-To: <8B34D807-BB8D-482D-B7C7-911DD9B516CB...>
    >>>> Date: Wed, 19 Dec 2007 10:35:29 +0100
    >>>> Message-ID: <DEFCF398-BF7B-4CB0-9570-B1EA5CB4B98C...>
    >>>>
    >>>> Right,
    >>>>
    >>>> It looks like I'm going to have to go down the RBSplitView route
    >>>> then..
    >>>>
    >>>> On 18 Dec 2007, at 10:05, Frank Reiff wrote:
    >>>>> What I want is a three view (2 vertical splitters) with the
    >>>>> central view being of fixed size, e.g.
    >>>>>
    >>>>> <-->|    |<-->
    >>>>>
    >>>>> When I pull the left splitter towards the right, the left view
    >>>>> should get bigger, the central view stay the same size and the
    >>>>> right view get smaller, e.g.
    >>>>>
    >>>>> <--->|      |<->
    >>>>>
    >>>>> When I pull the left splitter towards the left, the left view
    >>>>> should get smaller and the right view larger:
    >>>>>
    >>>>> <->|      |<--->
    >>>>>
    >>>>> ....
    >>>>> The essential thing is that the central view should "slide"
    >>>>> around.
    >>>
    >>> RBSplitView should do most of what you want; just set the min and
    >>> max sizes of the central view to the same fixed number. Collapsing
    >>> etc. will also work just by setting parameters in IB.
    >>>
    >>> However, the current version won't work by dragging the fixed view
    >>> "behind" the mouse movement; I'll try to do this in the next
    >>> version. It will allow you to push the fixed view ahead of the
    >>> movement, though. Sorry about that.
    >>>
    >>> --
    >>> Rainer Brockerhoff  <rainer...>
    >>> Belo Horizonte, Brazil
    >>> "In the affairs of others even fools are wise
    >>> In their own business even sages err."
    >>> Weblog: http://www.brockerhoff.net/bb/viewtopic.php

  • At 16:54 +0100 20/12/2007, Frank Reiff wrote:
    > Michael Watson wrote:
    >> Perhaps you should consider enhancing RBSplitView yourself. Rainer distributes the source under the MIT license, after all. (And then submit your enhancement to him!)
    >
    > Thanks for the suggestion. I'm not sure how Rainer feels about contributed code, but since he's already planning on supporting this in his next release I think he's probably got his own ideas on how to do this already.

    No ideas yet; the whole view readjust process can (and probably should) be redone entirely for Leopard, anyway.

    Regarding contributed code, I've folded some fixes provided by other developers back in before, but it's rather ad-hoc. Fixes are welcome, but time is short, and there's lots of stuff in my queue...

    > The earliest I could start working in earnest on anything more than a quick and dirty hack to RBSplit would be summer 2008. That being said it would be interesting to cooperate with Rainer and give something back to the community. I'm still a recovering J2EE guy at heart, so I could certainly learn a thing or two about Cocoa by doing this..

    Feel free to contact me privately or over AIM for discussions.

    --
    Rainer Brockerhoff  <rainer...>
    Belo Horizonte, Brazil
    "In the affairs of others even fools are wise
    In their own business even sages err."
    Weblog: http://www.brockerhoff.net/bb/viewtopic.php
previous month december 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
31            
Go to today