summaryrefslogtreecommitdiffstats
path: root/macosx/HBPicture.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/HBPicture.m')
-rw-r--r--macosx/HBPicture.m68
1 files changed, 41 insertions, 27 deletions
diff --git a/macosx/HBPicture.m b/macosx/HBPicture.m
index 97b1631aa..5578245e4 100644
--- a/macosx/HBPicture.m
+++ b/macosx/HBPicture.m
@@ -269,52 +269,36 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
- (BOOL)validateCropTop:(id *)ioValue error:(NSError * __autoreleasing *)outError
{
- [self validateVCrop:ioValue];
+ [self validateCrop:ioValue max:self.maxTopCrop];
return YES;
}
- (BOOL)validateCropBottom:(id *)ioValue error:(NSError * __autoreleasing *)outError
{
- [self validateVCrop:ioValue];
+ [self validateCrop:ioValue max:self.maxBottomCrop];
return YES;
}
- (BOOL)validateCropLeft:(id *)ioValue error:(NSError * __autoreleasing *)outError
{
- [self validateHCrop:ioValue];
+ [self validateCrop:ioValue max:self.maxLeftCrop];
return YES;
}
- (BOOL)validateCropRight:(id *)ioValue error:(NSError * __autoreleasing *)outError
{
- [self validateHCrop:ioValue];
+ [self validateCrop:ioValue max:self.maxRightCrop];
return YES;
}
-- (void)validateHCrop:(NSNumber **)ioValue
+- (void)validateCrop:(NSNumber **)ioValue max:(int)maxCrop
{
if (nil != *ioValue)
{
int value = [*ioValue intValue];
- if (value >= self.maxHorizontalCrop)
+ if (value >= maxCrop)
{
- *ioValue = @(self.maxHorizontalCrop);
- }
- else if (value < 0)
- {
- *ioValue = @0;
- }
- }
-}
-
-- (void)validateVCrop:(NSNumber **)ioValue
-{
- if (nil != *ioValue)
- {
- int value = [*ioValue intValue];
- if (value >= self.maxVerticalCrop)
- {
- *ioValue = @(self.maxVerticalCrop);
+ *ioValue = @(maxCrop);
}
else if (value < 0)
{
@@ -414,14 +398,44 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
return self.sourceHeight - self.cropTop - self.cropBottom;
}
-- (int)maxVerticalCrop
++ (NSSet<NSString *> *)keyPathsForValuesAffectingMaxTopCrop
+{
+ return [NSSet setWithObjects:@"cropBottom", nil];
+}
+
+- (int)maxTopCrop
+{
+ return self.sourceHeight - self.cropBottom - 32;
+}
+
++ (NSSet<NSString *> *)keyPathsForValuesAffectingMaxBottomCrop
+{
+ return [NSSet setWithObjects:@"cropTop", nil];
+}
+
+- (int)maxBottomCrop
+{
+ return self.sourceHeight - self.cropTop - 32;
+}
+
++ (NSSet<NSString *> *)keyPathsForValuesAffectingMaxLeftCrop
+{
+ return [NSSet setWithObjects:@"cropRight", nil];
+}
+
+- (int)maxLeftCrop
+{
+ return self.sourceWidth - self.cropRight - 32;
+}
+
++ (NSSet<NSString *> *)keyPathsForValuesAffectingMaxRightCrop
{
- return self.sourceHeight / 2 - 2;
+ return [NSSet setWithObjects:@"cropLeft", nil];
}
-- (int)maxHorizontalCrop
+- (int)maxRightCrop
{
- return self.sourceWidth / 2 - 2;
+ return self.sourceWidth - self.cropLeft - 32;
}
- (int)sourceDisplayWidth