• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Window/View Size Constraining
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Window/View Size Constraining


  • Subject: Window/View Size Constraining
  • From: Gordon Apple <email@hidden>
  • Date: Sat, 20 Oct 2007 09:55:48 -0500

    The following code is my attempt to constrain a displayView and window
size such that the displayView maintains the proper aspect ratio when the
window is resized.  I have two issues:

1.  It sort of works. However, the displayView size tracking lags by at
least one time sample and I then have to gently nudge the window size to get
it right.

2.  This is a variable size window that is intended to show a miniature
display of what is in the main window (elsewhere).  I made an abortive
attempt to scale the coordinates of displayView.  Apparently, I don't
understand the "scaleUnitSquareToSize" call and the docs don't help.  Any
suggestions?


//    Window delegate for size
- (NSSize)windowWillResize:(NSWindow*)sender
                    toSize:(NSSize)frameSize
{
    //    displayView/controlView are outlets to top/bottom views in the
window.
    //    displayView has variable height, controlView fixed height.

    //    First, get the size of main view (elsewhere).
    NSSize fullSize = [[document
valueForKeyPath:@"course.props.presentaionSize"] sizeValue];
    float frameWidth = frameSize.width;
    //    Maintain aspect ratio of display view.
    float displayHeight = frameWidth * fullSize.height / fullSize.width;
    [displayView setFrameSize:NSMakeSize(frameWidth, displayHeight)];

    float controlViewHeight = [controlView frame].size.height;
    float winHeight = displayHeight + controlViewHeight;

//    Abortive attempt to scale display coordinates to fit.
//    float scale = frameWidth / fullSize.width;    //  Tried reciprocal
also.
//    [displayView scaleUnitSquareToSize:NSMakeSize(scale, scale)];

   return NSMakeSize (frameSize.width, winHeight);
}

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: What is a task?
  • Next by Date: Re: insertObject:in<myManagedObject>AtIndex:
  • Previous by thread: Re: What is a task?
  • Next by thread: Re: Window/View Size Constraining
  • Index(es):
    • Date
    • Thread