From eb7de2a917df2680a0023151a9c1e0a49599d00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <felix@feepk.net> Date: Thu, 2 May 2019 22:53:53 +0200 Subject: [PATCH] macosx: add custom linear progress indicator view --- .../macosx/VLC.xcodeproj/project.pbxproj | 6 ++ modules/gui/macosx/Makefile.am | 2 + .../macosx/views/VLCLinearProgressIndicator.h | 33 ++++++++++ .../macosx/views/VLCLinearProgressIndicator.m | 61 +++++++++++++++++++ po/POTFILES.in | 2 + 5 files changed, 104 insertions(+) create mode 100644 modules/gui/macosx/views/VLCLinearProgressIndicator.h create mode 100644 modules/gui/macosx/views/VLCLinearProgressIndicator.m diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj index 0dec0a06b392..6e7538ffa8e2 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 3216a04a884c..92af812533c6 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 000000000000..19531d082237 --- /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 + +@interface VLCLinearProgressIndicator : NSView + +@property (nonatomic) CGFloat progress; + +@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 000000000000..faaa022df7e3 --- /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" + +@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; +} + +@end diff --git a/po/POTFILES.in b/po/POTFILES.in index 3e9fdaf746d2..aa78d72322ee 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 -- GitLab