Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support to proportionally scale to fit to CPImageView #1500

Closed
wants to merge 1 commit into from

2 participants

@BlairDuncan

Although not in cocoa, in cappuccino it is required to display an image larger than its original size.

@aparajita aparajita commented on the diff
AppKit/CPImageView.j
@@ -27,9 +27,10 @@
@import "CPShadowView.j"
-CPScaleProportionally = 0;
-CPScaleToFit = 1;
-CPScaleNone = 2;
+CPScaleProportionally = 0;
+CPScaleToFit = 1;
+CPScaleNone = 2;
+CPScaleToFitProportionally = 4;
@aparajita Owner

This isn't a bit flag, that should be 3, not 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@aparajita aparajita commented on the diff
AppKit/CPImageView.j
@@ -310,11 +311,11 @@ var CPImageViewEmptyPlaceholderImage = nil;
if (size.width == -1 && size.height == -1)
return;
- if (imageScaling === CPScaleProportionally)
+ if (imageScaling === CPScaleProportionally || imageScaling === CPScaleToFitProportionally)
@aparajita Owner

Hmmm...looking at this whole chunk of code, including the if (imageScaling === CPScaleNone), it's pretty messy. And I can't even see where CPScaleToFit is handled. I think the whole section needs cleaning up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@aparajita
Owner

Turns out in Cocoa the current scaling constant names have been deprecated, and a new one, NSImageScaleProportionallyUpOrDown, has been added. I will merge your changes with some other fixes.

@aparajita
Owner

Implemented in aeb2671, thanks for the inspiration.

@aparajita aparajita closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +6 −5 AppKit/CPImageView.j
View
11 AppKit/CPImageView.j
@@ -27,9 +27,10 @@
@import "CPShadowView.j"
-CPScaleProportionally = 0;
-CPScaleToFit = 1;
-CPScaleNone = 2;
+CPScaleProportionally = 0;
+CPScaleToFit = 1;
+CPScaleNone = 2;
+CPScaleToFitProportionally = 4;
@aparajita Owner

This isn't a bit flag, that should be 3, not 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
CPImageAlignCenter = 0;
CPImageAlignTop = 1;
@@ -310,11 +311,11 @@ var CPImageViewEmptyPlaceholderImage = nil;
if (size.width == -1 && size.height == -1)
return;
- if (imageScaling === CPScaleProportionally)
+ if (imageScaling === CPScaleProportionally || imageScaling === CPScaleToFitProportionally)
@aparajita Owner

Hmmm...looking at this whole chunk of code, including the if (imageScaling === CPScaleNone), it's pretty messy. And I can't even see where CPScaleToFit is handled. I think the whole section needs cleaning up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
// The max size it can be is size.width x size.height, so only
// only proportion otherwise.
- if (width >= size.width && height >= size.height)
+ if (width >= size.width && height >= size.height && imageScaling === CPScaleProportionally)
{
width = size.width;
height = size.height;
Something went wrong with that request. Please try again.