[vlc-commits] macosx: added a 1.5px shadow (white) to the window title and the time counter

Felix Paul Kühne git at videolan.org
Mon Feb 6 00:06:32 CET 2012


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Feb  5 20:27:26 2012 +0100| [ee6c4a295a494f6670c1466ce9cc360c8b414f9e] | committer: Felix Paul Kühne

macosx: added a 1.5px shadow (white) to the window title and the time counter

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ee6c4a295a494f6670c1466ce9cc360c8b414f9e
---

 modules/gui/macosx/MainWindow.m      |    1 -
 modules/gui/macosx/MainWindowTitle.h |    2 +
 modules/gui/macosx/MainWindowTitle.m |   27 ++++++++++++++++++++++++-
 modules/gui/macosx/misc.h            |    3 ++
 modules/gui/macosx/misc.m            |   36 ++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 04a3ce8..deebd4e 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -214,7 +214,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
         o_shuffle_pressed_img = [[NSImage imageNamed:@"shuffle-pressed_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_time_fld setTextColor: [NSColor colorWithCalibratedRed:229.0 green:229.0 blue:229.0 alpha:100.0]];
         [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_volume_down_btn setImage: [NSImage imageNamed:@"volume-low_dark"]];
         [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track_dark"]];
diff --git a/modules/gui/macosx/MainWindowTitle.h b/modules/gui/macosx/MainWindowTitle.h
index 7180850..0a45360 100644
--- a/modules/gui/macosx/MainWindowTitle.h
+++ b/modules/gui/macosx/MainWindowTitle.h
@@ -39,6 +39,8 @@
     NSImage * o_green_img;
     NSImage * o_green_over_img;
     NSImage * o_green_on_img;
+    NSShadow * o_window_title_shadow;
+    NSDictionary * o_window_title_attributes_dict;
 
     IBOutlet id o_red_btn;
     IBOutlet id o_yellow_btn;
diff --git a/modules/gui/macosx/MainWindowTitle.m b/modules/gui/macosx/MainWindowTitle.m
index effee09..e01c6f1 100644
--- a/modules/gui/macosx/MainWindowTitle.m
+++ b/modules/gui/macosx/MainWindowTitle.m
@@ -36,6 +36,13 @@
  *****************************************************************************/
 
 @implementation VLCMainWindowTitleView
+- (id)init
+{
+    o_window_title_attributes_dict = [[NSDictionary dictionaryWithObjectsAndKeys: [NSColor whiteColor], NSForegroundColorAttributeName, [NSFont titleBarFontOfSize:12.0], NSFontAttributeName, nil] retain];
+
+    return [super init];
+}
+
 - (void)dealloc
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
@@ -50,6 +57,9 @@
     [o_green_over_img release];
     [o_green_on_img release];
 
+    [o_window_title_shadow release];
+    [o_window_title_attributes_dict release];
+
     [super dealloc];
 }
 
@@ -174,7 +184,22 @@
 
 - (void)setWindowTitle:(NSString *)title
 {
-    [o_title_lbl setStringValue: title];
+    if (!o_window_title_shadow)
+    {
+        o_window_title_shadow = [[NSShadow alloc] init];
+        [o_window_title_shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]];
+        [o_window_title_shadow setShadowOffset:NSMakeSize(0.0, -1.5)];
+        [o_window_title_shadow setShadowBlurRadius:0.5];
+        [o_window_title_shadow retain];
+    }
+
+    NSMutableAttributedString *o_attributed_title = [[NSMutableAttributedString alloc] initWithString:title attributes: o_window_title_attributes_dict];
+    NSUInteger i_titleLength = [title length];
+
+    [o_attributed_title addAttribute:NSShadowAttributeName value:o_window_title_shadow range:NSMakeRange(0, i_titleLength)];
+    [o_attributed_title setAlignment: NSCenterTextAlignment range:NSMakeRange(0, i_titleLength)];
+    [o_title_lbl setAttributedStringValue:o_attributed_title];
+    [o_attributed_title release];
 }
 
 - (void)setFullscreenButtonHidden:(BOOL)b_value
diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h
index bfc2d5f..65b9905 100644
--- a/modules/gui/macosx/misc.h
+++ b/modules/gui/macosx/misc.h
@@ -151,7 +151,10 @@
 
 @interface VLCTimeField : NSTextField
 {
+    NSShadow * o_string_shadow;
+    NSDictionary * o_string_attributes_dict;
 }
+
 - (BOOL)timeRemaining;
 @end
 
diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index ea3df8d..623ae90 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -707,6 +707,42 @@ void _drawFrameInRect(NSRect frameRect)
     [defaults registerDefaults:appDefaults];
 }
 
+- (void)awakeFromNib
+{
+    NSColor *o_string_color;
+    if (!config_GetInt( VLCIntf, "macosx-interfacestyle"))
+        o_string_color = [NSColor colorWithCalibratedRed:0.229 green:0.229 blue:0.229 alpha:100.0];
+    else
+        o_string_color = [NSColor colorWithCalibratedRed:0.64 green:0.64 blue:0.64 alpha:100.0];
+
+    o_string_attributes_dict = [[NSDictionary dictionaryWithObjectsAndKeys: o_string_color, NSForegroundColorAttributeName, [NSFont titleBarFontOfSize:10.0], NSFontAttributeName, nil] retain];
+}
+
+- (void)dealloc
+{
+    [o_string_shadow release];
+    [o_string_attributes_dict release];
+}
+
+- (void)setStringValue:(NSString *)string
+{
+    if (!o_string_shadow)
+    {
+        o_string_shadow = [[NSShadow alloc] init];
+        [o_string_shadow setShadowColor: [NSColor colorWithCalibratedWhite:1.0 alpha:0.5]];
+        [o_string_shadow setShadowOffset:NSMakeSize(0.0, -1.5)];
+        [o_string_shadow setShadowBlurRadius:0.0];
+    }
+
+    NSMutableAttributedString *o_attributed_string = [[NSMutableAttributedString alloc] initWithString:string attributes: o_string_attributes_dict];
+    NSUInteger i_stringLength = [string length];
+
+    [o_attributed_string addAttribute: NSShadowAttributeName value: o_string_shadow range: NSMakeRange(0, i_stringLength)];
+    [o_attributed_string setAlignment: NSCenterTextAlignment range: NSMakeRange(0, i_stringLength)];
+    [self setAttributedStringValue: o_attributed_string];
+    [o_attributed_string release];
+}
+
 - (void)mouseDown: (NSEvent *)ourEvent
 {
     if( [ourEvent clickCount] > 1 )



More information about the vlc-commits mailing list