[vlc-commits] macosx/main menu: allow custom crop and aspect ratio changes

Felix Paul Kühne git at videolan.org
Wed Aug 28 17:06:37 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed Aug 28 17:05:18 2019 +0200| [89e4a7ad73a556533ec7745f7bffd24d7ca25669] | committer: Felix Paul Kühne

macosx/main menu: allow custom crop and aspect ratio changes

Closes #19838

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

 .../package/macosx/VLC.xcodeproj/project.pbxproj   |   8 ++
 modules/gui/macosx/Makefile.am                     |   3 +
 modules/gui/macosx/UI/VLCCustomCropARPanel.xib     | 125 +++++++++++++++++++++
 modules/gui/macosx/menus/VLCMainMenu.m             |  48 +++++++-
 .../dialogs/VLCCustomCropArWindowController.h      |  52 +++++++++
 .../dialogs/VLCCustomCropArWindowController.m      |  63 +++++++++++
 po/POTFILES.in                                     |   2 +
 7 files changed, 300 insertions(+), 1 deletion(-)

diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index 3e28d52b18..2a3dcdcb9d 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -137,6 +137,7 @@
 		7D903EAF224392B400917358 /* timespec_get.c in Sources */ = {isa = PBXBuildFile; fileRef = 7D903EAE224392B400917358 /* timespec_get.c */; };
 		7D903EB6224394BE00917358 /* specific.c in Sources */ = {isa = PBXBuildFile; fileRef = 7D903EB5224394BE00917358 /* specific.c */; };
 		7D903EB92243952100917358 /* threads.c in Sources */ = {isa = PBXBuildFile; fileRef = 7D903EB82243952100917358 /* threads.c */; };
+		7D93D8FC2316C2DC001C0063 /* VLCCustomCropArWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D93D8FB2316C2DC001C0063 /* VLCCustomCropArWindowController.m */; };
 		7DB40D2A20CBCEB500F63173 /* VLCMainMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DB40D2920CBCEB500F63173 /* VLCMainMenu.m */; };
 		7DB40D2D20CBCEC200F63173 /* VLCStatusBarIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DB40D2B20CBCEC200F63173 /* VLCStatusBarIcon.m */; };
 		7DB7F1EC20CC036D00C2CAED /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DB7F1EB20CC036D00C2CAED /* AudioUnit.framework */; };
@@ -527,6 +528,9 @@
 		7D903EAE224392B400917358 /* timespec_get.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = timespec_get.c; path = ../../../../compat/timespec_get.c; sourceTree = "<group>"; };
 		7D903EB5224394BE00917358 /* specific.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = specific.c; path = ../../../src/darwin/specific.c; sourceTree = "<group>"; };
 		7D903EB82243952100917358 /* threads.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = threads.c; path = ../../../../src/misc/threads.c; sourceTree = "<group>"; };
+		7D93D8F92316C142001C0063 /* VLCCustomCropARPanel.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VLCCustomCropARPanel.xib; sourceTree = "<group>"; };
+		7D93D8FA2316C2DC001C0063 /* VLCCustomCropArWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCCustomCropArWindowController.h; sourceTree = "<group>"; };
+		7D93D8FB2316C2DC001C0063 /* VLCCustomCropArWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCCustomCropArWindowController.m; sourceTree = "<group>"; };
 		7DB40D2820CBCEB500F63173 /* VLCMainMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCMainMenu.h; sourceTree = "<group>"; };
 		7DB40D2920CBCEB500F63173 /* VLCMainMenu.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCMainMenu.m; sourceTree = "<group>"; };
 		7DB40D2B20CBCEC200F63173 /* VLCStatusBarIcon.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCStatusBarIcon.m; sourceTree = "<group>"; };
@@ -1105,6 +1109,8 @@
 				CC461F6D160078340022423C /* VLCTextfieldPanelController.m */,
 				1C7CB91A1D787E7600388902 /* VLCPopupPanelController.h */,
 				1C7CB91B1D787E7600388902 /* VLCPopupPanelController.m */,
+				7D93D8FA2316C2DC001C0063 /* VLCCustomCropArWindowController.h */,
+				7D93D8FB2316C2DC001C0063 /* VLCCustomCropArWindowController.m */,
 			);
 			path = dialogs;
 			sourceTree = "<group>";
@@ -1540,6 +1546,7 @@
 				7DF14FBC2270CB1C0008ABE4 /* VLCMediaSourceDeviceCollectionViewItem.xib */,
 				6B82241A1E4D2A9000833BE1 /* VLCStatusBarIconMainMenu.xib */,
 				6B8224181E4D2A9000833BE1 /* VLCFullScreenPanel.xib */,
