Commit 848daa45 authored by Felix Paul Kühne's avatar Felix Paul Kühne Committed by Jean-Baptiste Kempf

macosx: re-written the way we render 3 part images by using another custom view (refs #5742)

this fixes various drawing issues with the time slider and the window title
(cherry picked from commit fb10d756)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent c4364d3b
...@@ -51,10 +51,7 @@ ...@@ -51,10 +51,7 @@
IBOutlet id o_time_fld; IBOutlet id o_time_fld;
IBOutlet id o_progress_bar; IBOutlet id o_progress_bar;
IBOutlet id o_bottombar_view; IBOutlet id o_bottombar_view;
IBOutlet id o_time_sld_left_view; IBOutlet id o_time_sld_background;
IBOutlet id o_time_sld_middle_view;
IBOutlet id o_time_sld_right_view;
// TODO Playlist table, additional ui stuff at the top of the window
IBOutlet id o_playlist_table; IBOutlet id o_playlist_table;
IBOutlet id o_video_view; IBOutlet id o_video_view;
IBOutlet id o_split_view; IBOutlet id o_split_view;
...@@ -172,12 +169,3 @@ ...@@ -172,12 +169,3 @@
- (void)windowWillExitFullScreen:(NSNotification *)notification; - (void)windowWillExitFullScreen:(NSNotification *)notification;
@end @end
@interface VLCProgressBarGradientEffect : NSView {
NSImage * o_time_sld_gradient_left_img;
NSImage * o_time_sld_gradient_middle_img;
NSImage * o_time_sld_gradient_right_img;
}
- (void)loadImagesInDarkStyle:(BOOL)b_value;
@end
...@@ -162,9 +162,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -162,9 +162,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
o_shuffle_pressed_img = [[NSImage imageNamed:@"shuffle-pressed"] retain]; o_shuffle_pressed_img = [[NSImage imageNamed:@"shuffle-pressed"] retain];
o_shuffle_on_img = [[NSImage imageNamed:@"shuffle-blue"] retain]; o_shuffle_on_img = [[NSImage imageNamed:@"shuffle-blue"] retain];
o_shuffle_on_pressed_img = [[NSImage imageNamed:@"shuffle-blue-pressed"] retain]; o_shuffle_on_pressed_img = [[NSImage imageNamed:@"shuffle-blue-pressed"] retain];
[o_time_sld_left_view setImage: [NSImage imageNamed:@"progression-track-wrapper-left"]]; [o_time_sld_background setImagesLeft: [NSImage imageNamed:@"progression-track-wrapper-left"] middle: [NSImage imageNamed:@"progression-track-wrapper-middle"] right: [NSImage imageNamed:@"progression-track-wrapper-right"]];
[o_time_sld_middle_view setImage: [NSImage imageNamed:@"progression-track-wrapper-middle"]];
[o_time_sld_right_view setImage: [NSImage imageNamed:@"progression-track-wrapper-right"]];
[o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low"]]; [o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low"]];
[o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track"]]; [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track"]];
[o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high"]]; [o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high"]];
...@@ -180,7 +178,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -180,7 +178,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
[o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons"]]; [o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons"]];
[o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed"]]; [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed"]];
[o_time_sld_fancygradient_view loadImagesInDarkStyle:NO]; [o_time_sld_fancygradient_view setImagesLeft:[NSImage imageNamed:@"progression-fill-left"] middle:[NSImage imageNamed:@"progression-fill-middle"] right:[NSImage imageNamed:@"progression-fill-right"]];
} }
else else
{ {
...@@ -208,9 +206,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -208,9 +206,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
o_shuffle_on_img = [[NSImage imageNamed:@"shuffle-blue_dark"] retain]; o_shuffle_on_img = [[NSImage imageNamed:@"shuffle-blue_dark"] retain];
o_shuffle_on_pressed_img = [[NSImage imageNamed:@"shuffle-blue-pressed_dark"] retain]; o_shuffle_on_pressed_img = [[NSImage imageNamed:@"shuffle-blue-pressed_dark"] retain];
[o_time_fld setTextColor: [NSColor colorWithCalibratedRed:229.0 green:229.0 blue:229.0 alpha:100.0]]; [o_time_fld setTextColor: [NSColor colorWithCalibratedRed:229.0 green:229.0 blue:229.0 alpha:100.0]];
[o_time_sld_left_view setImage: [NSImage imageNamed:@"progression-track-wrapper-left_dark"]]; [o_time_sld_background setImagesLeft: [NSImage imageNamed:@"progression-track-wrapper-left_dark"] middle: [NSImage imageNamed:@"progression-track-wrapper-middle_dark"] right: [NSImage imageNamed:@"progression-track-wrapper-right_dark"]];
[o_time_sld_middle_view setImage: [NSImage imageNamed:@"progression-track-wrapper-middle_dark"]];
[o_time_sld_right_view setImage: [NSImage imageNamed:@"progression-track-wrapper-right_dark"]];
[o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low_dark"]]; [o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low_dark"]];
[o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track_dark"]]; [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track_dark"]];
[o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high_dark"]]; [o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high_dark"]];
...@@ -226,7 +222,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -226,7 +222,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
[o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons_dark"]]; [o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons_dark"]];
[o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed_dark"]]; [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed_dark"]];
[o_time_sld_fancygradient_view loadImagesInDarkStyle:YES]; [o_time_sld_fancygradient_view setImagesLeft:[NSImage imageNamed:@"progressbar-fill-left_dark"] middle:[NSImage imageNamed:@"progressbar-fill-middle_dark"] right:[NSImage imageNamed:@"progressbar-fill-right_dark"]];
} }
[o_repeat_btn setImage: o_repeat_img]; [o_repeat_btn setImage: o_repeat_img];
[o_repeat_btn setAlternateImage: o_repeat_pressed_img]; [o_repeat_btn setAlternateImage: o_repeat_pressed_img];
...@@ -267,7 +263,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -267,7 +263,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
moveItem( o_volume_track_view ); moveItem( o_volume_track_view );
moveItem( o_volume_down_btn ); moveItem( o_volume_down_btn );
moveItem( o_time_fld ); moveItem( o_time_fld );
moveItem( o_time_sld_right_view ); moveItem( o_time_sld_background );
#undef moveItem #undef moveItem
#define enlargeItem( item ) \ #define enlargeItem( item ) \
...@@ -277,7 +273,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -277,7 +273,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
enlargeItem( o_time_sld ); enlargeItem( o_time_sld );
enlargeItem( o_progress_bar ); enlargeItem( o_progress_bar );
enlargeItem( o_time_sld_middle_view ); enlargeItem( o_time_sld_background );
enlargeItem( o_time_sld_fancygradient_view ); enlargeItem( o_time_sld_fancygradient_view );
#undef enlargeItem #undef enlargeItem
...@@ -1021,15 +1017,15 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1021,15 +1017,15 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)drawFancyGradientEffectForTimeSlider - (void)drawFancyGradientEffectForTimeSlider
{ {
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
float f_value = [o_time_sld_middle_view frame].size.width * ([o_time_sld intValue] / [o_time_sld maxValue]); float f_value = ([o_time_sld frame].size.width - [o_time_sld frame].origin.x - [o_time_sld knobPosition]) * -1.0;
if (f_value > 5.0) if (f_value > 7.5)
{ {
if (f_value != [o_time_sld_fancygradient_view frame].size.width) NSRect oldFrame = [o_time_sld_fancygradient_view frame];
if (f_value != oldFrame.size.width)
{ {
[o_time_sld_fancygradient_view setHidden: NO]; [o_time_sld_fancygradient_view setHidden: NO];
[o_time_sld_fancygradient_view setFrame: NSMakeRect( [o_time_sld_fancygradient_view frame].origin.x, [o_time_sld_fancygradient_view frame].origin.y, f_value, [o_time_sld_fancygradient_view frame].size.height )]; [o_time_sld_fancygradient_view setFrame: NSMakeRect( oldFrame.origin.x, oldFrame.origin.y, f_value, oldFrame.size.height )];
[o_time_sld_fancygradient_view setNeedsDisplay:YES]; [o_time_sld_fancygradient_view setNeedsDisplay:YES];
[o_time_sld_middle_view setNeedsDisplay:YES];
} }
} }
else else
...@@ -1806,35 +1802,3 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1806,35 +1802,3 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
@end @end
@implementation VLCProgressBarGradientEffect
- (void)dealloc
{
[o_time_sld_gradient_left_img release];
[o_time_sld_gradient_middle_img release];
[o_time_sld_gradient_right_img release];
[super dealloc];
}
- (void)loadImagesInDarkStyle: (BOOL)b_value
{
if (b_value)
{
o_time_sld_gradient_left_img = [[NSImage imageNamed:@"progressbar-fill-left_dark"] retain];
o_time_sld_gradient_middle_img = [[NSImage imageNamed:@"progressbar-fill-middle_dark"] retain];
o_time_sld_gradient_right_img = [[NSImage imageNamed:@"progressbar-fill-right_dark"] retain];
}
else
{
o_time_sld_gradient_left_img = [[NSImage imageNamed:@"progression-fill-left"] retain];
o_time_sld_gradient_middle_img = [[NSImage imageNamed:@"progression-fill-middle"] retain];
o_time_sld_gradient_right_img = [[NSImage imageNamed:@"progression-fill-right"] retain];
}
}
- (void)drawRect:(NSRect)rect
{
NSRect bnds = [self bounds];
NSDrawThreePartImage( bnds, o_time_sld_gradient_left_img, o_time_sld_gradient_middle_img, o_time_sld_gradient_right_img, NO, NSCompositeSourceOver, 1, NO );
}
@end
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
*****************************************************************************/ *****************************************************************************/
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "misc.h"
/***************************************************************************** /*****************************************************************************
* VLCMainWindowTitleView * VLCMainWindowTitleView
*****************************************************************************/ *****************************************************************************/
@interface VLCMainWindowTitleView : NSImageView @interface VLCMainWindowTitleView : VLCThreePartImageView
{ {
NSImage * o_red_img; NSImage * o_red_img;
NSImage * o_red_over_img; NSImage * o_red_over_img;
......
...@@ -55,11 +55,8 @@ ...@@ -55,11 +55,8 @@
- (void)awakeFromNib - (void)awakeFromNib
{ {
[self setImageScaling: NSScaleToFit];
[self setImageFrameStyle: NSImageFrameNone];
[self setImageAlignment: NSImageAlignCenter];
[self setImage: [NSImage imageNamed:@"topbar-dark-center-fill"]];
[self setAutoresizesSubviews: YES]; [self setAutoresizesSubviews: YES];
[self setImagesLeft:[NSImage imageNamed:@"topbar-dark-left"] middle: [NSImage imageNamed:@"topbar-dark-center-fill"] right:[NSImage imageNamed:@"topbar-dark-right"]];
[self loadButtonIcons]; [self loadButtonIcons];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(controlTintChanged:) name: NSControlTintDidChangeNotification object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(controlTintChanged:) name: NSControlTintDidChangeNotification object: nil];
...@@ -208,7 +205,6 @@ ...@@ -208,7 +205,6 @@
else else
[o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]]; [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
} }
@end @end
/***************************************************************************** /*****************************************************************************
......
...@@ -118,7 +118,10 @@ ...@@ -118,7 +118,10 @@
@interface TimeLineSlider : NSSlider @interface TimeLineSlider : NSSlider
{ {
NSImage *o_knob_img;
NSRect img_rect;
} }
- (CGFloat)knobPosition;
- (void)drawRect:(NSRect)rect; - (void)drawRect:(NSRect)rect;
- (void)drawKnobInRect:(NSRect)knobRect; - (void)drawKnobInRect:(NSRect)knobRect;
...@@ -158,3 +161,16 @@ ...@@ -158,3 +161,16 @@
} }
@end @end
/*****************************************************************************
* VLCThreePartImageView interface
*****************************************************************************/
@interface VLCThreePartImageView : NSView
{
NSImage * o_left_img;
NSImage * o_middle_img;
NSImage * o_right_img;
}
- (void)setImagesLeft:(NSImage *)left middle: (NSImage *)middle right:(NSImage *)right;
@end
...@@ -601,17 +601,32 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -601,17 +601,32 @@ void _drawFrameInRect(NSRect frameRect)
@implementation TimeLineSlider @implementation TimeLineSlider
- (void)awakeFromNib
{
o_knob_img = [NSImage imageNamed:@"progression-knob"];
img_rect.size = [o_knob_img size];
img_rect.origin.x = img_rect.origin.y = 0;
}
- (void)dealloc
{
[o_knob_img release];
[super dealloc];
}
- (CGFloat)knobPosition
{
NSRect knobRect = [[self cell] knobRectFlipped:NO];
knobRect.origin.x += knobRect.size.width / 2;
return knobRect.origin.x;
}
- (void)drawKnobInRect:(NSRect)knobRect - (void)drawKnobInRect:(NSRect)knobRect
{ {
NSRect image_rect; knobRect.origin.x += (knobRect.size.width - img_rect.size.width) / 2;
NSImage *img = [NSImage imageNamed:@"progression-knob"]; knobRect.size.width = img_rect.size.width;
image_rect.size = [img size]; knobRect.size.height = img_rect.size.height;
image_rect.origin.x = 0; [o_knob_img drawInRect:knobRect fromRect:img_rect operation:NSCompositeSourceOver fraction:1];
image_rect.origin.y = 0;
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;
[img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1];
} }
- (void)drawRect:(NSRect)rect - (void)drawRect:(NSRect)rect
...@@ -732,3 +747,38 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -732,3 +747,38 @@ void _drawFrameInRect(NSRect frameRect)
[[o_subviews objectAtIndex:1] setFrame: rightViewDimensions]; [[o_subviews objectAtIndex:1] setFrame: rightViewDimensions];
} }
@end @end
/*****************************************************************************
* VLCThreePartImageView interface
*****************************************************************************/
@implementation VLCThreePartImageView
- (void)dealloc
{
[o_left_img release];
[o_middle_img release];
[o_right_img release];
[super dealloc];
}
- (void)setImagesLeft:(NSImage *)left middle: (NSImage *)middle right:(NSImage *)right
{
if (o_left_img)
[o_left_img release];
if (o_middle_img)
[o_middle_img release];
if (o_right_img)
[o_right_img release];
o_left_img = [left retain];
o_middle_img = [middle retain];
o_right_img = [right retain];
}
- (void)drawRect:(NSRect)rect
{
NSRect bnds = [self bounds];
NSDrawThreePartImage( bnds, o_left_img, o_middle_img, o_right_img, NO, NSCompositeSourceOver, 1, NO );
}
@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