[vlc-commits] macOS: Unify VLCHUDToggleButton/VLCHUDImageButton to VLCImageButton

Marvin Scholz git at videolan.org
Thu Jun 1 13:44:15 CEST 2017


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Thu Jun  1 13:43:35 2017 +0200| [cecb49ed6556143f94d69d581fc934ef9b74ecc8] | committer: Marvin Scholz

macOS: Unify VLCHUDToggleButton/VLCHUDImageButton to VLCImageButton

The implementation of these buttons is nearly the same, so it makes no
sense to have separate classes for them.

Only reason to do so, was the inability to get the button type, which
for now is worked-around by using an IBInspectable BOOL that has to be
set, if the button is a toggle button.

Not the nicest solution, but there is no better way, as far as I know.

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

 .../package/macosx/VLC.xcodeproj/project.pbxproj   | 18 ++++------
 modules/gui/macosx/Makefile.am                     |  3 +-
 modules/gui/macosx/UI/VLCFullScreenPanel.xib       | 27 ++++++++-------
 modules/gui/macosx/UI/VLCStatusBarIconMainMenu.xib | 15 +++++----
 modules/gui/macosx/VLCHUDToggleButton.h            | 28 ----------------
 modules/gui/macosx/VLCHUDToggleButton.m            | 38 ----------------------
 .../{VLCHUDImageButton.h => VLCImageButton.h}      |  7 ++--
 .../{VLCHUDImageButton.m => VLCImageButton.m}      | 24 +++++++++++---
 8 files changed, 55 insertions(+), 105 deletions(-)

diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index 8b2e32b7bd..24b295a2d6 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -70,8 +70,7 @@
 		1C31140D1E508C8800D4DD76 /* SPMediaKeyTap.m in Sources */ = {isa = PBXBuildFile; fileRef = CCF0777C13659A8000AF19FD /* SPMediaKeyTap.m */; };
 		1C69FDF61EAB30C7007724ED /* Windows.m in Sources */ = {isa = PBXBuildFile; fileRef = E06CF7F516020F6200C698B7 /* Windows.m */; };
 		1CFE8D591EA0D42A00E94451 /* VLCErrorWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFE8D581EA0D42A00E94451 /* VLCErrorWindowController.m */; };
-		6B3BE42C1E6217CB008D098A /* VLCHUDImageButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3BE42B1E6217CB008D098A /* VLCHUDImageButton.m */; };
-		6B3BE4321E621F24008D098A /* VLCHUDToggleButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3BE4311E621F24008D098A /* VLCHUDToggleButton.m */; };
+		6B3BE42C1E6217CB008D098A /* VLCImageButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3BE42B1E6217CB008D098A /* VLCImageButton.m */; };
 		6B4D50901E79781F004479B5 /* VLCHotkeyChangeWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B4D508F1E79781F004479B5 /* VLCHotkeyChangeWindow.m */; };
 		6B4D50931E7979CB004479B5 /* VLCSimplePrefsWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B4D50921E7979CB004479B5 /* VLCSimplePrefsWindow.m */; };
 		6B4D50961E7A7D16004479B5 /* NSSound+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B4D50951E7A7D16004479B5 /* NSSound+VLCAdditions.m */; };
@@ -114,10 +113,8 @@
 		633121CB1B51122700E636DA /* VLCResumeDialogController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCResumeDialogController.m; sourceTree = "<group>"; };
 		6B13E2A61BC67678001AD24A /* VLCScrollingClipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCScrollingClipView.h; sourceTree = "<group>"; };
 		6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCScrollingClipView.m; sourceTree = "<group>"; };
-		6B3BE42A1E6217CB008D098A /* VLCHUDImageButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHUDImageButton.h; sourceTree = "<group>"; };
-		6B3BE42B1E6217CB008D098A /* VLCHUDImageButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHUDImageButton.m; sourceTree = "<group>"; };
-		6B3BE4301E621F24008D098A /* VLCHUDToggleButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHUDToggleButton.h; sourceTree = "<group>"; };
-		6B3BE4311E621F24008D098A /* VLCHUDToggleButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHUDToggleButton.m; sourceTree = "<group>"; };
+		6B3BE42A1E6217CB008D098A /* VLCImageButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCImageButton.h; sourceTree = "<group>"; };
+		6B3BE42B1E6217CB008D098A /* VLCImageButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCImageButton.m; sourceTree = "<group>"; };
 		6B4D508E1E79781F004479B5 /* VLCHotkeyChangeWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHotkeyChangeWindow.h; sourceTree = "<group>"; };
 		6B4D508F1E79781F004479B5 /* VLCHotkeyChangeWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHotkeyChangeWindow.m; sourceTree = "<group>"; };
 		6B4D50911E7979CB004479B5 /* VLCSimplePrefsWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCSimplePrefsWindow.h; sourceTree = "<group>"; };
@@ -850,10 +847,8 @@
 		08FB77AFFE84173DC02AAC07 /* Classes */ = {
 			isa = PBXGroup;
 			children = (
-				6B3BE42A1E6217CB008D098A /* VLCHUDImageButton.h */,
-				6B3BE42B1E6217CB008D098A /* VLCHUDImageButton.m */,
-				6B3BE4301E621F24008D098A /* VLCHUDToggleButton.h */,
-				6B3BE4311E621F24008D098A /* VLCHUDToggleButton.m */,
+				6B3BE42A1E6217CB008D098A /* VLCImageButton.h */,
+				6B3BE42B1E6217CB008D098A /* VLCImageButton.m */,
 				1C67C8A61D58C0A40079E1C1 /* VLCAboutWindowController.h */,
 				1C67C8A71D58C0A40079E1C1 /* VLCAboutWindowController.m */,
 				1C67C8A31D58C0980079E1C1 /* VLCHelpWindowController.h */,
@@ -1841,7 +1836,7 @@
 				6B8166291EBFC34300C26F1B /* VLCDefaultValueSlider.m in Sources */,
 				6B81662A1EBFC34300C26F1B /* VLCDefaultValueSliderCell.m in Sources */,
 				1C69FDF61EAB30C7007724ED /* Windows.m in Sources */,
-				6B3BE42C1E6217CB008D098A /* VLCHUDImageButton.m in Sources */,
+				6B3BE42C1E6217CB008D098A /* VLCImageButton.m in Sources */,
 				6B4D50901E79781F004479B5 /* VLCHotkeyChangeWindow.m in Sources */,
 				1C3114031E508C8800D4DD76 /* AppleRemote.m in Sources */,
 				1CFE8D591EA0D42A00E94451 /* VLCErrorWindowController.m in Sources */,
@@ -1853,7 +1848,6 @@
 				1C31140D1E508C8800D4DD76 /* SPMediaKeyTap.m in Sources */,
 				1C3113EF1E508C7600D4DD76 /* VLCRendererDiscovery.m in Sources */,
 				1C3113F11E508C7600D4DD76 /* VLCRendererItem.m in Sources */,
-				6B3BE4321E621F24008D098A /* VLCHUDToggleButton.m in Sources */,
 				1C3113F31E508C7600D4DD76 /* VLCRendererDialog.m in Sources */,
 				1C3113F51E508C7600D4DD76 /* VLCHUDTextFieldCell.m in Sources */,
 				1C3113F71E508C7600D4DD76 /* VLCHUDButtonCell.m in Sources */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 3c718afa94..bc367b5f8b 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -89,8 +89,7 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/VLCFSPanelDraggableView.h gui/macosx/VLCFSPanelDraggableView.m \
 	gui/macosx/VLCDefaultValueSlider.h gui/macosx/VLCDefaultValueSlider.m \
 	gui/macosx/VLCDefaultValueSliderCell.h gui/macosx/VLCDefaultValueSliderCell.m \
-	gui/macosx/VLCHUDImageButton.h gui/macosx/VLCHUDImageButton.m \
-	gui/macosx/VLCHUDToggleButton.h gui/macosx/VLCHUDToggleButton.m \
+	gui/macosx/VLCImageButton.h gui/macosx/VLCImageButton.m \
 	gui/macosx/VLCTimeField.h gui/macosx/VLCTimeField.m
 
 # User interface compilation
diff --git a/modules/gui/macosx/UI/VLCFullScreenPanel.xib b/modules/gui/macosx/UI/VLCFullScreenPanel.xib
index 3152cfcd24..950b4176ce 100644
--- a/modules/gui/macosx/UI/VLCFullScreenPanel.xib
+++ b/modules/gui/macosx/UI/VLCFullScreenPanel.xib
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12100" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
-        <deployment identifier="macosx"/>
+        <deployment version="1070" identifier="macosx"/>
         <development version="7000" identifier="xcode"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12100"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/>
         <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
         <capability name="system font weights other than Regular or Bold" minToolsVersion="7.0"/>
     </dependencies>
@@ -42,7 +42,7 @@
                     <customView translatesAutoresizingMaskIntoConstraints="NO" id="VLH-qy-cwr">
                         <rect key="frame" x="0.0" y="0.0" width="480" height="42"/>
                         <subviews>
-                            <button translatesAutoresizingMaskIntoConstraints="NO" id="YSL-bH-k6U" customClass="VLCHUDToggleButton">
+                            <button translatesAutoresizingMaskIntoConstraints="NO" id="YSL-bH-k6U" customClass="VLCImageButton">
                                 <rect key="frame" x="226" y="7" width="35" height="29"/>
                                 <constraints>
                                     <constraint firstAttribute="width" secondItem="YSL-bH-k6U" secondAttribute="height" multiplier="1:1" constant="6" id="2if-S8-t0u"/>
@@ -51,11 +51,14 @@
                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                     <font key="font" metaFont="system"/>
                                 </buttonCell>
+                                <userDefinedRuntimeAttributes>
+                                    <userDefinedRuntimeAttribute type="boolean" keyPath="toggle" value="YES"/>
+                                </userDefinedRuntimeAttributes>
                                 <connections>
                                     <action selector="togglePlayPause:" target="-2" id="9os-DP-jAN"/>
                                 </connections>
                             </button>
-                            <button translatesAutoresizingMaskIntoConstraints="NO" id="jSN-hV-r5D" customClass="VLCHUDImageButton">
+                            <button translatesAutoresizingMaskIntoConstraints="NO" id="jSN-hV-r5D" customClass="VLCImageButton">
                                 <rect key="frame" x="263" y="7" width="34" height="29"/>
                                 <constraints>
                                     <constraint firstAttribute="width" secondItem="jSN-hV-r5D" secondAttribute="height" multiplier="19:16" id="m1w-9i-bkp"/>
@@ -68,7 +71,7 @@
                                     <action selector="jumpForward:" target="-2" id="bjn-qc-BJ7"/>
                                 </connections>
                             </button>
-                            <button translatesAutoresizingMaskIntoConstraints="NO" id="7QH-jb-QdM" customClass="VLCHUDImageButton">
+                            <button translatesAutoresizingMaskIntoConstraints="NO" id="7QH-jb-QdM" customClass="VLCImageButton">
                                 <rect key="frame" x="189" y="7" width="35" height="29"/>
                                 <constraints>
                                     <constraint firstAttribute="width" secondItem="7QH-jb-QdM" secondAttribute="height" multiplier="19:16" id="isk-o2-kZY"/>
@@ -93,7 +96,7 @@
                                     <action selector="volumeSliderUpdate:" target="-2" id="doI-qM-Pde"/>
                                 </connections>
                             </slider>
-                            <button translatesAutoresizingMaskIntoConstraints="NO" id="2ai-dB-Wpq" customClass="VLCHUDImageButton">
+                            <button translatesAutoresizingMaskIntoConstraints="NO" id="2ai-dB-Wpq" customClass="VLCImageButton">
                                 <rect key="frame" x="299" y="7" width="34" height="29"/>
                                 <constraints>
                                     <constraint firstAttribute="width" secondItem="2ai-dB-Wpq" secondAttribute="height" multiplier="19:16" id="Itj-7f-YDa"/>
@@ -106,7 +109,7 @@
                                     <action selector="gotoNext:" target="-2" id="flJ-52-Pcb"/>
                                 </connections>
                             </button>
-                            <button translatesAutoresizingMaskIntoConstraints="NO" id="TVM-DT-2yo" customClass="VLCHUDImageButton">
+                            <button translatesAutoresizingMaskIntoConstraints="NO" id="TVM-DT-2yo" customClass="VLCImageButton">
                                 <rect key="frame" x="153" y="7" width="34" height="29"/>
                                 <constraints>
                                     <constraint firstAttribute="width" secondItem="TVM-DT-2yo" secondAttribute="height" multiplier="19:16" id="oKb-iw-6S1"/>
@@ -130,7 +133,7 @@
                                     <font key="font" metaFont="system"/>
                                 </buttonCell>
                             </button>
-                            <button translatesAutoresizingMaskIntoConstraints="NO" id="C5K-aX-3aJ" customClass="VLCHUDImageButton">
+                            <button translatesAutoresizingMaskIntoConstraints="NO" id="C5K-aX-3aJ" customClass="VLCImageButton">
                                 <rect key="frame" x="438" y="10" width="22" height="22"/>
                                 <constraints>
                                     <constraint firstAttribute="width" secondItem="C5K-aX-3aJ" secondAttribute="height" multiplier="1:1" id="VWl-0x-p1I"/>
@@ -172,7 +175,7 @@
                             <constraint firstItem="C5K-aX-3aJ" firstAttribute="top" secondItem="VLH-qy-cwr" secondAttribute="top" constant="10" id="yLu-H1-w7g"/>
                         </constraints>
                     </customView>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nJc-M4-sMF" customClass="VLCTimeField">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nJc-M4-sMF" customClass="VLCTimeField">
                         <rect key="frame" x="18" y="57" width="79" height="14"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="75" id="IGO-bJ-xu2"/>
@@ -184,7 +187,7 @@
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="T3x-es-c7v" customClass="VLCTimeField">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T3x-es-c7v" customClass="VLCTimeField">
                         <rect key="frame" x="383" y="57" width="79" height="14"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="14" id="a6B-fU-pHt"/>
@@ -196,7 +199,7 @@
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Vd8-0f-Usz">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Vd8-0f-Usz">
                         <rect key="frame" x="98" y="57" width="284" height="14"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="14" id="SsE-i5-v4k"/>
diff --git a/modules/gui/macosx/UI/VLCStatusBarIconMainMenu.xib b/modules/gui/macosx/UI/VLCStatusBarIconMainMenu.xib
index 49e3383237..5b21205352 100755
--- a/modules/gui/macosx/UI/VLCStatusBarIconMainMenu.xib
+++ b/modules/gui/macosx/UI/VLCStatusBarIconMainMenu.xib
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12118" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
     <dependencies>
-        <deployment identifier="macosx"/>
+        <deployment version="1070" identifier="macosx"/>
         <development version="7000" identifier="xcode"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12118"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="VLCStatusBarIcon">
@@ -119,7 +119,7 @@
                         <action selector="toggelProgressTime:" target="-2" id="S3e-vr-guH"/>
                     </connections>
                 </button>
-                <button id="p8X-zU-PwN" customClass="VLCHUDImageButton">
+                <button id="p8X-zU-PwN" customClass="VLCImageButton">
                     <rect key="frame" x="76" y="20" width="28" height="24"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="VLCPreviousTemplate" imagePosition="overlaps" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="PSI-Wi-u0R">
@@ -130,18 +130,21 @@
                         <action selector="statusBarIconPrevious:" target="-2" id="kAL-hK-8qL"/>
                     </connections>
                 </button>
-                <button id="lvI-lN-t4O" customClass="VLCHUDToggleButton">
+                <button id="lvI-lN-t4O" customClass="VLCImageButton">
                     <rect key="frame" x="109" y="20" width="28" height="24"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="VLCPlayTemplate" imagePosition="only" alignment="center" alternateImage="VLCPauseTemplate" imageScaling="proportionallyUpOrDown" inset="2" id="nqu-wV-vI1">
                         <behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
                         <font key="font" metaFont="system"/>
                     </buttonCell>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="boolean" keyPath="toggle" value="YES"/>
+                    </userDefinedRuntimeAttributes>
                     <connections>
                         <action selector="statusBarIconTogglePlayPause:" target="-2" id="K38-Dr-lNS"/>
                     </connections>
                 </button>
-                <button id="NHj-Vf-SPF" customClass="VLCHUDImageButton">
+                <button id="NHj-Vf-SPF" customClass="VLCImageButton">
                     <rect key="frame" x="141" y="20" width="28" height="24"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="VLCNextTemplate" imagePosition="overlaps" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="BIa-Vy-yD2">
diff --git a/modules/gui/macosx/VLCHUDToggleButton.h b/modules/gui/macosx/VLCHUDToggleButton.h
deleted file mode 100644
index 449eccbca8..0000000000
--- a/modules/gui/macosx/VLCHUDToggleButton.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*****************************************************************************
- * VLCHUDToggleButton.h
- *****************************************************************************
- * Copyright (C) 2017 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Cameron Mozie <camsw0rld14 at gmail.com>
- *
- * 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 "VLCHUDImageButton.h"
-
- at interface VLCHUDToggleButton : VLCHUDImageButton
-
- at end
diff --git a/modules/gui/macosx/VLCHUDToggleButton.m b/modules/gui/macosx/VLCHUDToggleButton.m
deleted file mode 100644
index bc26fa60ad..0000000000
--- a/modules/gui/macosx/VLCHUDToggleButton.m
+++ /dev/null
@@ -1,38 +0,0 @@
-/*****************************************************************************
- * VLCHUDToggleButton.h
- *****************************************************************************
- * Copyright (C) 2017 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Cameron Mozie <camsw0rld14 at gmail.com>
- *
- * 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 "VLCHUDToggleButton.h"
-
- at implementation VLCHUDToggleButton
-
-- (instancetype)initWithCoder:(NSCoder *)coder
-{
-    self =  [super initWithCoder:coder];
-    if (self) {
-        [(NSButtonCell*)[self cell] setHighlightsBy:NSPushInCellMask];
-        [(NSButtonCell*)[self cell] setShowsStateBy:NSContentsCellMask];
-    }
-    return self;
-}
-
- at end
diff --git a/modules/gui/macosx/VLCHUDImageButton.h b/modules/gui/macosx/VLCImageButton.h
similarity index 87%
rename from modules/gui/macosx/VLCHUDImageButton.h
rename to modules/gui/macosx/VLCImageButton.h
index 93a53c3651..8bfa7a9b2c 100644
--- a/modules/gui/macosx/VLCHUDImageButton.h
+++ b/modules/gui/macosx/VLCImageButton.h
@@ -1,10 +1,11 @@
 /*****************************************************************************
- * VLCHUDImageButton.h
+ * VLCImageButton.h
  *****************************************************************************
  * Copyright (C) 2017 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Cameron Mozie <camsw0rld14 at gmail.com>
+ *          Marvin Scholz <epirat07 at gmail dot com>
  *
  * 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
@@ -23,6 +24,8 @@
 
 #import <Cocoa/Cocoa.h>
 
- at interface VLCHUDImageButton : NSButton
+ at interface VLCImageButton : NSButton
+
+ at property (nonatomic) IBInspectable BOOL toggle;
 
 @end
diff --git a/modules/gui/macosx/VLCHUDImageButton.m b/modules/gui/macosx/VLCImageButton.m
similarity index 69%
rename from modules/gui/macosx/VLCHUDImageButton.m
rename to modules/gui/macosx/VLCImageButton.m
index 49ea850a59..d891b25ad5 100644
--- a/modules/gui/macosx/VLCHUDImageButton.m
+++ b/modules/gui/macosx/VLCImageButton.m
@@ -1,10 +1,11 @@
 /*****************************************************************************
- * VLCHUDImageButton.m
+ * VLCImageButton.m
  *****************************************************************************
  * Copyright (C) 2017 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Cameron Mozie <camsw0rld14 at gmail.com>
+ *          Marvin Scholz <epirat07 at gmail dot com>
  *
  * 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
@@ -21,18 +22,31 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#import "VLCHUDImageButton.h"
+#import "VLCImageButton.h"
 
- at implementation VLCHUDImageButton
+ at implementation VLCImageButton
+
+ at synthesize toggle = _toggle;
 
 - (instancetype)initWithCoder:(NSCoder *)coder
 {
     self =  [super initWithCoder:coder];
     if (self) {
-        [(NSButtonCell*)[self cell] setHighlightsBy:NSPushInCellMask];
-        [(NSButtonCell*)[self cell] setShowsStateBy:NSNoCellMask];
+        _toggle = NO;
     }
     return self;
 }
 
+- (void)awakeFromNib
+{
+    [(NSButtonCell*)[self cell] setHighlightsBy:NSPushInCellMask];
+    [(NSButtonCell*)[self cell] setShowsStateBy:(_toggle) ? NSContentsCellMask : NSNoCellMask];
+}
+
+- (void)setToggle:(BOOL)toggle
+{
+    _toggle = toggle;
+    [(NSButtonCell*)[self cell] setShowsStateBy:(_toggle) ? NSContentsCellMask : NSNoCellMask];
+}
+
 @end



More information about the vlc-commits mailing list