/*****************************************************************************
* misc.m: code not specific to vlc
*****************************************************************************
- * Copyright (C) 2003-2005 VideoLAN
+ * Copyright (C) 2003-2007 the VideoLAN team
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <Cocoa/Cocoa.h>
#include "intf.h" /* VLCApplication */
#include "misc.h"
#include "playlist.h"
+#include "controls.h"
/*****************************************************************************
* VLCControllerWindow
self = [super initWithContentRect:contentRect styleMask:styleMask //& ~NSTitledWindowMask
backing:backingType defer:flag];
- o_size_with_playlist = [self frame].size;
-
[[VLCMain sharedInstance] updateTogglePlaylistState];
return( self );
- (BOOL)performKeyEquivalent:(NSEvent *)o_event
{
- return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];
-}
-
-/*Stores the size the controller one resize, to be able to restore it when
- toggling the playlist*/
-
-- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize
-{
- o_size_with_playlist = proposedFrameSize;
-
- /*Callback to update the state of Playlist Toggle Button*/
- [[VLCMain sharedInstance] updateTogglePlaylistState];
-
- return proposedFrameSize;
-}
-
-- (NSSize)getSizeWithPlaylist
-{
- return o_size_with_playlist;
+ return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event] ||
+ [(VLCControls *)[[VLCMain sharedInstance] getControls] keyEvent:o_event];
}
@end
[super dealloc];
}
+#if GC_ENABLED
+- (void)finalize
+{
+ /* dealloc doesn't get called on 10.5 if GC is enabled, so we need to provide the basic functionality here */
+ [self unregisterDraggedTypes];
+ [super finalize];
+}
+#endif
+
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSTIFFPboardType,
[super dealloc];
}
+#if GC_ENABLED
+- (void)finalize
+{
+ /* dealloc doesn't get called on 10.5 if GC is enabled, so we need to provide the basic functionality here */
+ [self unregisterDraggedTypes];
+ [super finalize];
+}
+#endif
+
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSTIFFPboardType,
NSArray *o_types = [NSArray arrayWithObjects: NSFilenamesPboardType, nil];
NSString *o_desired_type = [o_paste availableTypeFromArray:o_types];
NSData *o_carried_data = [o_paste dataForType:o_desired_type];
+ BOOL b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
if( o_carried_data )
{
o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
o_array = [o_array arrayByAddingObject: o_dic];
}
- [[[VLCMain sharedInstance] getPlaylist] appendArray: o_array atPos: -1 enqueue:NO];
+ if( b_autoplay )
+ [[[VLCMain sharedInstance] getPlaylist] appendArray: o_array atPos: -1 enqueue:NO];
+ else
+ [[[VLCMain sharedInstance] getPlaylist] appendArray: o_array atPos: -1 enqueue:YES];
return YES;
}
}
@end
+
+/*****************************************************************************
+ * ITSlider
+ *****************************************************************************/
+
+@implementation ITSlider
+
+- (void)awakeFromNib
+{
+ if ([[self cell] class] != [ITSliderCell class]) {
+ // replace cell
+ NSSliderCell *oldCell = [self cell];
+ NSSliderCell *newCell = [[[ITSliderCell alloc] init] autorelease];
+ [newCell setTag:[oldCell tag]];
+ [newCell setTarget:[oldCell target]];
+ [newCell setAction:[oldCell action]];
+ [newCell setControlSize:[oldCell controlSize]];
+ [newCell setType:[oldCell type]];
+ [newCell setState:[oldCell state]];
+ [newCell setAllowsTickMarkValuesOnly:[oldCell allowsTickMarkValuesOnly]];
+ [newCell setAltIncrementValue:[oldCell altIncrementValue]];
+ [newCell setControlTint:[oldCell controlTint]];
+ [newCell setKnobThickness:[oldCell knobThickness]];
+ [newCell setMaxValue:[oldCell maxValue]];
+ [newCell setMinValue:[oldCell minValue]];
+ [newCell setDoubleValue:[oldCell doubleValue]];
+ [newCell setNumberOfTickMarks:[oldCell numberOfTickMarks]];
+ [newCell setEditable:[oldCell isEditable]];
+ [newCell setEnabled:[oldCell isEnabled]];
+ [newCell setEntryType:[oldCell entryType]];
+ [newCell setHighlighted:[oldCell isHighlighted]];
+ [newCell setTickMarkPosition:[oldCell tickMarkPosition]];
+ [self setCell:newCell];
+ }
+}
+
+@end
+
+/*****************************************************************************
+ * ITSliderCell
+ *****************************************************************************/
+@implementation ITSliderCell
+
+- (id)init
+{
+ self = [super init];
+ _knobOff = [[NSImage imageNamed:@"volumeslider_normal"] retain];
+ _knobOn = [[NSImage imageNamed:@"volumeslider_blue"] retain];
+ b_mouse_down = FALSE;
+ return self;
+}
+
+- (void)dealloc
+{
+ [_knobOff release];
+ [_knobOn release];
+ [super dealloc];
+}
+
+- (void)drawKnob:(NSRect)knob_rect
+{
+ NSImage *knob;
+
+ if( b_mouse_down )
+ knob = _knobOn;
+ else
+ knob = _knobOff;
+
+ [[self controlView] lockFocus];
+ [knob compositeToPoint:NSMakePoint( knob_rect.origin.x + 1,
+ knob_rect.origin.y + knob_rect.size.height -2 )
+ operation:NSCompositeSourceOver];
+ [[self controlView] unlockFocus];
+}
+
+- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:
+ (NSView *)controlView mouseIsUp:(BOOL)flag
+{
+ b_mouse_down = NO;
+ [self drawKnob];
+ [super stopTracking:lastPoint at:stopPoint inView:controlView mouseIsUp:flag];
+}
+
+- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView
+{
+ b_mouse_down = YES;
+ [self drawKnob];
+ return [super startTrackingAt:startPoint inView:controlView];
+}
+
+@end
+