+				7D93D8F92316C142001C0063 /* VLCCustomCropARPanel.xib */,
 				6B8223FE1E4D2A8F00833BE1 /* About.xib */,
 				6B8223FF1E4D2A9000833BE1 /* AddonManager.xib */,
 				6B8224001E4D2A9000833BE1 /* AudioEffects.xib */,
@@ -1707,6 +1714,7 @@
 				7DFBDCB7226CDFD600B700A5 /* VLCImageView.m in Sources */,
 				7D404ABF2281892C00B28EF4 /* NSView+VLCAdditions.m in Sources */,
 				7DE9C7DD220728420089108F /* VLCPlayerController.m in Sources */,
+				7D93D8FC2316C2DC001C0063 /* VLCCustomCropArWindowController.m in Sources */,
 				1C3113941E508C6900D4DD76 /* VLCAddonsWindowController.m in Sources */,
 				7D2E0EDE20CD206F0033A221 /* VLCVideoWindowCommon.m in Sources */,
 				1C3113961E508C6900D4DD76 /* applescript.m in Sources */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index ef6db51d54..83f23d9337 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -133,6 +133,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/panels/VLCVideoEffectsWindowController.m \
 	gui/macosx/panels/dialogs/VLCCoreDialogProvider.h \
 	gui/macosx/panels/dialogs/VLCCoreDialogProvider.m \
+	gui/macosx/panels/dialogs/VLCCustomCropArWindowController.h \
+	gui/macosx/panels/dialogs/VLCCustomCropArWindowController.m \
 	gui/macosx/panels/dialogs/VLCPopupPanelController.h \
 	gui/macosx/panels/dialogs/VLCPopupPanelController.m \
 	gui/macosx/panels/dialogs/VLCResumeDialogController.h \
@@ -269,6 +271,7 @@ libmacosx_plugin_la_XIB_SOURCES = \
 	gui/macosx/UI/Help.xib \
 	gui/macosx/UI/LogMessageWindow.xib \
 	gui/macosx/UI/MainMenu.xib \
+	gui/macosx/UI/VLCCustomCropARPanel.xib \
 	gui/macosx/UI/VLCLibraryAlbumTableCellView.xib \
 	gui/macosx/UI/VLCLibraryWindow.xib \
 	gui/macosx/UI/VLCLibraryTableCellView.xib \
