summaryrefslogtreecommitdiffstats
path: root/macosx/HBSummaryViewController.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-12-15 15:13:46 +0100
committerDamiano Galassi <[email protected]>2017-12-15 15:13:46 +0100
commitdd89c106cf88c972f90ec425442b2fa305a4c602 (patch)
treec566d6822fcde275e1dd651c69fda3316f6c618e /macosx/HBSummaryViewController.m
parentb16949a1c14e42c0b56873b5488a339812225bf9 (diff)
MacGui: add a next and previous button to the summary panel preview.
Diffstat (limited to 'macosx/HBSummaryViewController.m')
-rw-r--r--macosx/HBSummaryViewController.m60
1 files changed, 18 insertions, 42 deletions
diff --git a/macosx/HBSummaryViewController.m b/macosx/HBSummaryViewController.m
index e16f26e87..52c192172 100644
--- a/macosx/HBSummaryViewController.m
+++ b/macosx/HBSummaryViewController.m
@@ -5,7 +5,8 @@
It may be used under the terms of the GNU General Public License. */
#import "HBSummaryViewController.h"
-#import "HBPreviewView.h"
+
+#import "HBPreviewViewController.h"
#import "HBPreviewGenerator.h"
@import HandBrakeKit;
@@ -25,14 +26,14 @@ static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsCo
@property (nonatomic, strong) IBOutlet NSTextField *filtersLabel;
@property (nonatomic, strong) IBOutlet NSTextField *dimensionLabel;
-@property (nonatomic, strong) IBOutlet HBPreviewView *previewView;
+@property (nonatomic, strong) IBOutlet NSView *previewView;
+
+@property (nonatomic, strong) HBPreviewViewController *previewViewController;
@property (nonatomic) BOOL tracksReloadInQueue;
@property (nonatomic) BOOL filtersReloadInQueue;
@property (nonatomic) BOOL pictureReloadInQueue;
-@property (nonatomic) BOOL visible;
-
@end
@implementation HBSummaryViewController
@@ -40,43 +41,25 @@ static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsCo
- (instancetype)init
{
self = [super initWithNibName:@"HBSummaryViewController" bundle:nil];
+ if (self)
+ {
+ _previewViewController = [[HBPreviewViewController alloc] init];
+ }
return self;
}
- (void)loadView
{
[super loadView];
- self.previewView.showShadow = NO;
- self.visible = YES;
+ self.previewViewController.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
+ self.previewViewController.view.frame = NSMakeRect(0, 0, self.previewView.frame.size.width, self.previewView.frame.size.height);
+ [self.previewView addSubview:self.previewViewController.view];
[self resetLabels];
}
-- (void)viewWillAppear
-{
- self.visible = YES;
- if (self.pictureReloadInQueue || self.previewView.image == NULL)
- {
- [self updatePicture];
- }
-}
-
-- (void)viewDidDisappear
-{
- self.visible = NO;
-}
-
- (void)setGenerator:(HBPreviewGenerator *)generator
{
- _generator = generator;
-
- if (generator)
- {
- [self updatePicture];
- }
- else
- {
- self.previewView.image = nil;
- }
+ self.previewViewController.generator = generator;
}
- (void)setJob:(HBJob *)job
@@ -258,7 +241,7 @@ static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsCo
// to avoid reloading the same image multiple times.
if (self.pictureReloadInQueue == NO)
{
- [[NSRunLoop mainRunLoop] performSelector:@selector(updatePicture) target:self argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
+ [[NSRunLoop mainRunLoop] performSelector:@selector(updatePictureLabel) target:self argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
self.pictureReloadInQueue = YES;
}
}
@@ -285,18 +268,11 @@ static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsCo
self.filtersReloadInQueue = NO;
}
-- (void)updatePicture
+- (void)updatePictureLabel
{
- if (self.visible && self.generator)
- {
- NSUInteger index = self.generator.imagesCount > 1 ? 1 : 0;
- CGImageRef fPreviewImage = [self.generator copyImageAtIndex:index shouldCache:NO];
- self.previewView.image = fPreviewImage;
- CFRelease(fPreviewImage);
- self.pictureReloadInQueue = NO;
-
- self.dimensionLabel.stringValue = self.job.picture.shortInfo;
- }
+ self.pictureReloadInQueue = NO;
+ self.dimensionLabel.stringValue = self.job.picture.shortInfo;
+ [self.previewViewController update];
}
@end