Commit 971896b9 authored by Felix Paul Kühne's avatar Felix Paul Kühne

hide the FSPanel at the same time as the cursor

Additionally, fixed a minor layout bug in the Error & Messages panel
parent a8b61130
{ <?xml version="1.0" encoding="UTF-8"?>
IBClasses = ( <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, <plist version="1.0">
{ <dict>
ACTIONS = {cleanupTable = id; showMessages = id; }; <key>IBClasses</key>
CLASS = VLCErrorInteractionPanel; <array>
LANGUAGE = ObjC; <dict>
OUTLETS = { <key>CLASS</key>
"o_cleanup_button" = id; <string>NSApplication</string>
"o_error_table" = id; <key>LANGUAGE</key>
"o_messages_btn" = id; <string>ObjC</string>
"o_window" = id; <key>SUPERCLASS</key>
}; <string>NSResponder</string>
SUPERCLASS = NSObject; </dict>
} <dict>
); <key>ACTIONS</key>
IBVersion = 1; <dict>
} <key>cleanupTable</key>
\ No newline at end of file <string>id</string>
<key>showMessages</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>VLCErrorInteractionPanel</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>o_cleanup_button</key>
<string>id</string>
<key>o_error_table</key>
<string>id</string>
<key>o_messages_btn</key>
<string>id</string>
<key>o_window</key>
<string>id</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSObject</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
</dict>
</plist>
...@@ -2,15 +2,19 @@ ...@@ -2,15 +2,19 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>IBDocumentLocation</key>
<string>46 162 356 240 0 0 1440 878 </string>
<key>IBFramework Version</key> <key>IBFramework Version</key>
<string>456.0</string> <string>644</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../../vlc.xcodeproj</string>
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>5</integer> <integer>6</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>9A377a</string> <string>9C31</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict> </dict>
</plist> </plist>
/***************************************************************************** /*****************************************************************************
* fspanel.m: MacOS X full screen panel * fspanel.m: MacOS X full screen panel
***************************************************************************** *****************************************************************************
* Copyright (C) 2006-2007 the VideoLAN team * Copyright (C) 2006-2008 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Jérôme Decoodt <djc at videolan dot org> * Authors: Jérôme Decoodt <djc at videolan dot org>
* Felix Kühne <fkuehne at videolan dot org> * Felix Paul Kühne <fkuehne at videolan dot org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
/***************************************************************************** /*****************************************************************************
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#import "intf.h" #import "intf.h"
#import "controls.h" #import "controls.h"
#import "vout.h" #import "vout.h"
#import "misc.h" #import "misc.h"
#import "fspanel.h" #import "fspanel.h"
#define KEEP_VISIBLE_AFTER_ACTION 4 /* time in half-sec until this panel will hide again after a user's action */ /*****************************************************************************
* VLCFSPanel
/***************************************************************************** *****************************************************************************/
* VLCFSPanel @implementation VLCFSPanel
*****************************************************************************/ /* We override this initializer so we can set the NSBorderlessWindowMask styleMask, and set a few other important settings */
@implementation VLCFSPanel - (id)initWithContentRect:(NSRect)contentRect
/* We override this initializer so we can set the NSBorderlessWindowMask styleMask, and set a few other important settings */ styleMask:(unsigned int)aStyle
- (id)initWithContentRect:(NSRect)contentRect backing:(NSBackingStoreType)bufferingType
styleMask:(unsigned int)aStyle defer:(BOOL)flag
backing:(NSBackingStoreType)bufferingType {
defer:(BOOL)flag id win = [super initWithContentRect:contentRect styleMask:NSTexturedBackgroundWindowMask backing:bufferingType defer:flag];
{ [win setOpaque:NO];
id win = [super initWithContentRect:contentRect styleMask:NSTexturedBackgroundWindowMask backing:bufferingType defer:flag]; [win setHasShadow: NO];
[win setOpaque:NO]; [win setBackgroundColor:[NSColor clearColor]];
[win setHasShadow: NO];
[win setBackgroundColor:[NSColor clearColor]]; /* let the window sit on top of everything else and start out completely transparent */
[win setLevel:NSModalPanelWindowLevel];
/* let the window sit on top of everything else and start out completely transparent */ i_device = 0;
[win setLevel:NSModalPanelWindowLevel]; [win center];
i_device = 0; [self setNonActive:nil];
[win center];
[self setNonActive:nil]; return win;
}
return win;
} - (void)awakeFromNib
{
- (void)awakeFromNib [self setContentView:[[VLCFSPanelView alloc] initWithFrame: [self frame]]];
{ BOOL isInside = (NSPointInRect([NSEvent mouseLocation],[self frame]));
[self setContentView:[[VLCFSPanelView alloc] initWithFrame: [self frame]]]; [[self contentView] addTrackingRect:[[self contentView] bounds] owner:self userData:nil assumeInside:isInside];
BOOL isInside = (NSPointInRect([NSEvent mouseLocation],[self frame])); if (isInside)
[[self contentView] addTrackingRect:[[self contentView] bounds] owner:self userData:nil assumeInside:isInside]; [self mouseEntered:NULL];
if (isInside) if (!isInside)
[self mouseEntered:NULL]; [self mouseExited:NULL];
if (!isInside)
[self mouseExited:NULL]; /* get a notification if VLC isn't the active app anymore */
[[NSNotificationCenter defaultCenter]
/* get a notification if VLC isn't the active app anymore */ addObserver: self
[[NSNotificationCenter defaultCenter] selector: @selector(setNonActive:)
addObserver: self name: NSApplicationDidResignActiveNotification
selector: @selector(setNonActive:) object: NSApp];
name: NSApplicationDidResignActiveNotification
object: NSApp]; /* get a notification if VLC is the active app again */
[[NSNotificationCenter defaultCenter]
/* get a notification if VLC is the active app again */ addObserver: self
[[NSNotificationCenter defaultCenter] selector: @selector(setActive:)
addObserver: self name: NSApplicationDidBecomeActiveNotification
selector: @selector(setActive:) object: NSApp];
name: NSApplicationDidBecomeActiveNotification }
object: NSApp];
} /* Windows created with NSBorderlessWindowMask normally can't be key, but we want ours to be */
- (BOOL)canBecomeKeyWindow
/* Windows created with NSBorderlessWindowMask normally can't be key, but we want ours to be */ {
- (BOOL)canBecomeKeyWindow return YES;
{ }
return YES;
} - (BOOL)mouseDownCanMoveWindow
{
- (BOOL)mouseDownCanMoveWindow return YES;
{ }
return YES;
} -(void)dealloc
{
-(void)dealloc [[NSNotificationCenter defaultCenter] removeObserver: self];
{
[[NSNotificationCenter defaultCenter] removeObserver: self]; if( hideAgainTimer )
[hideAgainTimer release];
if( hideAgainTimer ) [self setFadeTimer:nil];
[hideAgainTimer release]; [super dealloc];
[self setFadeTimer:nil]; }
[super dealloc];
} -(void)center
{
-(void)center /* centre the panel in the lower third of the screen */
{ NSPoint theCoordinate;
/* centre the panel in the lower third of the screen */ NSRect theScreensFrame;
NSPoint theCoordinate; NSRect theWindowsFrame;
NSRect theScreensFrame; NSScreen *screen;
NSRect theWindowsFrame;
NSScreen *screen; /* user-defined screen */
screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
/* user-defined screen */
screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device]; if (!screen)
{
if (!screen) /* invalid preferences or none specified, using main screen */
{ screen = [NSScreen mainScreen];
/* invalid preferences or none specified, using main screen */ }
screen = [NSScreen mainScreen];
} theScreensFrame = [screen frame];
theScreensFrame = [screen frame]; theWindowsFrame = [self frame];
theWindowsFrame = [self frame]; theCoordinate.x = (theScreensFrame.size.width - theWindowsFrame.size.width) / 2 + theScreensFrame.origin.x;
theCoordinate.y = (theScreensFrame.size.height / 3) - theWindowsFrame.size.height + theScreensFrame.origin.y;
theCoordinate.x = (theScreensFrame.size.width - theWindowsFrame.size.width) / 2 + theScreensFrame.origin.x; [self setFrameTopLeftPoint: theCoordinate];
theCoordinate.y = (theScreensFrame.size.height / 3) - theWindowsFrame.size.height + theScreensFrame.origin.y; }
[self setFrameTopLeftPoint: theCoordinate];
} - (void)setPlay
{
- (void)setPlay [[self contentView] setPlay];
{ }
[[self contentView] setPlay];
} - (void)setPause
{
- (void)setPause [[self contentView] setPause];
{ }
[[self contentView] setPause];
} - (void)setStreamTitle:(NSString *)o_title
{
- (void)setStreamTitle:(NSString *)o_title [[self contentView] setStreamTitle: o_title];
{ }
[[self contentView] setStreamTitle: o_title];
} - (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time
{
- (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time [[self contentView] setStreamPos:f_pos andTime: o_time];
{ }
[[self contentView] setStreamPos:f_pos andTime: o_time];
} - (void)setSeekable:(BOOL) b_seekable
{
- (void)setSeekable:(BOOL) b_seekable [[self contentView] setSeekable: b_seekable];
{ }
[[self contentView] setSeekable: b_seekable];
} - (void)setVolumeLevel: (float)f_volumeLevel
{
- (void)setVolumeLevel: (float)f_volumeLevel [[self contentView] setVolumeLevel: f_volumeLevel];
{ }
[[self contentView] setVolumeLevel: f_volumeLevel];
} - (void)setNonActive:(id)noData
{
- (void)setNonActive:(id)noData b_nonActive = YES;
{ [self orderOut: self];
b_nonActive = YES;
[self orderOut: self]; /* here's fadeOut, just without visibly fading */
b_displayed = NO;
/* here's fadeOut, just without visibly fading */ [self setAlphaValue:0.0];
b_displayed = NO; [self setFadeTimer:nil];
[self setAlphaValue:0.0]; b_fadeQueued = NO;
[self setFadeTimer:nil]; }
b_fadeQueued = NO;
} - (void)setActive:(id)noData
{
- (void)setActive:(id)noData if( [[[[VLCMain sharedInstance] getControls] getVoutView] isFullscreen] )
{ {
if( [[[[VLCMain sharedInstance] getControls] getVoutView] isFullscreen] ) b_nonActive = NO;
{ [self fadeIn];
b_nonActive = NO; }
[self fadeIn]; }
}
} /* This routine is called repeatedly to fade in the window */
- (void)focus:(NSTimer *)timer
/* This routine is called repeatedly to fade in the window */ {
- (void)focus:(NSTimer *)timer /* we need to push ourselves to front if the vout window was closed since our last display */
{ if( b_voutWasUpdated )
/* we need to push ourselves to front if the vout window was closed since our last display */ {
if( b_voutWasUpdated ) [self orderFront: self];
{ b_voutWasUpdated = NO;
[self orderFront: self]; }
b_voutWasUpdated = NO;
} if( [self alphaValue] < 1.0 )
[self setAlphaValue:[self alphaValue]+0.1];
if( [self alphaValue] < 1.0 ) if( [self alphaValue] >= 1.0 )
[self setAlphaValue:[self alphaValue]+0.1]; {
if( [self alphaValue] >= 1.0 ) b_displayed = YES;
{ [self setAlphaValue: 1.0];
b_displayed = YES; [self setFadeTimer:nil];
[self setAlphaValue: 1.0]; if( b_fadeQueued )
[self setFadeTimer:nil]; {
if( b_fadeQueued ) b_fadeQueued=NO;
{ [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(unfocus:) userInfo:NULL repeats:YES]];
b_fadeQueued=NO; }
[self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(unfocus:) userInfo:NULL repeats:YES]]; }
} }
}
} /* This routine is called repeatedly to hide the window */
- (void)unfocus:(NSTimer *)timer
/* This routine is called repeatedly to hide the window */ {
- (void)unfocus:(NSTimer *)timer if( b_keptVisible )
{ {
if( b_keptVisible ) b_keptVisible = NO;
{ b_fadeQueued = NO;
b_keptVisible = NO; [self setFadeTimer: NULL];
b_fadeQueued = NO; [self fadeIn];
[self setFadeTimer: NULL]; return;
[self fadeIn]; }
return; if( [self alphaValue] > 0.0 )
} [self setAlphaValue:[self alphaValue]-0.05];
if( [self alphaValue] > 0.0 ) if( [self alphaValue] <= 0.05 )
[self setAlphaValue:[self alphaValue]-0.05]; {
if( [self alphaValue] <= 0.05 ) b_displayed = NO;
{ [self setAlphaValue:0.0];
b_displayed = NO; [self setFadeTimer:nil];
[self setAlphaValue:0.0]; if( b_fadeQueued )
[self setFadeTimer:nil]; {
if( b_fadeQueued ) b_fadeQueued=NO;
{ [self setFadeTimer:
b_fadeQueued=NO; [NSTimer scheduledTimerWithTimeInterval:0.1
[self setFadeTimer: target:self
[NSTimer scheduledTimerWithTimeInterval:0.1 selector:@selector(focus:)
target:self userInfo:NULL
selector:@selector(focus:) repeats:YES]];
userInfo:NULL }
repeats:YES]]; }
} }
}
} - (void)mouseExited:(NSEvent *)theEvent
{
- (void)mouseExited:(NSEvent *)theEvent /* give up our focus, so the vout may show us again without letting the user clicking it */
{ if( [[[[VLCMain sharedInstance] getControls] getVoutView] isFullscreen] )
/* give up our focus, so the vout may show us again without letting the user clicking it */ [[[[[VLCMain sharedInstance] getControls] getVoutView] window] makeKeyWindow];
if( [[[[VLCMain sharedInstance] getControls] getVoutView] isFullscreen] ) }
[[[[[VLCMain sharedInstance] getControls] getVoutView] window] makeKeyWindow];
} - (void)fadeIn
{
- (void)fadeIn /* in case that the user don't want us to appear, just return here */
{ if(! config_GetInt( VLCIntf, "macosx-fspanel" ) || b_nonActive )
/* in case that the user don't want us to appear, just return here */ return;
if(! config_GetInt( VLCIntf, "macosx-fspanel" ) || b_nonActive )
return; [self orderFront: nil];
[self orderFront: nil]; if( [self alphaValue] < 1.0 || b_displayed != YES )
{
if( [self alphaValue] < 1.0 || b_displayed != YES ) if (![self fadeTimer])
{ [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(focus:) userInfo:[NSNumber numberWithShort:1] repeats:YES]];
if (![self fadeTimer]) else if ([[[self fadeTimer] userInfo] shortValue]==0)
[self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(focus:) userInfo:[NSNumber numberWithShort:1] repeats:YES]]; b_fadeQueued=YES;
else if ([[[self fadeTimer] userInfo] shortValue]==0) }
b_fadeQueued=YES; [self autoHide];
} }
[self autoHide];
} - (void)fadeOut
{
- (void)fadeOut if( NSPointInRect([NSEvent mouseLocation],[self frame]))
{ return;
if( NSPointInRect([NSEvent mouseLocation],[self frame]))
return; if( ( [self alphaValue] > 0.0 ) )
{
if( ( [self alphaValue] > 0.0 ) ) if (![self fadeTimer])
{ [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(unfocus:) userInfo:[NSNumber numberWithShort:0] repeats:YES]];
if (![self fadeTimer]) else if ([[[self fadeTimer] userInfo] shortValue]==1)
[self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(unfocus:) userInfo:[NSNumber numberWithShort:0] repeats:YES]]; b_fadeQueued=YES;
else if ([[[self fadeTimer] userInfo] shortValue]==1) }
b_fadeQueued=YES; }
}
} /* triggers a timer to autoHide us again after some seconds of no activity */
- (void)autoHide
/* triggers a timer to autoHide us again after some seconds of no activity */ {
- (void)autoHide /* this will tell the timer to start over again or to start at all */
{ b_keptVisible = YES;
/* this will tell the timer to start over again or to start at all */
b_keptVisible = YES; /* get us a valid timer */
if(! b_alreadyCounting )
/* get us a valid timer */ {
if(! b_alreadyCounting ) i_timeToKeepVisibleInSec = config_GetInt( VLCIntf, "mouse-hide-timeout" ) / 500;
{ hideAgainTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5
hideAgainTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5 target: self
target: self selector: @selector(keepVisible:)
selector: @selector(keepVisible:) userInfo: nil
userInfo: nil repeats: YES];
repeats: YES]; [hideAgainTimer fire];
[hideAgainTimer fire]; [hideAgainTimer retain];
[hideAgainTimer retain]; b_alreadyCounting = YES;
b_alreadyCounting = YES; }
} }
}
- (void)keepVisible:(NSTimer *)timer
- (void)keepVisible:(NSTimer *)timer {
{ /* if the user triggered an action, start over again */
/* if the user triggered an action, start over again */ if( b_keptVisible )
if( b_keptVisible ) b_keptVisible = NO;
{
i_timeToKeepVisibleInSec = KEEP_VISIBLE_AFTER_ACTION; /* count down until we hide ourselfes again and do so if necessary */
b_keptVisible = NO; i_timeToKeepVisibleInSec -= 1;
} if( i_timeToKeepVisibleInSec < 1 )
{
/* count down until we hide ourselfes again and do so if necessary */ [NSCursor setHiddenUntilMouseMoves: YES];
i_timeToKeepVisibleInSec -= 1; [self fadeOut];
if( i_timeToKeepVisibleInSec < 1 ) [timer invalidate];
{ [timer release];
[NSCursor setHiddenUntilMouseMoves: YES]; b_alreadyCounting = NO;
[self fadeOut]; timer = NULL;
[timer invalidate]; }
[timer release]; }
b_alreadyCounting = NO;
timer = NULL; /* A getter and setter for our main timer that handles window fading */
} - (NSTimer *)fadeTimer
} {
return fadeTimer;
/* A getter and setter for our main timer that handles window fading */ }
- (NSTimer *)fadeTimer
{ - (void)setFadeTimer:(NSTimer *)timer
return fadeTimer; {
} [timer retain];
[fadeTimer invalidate];
- (void)setFadeTimer:(NSTimer *)timer [fadeTimer release];
{ fadeTimer=timer;
[timer retain]; }
[fadeTimer invalidate];
[fadeTimer release]; - (void)mouseDown:(NSEvent *)theEvent
fadeTimer=timer; {
} mouseClic = [theEvent locationInWindow];
}
- (void)mouseDown:(NSEvent *)theEvent
{ - (void)mouseDragged:(NSEvent *)theEvent
mouseClic = [theEvent locationInWindow]; {
} NSPoint point = [NSEvent mouseLocation];
point.x -= mouseClic.x;
- (void)mouseDragged:(NSEvent *)theEvent point.y -= mouseClic.y;
{ [self setFrameOrigin:point];
NSPoint point = [NSEvent mouseLocation]; }
point.x -= mouseClic.x;
point.y -= mouseClic.y; - (BOOL)isDisplayed
[self setFrameOrigin:point]; {
} return b_displayed;
}
- (BOOL)isDisplayed
{ - (void)setVoutWasUpdated: (int)i_newdevice;
return b_displayed; {
} b_voutWasUpdated = YES;
if( i_newdevice != i_device )
- (void)setVoutWasUpdated: (int)i_newdevice; {
{ i_device = i_newdevice;
b_voutWasUpdated = YES; [self center];
if( i_newdevice != i_device ) }
{ }
i_device = i_newdevice; @end
[self center];
} /*****************************************************************************
} * FSPanelView
@end *****************************************************************************/
@implementation VLCFSPanelView
/*****************************************************************************
* FSPanelView #define addButton( o_button, imageOff, imageOn, _x, _y, action ) \
*****************************************************************************/ s_rc.origin.x = _x; \
@implementation VLCFSPanelView s_rc.origin.y = _y; \
o_button = [[NSButton alloc] initWithFrame: s_rc]; \
#define addButton( o_button, imageOff, imageOn, _x, _y, action ) \ [o_button setButtonType: NSMomentaryChangeButton]; \
s_rc.origin.x = _x; \ [o_button setBezelStyle: NSRegularSquareBezelStyle]; \
s_rc.origin.y = _y; \ [o_button setBordered: NO]; \
o_button = [[NSButton alloc] initWithFrame: s_rc]; \ [o_button setFont:[NSFont systemFontOfSize:0]]; \
[o_button setButtonType: NSMomentaryChangeButton]; \ [o_button setImage:[NSImage imageNamed:imageOff]]; \
[o_button setBezelStyle: NSRegularSquareBezelStyle]; \ [o_button setAlternateImage:[NSImage imageNamed:imageOn]]; \
[o_button setBordered: NO]; \ [o_button sizeToFit]; \
[o_button setFont:[NSFont systemFontOfSize:0]]; \ [o_button setTarget: self]; \
[o_button setImage:[NSImage imageNamed:imageOff]]; \ [o_button setAction: @selector(action:)]; \
[o_button setAlternateImage:[NSImage imageNamed:imageOn]]; \ [self addSubview:o_button];
[o_button sizeToFit]; \
[o_button setTarget: self]; \ #define addTextfield( o_text, align, font, color, size ) \
[o_button setAction: @selector(action:)]; \ o_text = [[NSTextField alloc] initWithFrame: s_rc]; \
[self addSubview:o_button]; [o_text setDrawsBackground: NO]; \
[o_text setBordered: NO]; \
#define addTextfield( o_text, align, font, color, size ) \ [o_text setEditable: NO]; \
o_text = [[NSTextField alloc] initWithFrame: s_rc]; \ [o_text setSelectable: NO]; \
[o_text setDrawsBackground: NO]; \ [o_text setStringValue: _NS("(no item is being played)")]; \
[o_text setBordered: NO]; \ [o_text setAlignment: align]; \
[o_text setEditable: NO]; \ [o_text setTextColor: [NSColor color]]; \
[o_text setSelectable: NO]; \ [o_text setFont:[NSFont font:[NSFont smallSystemFontSize] - size]]; \
[o_text setStringValue: _NS("(no item is being played)")]; \ [self addSubview:o_text];
[o_text setAlignment: align]; \
[o_text setTextColor: [NSColor color]]; \ - (id)initWithFrame:(NSRect)frameRect
[o_text setFont:[NSFont font:[NSFont smallSystemFontSize] - size]]; \ {
[self addSubview:o_text]; id view = [super initWithFrame:frameRect];
fillColor = [[NSColor clearColor] retain];
- (id)initWithFrame:(NSRect)frameRect NSRect s_rc = [self frame];
{ addButton( o_prev, @"fs_skip_previous" , @"fs_skip_previous_highlight", 174, 15, prev );
id view = [super initWithFrame:frameRect]; addButton( o_bwd, @"fs_rewind" , @"fs_rewind_highlight" , 211, 14, backward );
fillColor = [[NSColor clearColor] retain]; addButton( o_play, @"fs_play" , @"fs_play_highlight" , 267, 10, play );
NSRect s_rc = [self frame]; addButton( o_fwd, @"fs_forward" , @"fs_forward_highlight" , 313, 14, forward );
addButton( o_prev, @"fs_skip_previous" , @"fs_skip_previous_highlight", 174, 15, prev ); addButton( o_next, @"fs_skip_next" , @"fs_skip_next_highlight" , 365, 15, next );
addButton( o_bwd, @"fs_rewind" , @"fs_rewind_highlight" , 211, 14, backward ); addButton( o_fullscreen, @"fs_exit_fullscreen", @"fs_exit_fullscreen_hightlight", 507, 13, windowAction );
addButton( o_play, @"fs_play" , @"fs_play_highlight" , 267, 10, play ); /*
addButton( o_fwd, @"fs_forward" , @"fs_forward_highlight" , 313, 14, forward ); addButton( o_button, @"image (off state)", @"image (on state)", 38, 51, something );
addButton( o_next, @"fs_skip_next" , @"fs_skip_next_highlight" , 365, 15, next ); */
addButton( o_fullscreen, @"fs_exit_fullscreen", @"fs_exit_fullscreen_hightlight", 507, 13, windowAction );
/* /* time slider */
addButton( o_button, @"image (off state)", @"image (on state)", 38, 51, something ); s_rc = [self frame];
*/ s_rc.origin.x = 15;
s_rc.origin.y = 53;
/* time slider */ s_rc.size.width = 518;
s_rc = [self frame]; s_rc.size.height = 9;
s_rc.origin.x = 15; o_fs_timeSlider = [[VLCFSTimeSlider alloc] initWithFrame: s_rc];
s_rc.origin.y = 53; [o_fs_timeSlider setMinValue:0];
s_rc.size.width = 518; [o_fs_timeSlider setMaxValue:10000];
s_rc.size.height = 9; [o_fs_timeSlider setFloatValue: 0];
o_fs_timeSlider = [[VLCFSTimeSlider alloc] initWithFrame: s_rc]; [o_fs_timeSlider setContinuous: YES];
[o_fs_timeSlider setMinValue:0]; [o_fs_timeSlider setTarget: self];
[o_fs_timeSlider setMaxValue:10000]; [o_fs_timeSlider setAction: @selector(fsTimeSliderUpdate:)];
[o_fs_timeSlider setFloatValue: 0]; [self addSubview: o_fs_timeSlider];
[o_fs_timeSlider setContinuous: YES];
[o_fs_timeSlider setTarget: self]; /* volume slider */
[o_fs_timeSlider setAction: @selector(fsTimeSliderUpdate:)]; s_rc = [self frame];
[self addSubview: o_fs_timeSlider]; s_rc.origin.x = 26;
s_rc.origin.y = 17.5;
/* volume slider */ s_rc.size.width = 95;
s_rc = [self frame]; s_rc.size.height = 10;
s_rc.origin.x = 26; o_fs_volumeSlider = [[VLCFSVolumeSlider alloc] initWithFrame: s_rc];
s_rc.origin.y = 17.5; [o_fs_volumeSlider setMinValue:0];
s_rc.size.width = 95; [o_fs_volumeSlider setMaxValue:32];
s_rc.size.height = 10; [o_fs_volumeSlider setFloatValue: 0];
o_fs_volumeSlider = [[VLCFSVolumeSlider alloc] initWithFrame: s_rc]; [o_fs_volumeSlider setContinuous: YES];
[o_fs_volumeSlider setMinValue:0]; [o_fs_volumeSlider setTarget: self];
[o_fs_volumeSlider setMaxValue:32]; [o_fs_volumeSlider setAction: @selector(fsVolumeSliderUpdate:)];
[o_fs_volumeSlider setFloatValue: 0]; [self addSubview: o_fs_volumeSlider];
[o_fs_volumeSlider setContinuous: YES];
[o_fs_volumeSlider setTarget: self]; /* time counter and stream title output fields */
[o_fs_volumeSlider setAction: @selector(fsVolumeSliderUpdate:)]; s_rc = [self frame];
[self addSubview: o_fs_volumeSlider]; s_rc.origin.x = 98;
s_rc.origin.y = 64;
/* time counter and stream title output fields */ s_rc.size.width = 352;
s_rc = [self frame]; s_rc.size.height = 14;
s_rc.origin.x = 98; addTextfield( o_streamTitle_txt, NSCenterTextAlignment, systemFontOfSize, whiteColor, 0 );
s_rc.origin.y = 64; s_rc.origin.x = 486;
s_rc.size.width = 352; s_rc.origin.y = 64;
s_rc.size.height = 14; s_rc.size.width = 50;
addTextfield( o_streamTitle_txt, NSCenterTextAlignment, systemFontOfSize, whiteColor, 0 ); addTextfield( o_streamPosition_txt, NSRightTextAlignment, systemFontOfSize, whiteColor, 0 );
s_rc.origin.x = 486;
s_rc.origin.y = 64; return view;
s_rc.size.width = 50; }
addTextfield( o_streamPosition_txt, NSRightTextAlignment, systemFontOfSize, whiteColor, 0 );
- (void)dealloc
return view; {
} [o_fs_timeSlider release];
[o_fs_volumeSlider release];
- (void)dealloc [o_prev release];
{ [o_next release];
[o_fs_timeSlider release]; [o_bwd release];
[o_fs_volumeSlider release]; [o_play release];
[o_prev release]; [o_fwd release];
[o_next release]; [o_fullscreen release];
[o_bwd release]; [o_streamTitle_txt release];
[o_play release]; [o_streamPosition_txt release];
[o_fwd release]; [super dealloc];
[o_fullscreen release]; }
[o_streamTitle_txt release];
[o_streamPosition_txt release]; - (void)setPlay
[super dealloc]; {
} [o_play setImage:[NSImage imageNamed:@"fs_play"]];
[o_play setAlternateImage: [NSImage imageNamed:@"fs_play_highlight"]];
- (void)setPlay }
{
[o_play setImage:[NSImage imageNamed:@"fs_play"]]; - (void)setPause
[o_play setAlternateImage: [NSImage imageNamed:@"fs_play_highlight"]]; {
} [o_play setImage: [NSImage imageNamed:@"fs_pause"]];
[o_play setAlternateImage: [NSImage imageNamed:@"fs_pause_highlight"]];
- (void)setPause }
{
[o_play setImage: [NSImage imageNamed:@"fs_pause"]]; - (void)setStreamTitle:(NSString *)o_title
[o_play setAlternateImage: [NSImage imageNamed:@"fs_pause_highlight"]]; {
} [o_streamTitle_txt setStringValue: o_title];
}
- (void)setStreamTitle:(NSString *)o_title
{ - (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time
[o_streamTitle_txt setStringValue: o_title]; {
} [o_streamPosition_txt setStringValue: o_time];
[o_fs_timeSlider setFloatValue: f_pos];
- (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time }
{
[o_streamPosition_txt setStringValue: o_time]; - (void)setSeekable:(BOOL)b_seekable
[o_fs_timeSlider setFloatValue: f_pos]; {
} [o_bwd setEnabled: b_seekable];
[o_fwd setEnabled: b_seekable];
- (void)setSeekable:(BOOL)b_seekable [o_fs_timeSlider setEnabled: b_seekable];
{ }
[o_bwd setEnabled: b_seekable];
[o_fwd setEnabled: b_seekable]; - (void)setVolumeLevel: (float)f_volumeLevel
[o_fs_timeSlider setEnabled: b_seekable]; {
} [o_fs_volumeSlider setFloatValue: f_volumeLevel];
}
- (void)setVolumeLevel: (float)f_volumeLevel
{ - (IBAction)play:(id)sender
[o_fs_volumeSlider setFloatValue: f_volumeLevel]; {
} [[[VLCMain sharedInstance] getControls] play: sender];
}
- (IBAction)play:(id)sender
{ - (IBAction)forward:(id)sender
[[[VLCMain sharedInstance] getControls] play: sender]; {
} [[[VLCMain sharedInstance] getControls] forward: sender];
}
- (IBAction)forward:(id)sender
{ - (IBAction)backward:(id)sender
[[[VLCMain sharedInstance] getControls] forward: sender]; {
} [[[VLCMain sharedInstance] getControls] backward: sender];
}
- (IBAction)backward:(id)sender
{ - (IBAction)prev:(id)sender
[[[VLCMain sharedInstance] getControls] backward: sender]; {
} [[[VLCMain sharedInstance] getControls] prev: sender];
}
- (IBAction)prev:(id)sender
{ - (IBAction)next:(id)sender
[[[VLCMain sharedInstance] getControls] prev: sender]; {
} [[[VLCMain sharedInstance] getControls] next: sender];
}
- (IBAction)next:(id)sender
{ - (IBAction)windowAction:(id)sender
[[[VLCMain sharedInstance] getControls] next: sender]; {
} [[[VLCMain sharedInstance] getControls] windowAction: sender];
}
- (IBAction)windowAction:(id)sender
{ - (IBAction)fsTimeSliderUpdate:(id)sender
[[[VLCMain sharedInstance] getControls] windowAction: sender]; {
} [[VLCMain sharedInstance] timesliderUpdate: sender];
}
- (IBAction)fsTimeSliderUpdate:(id)sender
{ - (IBAction)fsVolumeSliderUpdate:(id)sender
[[VLCMain sharedInstance] timesliderUpdate: sender]; {
} [[[VLCMain sharedInstance] getControls] volumeSliderUpdated: sender];
}
- (IBAction)fsVolumeSliderUpdate:(id)sender
{ #define addImage(image, _x, _y, mode, _width) \
[[[VLCMain sharedInstance] getControls] volumeSliderUpdated: sender]; img = [NSImage imageNamed:image]; \
} image_rect.size = [img size]; \
image_rect.origin.x = 0; \
#define addImage(image, _x, _y, mode, _width) \ image_rect.origin.y = 0; \
img = [NSImage imageNamed:image]; \ frame.origin.x = _x; \
image_rect.size = [img size]; \ frame.origin.y = _y; \
image_rect.origin.x = 0; \ frame.size = [img size]; \
image_rect.origin.y = 0; \ if( _width ) frame.size.width = _width; \
frame.origin.x = _x; \ [img drawInRect:frame fromRect:image_rect operation:mode fraction:1];
frame.origin.y = _y; \
frame.size = [img size]; \ - (void)drawRect:(NSRect)rect
if( _width ) frame.size.width = _width; \ {
[img drawInRect:frame fromRect:image_rect operation:mode fraction:1]; NSRect frame = [self frame];
NSRect image_rect;
- (void)drawRect:(NSRect)rect NSImage *img;
{ addImage( @"fs_background", 0, 0, NSCompositeCopy, 0 );
NSRect frame = [self frame]; addImage( @"fs_volume_slider_bar", 26, 22, NSCompositeSourceOver, 0 );
NSRect image_rect; addImage( @"fs_volume_mute", 16, 18, NSCompositeSourceOver, 0 );
NSImage *img; addImage( @"fs_volume_max", 124, 17, NSCompositeSourceOver, 0 );
addImage( @"fs_background", 0, 0, NSCompositeCopy, 0 ); addImage( @"fs_time_slider", 15, 53, NSCompositeSourceOver, 0);
addImage( @"fs_volume_slider_bar", 26, 22, NSCompositeSourceOver, 0 ); }
addImage( @"fs_volume_mute", 16, 18, NSCompositeSourceOver, 0 );
addImage( @"fs_volume_max", 124, 17, NSCompositeSourceOver, 0 ); @end
addImage( @"fs_time_slider", 15, 53, NSCompositeSourceOver, 0);
} /*****************************************************************************
* VLCFSTimeSlider
@end *****************************************************************************/
@implementation VLCFSTimeSlider
/***************************************************************************** - (void)drawKnobInRect:(NSRect)knobRect
* VLCFSTimeSlider {
*****************************************************************************/ NSRect image_rect;
@implementation VLCFSTimeSlider NSImage *img = [NSImage imageNamed:@"fs_time_slider_knob_highlight"];
- (void)drawKnobInRect:(NSRect)knobRect image_rect.size = [img size];
{ image_rect.origin.x = 0;
NSRect image_rect; image_rect.origin.y = 0;
NSImage *img = [NSImage imageNamed:@"fs_time_slider_knob_highlight"]; knobRect.origin.x += (knobRect.size.width - image_rect.size.width) / 2;
image_rect.size = [img size]; knobRect.size.width = image_rect.size.width;
image_rect.origin.x = 0; knobRect.size.height = image_rect.size.height;
image_rect.origin.y = 0; [img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1];
knobRect.origin.x += (knobRect.size.width - image_rect.size.width) / 2; }
knobRect.size.width = image_rect.size.width;
knobRect.size.height = image_rect.size.height; - (void)drawRect:(NSRect)rect
[img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1]; {
} /* Draw default to make sure the slider behaves correctly */
[[NSGraphicsContext currentContext] saveGraphicsState];
- (void)drawRect:(NSRect)rect NSRectClip(NSZeroRect);
{ [super drawRect:rect];
/* Draw default to make sure the slider behaves correctly */ [[NSGraphicsContext currentContext] restoreGraphicsState];
[[NSGraphicsContext currentContext] saveGraphicsState];
NSRectClip(NSZeroRect); NSRect knobRect = [[self cell] knobRectFlipped:NO];
[super drawRect:rect]; knobRect.origin.y+=7.5;
[[NSGraphicsContext currentContext] restoreGraphicsState]; [[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
[self drawKnobInRect: knobRect];
NSRect knobRect = [[self cell] knobRectFlipped:NO]; }
knobRect.origin.y+=7.5;
[[[NSColor blackColor] colorWithAlphaComponent:0.6] set]; @end
[self drawKnobInRect: knobRect];
} /*****************************************************************************
* VLCFSVolumeSlider
@end *****************************************************************************/
@implementation VLCFSVolumeSlider
/***************************************************************************** - (void)drawKnobInRect:(NSRect) knobRect
* VLCFSVolumeSlider {
*****************************************************************************/ NSRect image_rect;
@implementation VLCFSVolumeSlider NSImage *img = [NSImage imageNamed:@"fs_volume_slider_knob"];
- (void)drawKnobInRect:(NSRect) knobRect image_rect.size = [img size];
{ image_rect.origin.x = 0;
NSRect image_rect; image_rect.origin.y = 0;
NSImage *img = [NSImage imageNamed:@"fs_volume_slider_knob"]; knobRect.origin.x += (knobRect.size.width - image_rect.size.width) / 2;
image_rect.size = [img size]; knobRect.size.width = image_rect.size.width;
image_rect.origin.x = 0; knobRect.size.height = image_rect.size.height;
image_rect.origin.y = 0; [img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1];
knobRect.origin.x += (knobRect.size.width - image_rect.size.width) / 2; }
knobRect.size.width = image_rect.size.width;
knobRect.size.height = image_rect.size.height; - (void)drawRect:(NSRect)rect
[img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1]; {
} /* Draw default to make sure the slider behaves correctly */
[[NSGraphicsContext currentContext] saveGraphicsState];
- (void)drawRect:(NSRect)rect NSRectClip(NSZeroRect);
{ [super drawRect:rect];
/* Draw default to make sure the slider behaves correctly */ [[NSGraphicsContext currentContext] restoreGraphicsState];
[[NSGraphicsContext currentContext] saveGraphicsState];
NSRectClip(NSZeroRect); NSRect knobRect = [[self cell] knobRectFlipped:NO];
[super drawRect:rect]; knobRect.origin.y+=6;
[[NSGraphicsContext currentContext] restoreGraphicsState]; [[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
[self drawKnobInRect: knobRect];
NSRect knobRect = [[self cell] knobRectFlipped:NO]; }
knobRect.origin.y+=6;
[[[NSColor blackColor] colorWithAlphaComponent:0.6] set]; @end
[self drawKnobInRect: knobRect];
}
@end
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