[vlc-commits] macosx: introduce a textfield with rounded background corners and use it in the library view

Felix Paul Kühne git at videolan.org
Fri May 31 14:35:59 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri May 31 14:35:36 2019 +0200| [a4dac2767da0a41777e8427088f058dfc585faec] | committer: Felix Paul Kühne

macosx: introduce a textfield with rounded background corners and use it in the library view

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

 .../package/macosx/VLC.xcodeproj/project.pbxproj   |  6 +++
 modules/gui/macosx/Makefile.am                     |  2 +
 .../gui/macosx/UI/VLCLibraryCollectionViewItem.xib | 12 ++---
 .../gui/macosx/views/VLCRoundedCornerTextField.h   | 31 ++++++++++++
 .../gui/macosx/views/VLCRoundedCornerTextField.m   | 59 ++++++++++++++++++++++
 po/POTFILES.in                                     |  2 +
 6 files changed, 106 insertions(+), 6 deletions(-)

diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index 5701bc5974..fea8965c80 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -103,6 +103,7 @@
 		7D0F63FF2201F63400FDB91F /* VLCPlaylistTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0F63FE2201F63400FDB91F /* VLCPlaylistTableCellView.m */; };
 		7D0F64062202047900FDB91F /* VLCLibraryCollectionViewItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0F64042202047900FDB91F /* VLCLibraryCollectionViewItem.m */; };
 		7D0F640C2202163E00FDB91F /* VLCPlaylistDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0F640B2202163E00FDB91F /* VLCPlaylistDataSource.m */; };
+		7D1BF28A22A153E20027C50F /* VLCRoundedCornerTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D1BF28922A153E20027C50F /* VLCRoundedCornerTextField.m */; };
 		7D20081A2289835C002679DF /* VLCTrackingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2008192289835C002679DF /* VLCTrackingView.m */; };
 		7D28E6362275B4820098D30E /* NSColor+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D28E6352275B4820098D30E /* NSColor+VLCAdditions.m */; };
 		7D28E6392275B7340098D30E /* NSFont+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D28E6382275B7340098D30E /* NSFont+VLCAdditions.m */; };
@@ -449,6 +450,8 @@
 		7D0F64052202047900FDB91F /* VLCLibraryCollectionViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCLibraryCollectionViewItem.xib; sourceTree = "<group>"; };
 		7D0F640A2202163E00FDB91F /* VLCPlaylistDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaylistDataSource.h; sourceTree = "<group>"; };
 		7D0F640B2202163E00FDB91F /* VLCPlaylistDataSource.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistDataSource.m; sourceTree = "<group>"; };
+		7D1BF28822A153E20027C50F /* VLCRoundedCornerTextField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCRoundedCornerTextField.h; sourceTree = "<group>"; };
+		7D1BF28922A153E20027C50F /* VLCRoundedCornerTextField.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCRoundedCornerTextField.m; sourceTree = "<group>"; };
 		7D2008182289835C002679DF /* VLCTrackingView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCTrackingView.h; sourceTree = "<group>"; };
 		7D2008192289835C002679DF /* VLCTrackingView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCTrackingView.m; sourceTree = "<group>"; };
 		7D28E6342275B4820098D30E /* NSColor+VLCAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSColor+VLCAdditions.h"; sourceTree = "<group>"; };
@@ -851,6 +854,8 @@
 				7D2008192289835C002679DF /* VLCTrackingView.m */,
 				7D460B0A229EB4C700097948 /* VLCDragDropView.h */,
 				7D460B0B229EB4C700097948 /* VLCDragDropView.m */,
+				7D1BF28822A153E20027C50F /* VLCRoundedCornerTextField.h */,
+				7D1BF28922A153E20027C50F /* VLCRoundedCornerTextField.m */,
 			);
 			path = views;
 			sourceTree = "<group>";
@@ -1752,6 +1757,7 @@
 				1C3113DD1E508C6900D4DD76 /* VLCTrackSynchronizationWindowController.m in Sources */,
 				7D0F5A9B2264EB410009C48A /* VLCHotkeysController.m in Sources */,
 				6B6FFF701EF9EC350001CEB1 /* CompatibilityFixes.m in Sources */,
+				7D1BF28A22A153E20027C50F /* VLCRoundedCornerTextField.m in Sources */,
 				7DFBDCB4226CD00900B700A5 /* VLCLibraryDataTypes.m in Sources */,
 				1C3113DF1E508C6900D4DD76 /* VLCVideoEffectsWindowController.m in Sources */,
 				1C3113E11E508C6900D4DD76 /* VLCVoutView.m in Sources */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 49e8e04a19..9be4e91373 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -185,6 +185,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/views/VLCImageView.m \
 	gui/macosx/views/VLCLinearProgressIndicator.h \
 	gui/macosx/views/VLCLinearProgressIndicator.m \
+	gui/macosx/views/VLCRoundedCornerTextField.h \
+	gui/macosx/views/VLCRoundedCornerTextField.m \
 	gui/macosx/views/VLCScrollingClipView.h \
 	gui/macosx/views/VLCScrollingClipView.m \
 	gui/macosx/views/VLCSlider.h \