diff --git a/modules/gui/macosx/UI/VLCCustomCropARPanel.xib b/modules/gui/macosx/UI/VLCCustomCropARPanel.xib
new file mode 100644
index 0000000000..9936dc5635
--- /dev/null
+++ b/modules/gui/macosx/UI/VLCCustomCropARPanel.xib
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="VLCCustomCropArWindowController">
+            <connections>
+                <outlet property="applyButton" destination="ggs-u2-5DB" id="KYB-GX-w4R"/>
+                <outlet property="cancelButton" destination="J1x-uo-ZpT" id="oVQ-qk-o98"/>
+                <outlet property="denominatorTextField" destination="Smg-Kh-Pjv" id="WhX-dO-loi"/>
+                <outlet property="numeratorTextField" destination="KFt-K5-ogc" id="dE7-LF-UfA"/>
+                <outlet property="titleLabel" destination="bB6-Le-Ilg" id="MQv-r9-Qdw"/>
+                <outlet property="window" destination="Fqe-af-Tt9" id="u4H-rX-p0W"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <window title="Custom Crop" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="Fqe-af-Tt9" userLabel="CustomCropAr">
+            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+            <rect key="contentRect" x="429" y="553" width="265" height="110"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
+            <view key="contentView" id="NrR-3A-NOR">
+                <rect key="frame" x="0.0" y="0.0" width="265" height="122"/>
+                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                <subviews>
+                    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="bB6-Le-Ilg" userLabel="Testlabel">
+                        <rect key="frame" x="86" y="99" width="93" height="17"/>
+                        <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="Custom Crop" id="vXn-nw-Nrc">
+                            <font key="font" metaFont="systemBold"/>
+                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                    </textField>
+                    <textField verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Smg-Kh-Pjv" userLabel="Mins Text Field">
+                        <rect key="frame" x="145" y="59" width="33" height="22"/>
+                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" title="0" drawsBackground="YES" id="2wj-p0-8uH">
+                            <font key="font" metaFont="system"/>
+                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                        <connections>
+                            <outlet property="nextKeyView" destination="J1x-uo-ZpT" id="jSh-vr-TWH"/>
+                        </connections>
+                    </textField>
+                    <textField verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KFt-K5-ogc" userLabel="Hours Text Field">
+                        <rect key="frame" x="87" y="59" width="33" height="22"/>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="33" id="xwZ-sK-Qq8"/>
+                        </constraints>
+                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" title="0" drawsBackground="YES" id="UWz-WZ-unY">
+                            <font key="font" metaFont="system"/>
+                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                        <connections>
+                            <outlet property="nextKeyView" destination="Smg-Kh-Pjv" id="OlL-xH-Oc6"/>
+                        </connections>
+                    </textField>
+                    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="vW2-B8-0jf" userLabel="Testlabel">
+                        <rect key="frame" x="126" y="62" width="13" height="17"/>
+                        <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title=":" id="OUw-pe-eva">
+                            <font key="font" metaFont="systemBold"/>
+                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                    </textField>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ggs-u2-5DB">
+                        <rect key="frame" x="176" y="13" width="75" height="32"/>
+                        <buttonCell key="cell" type="push" title="Apply" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="1nM-QF-enb">
+                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                            <font key="font" metaFont="system"/>
+                            <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+                        </buttonCell>
+                        <connections>
+                            <action selector="buttonPressed:" target="-2" id="irY-sT-eAB"/>
+                            <outlet property="nextKeyView" destination="KFt-K5-ogc" id="SZR-3a-Nhx"/>
+                        </connections>
+                    </button>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="J1x-uo-ZpT">
+                        <rect key="frame" x="94" y="13" width="82" height="32"/>
+                        <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="AHd-5X-fcR">
+                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                            <font key="font" metaFont="system"/>
+                            <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+                        </buttonCell>
+                        <connections>
+                            <action selector="buttonPressed:" target="-2" id="dp8-L6-N7m"/>
+                            <outlet property="nextKeyView" destination="ggs-u2-5DB" id="tW3-MQ-uef"/>
+                        </connections>
+                    </button>
+                </subviews>
+                <constraints>
+                    <constraint firstAttribute="trailing" secondItem="ggs-u2-5DB" secondAttribute="trailing" constant="20" id="1W0-1s-3gv"/>
+                    <constraint firstItem="KFt-K5-ogc" firstAttribute="width" secondItem="Smg-Kh-Pjv" secondAttribute="width" id="24N-1L-5Qx"/>
+                    <constraint firstItem="Smg-Kh-Pjv" firstAttribute="centerY" secondItem="vW2-B8-0jf" secondAttribute="centerY" id="2mI-T4-igU"/>
+                    <constraint firstItem="J1x-uo-ZpT" firstAttribute="top" secondItem="Smg-Kh-Pjv" secondAttribute="bottom" constant="18" id="4tw-eG-Guy"/>
+                    <constraint firstItem="ggs-u2-5DB" firstAttribute="centerY" secondItem="J1x-uo-ZpT" secondAttribute="centerY" id="5tD-9J-E96"/>
+                    <constraint firstAttribute="bottom" secondItem="ggs-u2-5DB" secondAttribute="bottom" constant="20" id="8kZ-L4-ND0"/>
+                    <constraint firstItem="bB6-Le-Ilg" firstAttribute="top" secondItem="NrR-3A-NOR" secondAttribute="top" constant="6" id="AmG-Sh-CJP"/>
+                    <constraint firstItem="Smg-Kh-Pjv" firstAttribute="leading" secondItem="vW2-B8-0jf" secondAttribute="trailing" constant="8" id="OEg-PS-VM3"/>
+                    <constraint firstItem="ggs-u2-5DB" firstAttribute="leading" secondItem="J1x-uo-ZpT" secondAttribute="trailing" constant="12" id="aCf-3u-Xfg"/>
+                    <constraint firstItem="vW2-B8-0jf" firstAttribute="centerX" secondItem="NrR-3A-NOR" secondAttribute="centerX" id="ddl-Ly-MTh"/>
+                    <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="bB6-Le-Ilg" secondAttribute="trailing" constant="20" symbolic="YES" id="epj-mp-Lnm"/>
+                    <constraint firstItem="bB6-Le-Ilg" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="NrR-3A-NOR" secondAttribute="leading" constant="20" symbolic="YES" id="j6a-V4-oje"/>
+                    <constraint firstItem="KFt-K5-ogc" firstAttribute="centerY" secondItem="vW2-B8-0jf" secondAttribute="centerY" id="kWs-Sa-960"/>
+                    <constraint firstItem="Smg-Kh-Pjv" firstAttribute="baseline" secondItem="KFt-K5-ogc" secondAttribute="baseline" id="mOE-Qf-1wF"/>
+                    <constraint firstItem="KFt-K5-ogc" firstAttribute="top" secondItem="bB6-Le-Ilg" secondAttribute="bottom" constant="18" id="oqx-8I-mgW"/>
+                    <constraint firstItem="vW2-B8-0jf" firstAttribute="leading" secondItem="KFt-K5-ogc" secondAttribute="trailing" constant="8" id="sHD-Ov-r3y"/>
+                    <constraint firstItem="bB6-Le-Ilg" firstAttribute="centerX" secondItem="NrR-3A-NOR" secondAttribute="centerX" id="uga-pS-4jS"/>
+                </constraints>
+            </view>
+            <connections>
+                <outlet property="initialFirstResponder" destination="KFt-K5-ogc" id="RUn-tc-Qvg"/>
+            </connections>
+            <point key="canvasLocation" x="146.5" y="157"/>
+        </window>
+    </objects>
+</document>
diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
index c90e1e7caa..d869b1a637 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.m
+++ b/modules/gui/macosx/menus/VLCMainMenu.m
@@ -37,6 +37,7 @@
 #import "panels/VLCVideoEffectsWindowController.h"
 #import "panels/VLCBookmarksWindowController.h"
 #import "panels/dialogs/VLCCoreDialogProvider.h"
