summaryrefslogtreecommitdiffstats
path: root/macosx/HBPicture+UIAdditions.m
blob: 60b76158889a46e5aba0f0e7c7f55bb0c9fa0f0d (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*  HBPicture+UIAdditions.m $

 This file is part of the HandBrake source code.
 Homepage: <http://handbrake.fr/>.
 It may be used under the terms of the GNU General Public License. */

#import "HBPicture+UIAdditions.h"
#import "HBTitle.h"
#include "hb.h"

@implementation HBPicture (UIAdditions)

@dynamic maxHeight;
@dynamic maxWidth;

@dynamic maxHorizontalCrop;
@dynamic maxVerticalCrop;

@dynamic keepDisplayAspectEditable;

#pragma mark - Editable state

- (BOOL)isWidthEditable
{
    return (self.anamorphicMode != HB_ANAMORPHIC_STRICT) ? YES : NO;
}

- (BOOL)isHeightEditable
{
    return (self.anamorphicMode != HB_ANAMORPHIC_STRICT) ? YES : NO;
}

- (BOOL)isKeepDisplayAspectEditable
{
    if (self.anamorphicMode == HB_ANAMORPHIC_STRICT ||
        self.anamorphicMode == HB_ANAMORPHIC_LOOSE)
    {
        return NO;
    }
    else
    {
        return YES;
    }
}

- (BOOL)isCustomAnamorphicEnabled
{
    return self.anamorphicMode == HB_ANAMORPHIC_CUSTOM;
}

- (NSString *)info
{
    NSString *sizeInfo = @"";

    if (self.title)
    {
        hb_title_t *title = self.title.hb_title;
        sizeInfo = [NSString stringWithFormat:
                    @"Source: %dx%d, ",
                    title->geometry.width, title->geometry.height];
    }

    if (self.anamorphicMode == HB_ANAMORPHIC_STRICT) // Original PAR Implementation
    {
        sizeInfo = [NSString stringWithFormat:
                    @"%@Output: %dx%d, Anamorphic: %dx%d Strict",
                    sizeInfo, self.width, self.height, self.displayWidth, self.height];
    }
    else if (self.anamorphicMode == HB_ANAMORPHIC_LOOSE) // Loose Anamorphic
    {
        sizeInfo = [NSString stringWithFormat:
                    @"%@Output: %dx%d, Anamorphic: %dx%d Loose",
                    sizeInfo, self.width, self.height, self.displayWidth, self.height];
    }
    else if (self.anamorphicMode == HB_ANAMORPHIC_CUSTOM) // Custom Anamorphic
    {
        sizeInfo = [NSString stringWithFormat:
                    @"%@Output: %dx%d, Anamorphic: %dx%d Custom",
                    sizeInfo, self.width, self.height, self.displayWidth, self.height];
    }
    else // No Anamorphic
    {
        sizeInfo = [NSString stringWithFormat:
                    @"%@Output: %dx%d",
                    sizeInfo, self.width, self.height];
    }

    return sizeInfo;
}

- (NSString *)summary
{
    NSMutableString *summary = [NSMutableString stringWithString:@""];
    [summary appendString:self.info];

    if (self.anamorphicMode != HB_ANAMORPHIC_STRICT)
    {
        // anamorphic is not Strict, show the modulus
        [summary appendFormat:@", Modulus: %d", self.modulus];
    }

    [summary appendFormat:@", Crop: %s %d/%d/%d/%d",
     self.autocrop ? "Auto" : "Custom",
     self.cropTop, self.cropBottom,
     self.cropLeft, self.cropRight];

    return [[summary copy] autorelease];
}

@end