[vlc-commits] macosx/info: prepare for re-use outside the main menu

Felix Paul Kühne git at videolan.org
Mon Jul 1 16:56:22 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Jul  1 16:37:19 2019 +0200| [ef36fe1aee53a593d244bcb5df6024e7c8f66ea5] | committer: Felix Paul Kühne

macosx/info: prepare for re-use outside the main menu

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ef36fe1aee53a593d244bcb5df6024e7c8f66ea5
---

 modules/gui/macosx/UI/MediaInfo.xib                | 19 ++++----
 modules/gui/macosx/menus/VLCMainMenu.m             | 10 +++--
 .../macosx/panels/VLCInformationWindowController.h |  1 +
 .../macosx/panels/VLCInformationWindowController.m | 51 +++++++++++++---------
 4 files changed, 49 insertions(+), 32 deletions(-)

diff --git a/modules/gui/macosx/UI/MediaInfo.xib b/modules/gui/macosx/UI/MediaInfo.xib
index f9b5da7f33..0ec40b425e 100644
--- a/modules/gui/macosx/UI/MediaInfo.xib
+++ b/modules/gui/macosx/UI/MediaInfo.xib
@@ -71,16 +71,16 @@
             <windowPositionMask key="initialPositionMask" leftStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="34" width="506" height="476"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
-            <view key="contentView" misplaced="YES" id="3">
+            <view key="contentView" id="3">
                 <rect key="frame" x="0.0" y="0.0" width="506" height="476"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <tabView misplaced="YES" drawsBackground="NO" type="noTabsNoBorder" initialItem="419" translatesAutoresizingMaskIntoConstraints="NO" id="418">
+                    <tabView drawsBackground="NO" type="noTabsNoBorder" initialItem="419" translatesAutoresizingMaskIntoConstraints="NO" id="418">
                         <rect key="frame" x="-21" y="-1" width="542" height="444"/>
                         <font key="font" metaFont="system"/>
                         <tabViewItems>
                             <tabViewItem label="General" identifier="1" id="419">
-                                <view key="view" id="422">
+                                <view key="view" misplaced="YES" id="422">
                                     <rect key="frame" x="0.0" y="0.0" width="542" height="444"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <subviews>
@@ -459,9 +459,9 @@
                                             <rect key="frame" x="17" y="0.0" width="510" height="440"/>
                                             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="jDW-Lc-WE4">
                                                 <rect key="frame" x="0.0" y="0.0" width="510" height="440"/>
-                                                <autoresizingMask key="autoresizingMask"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
-                                                    <outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" indentationPerLevel="16" autoresizesOutlineColumn="YES" outlineTableColumn="521" id="519">
+                                                    <outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" indentationPerLevel="16" autoresizesOutlineColumn="YES" outlineTableColumn="521" id="519" customClass="VLCHUDOutlineView">
                                                         <rect key="frame" x="0.0" y="0.0" width="510" height="440"/>
                                                         <autoresizingMask key="autoresizingMask"/>
                                                         <size key="intercellSpacing" width="3" height="2"/>
@@ -471,7 +471,7 @@
                                                             <tableColumn identifier="0" editable="NO" width="241.91015625" minWidth="16" maxWidth="1000" id="521">
                                                                 <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
                                                                     <font key="font" metaFont="smallSystem"/>
-                                                                    <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                                    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                                                     <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
                                                                 </tableHeaderCell>
                                                                 <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="524">
@@ -484,7 +484,7 @@
                                                             <tableColumn identifier="1" editable="NO" width="262" minWidth="10" maxWidth="3.4028234663852886e+38" id="644">
                                                                 <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
                                                                     <font key="font" metaFont="smallSystem"/>
-                                                                    <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                                    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                                                     <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
                                                                 </tableHeaderCell>
                                                                 <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="645">
@@ -497,6 +497,7 @@
                                                         </tableColumns>
                                                     </outlineView>
                                                 </subviews>
+                                                <nil key="backgroundColor"/>
                                             </clipView>
                                             <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="518">
                                                 <rect key="frame" x="0.0" y="428" width="510" height="16"/>
@@ -843,7 +844,7 @@
                             </tabViewItem>
                         </tabViewItems>
                     </tabView>
-                    <segmentedControl verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GFW-aJ-Pub">
+                    <segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="GFW-aJ-Pub">
                         <rect key="frame" x="118" y="448" width="270" height="24"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="21" id="WVH-Tg-9g5"/>
@@ -860,7 +861,7 @@
                             <action selector="takeSelectedTabViewItemFromSender:" target="418" id="Z4V-Lm-ikS"/>
                         </connections>
                     </segmentedControl>
-                    <box verticalHuggingPriority="750" misplaced="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="cFC-fJ-8UH">
+                    <box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="cFC-fJ-8UH">
                         <rect key="frame" x="0.0" y="440" width="506" height="5"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="1" id="ivG-J4-70G"/>
diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
index a4142747e1..853f9de4fe 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.m
+++ b/modules/gui/macosx/menus/VLCMainMenu.m
@@ -97,6 +97,7 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
     VLCPlayerController *_playerController;
     NSTimer *_cancelRendererDiscoveryTimer;
     VLCPlaylistSortingMenuController *_playlistSortingController;
+    VLCInformationWindowController *_infoWindowController;
 
     NSMenu *_playlistTableColumnsContextMenu;
 