+#import "panels/dialogs/VLCCustomCropArWindowController.h"
 #import "panels/VLCInformationWindowController.h"
 #import "panels/VLCTimeSelectionPanelController.h"
 
@@ -106,6 +107,7 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
     NSMenu *_playlistTableColumnsContextMenu;
 
     __strong VLCTimeSelectionPanelController *_timeSelectionPanel;
+    __strong VLCCustomCropArWindowController *_customARController;
 }
 @end
 
@@ -647,12 +649,14 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
                         objectType:VLCObjectTypeVout
                                var:"aspect-ratio"
                           selector:@selector(toggleVar:)];
+            [self appendCustomizationItem:_aspect_ratio];
 
             [self setupVarMenuItem:_crop
                             target:VLC_OBJECT(p_vout)
                         objectType:VLCObjectTypeVout
                                var:"crop"
                           selector:@selector(toggleVar:)];
+            [self appendCustomizationItem:_crop];
 
             [self setupVarMenuItem:_deinterlace
                             target:VLC_OBJECT(p_vout)
@@ -1619,7 +1623,6 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
     free(text);
 }
 
-
 - (void)setupVarMenu:(NSMenu *)menu
          forMenuItem:(NSMenuItem *)parent
               target:(vlc_object_t *)p_object
@@ -1772,6 +1775,49 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
     }
 }
 
+#pragma mark - crop and AR customization
+
+- (void)appendCustomizationItem:(NSMenuItem *)menuItem
+{
+    NSMenu *submenu = menuItem.submenu;
+    NSMenuItem *customizationItem = [[NSMenuItem alloc] initWithTitle:_NS("Custom")
+                                                               action:menuItem == _aspect_ratio ? @selector(performCustomAspectRatio:) : @selector(performCustomCrop:)
+                                                        keyEquivalent:@""];
+    [customizationItem setTarget:self];
+    [submenu addItem:[NSMenuItem separatorItem]];
+    [submenu addItem:customizationItem];
+}
+
+- (void)performCustomCropOrAspectRatioActionWithVariable:(const char *)variable andl10nString:(NSString *)l10nString
+{
+    if (!_customARController) {
+        _customARController = [[VLCCustomCropArWindowController alloc] init];
+    }
+    _customARController.title = l10nString;
+    [_customARController runModalForWindow:[NSApp mainWindow]
+                         completionHandler:^(NSInteger returnCode, NSString * _Nonnull geometry) {
+                             if (returnCode != NSModalResponseOK) {
+                                 return;
+                             }
+
+                             vout_thread_t *p_vout = [self->_playerController videoOutputThreadForKeyWindow];
+                             if (p_vout) {
+                                 var_SetString(p_vout, variable, [geometry UTF8String]);
+                                 vout_Release(p_vout);
+                             }
+                         }];
+}
+
+- (void)performCustomAspectRatio:(id)sender
+{
+    [self performCustomCropOrAspectRatioActionWithVariable:"aspect-ratio" andl10nString:_NS("Aspect Ratio")];
+}
+
+- (void)performCustomCrop:(id)sender
+{
+    [self performCustomCropOrAspectRatioActionWithVariable:"crop" andl10nString:_NS("Crop")];
+}
+
 #pragma mark - menu delegation
 
 - (void)menuWillOpen:(NSMenu *)menu
