Skip to content

Commit

Permalink
macosx: Extract parts of presentVideoView in VLCLibraryVideoViewContr…
Browse files Browse the repository at this point in the history
…oller into separate methods

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra authored and fkuehne committed Jan 3, 2023
1 parent d08774e commit cbdb999
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 33 deletions.
2 changes: 1 addition & 1 deletion modules/gui/macosx/library/VLCLibraryWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ - (IBAction)segmentedControlAction:(id)sender

- (void)showVideoLibrary
{
[_libraryVideoViewController presentVideoLibraryView];
[_libraryVideoViewController presentVideoView];

self.gridVsListSegmentedControl.target = self;
self.gridVsListSegmentedControl.action = @selector(segmentedControlAction:);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

NS_ASSUME_NONNULL_BEGIN

// Controller for the video library views

@interface VLCLibraryVideoViewController : NSObject

@property (readonly) VLCLibraryWindow *libraryWindow;
Expand All @@ -54,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) NSArray<NSLayoutConstraint *> *videoPlaceholderImageViewSizeConstraints;

- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow;
- (void)presentVideoLibraryView;
- (void)presentVideoView;


@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,49 +114,59 @@ - (void)setupVideoPlaceholderView

#pragma mark - Show the video library view

- (void)presentVideoLibraryView
- (void)presentVideoView
{
for (NSView *subview in _libraryTargetView.subviews) {
[subview removeFromSuperview];
}

if (_libraryVideoTableViewDataSource.libraryModel.numberOfVideoMedia == 0) { // empty library
for (NSLayoutConstraint *constraint in _libraryWindow.libraryAudioViewController.audioPlaceholderImageViewSizeConstraints) {
constraint.active = NO;
}
for (NSLayoutConstraint *constraint in _videoPlaceholderImageViewSizeConstraints) {
constraint.active = YES;
}

_emptyLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
[_libraryTargetView addSubview:_emptyLibraryView];
NSDictionary *dict = NSDictionaryOfVariableBindings(_emptyLibraryView);
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_emptyLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_emptyLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];

_placeholderImageView.image = [NSImage imageNamed:@"placeholder-video"];
_placeholderLabel.stringValue = _NS("Your favorite videos will appear here.\nGo to the Browse section to add videos you love.");
[self presentPlaceholderVideoLibraryView];
} else {
_videoLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
[_libraryTargetView addSubview:_videoLibraryView];
NSDictionary *dict = NSDictionaryOfVariableBindings(_videoLibraryView);
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_videoLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_videoLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];

if (self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment) {
_videoLibrarySplitView.hidden = YES;
_videoLibraryCollectionViewsStackViewScrollView.hidden = NO;
[_libraryVideoCollectionViewsStackViewController reloadData];
} else {
_videoLibrarySplitView.hidden = NO;
_videoLibraryCollectionViewsStackViewScrollView.hidden = YES;
[_libraryVideoTableViewDataSource reloadData];
}
[self presentVideoLibraryView];
}

_librarySortButton.hidden = NO;
_librarySearchField.enabled = YES;
_optionBarView.hidden = YES;
}

- (void)presentPlaceholderVideoLibraryView
{
for (NSLayoutConstraint *constraint in _libraryWindow.libraryAudioViewController.audioPlaceholderImageViewSizeConstraints) {
constraint.active = NO;
}
for (NSLayoutConstraint *constraint in _videoPlaceholderImageViewSizeConstraints) {
constraint.active = YES;
}

_emptyLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
[_libraryTargetView addSubview:_emptyLibraryView];
NSDictionary *dict = NSDictionaryOfVariableBindings(_emptyLibraryView);
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_emptyLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_emptyLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];

_placeholderImageView.image = [NSImage imageNamed:@"placeholder-video"];
_placeholderLabel.stringValue = _NS("Your favorite videos will appear here.\nGo to the Browse section to add videos you love.");
}

- (void)presentVideoLibraryView
{
_videoLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
[_libraryTargetView addSubview:_videoLibraryView];
NSDictionary *dict = NSDictionaryOfVariableBindings(_videoLibraryView);
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_videoLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_videoLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];

if (self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment) {
_videoLibrarySplitView.hidden = YES;
_videoLibraryCollectionViewsStackViewScrollView.hidden = NO;
[_libraryVideoCollectionViewsStackViewController reloadData];
} else {
_videoLibrarySplitView.hidden = NO;
_videoLibraryCollectionViewsStackViewScrollView.hidden = YES;
[_libraryVideoTableViewDataSource reloadData];
}
}

@end

0 comments on commit cbdb999

Please sign in to comment.