@@ -1423,9 +1424,12 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
 
 - (IBAction)showInformationPanel:(id)sender
 {
-    VLCInformationWindowController *informationController = [[VLCInformationWindowController alloc] init];
-    informationController.representedInputItem = _playlistController.currentlyPlayingInputItem;
-    [informationController toggleWindow:sender];
+    if (!_infoWindowController) {
+        _infoWindowController = [[VLCInformationWindowController alloc] init];
+        _infoWindowController.mainMenuInstance = YES;
+    }
+    _infoWindowController.representedInputItem = _playlistController.currentlyPlayingInputItem;
+    [_infoWindowController toggleWindow:sender];
 }
 
 #pragma mark - playback state
diff --git a/modules/gui/macosx/panels/VLCInformationWindowController.h b/modules/gui/macosx/panels/VLCInformationWindowController.h
index ea4b4089a0..f71375b44e 100644
--- a/modules/gui/macosx/panels/VLCInformationWindowController.h
+++ b/modules/gui/macosx/panels/VLCInformationWindowController.h
@@ -84,6 +84,7 @@
 @property (readwrite, weak) IBOutlet NSTextField *videoDecodedTextField;
 
 @property (readwrite, strong, nonatomic) VLCInputItem *representedInputItem;
+ at property (readwrite) BOOL mainMenuInstance;
 
 - (IBAction)toggleWindow:(id)sender;
 
diff --git a/modules/gui/macosx/panels/VLCInformationWindowController.m b/modules/gui/macosx/panels/VLCInformationWindowController.m
index 4019098f0d..f2508bbf42 100644
--- a/modules/gui/macosx/panels/VLCInformationWindowController.m
+++ b/modules/gui/macosx/panels/VLCInformationWindowController.m
@@ -45,6 +45,11 @@
 
 @implementation VLCCodecInformationTreeItem
 
+- (NSString *)description
+{
+    return [NSString stringWithFormat:@"%@: name: %@ value: %@ children: %lu", NSStringFromClass([self class]), self.name, self.value, self.children.count];
+}
+
 @end
 
 #pragma mark - window controller
@@ -62,21 +67,6 @@
 - (id)init
 {
     self = [super initWithWindowNibName:@"MediaInfo"];
-    if (self) {
-        NSNotificationCenter *defaultNotificationCenter = [NSNotificationCenter defaultCenter];
-        [defaultNotificationCenter addObserver:self
-                                                 selector:@selector(currentPlaylistItemChanged:)
-                                                     name:VLCPlaylistCurrentItemChanged
-                                                   object:nil];
-        [defaultNotificationCenter addObserver:self
-                                      selector:@selector(updateStatistics:)
-                                          name:VLCPlayerStatisticsUpdated
-                                        object:nil];
-        [defaultNotificationCenter addObserver:self
-                                      selector:@selector(updateCocoaWindowLevel:)
-                                          name:VLCWindowShouldUpdateLevel
-                                        object:nil];
-    }
     return self;
 }
 
@@ -85,7 +75,7 @@
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
-- (void)windowDidLoad
+- (void)awakeFromNib
 {
     [self.window setExcludedFromWindowsMenu: YES];
     [self.window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
@@ -93,10 +83,28 @@
 
     _outlineView.dataSource = self;
 
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+    if (_mainMenuInstance) {
+        [notificationCenter addObserver:self
+                               selector:@selector(currentPlaylistItemChanged:)
+                                   name:VLCPlaylistCurrentItemChanged
+                                 object:nil];
+        [notificationCenter addObserver:self
+                               selector:@selector(updateStatistics:)
+                                   name:VLCPlayerStatisticsUpdated
+                                 object:nil];
+    }
+    [notificationCenter addObserver:self
+                           selector:@selector(updateCocoaWindowLevel:)
+                               name:VLCWindowShouldUpdateLevel
+                             object:nil];
+
+    [notificationCenter postNotificationName:VLCPlayerStatisticsUpdated object:self];
+
     [self initStrings];
 
     _statisticsEnabled = var_InheritBool(getIntf(), "stats");
-    if (!_statisticsEnabled) {
+    if (!_statisticsEnabled || !_mainMenuInstance) {
         if ([_segmentedView segmentCount] >= 3)
             [_segmentedView setSegmentCount: 2];
     } else {
@@ -259,11 +267,9 @@
         [_imageWell setImage: [NSImage imageNamed: @"noart.png"]];
     } else {
         if (!_representedInputItem.preparsed) {
-            NSLog(@"item wasn't preparsed");
             [_representedInputItem preparseInputItem];
         }
 
-        NSLog(@"%s: %@ - %@ - %@", __PRETTY_FUNCTION__, _representedInputItem.title, _representedInputItem.MRL, _uriTextField);
         _uriTextField.stringValue = _representedInputItem.MRL;
         _titleTextField.stringValue = _representedInputItem.title;
         _authorTextField.stringValue = _representedInputItem.artist;
@@ -287,6 +293,10 @@
             artwork = [NSImage imageNamed: @"noart.png"];
         }
         [_imageWell setImage:artwork];
+
+        if (!_mainMenuInstance) {
+            [self.window setTitle:_representedInputItem.title];
+        }
     }
 
     /* reload the codec details table */
@@ -375,7 +385,8 @@
 }
 
 - (BOOL)outlineView:(NSOutlineView *)outlineView
-   isItemExpandable:(id)item {
+   isItemExpandable:(id)item
+{
     return ([item children].count > 0);
 }
 



More information about the vlc-commits mailing list