[vlc-commits] macosx: add custom linear progress indicator view
Felix Paul Kühne
git at videolan.org
Thu May 2 22:56:23 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Thu May 2 22:53:53 2019 +0200| [eb7de2a917df2680a0023151a9c1e0a49599d00e] | committer: Felix Paul Kühne
macosx: add custom linear progress indicator view
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eb7de2a917df2680a0023151a9c1e0a49599d00e
---
.../package/macosx/VLC.xcodeproj/project.pbxproj | 6 +++
modules/gui/macosx/Makefile.am | 2 +
.../gui/macosx/views/VLCLinearProgressIndicator.h | 33 ++++++++++++
.../gui/macosx/views/VLCLinearProgressIndicator.m | 61 ++++++++++++++++++++++
po/POTFILES.in | 2 +
5 files changed, 104 insertions(+)
diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index 0dec0a06b3..6e7538ffa8 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -107,6 +107,7 @@
7D28E6392275B7340098D30E /* NSFont+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D28E6382275B7340098D30E /* NSFont+VLCAdditions.m */; };
7D2E0EDB20CD204D0033A221 /* VLCWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2E0ED920CD204D0033A221 /* VLCWindow.m */; };
7D2E0EDE20CD206F0033A221 /* VLCVideoWindowCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2E0EDD20CD206F0033A221 /* VLCVideoWindowCommon.m */; };
+ 7D2FFA40227B8A5B0085D649 /* VLCLinearProgressIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2FFA3F227B8A5B0085D649 /* VLCLinearProgressIndicator.m */; };
7D445D812202524000263D34 /* VLCPlaylistController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D445D802202524000263D34 /* VLCPlaylistController.m */; };
7D445D842202524D00263D34 /* VLCPlaylistItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D445D832202524D00263D34 /* VLCPlaylistItem.m */; };
7D445D872202574B00263D34 /* VLCPlaylistModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D445D862202574B00263D34 /* VLCPlaylistModel.m */; };
@@ -459,6 +460,8 @@
7D2E0EDA20CD204D0033A221 /* VLCWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCWindow.h; sourceTree = "<group>"; };
7D2E0EDC20CD206F0033A221 /* VLCVideoWindowCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCVideoWindowCommon.h; sourceTree = "<group>"; };
7D2E0EDD20CD206F0033A221 /* VLCVideoWindowCommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCVideoWindowCommon.m; sourceTree = "<group>"; };
+ 7D2FFA3E227B8A5B0085D649 /* VLCLinearProgressIndicator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLinearProgressIndicator.h; sourceTree = "<group>"; };
+ 7D2FFA3F227B8A5B0085D649 /* VLCLinearProgressIndicator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLinearProgressIndicator.m; sourceTree = "<group>"; };
7D445D7F2202524000263D34 /* VLCPlaylistController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaylistController.h; sourceTree = "<group>"; };
7D445D802202524000263D34 /* VLCPlaylistController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistController.m; sourceTree = "<group>"; };
7D445D822202524D00263D34 /* VLCPlaylistItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaylistItem.h; sourceTree = "<group>"; };
@@ -818,6 +821,8 @@
1C1C62001F8260A90052DD4F /* VLCWrappableTextField.m */,
7DFBDCB5226CDFD600B700A5 /* VLCImageView.h */,
7DFBDCB6226CDFD600B700A5 /* VLCImageView.m */,
+ 7D2FFA3E227B8A5B0085D649 /* VLCLinearProgressIndicator.h */,
+ 7D2FFA3F227B8A5B0085D649 /* VLCLinearProgressIndicator.m */,
);
path = views;
sourceTree = "<group>";
@@ -1685,6 +1690,7 @@
7D0F63FF2201F63400FDB91F /* VLCPlaylistTableCellView.m in Sources */,
1C3113D11E508C6900D4DD76 /* prefs.m in Sources */,
1C3113D31E508C6900D4DD76 /* VLCResumeDialogController.m in Sources */,
+ 7D2FFA40227B8A5B0085D649 /* VLCLinearProgressIndicator.m in Sources */,
7DFBDCB1226A518400B700A5 /* VLCLibraryMenuController.m in Sources */,
1C3113D51E508C6900D4DD76 /* VLCTextfieldPanelController.m in Sources */,
7DFBDCAE2269ED0C00B700A5 /* VLCLibraryDataSource.m in Sources */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 3216a04a88..92af812533 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -171,6 +171,8 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/views/VLCImageButton.m \
gui/macosx/views/VLCImageView.h \
gui/macosx/views/VLCImageView.m \
+ gui/macosx/views/VLCLinearProgressIndicator.h \
+ gui/macosx/views/VLCLinearProgressIndicator.m \
gui/macosx/views/VLCScrollingClipView.h \
gui/macosx/views/VLCScrollingClipView.m \
gui/macosx/views/VLCSlider.h \
diff --git a/modules/gui/macosx/views/VLCLinearProgressIndicator.h b/modules/gui/macosx/views/VLCLinearProgressIndicator.h
new file mode 100644
index 0000000000..19531d0822
--- /dev/null
+++ b/modules/gui/macosx/views/VLCLinearProgressIndicator.h
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * VLCLinearProgressIndicator.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2013, 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 VLCLinearProgressIndicator : NSView
+
+ at property (nonatomic) CGFloat progress;
+
+ at end
+
+NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/views/VLCLinearProgressIndicator.m b/modules/gui/macosx/views/VLCLinearProgressIndicator.m
new file mode 100644
index 0000000000..faaa022df7
--- /dev/null
+++ b/modules/gui/macosx/views/VLCLinearProgressIndicator.m
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * VLCLinearProgressIndicator.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2013, 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 "VLCLinearProgressIndicator.h"
+#import "extensions/NSColor+VLCAdditions.h"
+
+ at implementation VLCLinearProgressIndicator
+
+- (void)drawRect:(NSRect)dirtyRect
+{
+ [super drawRect:dirtyRect];
+
+ CGRect rect = NSRectToCGRect(dirtyRect);
+
+ CGContextClearRect([NSGraphicsContext currentContext].CGContext, rect);
+
+ NSColor *drawingColor = [NSColor VLClibraryHighlightColor];
+
+ NSBezierPath* bezierPath = [NSBezierPath bezierPath];
+
+ float progress_width = self.progress * rect.size.width;
+
+ // Create our triangle
+ [bezierPath moveToPoint:CGPointMake(progress_width - rect.size.height + 3., 2.)];
+ [bezierPath lineToPoint:CGPointMake(progress_width - (rect.size.height/2), rect.size.height - 5.)];
+ [bezierPath lineToPoint:CGPointMake(progress_width - 3., 2.)];
+ [bezierPath closePath];
+
+ // Set the display for the path, and stroke it
+ bezierPath.lineWidth = 6.;
+ [drawingColor setStroke];
+ [bezierPath stroke];
+ [drawingColor setFill];
+ [bezierPath fill];
+}
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+ at end
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3e9fdaf746..aa78d72322 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -587,6 +587,8 @@ modules/gui/macosx/views/VLCImageButton.h
modules/gui/macosx/views/VLCImageButton.m
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/VLCScrollingClipView.h
modules/gui/macosx/views/VLCScrollingClipView.m
modules/gui/macosx/views/VLCSlider.h
More information about the vlc-commits
mailing list