NSAnimation to trigger live resize

  • Hello,

    for days I'm trying to resize 2 subviews of a NSSplitView
    programticly. It kinda works but the views are too slow drawing
    themselves. I somehow think I should trigger a live resize so the
    subviews  no they gotta be fast (they are optimized for it and it
    works just fine when manually moving the divider.

    I hope you have some trick for me,

    Regards,
    Dominik
  • Dominik:

      Please review the list guidelines for posting questions. You're
    asking for help, stating your method of resizing the views is slow,
    but you give us no information on what, exactly, that method entails.

      Please post the relevant code so people can guide you from there. :-)

    --
    I.S.

    On Sep 29, 2006, at 4:04 PM, Dominik Pich wrote:

    > Hello,
    >
    > for days I'm trying to resize 2 subviews of a NSSplitView
    > programticly. It kinda works but the views are too slow drawing
    > themselves. I somehow think I should trigger a live resize so the
    > subviews  no they gotta be fast (they are optimized for it and it
    > works just fine when manually moving the divider.
    >
    > I hope you have some trick for me,
    >
    > Regards,
    > Dominik
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/idiotsavant2005%
    > 40gmail.com
    >
    > This email sent to <idiotsavant2005...>
  • Hi,

    For days I'm trying to resize 2 subviews of a NSSplitView
    programticly. It kinda works but the views are too slow drawing
    themselves. I somehow think I should trigger a live resize so the
    subviews  no they gotta be fast (they are optimized for it and it
    works just fine when manually moving the divider.

    here is the code I use to resize my views. I still hope, people can
    help me:

    // right aligned -> right view is repositioned and only for vertical
    splitter
    //BUGBUG: Enable liveResize
    -(void) resizeForLeft:(NSSize)leftSizeAtTheEnd RightSide:(NSSize)
    rightSizeAtTheEnd withAnimation:(BOOL)flag {
    [self releaseAnimationAndReset:YES];

    NSView *leftView, *rightView;
    NSRect bounds, leftEndFrame, rightEndFrame;
    NSDictionary *animationParameters1, *animationParameters2;

    bounds = [self bounds];

    leftView = [[self subviews] objectAtIndex:0];
    rightView = [[self subviews] objectAtIndex:1];

    leftEndFrame = [leftView frame];
    rightEndFrame = [rightView frame];

    if( rightEndFrame.size.width == round(rightSizeAtTheEnd.width) )
      return;

    leftEndFrame.size.width = leftSizeAtTheEnd.width;

    rightEndFrame.origin.x -= rightSizeAtTheEnd.width;
    rightEndFrame.size.width = rightSizeAtTheEnd.width;

    if(flag) {
      animationParameters1 = [NSDictionary dictionaryWithObjectsAndKeys:
            leftView, NSViewAnimationTargetKey,
            [NSValue valueWithRect: leftEndFrame],
    NSViewAnimationEndFrameKey,
            nil];
      animationParameters2 = [NSDictionary dictionaryWithObjectsAndKeys:
              rightView, NSViewAnimationTargetKey,
              [NSValue valueWithRect: rightEndFrame],
    NSViewAnimationEndFrameKey,
              nil];

      _animation = [[PGSplitViewAnimation alloc] initWithViewAnimations:
    [NSArray arrayWithObjects:animationParameters1, animationParameters2]];

      [_animation setAnimationBlockingMode:NSAnimationNonblocking];
      [_animation setDelegate:self];
      [_animation startAnimation];

    } else {
      [leftView setFrame:leftEndFrame];
      [rightView setFrame:rightEndFrame];
      [self adjustSubviews];
      [self setNeedsDisplay:YES];
    }
    }

    // Override NSAnimation's -setCurrentProgress: method
    - (void)setCurrentProgress:(NSAnimationProgress)progress {
        [super setCurrentProgress:progress];
    [[self delegate] adjustSubviews];
    [[self delegate] display];
    }

    Regards,
    Dominik
previous month september 2006 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