mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 21:50:37 +00:00
* Headers/AppKit/NSImageCell.h:
* Source/NSImageCell.m: Add support for NSImageScaleProportionallyUpOrDown git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33309 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ad79d99943
commit
82c961c9c1
3 changed files with 22 additions and 10 deletions
|
@ -172,7 +172,7 @@ yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
|
|||
}
|
||||
|
||||
static inline NSSize
|
||||
scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
||||
scaleProportionally(NSSize imageSize, NSRect canvasRect, BOOL scaleUpOrDown)
|
||||
{
|
||||
float ratio;
|
||||
|
||||
|
@ -180,11 +180,8 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
|||
ratio = MIN(NSWidth(canvasRect) / imageSize.width,
|
||||
NSHeight(canvasRect) / imageSize.height);
|
||||
|
||||
/* According to the API (see NSScaleProportionally), we should never
|
||||
* scale images up; we only scale them down. If you want your image
|
||||
* to scale both up and down, you should use NSScaleToFit.
|
||||
*/
|
||||
if (ratio < 1.0)
|
||||
/* Only scale down, unless scaleUpOrDown is YES */
|
||||
if (ratio < 1.0 || scaleUpOrDown)
|
||||
{
|
||||
imageSize.width *= ratio;
|
||||
imageSize.height *= ratio;
|
||||
|
@ -215,7 +212,7 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
|||
case NSScaleProportionally:
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSScaleProportionally");
|
||||
imageSize = scaleProportionally (realImageSize, cellFrame);
|
||||
imageSize = scaleProportionally (realImageSize, cellFrame, NO);
|
||||
break;
|
||||
}
|
||||
case NSScaleToFit:
|
||||
|
@ -231,6 +228,12 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
|||
imageSize = realImageSize;
|
||||
break;
|
||||
}
|
||||
case NSImageScaleProportionallyUpOrDown:
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSImageScaleProportionallyUpOrDown");
|
||||
imageSize = scaleProportionally (realImageSize, cellFrame, YES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (_imageAlignment)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue