macOS: Unify VLCHUDToggleButton/VLCHUDImageButton to VLCImageButton
authorMarvin Scholz <epirat07@gmail.com>
Thu, 1 Jun 2017 11:43:35 +0000 (13:43 +0200)
committerMarvin Scholz <epirat07@gmail.com>
Thu, 1 Jun 2017 11:43:59 +0000 (13:43 +0200)
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.

extras/package/macosx/VLC.xcodeproj/project.pbxproj
modules/gui/macosx/Makefile.am
modules/gui/macosx/UI/VLCFullScreenPanel.xib
modules/gui/macosx/UI/VLCStatusBarIconMainMenu.xib
modules/gui/macosx/VLCHUDImageButton.h [deleted file]
modules/gui/macosx/VLCHUDImageButton.m [deleted file]
modules/gui/macosx/VLCHUDToggleButton.h [deleted file]
modules/gui/macosx/VLCHUDToggleButton.m [deleted file]
modules/gui/macosx/VLCImageButton.h [new file with mode: 0644]
modules/gui/macosx/VLCImageButton.m [new file with mode: 0644]

index 8b2e32b..24b295a 100644 (file)
@@ -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 */; };
                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>"; };
                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 */,
                                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 */,
                                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 */,
index 3c718af..bc367b5 100644 (file)
@@ -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
index 3152cfc..950b417 100644 (file)
@@ -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"/>
                                     <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"/>
                                     <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"/>
                                     <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"/>
                             <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"/>
                             <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"/>
                             <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"/>
index 49e3383..5b21205 100755 (executable)
@@ -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">
                         <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">
                         <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/VLCHUDImageButton.h b/modules/gui/macosx/VLCHUDImageButton.h
deleted file mode 100644 (file)
index 93a53c3..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*****************************************************************************
- * VLCHUDImageButton.h
- *****************************************************************************
- * Copyright (C) 2017 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Cameron Mozie <camsw0rld14@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 <Cocoa/Cocoa.h>
-
-@interface VLCHUDImageButton : NSButton
-
-@end
diff --git a/modules/gui/macosx/VLCHUDImageButton.m b/modules/gui/macosx/VLCHUDImageButton.m
deleted file mode 100644 (file)
index 49ea850..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*****************************************************************************
- * VLCHUDImageButton.m
- *****************************************************************************
- * Copyright (C) 2017 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Cameron Mozie <camsw0rld14@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"
-
-@implementation VLCHUDImageButton
-
-- (instancetype)initWithCoder:(NSCoder *)coder
-{
-    self =  [super initWithCoder:coder];
-    if (self) {
-        [(NSButtonCell*)[self cell] setHighlightsBy:NSPushInCellMask];
-        [(NSButtonCell*)[self cell] setShowsStateBy:NSNoCellMask];
-    }
-    return self;
-}
-
-@end
diff --git a/modules/gui/macosx/VLCHUDToggleButton.h b/modules/gui/macosx/VLCHUDToggleButton.h
deleted file mode 100644 (file)
index 449eccb..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*****************************************************************************
- * VLCHUDToggleButton.h
- *****************************************************************************
- * Copyright (C) 2017 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Cameron Mozie <camsw0rld14@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"
-
-@interface VLCHUDToggleButton : VLCHUDImageButton
-
-@end
diff --git a/modules/gui/macosx/VLCHUDToggleButton.m b/modules/gui/macosx/VLCHUDToggleButton.m
deleted file mode 100644 (file)
index bc26fa6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*****************************************************************************
- * VLCHUDToggleButton.h
- *****************************************************************************
- * Copyright (C) 2017 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Cameron Mozie <camsw0rld14@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"
-
-@implementation VLCHUDToggleButton
-
-- (instancetype)initWithCoder:(NSCoder *)coder
-{
-    self =  [super initWithCoder:coder];
-    if (self) {
-        [(NSButtonCell*)[self cell] setHighlightsBy:NSPushInCellMask];
-        [(NSButtonCell*)[self cell] setShowsStateBy:NSContentsCellMask];
-    }
-    return self;
-}
-
-@end
diff --git a/modules/gui/macosx/VLCImageButton.h b/modules/gui/macosx/VLCImageButton.h
new file mode 100644 (file)
index 0000000..8bfa7a9
--- /dev/null
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * VLCImageButton.h
+ *****************************************************************************
+ * Copyright (C) 2017 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Cameron Mozie <camsw0rld14@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
+ * 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>
+
+@interface VLCImageButton : NSButton
+
+@property (nonatomic) IBInspectable BOOL toggle;
+
+@end
diff --git a/modules/gui/macosx/VLCImageButton.m b/modules/gui/macosx/VLCImageButton.m
new file mode 100644 (file)
index 0000000..d891b25
--- /dev/null
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * VLCImageButton.m
+ *****************************************************************************
+ * Copyright (C) 2017 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Cameron Mozie <camsw0rld14@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
+ * 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 "VLCImageButton.h"
+
+@implementation VLCImageButton
+
+@synthesize toggle = _toggle;
+
+- (instancetype)initWithCoder:(NSCoder *)coder
+{
+    self =  [super initWithCoder:coder];
+    if (self) {
+        _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