summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-11-12 12:41:42 +0100
committerDamiano Galassi <[email protected]>2017-11-12 12:41:42 +0100
commit2ce11e0c322fe78c0d7c62ac4b7a00178fd6ae46 (patch)
treec06a9794e8803fb77f3084893fdd07b06368e46f /macosx
parent2c750474608acba5da55f76b518f45f83d9757cb (diff)
MacGui: show a preview image in the summary tab.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/English.lproj/HBSummaryViewController.xib3
-rw-r--r--macosx/HBController.m5
-rw-r--r--macosx/HBPreviewView.h5
-rw-r--r--macosx/HBPreviewView.m5
-rw-r--r--macosx/HBSummaryViewController.h8
-rw-r--r--macosx/HBSummaryViewController.m26
6 files changed, 47 insertions, 5 deletions
diff --git a/macosx/English.lproj/HBSummaryViewController.xib b/macosx/English.lproj/HBSummaryViewController.xib
index b6005fc86..c39311b09 100644
--- a/macosx/English.lproj/HBSummaryViewController.xib
+++ b/macosx/English.lproj/HBSummaryViewController.xib
@@ -9,6 +9,7 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="HBSummaryViewController">
<connections>
+ <outlet property="previewView" destination="m5a-0z-QQ4" id="1G9-3A-dM4"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
@@ -158,7 +159,7 @@ Multiline Label
Multiline Label</string>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
- <customView wantsLayer="YES" translatesAutoresizingMaskIntoConstraints="NO" id="m5a-0z-QQ4">
+ <customView wantsLayer="YES" translatesAutoresizingMaskIntoConstraints="NO" id="m5a-0z-QQ4" customClass="HBPreviewView">
<rect key="frame" x="254" y="16" width="597" height="334"/>
</customView>
</subviews>
diff --git a/macosx/HBController.m b/macosx/HBController.m
index 5c255789b..2cd279343 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -813,7 +813,9 @@
if (job)
{
- fPreviewController.generator = [[HBPreviewGenerator alloc] initWithCore:self.core job:job];
+ HBPreviewGenerator *generator = [[HBPreviewGenerator alloc] initWithCore:self.core job:job];
+ fPreviewController.generator = generator;
+ self.summaryController.generator = generator;
HBTitle *title = job.title;
@@ -830,6 +832,7 @@
else
{
fPreviewController.generator = nil;
+ self.summaryController.generator = nil;
}
fPreviewController.picture = job.picture;
diff --git a/macosx/HBPreviewView.h b/macosx/HBPreviewView.h
index b590b7e8d..e521aa9f9 100644
--- a/macosx/HBPreviewView.h
+++ b/macosx/HBPreviewView.h
@@ -41,6 +41,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readwrite) BOOL showBorder;
/**
+ * If enabled, the view will show a shadow around the image.
+ */
+@property (nonatomic, readwrite) BOOL showShadow;
+
+/**
* Given the size of the preview image to be shown, returns the best possible
* size for the view.
*/
diff --git a/macosx/HBPreviewView.m b/macosx/HBPreviewView.m
index e2e3c5459..1864f39b9 100644
--- a/macosx/HBPreviewView.m
+++ b/macosx/HBPreviewView.m
@@ -118,6 +118,11 @@
[self _updatePreviewLayout];
}
+- (void)setShowShadow:(BOOL)showShadow
+{
+ _backLayer.shadowOpacity = showShadow ? 0.5f : 0;
+}
+
- (void)setFrame:(NSRect)newRect {
// A change in size has required the view to be invalidated.
if ([self inLiveResize]) {
diff --git a/macosx/HBSummaryViewController.h b/macosx/HBSummaryViewController.h
index 912fb2f3f..e34c472c4 100644
--- a/macosx/HBSummaryViewController.h
+++ b/macosx/HBSummaryViewController.h
@@ -7,9 +7,15 @@
#import <Cocoa/Cocoa.h>
@class HBJob;
+@class HBPreviewGenerator;
+
+NS_ASSUME_NONNULL_BEGIN
@interface HBSummaryViewController : NSViewController
-@property (nonatomic, readwrite, weak) HBJob *job;
+@property (nonatomic, readwrite, weak, nullable) HBJob *job;
+@property (nonatomic, readwrite, weak, nullable) HBPreviewGenerator *generator;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/macosx/HBSummaryViewController.m b/macosx/HBSummaryViewController.m
index e8101692f..ae5e69f42 100644
--- a/macosx/HBSummaryViewController.m
+++ b/macosx/HBSummaryViewController.m
@@ -5,18 +5,40 @@
It may be used under the terms of the GNU General Public License. */
#import "HBSummaryViewController.h"
+#import "HBPreviewView.h"
+#import "HBPreviewGenerator.h"
-@import HandBrakeKit.HBJob;
+@import HandBrakeKit;
@interface HBSummaryViewController ()
+@property (strong) IBOutlet HBPreviewView *previewView;
+
@end
@implementation HBSummaryViewController
- (void)loadView {
[super loadView];
- // Do view setup here.
+ self.previewView.showShadow = NO;
+}
+
+- (void)setGenerator:(HBPreviewGenerator *)generator
+{
+ _generator = generator;
+
+ if (generator)
+ {
+ NSUInteger index = generator.imagesCount > 1 ? 1 : 0;
+ CGImageRef fPreviewImage = [generator copyImageAtIndex:index shouldCache:NO];
+ self.previewView.image = fPreviewImage;
+ CFRelease(fPreviewImage);
+ }
+ else
+ {
+ self.previewView.image = nil;
+ }
}
+
@end