Commit 1f44f443 authored by Marvin Scholz's avatar Marvin Scholz Committed by Felix Paul Kühne

macosx: Rewrote the About window auto-scroll behavior

It was impossible to scroll in the About Scroll Views as the code
was doing automatic scrolling. This patch removes all the related
code and introduces a new NSClipView subclass that handles the
automatic scrolling. If it detects that the user scrolls, the
animation is stopped and the user can scroll it as he wishes.
Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent e77a32e8
......@@ -460,6 +460,7 @@
1CE5ED2519DD6AB700FCEFD3 /* lion-window-fullscreen.png in Resources */ = {isa = PBXBuildFile; fileRef = 1CE5ED1F19DD6AB700FCEFD3 /* lion-window-fullscreen.png */; };
1CE5ED2619DD6AB700FCEFD3 /* lion-window-fullscreen@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1CE5ED2019DD6AB700FCEFD3 /* lion-window-fullscreen@2x.png */; };
633121D01B5112C300E636DA /* ResumeDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 633121CE1B5112C300E636DA /* ResumeDialog.xib */; };
6B13E2A81BC67678001AD24A /* VLCScrollingClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */; settings = {ASSET_TAGS = (); }; };
7D3F6525188051F2005776C4 /* BWQuincyMain.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D3F6523188051F2005776C4 /* BWQuincyMain.xib */; };
7D8BB0B71830311300FAE9B7 /* DebugMessageVisualizer.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B51830311300FAE9B7 /* DebugMessageVisualizer.xib */; };
7D8BB0BA1830367200FAE9B7 /* PlaylistMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B81830367200FAE9B7 /* PlaylistMenu.xib */; };
......@@ -1241,6 +1242,8 @@
633121CA1B51122700E636DA /* ResumeDialogController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ResumeDialogController.h; path = ../../../modules/gui/macosx/ResumeDialogController.h; sourceTree = "<group>"; };
633121CB1B51122700E636DA /* ResumeDialogController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ResumeDialogController.m; path = ../../../modules/gui/macosx/ResumeDialogController.m; sourceTree = "<group>"; };
633121CF1B5112C300E636DA /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/ResumeDialog.xib; sourceTree = "<group>"; };
6B13E2A61BC67678001AD24A /* VLCScrollingClipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCScrollingClipView.h; path = ../../../modules/gui/macosx/VLCScrollingClipView.h; sourceTree = "<group>"; };
6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCScrollingClipView.m; path = ../../../modules/gui/macosx/VLCScrollingClipView.m; sourceTree = "<group>"; };
7D3F6524188051F2005776C4 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/BWQuincyMain.xib; sourceTree = "<group>"; };
7D3F652618805297005776C4 /* BWQuincyManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BWQuincyManager.h; path = ../../../modules/gui/macosx/BWQuincyManager.h; sourceTree = SOURCE_ROOT; };
7D3F652718805297005776C4 /* BWQuincyManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BWQuincyManager.m; path = ../../../modules/gui/macosx/BWQuincyManager.m; sourceTree = SOURCE_ROOT; };
......@@ -1821,6 +1824,8 @@
7D871D391B5E684D000B56C0 /* helpers.h */,
8EE1AF9F044465080059A3A7 /* about.h */,
8EE1AFA0044465080059A3A7 /* about.m */,
6B13E2A61BC67678001AD24A /* VLCScrollingClipView.h */,
6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */,
7DF0435E1972E26A0022B534 /* AddonListDataSource.h */,
7DF0435F1972E26A0022B534 /* AddonListDataSource.m */,
7DB65D5218ABD6380053B874 /* AddonsWindowController.h */,
......@@ -3884,6 +3889,7 @@
1CCB5F701A62A724004C3E90 /* fspanel.h in Sources */,
1CCB5F711A62A724004C3E90 /* fspanel.m in Sources */,
1CCB5F721A62A724004C3E90 /* intf.h in Sources */,
6B13E2A81BC67678001AD24A /* VLCScrollingClipView.m in Sources */,
1CD3667B1B7A242E0054E39F /* VLCTimeSelectionPanelController.m in Sources */,
1CCB5F731A62A724004C3E90 /* intf.m in Sources */,
1CCB5F741A62A724004C3E90 /* macosx.m in Sources */,
......
......@@ -73,5 +73,6 @@ libmacosx_plugin_la_SOURCES = \
VideoView.h VideoView.m \
VLCTimeSelectionPanelController.h VLCTimeSelectionPanelController.m \
VLCUIWidgets.h VLCUIWidgets.m \
VLCScrollingClipView.h VLCScrollingClipView.m \
VLCVoutWindowController.h VLCVoutWindowController.m \
Windows.h Windows.m
/*****************************************************************************
* VLCScrollingClipView.h: NSClipView subclass that automatically scrolls
*****************************************************************************
* Copyright (C) 2015 VLC authors and VideoLAN
* $Id$
*
* Author: Marvin Scholz <epirat07@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 VLCScrollingClipView : NSClipView
/* Start scrolling. Does nothing if already scrolling. */
- (void)startScrolling;
/* Stop scrolling. Does not reset the position! */
- (void)stopScrolling;
/* Resets scrolling position to the top */
- (void)resetScrolling;
/* Outlet to the parent NSScrollView */
@property IBOutlet NSScrollView *parentScrollView;
@end
/*****************************************************************************
* VLCScrollingClipView.m: NSClipView subclass that automatically scrolls
*****************************************************************************
* Copyright (C) 2015 VLC authors and VideoLAN
* $Id$
*
* Author: Marvin Scholz <epirat07@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 "VLCScrollingClipView.h"
@implementation VLCScrollingClipView {
NSTimer *scrollTimer;
NSTimeInterval startInterval;
}
- (void)startScrolling {
// Start our timer unless running
if (!scrollTimer) {
scrollTimer = [NSTimer scheduledTimerWithTimeInterval: 1/6
target:self
selector:@selector(scrollTick:)
userInfo:nil
repeats:YES];
}
}
- (void)stopScrolling {
// Stop timer unless stopped
if (scrollTimer) {
[scrollTimer invalidate];
scrollTimer = nil;
}
}
- (void)resetScrolling {
startInterval = 0;
[self scrollToPoint:NSMakePoint(0.0, 0.0)];
if (_parentScrollView) {
[_parentScrollView reflectScrolledClipView:self];
}
}
- (void)scrollWheel:(NSEvent *)theEvent {
// Stop auto-scrolling if the user scrolls
[self stopScrolling];
[super scrollWheel:theEvent];
}
- (void)scrollTick:(NSTimer *)timer {
CGFloat maxHeight = self.documentRect.size.height;
CGFloat scrollPosition = self.documentVisibleRect.origin.y;
// Delay start
if (scrollPosition == 0.0 && !startInterval) {
startInterval = [NSDate timeIntervalSinceReferenceDate] + 2.0;
}
if ([NSDate timeIntervalSinceReferenceDate] >= startInterval) {
// Reset if we are past the end
if (scrollPosition > maxHeight) {
[self resetScrolling];
return;
}
// Scroll the view a bit on each tick
[self scrollToPoint:NSMakePoint(0.0, scrollPosition + 0.5)];
// Update the parent ScrollView
if (_parentScrollView) {
[_parentScrollView reflectScrolledClipView:self];
}
}
}
@end
......@@ -23,6 +23,7 @@
*****************************************************************************/
#import <WebKit/WebKit.h> //we need to be here, because we're using a WebView object below
#import "VLCScrollingClipView.h"
/*****************************************************************************
* VLAboutBox interface
......
......@@ -40,12 +40,6 @@
*****************************************************************************/
@interface AboutWindowController ()
{
NSTimer *o_scroll_timer;
float f_current;
CGFloat f_end;
NSTimeInterval i_start;
BOOL b_restart;
NSString *o_authors;
}
@end
......@@ -77,7 +71,6 @@
[self window];
/* Show the window */
b_restart = YES;
[o_credits_scrollview setHidden:YES];
[o_credits_textview setHidden:YES];
[o_joinus_txt setHidden:NO];
......@@ -182,46 +175,12 @@
- (void)windowDidBecomeKey:(NSNotification *)notification
{
o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval: 1/6
target:self
selector:@selector(scrollCredits:)
userInfo:nil
repeats:YES];
[(VLCScrollingClipView *)[o_credits_scrollview contentView] startScrolling];
}
- (void)windowDidResignKey:(NSNotification *)notification
{
[o_scroll_timer invalidate];
}
- (void)scrollCredits:(NSTimer *)timer
{
if (b_restart) {
/* Reset the starttime */
i_start = [NSDate timeIntervalSinceReferenceDate] + 4.0;
f_current = 0;
f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
b_restart = NO;
}
if ([NSDate timeIntervalSinceReferenceDate] >= i_start) {
/* Increment the scroll position */
f_current += 0.005;
/* Scroll to the position */
[o_credits_textview scrollPoint:NSMakePoint(0, f_current)];
/* If at end, restart at the top */
if (f_current >= f_end) {
/* f_end may be wrong on first run, so don't trust it too much */
if (f_end == [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height) {
sleep(2);
b_restart = YES;
[o_credits_textview scrollPoint:NSMakePoint(0, 0)];
} else
f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
}
}
[(VLCScrollingClipView *)[o_credits_scrollview contentView] stopScrolling];
}
- (IBAction)buttonAction:(id)sender
......@@ -240,8 +199,8 @@
else
[o_credits_textview setString:toNSStr(psz_license)];
[o_credits_textview scrollPoint:NSMakePoint(0, 0)];
b_restart = YES;
[(VLCScrollingClipView *)[o_credits_scrollview contentView] resetScrolling];
[(VLCScrollingClipView *)[o_credits_scrollview contentView] startScrolling];
}
/*****************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment