From 1d385240078ba08a5d6d16e90f3a172bcba98245 Mon Sep 17 00:00:00 2001 From: Jon Lech Johansen Date: Tue, 21 Jan 2003 00:47:43 +0000 Subject: [PATCH] * ./modules/gui/macosx/aout.m: output more debug info * ./modules/gui/macosx/misc.[mh]: MPSlider, iTunes-like slider: http://nanocrew.net/vlc/mpslider.png --- modules/gui/macosx/aout.m | 26 +++-- modules/gui/macosx/misc.h | 52 ++++++++++ modules/gui/macosx/misc.m | 194 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 262 insertions(+), 10 deletions(-) create mode 100644 modules/gui/macosx/misc.h create mode 100644 modules/gui/macosx/misc.m diff --git a/modules/gui/macosx/aout.m b/modules/gui/macosx/aout.m index b0d14dcb1d..9b89e9a8bc 100644 --- a/modules/gui/macosx/aout.m +++ b/modules/gui/macosx/aout.m @@ -2,7 +2,7 @@ * aout.m: CoreAudio output plugin ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: aout.m,v 1.21 2003/01/15 00:49:49 jlj Exp $ + * $Id: aout.m,v 1.22 2003/01/21 00:47:43 jlj Exp $ * * Authors: Colin Delacroix * Jon Lech Johansen @@ -41,6 +41,13 @@ #define A52_FRAME_NB 1536 +#define STREAM_FORMAT_MSG( pre, sfm ) \ + pre ": [%ld][%4.4s][%ld][%ld][%ld][%ld][%ld][%ld]", \ + (UInt32)sfm.mSampleRate, (char *)&sfm.mFormatID, \ + sfm.mFormatFlags, sfm.mBytesPerPacket, \ + sfm.mFramesPerPacket, sfm.mBytesPerFrame, \ + sfm.mChannelsPerFrame, sfm.mBitsPerChannel + /***************************************************************************** * aout_class_t ****************************************************************************/ @@ -251,15 +258,8 @@ int E_(OpenAudio)( vlc_object_t * p_this ) p_aout->output.output.i_rate = (unsigned int)p_sys->stream_format.mSampleRate; - msg_Dbg( p_aout, "format: [%ld][%4.4s][%ld][%ld][%ld][%ld][%ld][%ld]", - (UInt32)p_sys->stream_format.mSampleRate, - (char *)&p_sys->stream_format.mFormatID, - p_sys->stream_format.mFormatFlags, - p_sys->stream_format.mBytesPerPacket, - p_sys->stream_format.mFramesPerPacket, - p_sys->stream_format.mBytesPerFrame, - p_sys->stream_format.mChannelsPerFrame, - p_sys->stream_format.mBitsPerChannel ); + msg_Dbg( p_aout, STREAM_FORMAT_MSG( "using format", + p_sys->stream_format ) ); /* Get the buffer size */ i_param_size = sizeof( p_sys->i_buffer_size ); @@ -814,6 +814,12 @@ static int InitStream( UInt32 i_dev, aout_instance_t *p_aout, for( i = 0; i < i_streams; i++ ) { + if( j == 0 ) + { + msg_Dbg( p_aout, STREAM_FORMAT_MSG( "supported format", + P_STREAMS[i] ) ); + } + if( ( P_STREAMS[i].mFormatID != aout_classes[j].mFormatID ) || ( P_STREAMS[i].mChannelsPerFrame < aout_classes[j].mChannelsPerFrame ) ) diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h new file mode 100644 index 0000000000..8fdd3e89b8 --- /dev/null +++ b/modules/gui/macosx/misc.h @@ -0,0 +1,52 @@ +/***************************************************************************** + * misc.h: code not specific to vlc + ***************************************************************************** + * Copyright (C) 2003 VideoLAN + * $Id: misc.h,v 1.1 2003/01/21 00:47:43 jlj Exp $ + * + * Authors: Jon Lech Johansen + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * MPSlider + *****************************************************************************/ + +@interface MPSlider : NSSlider +{ + +} + +@end + +/***************************************************************************** + * MPSliderCell + *****************************************************************************/ + +@interface MPSliderCell : NSSliderCell +{ + NSColor * _bgColor; + NSColor * _knobColor; + float _knobThickness; +} + +- (void)setBackgroundColor:(NSColor *)newColor; +- (NSColor *)backgroundColor; + +- (void)setKnobColor:(NSColor *)newColor; +- (NSColor *)knobColor; + +@end \ No newline at end of file diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m new file mode 100644 index 0000000000..4bc23d6b9e --- /dev/null +++ b/modules/gui/macosx/misc.m @@ -0,0 +1,194 @@ +/***************************************************************************** + * misc.m: code not specific to vlc + ***************************************************************************** + * Copyright (C) 2003 VideoLAN + * $Id: misc.m,v 1.1 2003/01/21 00:47:43 jlj Exp $ + * + * Authors: Jon Lech Johansen + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include + +#include "misc.h" + +/***************************************************************************** + * MPSlider + *****************************************************************************/ + +@implementation MPSlider + ++ (Class)cellClass +{ + return( [MPSliderCell class] ); +} + +@end + +/***************************************************************************** + * MPSliderCell + *****************************************************************************/ + +@implementation MPSliderCell + +- (id)init +{ + self = [super init]; + + if( self != nil ) + { + _bgColor = [[NSColor colorWithDeviceRed: 0.8627451 + green: 0.8784314 + blue: 0.7725490 + alpha: 1.0] retain]; + _knobColor = [[NSColor blackColor] retain]; + } + + return( self ); +} + +- (void)dealloc +{ + [_bgColor release]; + [_knobColor release]; + [super dealloc]; +} + +- (void)setBackgroundColor:(NSColor *)newColor +{ + [_bgColor release]; + _bgColor = [newColor retain]; +} + +- (NSColor *)backgroundColor +{ + return( _bgColor ); +} + +- (void)setKnobColor:(NSColor *)newColor +{ + [_knobColor release]; + _knobColor = [newColor retain]; +} + +- (NSColor *)knobColor +{ + return( _knobColor ); +} + +- (void)setKnobThickness:(float)f_value +{ + _knobThickness = f_value; +} + +- (float)knobThickness +{ + return( _knobThickness ); +} + +- (NSSize)cellSizeForBounds:(NSRect)s_rc +{ + return( s_rc.size ); +} + +- (void)drawWithFrame:(NSRect)s_rc inView:(NSView *)o_view +{ + if( _scFlags.weAreVertical ) + { + s_rc.origin.x = 1; s_rc.size.width -= 3; + s_rc.origin.y = 2; s_rc.size.height -= 5; + } + else + { + s_rc.origin.x = 2; s_rc.size.width -= 5; + s_rc.origin.y = 1; s_rc.size.height -= 3; + } + + [super drawWithFrame: s_rc inView: o_view]; +} + +- (void)drawBarInside:(NSRect)s_rc flipped:(BOOL)b_flipped +{ + NSRect s_arc; + + s_rc.size.width += (s_rc.origin.x * 2) + 1; + s_rc.size.height += (s_rc.origin.y * 2) + 1; + s_rc.origin.x = s_rc.origin.y = 0; + + [[NSGraphicsContext currentContext] setShouldAntialias: NO]; + + [_bgColor set]; + NSRectFill( s_rc ); + + s_arc = s_rc; + s_arc.origin.x += 1.5; + s_arc.origin.y += 1.5; + s_arc.size.width -= s_arc.origin.x; + s_arc.size.height -= s_arc.origin.y; + [[_bgColor shadowWithLevel: 0.1] set]; + [NSBezierPath strokeRect: s_arc]; + + s_arc.origin = s_rc.origin; + [[NSColor blackColor] set]; + [NSBezierPath strokeRect: s_arc]; + + [[NSGraphicsContext currentContext] setShouldAntialias: YES]; +} + +- (NSRect)knobRectFlipped:(BOOL)b_flipped +{ + NSSize s_size; + NSPoint s_pto; + float floatValue; + + floatValue = [self floatValue]; + + if( _scFlags.weAreVertical && b_flipped ) + { + floatValue = _maxValue + _minValue - floatValue; + } + + floatValue = (floatValue - _minValue) / (_maxValue - _minValue); + + if( _scFlags.weAreVertical ) + { + s_size = NSMakeSize( _trackRect.size.width, _knobThickness ? + _knobThickness : _trackRect.size.width ); + s_pto = _trackRect.origin; + s_pto.y += (_trackRect.size.height - s_size.height) * floatValue; + } + else + { + s_size = NSMakeSize( _knobThickness ? _knobThickness : + _trackRect.size.height, _trackRect.size.height ); + s_pto = _trackRect.origin; + s_pto.x += (_trackRect.size.width - s_size.width) * floatValue; + } + + return NSMakeRect( s_pto.x, s_pto.y, s_size.width, s_size.height ); +} + +- (void)drawKnob:(NSRect)s_rc +{ + [[NSGraphicsContext currentContext] setShouldAntialias: NO]; + + [_knobColor set]; + NSRectFill( s_rc ); + + [[NSGraphicsContext currentContext] setShouldAntialias: YES]; +} + +@end -- 2.39.2