diff --git a/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib b/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib
index 7914071e39..42d21fd6fa 100644
--- a/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib
+++ b/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib
@@ -43,9 +43,9 @@
                                 <action selector="playInstantly:" target="-2" id="E2B-oj-rx3"/>
                             </connections>
                         </button>
-                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tm2-NW-WsZ">
-                            <rect key="frame" x="12" y="144" width="37" height="17"/>
-                            <textFieldCell key="cell" lineBreakMode="clipping" title="Label" drawsBackground="YES" id="tyb-Ur-7J9">
+                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tm2-NW-WsZ" customClass="VLCRoundedCornerTextField">
+                            <rect key="frame" x="8" y="144" width="37" height="17"/>
+                            <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="tyb-Ur-7J9">
                                 <font key="font" metaFont="system"/>
                                 <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -77,7 +77,7 @@
                     </textFieldCell>
                 </textField>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ubz-8I-W2F">
-                    <rect key="frame" x="216" y="187" width="20" height="20"/>
+                    <rect key="frame" x="222" y="187" width="20" height="20"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="20" id="XhX-7U-Nxj"/>
                         <constraint firstAttribute="height" constant="20" id="ZDT-YM-Cbr"/>
@@ -108,9 +108,9 @@
                 <constraint firstItem="u2r-zy-XEW" firstAttribute="centerY" secondItem="VAn-gF-QiZ" secondAttribute="centerY" id="H5N-j9-THf"/>
                 <constraint firstAttribute="bottom" secondItem="VAn-gF-QiZ" secondAttribute="bottom" id="Kp0-Hx-3Ek"/>
                 <constraint firstItem="VAn-gF-QiZ" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="QUW-dn-Fbc"/>
-                <constraint firstAttribute="trailing" secondItem="Ubz-8I-W2F" secondAttribute="trailing" constant="20" id="ZVz-SL-rxZ"/>
+                <constraint firstAttribute="trailing" secondItem="Ubz-8I-W2F" secondAttribute="trailing" constant="14" id="ZVz-SL-rxZ"/>
                 <constraint firstItem="tm2-NW-WsZ" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="7" id="cvk-A5-enS"/>
-                <constraint firstItem="tm2-NW-WsZ" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="12" id="fH0-Om-7gV"/>
+                <constraint firstItem="tm2-NW-WsZ" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="10" id="fH0-Om-7gV"/>
                 <constraint firstAttribute="trailing" secondItem="2aB-sB-hfY" secondAttribute="trailing" id="oZw-Ab-83p"/>
                 <constraint firstItem="2aB-sB-hfY" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="t9g-tX-AQX"/>
                 <constraint firstItem="OBS-Eh-1mT" firstAttribute="top" secondItem="2aB-sB-hfY" secondAttribute="bottom" constant="4" id="vJy-Kf-4Jh"/>
diff --git a/modules/gui/macosx/views/VLCRoundedCornerTextField.h b/modules/gui/macosx/views/VLCRoundedCornerTextField.h
new file mode 100644
index 0000000000..ded84ae0d3
--- /dev/null
+++ b/modules/gui/macosx/views/VLCRoundedCornerTextField.h
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * VLCRoundedCornerTextField.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan -dot- 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 VLCRoundedCornerTextField : NSTextField
+
+ at end
+
+NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/views/VLCRoundedCornerTextField.m b/modules/gui/macosx/views/VLCRoundedCornerTextField.m
new file mode 100644
index 0000000000..916ed44a06
--- /dev/null
+++ b/modules/gui/macosx/views/VLCRoundedCornerTextField.m
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * VLCRoundedCornerTextField.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan -dot- 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 "VLCRoundedCornerTextField.h"
+#import "extensions/NSColor+VLCAdditions.h"
+
+ at implementation VLCRoundedCornerTextField
+
+- (instancetype)initWithCoder:(NSCoder *)coder
+{
+    self = [super initWithCoder:coder];
+    if (self) {
+        [self setupCustomAppearance];
+    }
+    return self;
+}
+
+- (instancetype)initWithFrame:(NSRect)frameRect
+{
+    self = [super initWithFrame:frameRect];
+    if (self) {
+        [self setupCustomAppearance];
+    }
+    return self;
+}
+
+- (void)setupCustomAppearance
+{
+    self.wantsLayer = YES;
+    self.layer.cornerRadius = 3.;
+    self.layer.masksToBounds = YES;
+    self.layer.backgroundColor = [NSColor VLClibraryAnnotationBackgroundColor].CGColor;
+}
+
+- (void)setBackgroundColor:(NSColor *)backgroundColor
+{
+    self.layer.backgroundColor = backgroundColor.CGColor;
+}
+
+ at end
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8b4f5d00d1..49171fb386 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -589,6 +589,8 @@ modules/gui/macosx/views/VLCImageView.h
 modules/gui/macosx/views/VLCImageView.m
 modules/gui/macosx/views/VLCLinearProgressIndicator.h
 modules/gui/macosx/views/VLCLinearProgressIndicator.m
+modules/gui/macosx/views/VLCRoundedCornerTextField.h
+modules/gui/macosx/views/VLCRoundedCornerTextField.m
 modules/gui/macosx/views/VLCScrollingClipView.h
 modules/gui/macosx/views/VLCScrollingClipView.m
 modules/gui/macosx/views/VLCSlider.h



More information about the vlc-commits mailing list