diff --git a/modules/gui/macosx/panels/dialogs/VLCCustomCropArWindowController.h b/modules/gui/macosx/panels/dialogs/VLCCustomCropArWindowController.h
new file mode 100644
index 0000000000..b01723217a
--- /dev/null
+++ b/modules/gui/macosx/panels/dialogs/VLCCustomCropArWindowController.h
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * VLCCustomCropArWindowController.h: Controller for custom crop / AR panel
+ *****************************************************************************
+ * Copyright (C) 2019 VideoLAN and authors
+ * Author:       Felix Paul Kühne <fkuehne # videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at interface VLCCustomCropArWindowController : NSWindowController
+
+ at property (readwrite, weak) IBOutlet NSButton *cancelButton;
+ at property (readwrite, weak) IBOutlet NSButton *applyButton;
+ at property (readwrite, weak) IBOutlet NSTextField *titleLabel;
+ at property (readwrite, weak) IBOutlet NSTextField *numeratorTextField;
+ at property (readwrite, weak) IBOutlet NSTextField *denominatorTextField;
+ at property (readwrite, retain) NSString *title;
+
+- (IBAction)buttonPressed:(id)sender;
+
+/**
+ * \param returnCode Result from panel. Can be NSModalResponseOK or NSModalResponseCancel.
+ * \param geometry Geometry based on numbers entered in panel
+ */
+typedef void(^CustomCropArCompletionHandler)(NSInteger returnCode, NSString *geometry);
+
+/**
+ * Shows the panel as a modal dialog with window as its owner.
+ * \param window Parent window for the dialog.
+ * \param handler Completion block.
+ */
+- (void)runModalForWindow:(NSWindow *)window completionHandler:(CustomCropArCompletionHandler)handler;
+
+ at end
+
+NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/panels/dialogs/VLCCustomCropArWindowController.m b/modules/gui/macosx/panels/dialogs/VLCCustomCropArWindowController.m
new file mode 100644
index 0000000000..026d85563a
--- /dev/null
+++ b/modules/gui/macosx/panels/dialogs/VLCCustomCropArWindowController.m
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * VLCCustomCropArWindowController.m: Controller for custom crop / AR panel
+ *****************************************************************************
+ * Copyright (C) 2019 VideoLAN and authors
+ * Author:       Felix Paul Kühne <fkuehne # videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCCustomCropArWindowController.h"
+#import "extensions/NSString+Helpers.h"
+
+ at interface VLCCustomCropArWindowController ()
+{
+    CustomCropArCompletionHandler _completionHandler;
+}
+ at end
+
+ at implementation VLCCustomCropArWindowController
+
+- (instancetype)init
+{
+    self = [super initWithWindowNibName:@"VLCCustomCropARPanel"];
+    return self;
+}
+
+- (void)windowDidLoad {
+    [super windowDidLoad];
+    
+    [_applyButton setTitle:_NS("Apply")];
+    [_cancelButton setTitle:_NS("Cancel")];
+    [_titleLabel setStringValue:self.title];
+}
+
+- (void)buttonPressed:(id)sender
+{
+    [self.window orderOut:sender];
+    [NSApp endSheet: self.window];
+    NSString *geometry = [NSString stringWithFormat:@"%@:%@", _numeratorTextField.stringValue, _denominatorTextField.stringValue];
+
+    if (_completionHandler)
+        _completionHandler(sender == _applyButton ? NSModalResponseOK : NSModalResponseCancel, geometry);
+}
+
+- (void)runModalForWindow:(NSWindow *)window completionHandler:(CustomCropArCompletionHandler)handler
+{
+    _completionHandler = handler;
+    [window beginSheet:self.window completionHandler:nil];
+}
+
+ at end
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6552e071a2..5cecd6ccd5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -539,6 +539,8 @@ modules/gui/macosx/panels/VLCVideoEffectsWindowController.h
 modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
 modules/gui/macosx/panels/dialogs/VLCCoreDialogProvider.h
 modules/gui/macosx/panels/dialogs/VLCCoreDialogProvider.m
+modules/gui/macosx/panels/dialogs/VLCCustomCropArWindowController.h
+modules/gui/macosx/panels/dialogs/VLCCustomCropArWindowController.m
 modules/gui/macosx/panels/dialogs/VLCPopupPanelController.h
 modules/gui/macosx/panels/dialogs/VLCPopupPanelController.m
 modules/gui/macosx/panels/dialogs/VLCResumeDialogController.h



More information about the vlc-commits mailing list