Commit 7c3d71b0 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: modernize main window title coding style

parent 679b36eb
......@@ -190,11 +190,11 @@
</textField>
</subviews>
<connections>
<outlet property="o_fullscreen_btn" destination="27" id="34"/>
<outlet property="o_green_btn" destination="26" id="36"/>
<outlet property="o_red_btn" destination="24" id="61"/>
<outlet property="o_title_lbl" destination="28" id="54"/>
<outlet property="o_yellow_btn" destination="25" id="35"/>
<outlet property="fullscreenButton" destination="27" id="Q7Q-c7-2mT"/>
<outlet property="greenButton" destination="26" id="ene-pt-Lib"/>
<outlet property="redButton" destination="24" id="gRU-rk-buI"/>
<outlet property="titleLabel" destination="28" id="hLC-1g-oFA"/>
<outlet property="yellowButton" destination="25" id="RzQ-RH-CMN"/>
</connections>
</customView>
<customObject id="3" userLabel="Detached Window Controls Bar" customClass="VLCControlsBarCommon">
......
......@@ -491,11 +491,11 @@
</textField>
</subviews>
<connections>
<outlet property="o_fullscreen_btn" destination="4898" id="4910"/>
<outlet property="o_green_btn" destination="4897" id="4911"/>
<outlet property="o_red_btn" destination="4895" id="4913"/>
<outlet property="o_title_lbl" destination="4899" id="4909"/>
<outlet property="o_yellow_btn" destination="4896" id="4912"/>
<outlet property="fullscreenButton" destination="4898" id="lbk-lI-Uov"/>
<outlet property="greenButton" destination="4897" id="2J9-uI-vLb"/>
<outlet property="redButton" destination="4895" id="ktq-aJ-S89"/>
<outlet property="titleLabel" destination="4899" id="44w-AH-65I"/>
<outlet property="yellowButton" destination="4896" id="aib-Yt-4kE"/>
</connections>
</customView>
<customView id="4722" userLabel="Dropzone">
......
......@@ -28,14 +28,20 @@
* VLCMainWindowTitleView
*****************************************************************************/
@class VLCCustomWindowCloseButton;
@class VLCCustomWindowMinimizeButton;
@class VLCCustomWindowZoomButton;
@class VLCCustomWindowFullscreenButton;
@class VLCWindowTitleTextField;
@interface VLCMainWindowTitleView : VLCThreePartImageView
{
IBOutlet id o_red_btn;
IBOutlet id o_yellow_btn;
IBOutlet id o_green_btn;
IBOutlet id o_fullscreen_btn;
IBOutlet id o_title_lbl;
}
@property (readwrite, strong) IBOutlet VLCCustomWindowCloseButton *redButton;
@property (readwrite, strong) IBOutlet VLCCustomWindowMinimizeButton *yellowButton;
@property (readwrite, strong) IBOutlet VLCCustomWindowZoomButton *greenButton;
@property (readwrite, strong) IBOutlet VLCCustomWindowFullscreenButton *fullscreenButton;
@property (readwrite, strong) IBOutlet VLCWindowTitleTextField *titleLabel;
@property (readonly) NSButton * closeButton;
@property (readonly) NSButton * minimizeButton;
@property (readonly) NSButton * zoomButton;
......
......@@ -38,26 +38,26 @@
@interface VLCMainWindowTitleView()
{
NSImage * o_red_img;
NSImage * o_red_over_img;
NSImage * o_red_on_img;
NSImage * o_yellow_img;
NSImage * o_yellow_over_img;
NSImage * o_yellow_on_img;
NSImage * o_green_img;
NSImage * o_green_over_img;
NSImage * o_green_on_img;
NSImage *_redImage;
NSImage *_redHoverImage;
NSImage *_redOnClickImage;
NSImage * _yellowImage;
NSImage * _yellowHoverImage;
NSImage * _yellowOnClickImage;
NSImage * _greenImage;
NSImage * _greenHoverImage;
NSImage * _greenOnClickImage;
// yosemite fullscreen images
NSImage * o_fullscreen_img;
NSImage * o_fullscreen_over_img;
NSImage * o_fullscreen_on_img;
NSImage * _fullscreenImage;
NSImage * _fullscreenHoverImage;
NSImage * _fullscreenOnClickImage;
// old native fullscreen images
NSImage * o_old_fullscreen_img;
NSImage * o_old_fullscreen_over_img;
NSImage * o_old_fullscreen_on_img;
NSImage * _oldFullscreenImage;
NSImage * _oldFullscreenHoverImage;
NSImage * _oldFullscreenOnClickImage;
NSShadow * o_window_title_shadow;
NSDictionary * o_window_title_attributes_dict;
NSShadow * _windowTitleShadow;
NSDictionary * _windowTitleAttributesDictionary;
BOOL b_nativeFullscreenMode;
......@@ -68,11 +68,16 @@
@end
@implementation VLCMainWindowTitleView
- (id)init
{
o_window_title_attributes_dict = [NSDictionary dictionaryWithObjectsAndKeys: [NSColor whiteColor], NSForegroundColorAttributeName, [NSFont titleBarFontOfSize:12.0], NSFontAttributeName, nil];
self = [super init];
if (self) {
_windowTitleAttributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys: [NSColor whiteColor], NSForegroundColorAttributeName, [NSFont titleBarFontOfSize:12.0], NSFontAttributeName, nil];
}
return [super init];
return self;
}
- (void)dealloc
......@@ -85,7 +90,7 @@
b_nativeFullscreenMode = var_InheritBool(getIntf(), "macosx-nativefullscreenmode");
if (!b_nativeFullscreenMode || OSX_YOSEMITE || OSX_EL_CAPITAN) {
[o_fullscreen_btn setHidden: YES];
[_fullscreenButton setHidden: YES];
}
[self setAutoresizesSubviews: YES];
......@@ -99,9 +104,9 @@
{
[self loadButtonIcons];
[o_red_btn setNeedsDisplay];
[o_yellow_btn setNeedsDisplay];
[o_green_btn setNeedsDisplay];
[_redButton setNeedsDisplay];
[_yellowButton setNeedsDisplay];
[_greenButton setNeedsDisplay];
}
- (void)informModifierPressed:(BOOL)b_is_altkey;
......@@ -135,46 +140,46 @@
- (void)loadButtonIcons
{
o_red_img = [self getButtonImage:@"window-close"];
o_red_over_img = [self getButtonImage:@"window-close-over"];
o_red_on_img = [self getButtonImage:@"window-close-on"];
o_yellow_img = [self getButtonImage:@"window-minimize"];
o_yellow_over_img = [self getButtonImage:@"window-minimize-over"];
o_yellow_on_img = [self getButtonImage:@"window-minimize-on"];
o_green_img = [self getButtonImage:@"window-zoom"];
o_green_over_img = [self getButtonImage:@"window-zoom-over"];
o_green_on_img = [self getButtonImage:@"window-zoom-on"];
_redImage = [self getButtonImage:@"window-close"];
_redHoverImage = [self getButtonImage:@"window-close-over"];
_redOnClickImage = [self getButtonImage:@"window-close-on"];
_yellowImage = [self getButtonImage:@"window-minimize"];
_yellowHoverImage = [self getButtonImage:@"window-minimize-over"];
_yellowOnClickImage = [self getButtonImage:@"window-minimize-on"];
_greenImage = [self getButtonImage:@"window-zoom"];
_greenHoverImage = [self getButtonImage:@"window-zoom-over"];
_greenOnClickImage = [self getButtonImage:@"window-zoom-on"];
// these files are only available in the yosemite variant
if (OSX_YOSEMITE || OSX_EL_CAPITAN) {
o_fullscreen_img = [self getButtonImage:@"window-fullscreen"];
o_fullscreen_over_img = [self getButtonImage:@"window-fullscreen-over"];
o_fullscreen_on_img = [self getButtonImage:@"window-fullscreen-on"];
_fullscreenImage = [self getButtonImage:@"window-fullscreen"];
_fullscreenHoverImage = [self getButtonImage:@"window-fullscreen-over"];
_fullscreenOnClickImage = [self getButtonImage:@"window-fullscreen-on"];
}
// old native fullscreen images are not available in graphite style
// thus they are loaded directly here
o_old_fullscreen_img = [NSImage imageNamed:@"lion-window-fullscreen"];
o_old_fullscreen_on_img = [NSImage imageNamed:@"lion-window-fullscreen-on"];
o_old_fullscreen_over_img = [NSImage imageNamed:@"lion-window-fullscreen-over"];
[o_red_btn setImage: o_red_img];
[o_red_btn setAlternateImage: o_red_on_img];
[[o_red_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
[[o_red_btn cell] setTag: 0];
[o_yellow_btn setImage: o_yellow_img];
[o_yellow_btn setAlternateImage: o_yellow_on_img];
[[o_yellow_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
[[o_yellow_btn cell] setTag: 1];
_oldFullscreenImage = [NSImage imageNamed:@"lion-window-fullscreen"];
_oldFullscreenOnClickImage = [NSImage imageNamed:@"lion-window-fullscreen-on"];
_oldFullscreenHoverImage = [NSImage imageNamed:@"lion-window-fullscreen-over"];
[_redButton setImage: _redImage];
[_redButton setAlternateImage: _redHoverImage];
[[_redButton cell] setShowsBorderOnlyWhileMouseInside: YES];
[[_redButton cell] setTag: 0];
[_yellowButton setImage: _yellowImage];
[_yellowButton setAlternateImage: _yellowHoverImage];
[[_yellowButton cell] setShowsBorderOnlyWhileMouseInside: YES];
[[_yellowButton cell] setTag: 1];
[self updateGreenButton];
[[o_green_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
[[o_green_btn cell] setTag: 2];
[[_greenButton cell] setShowsBorderOnlyWhileMouseInside: YES];
[[_greenButton cell] setTag: 2];
[o_fullscreen_btn setImage: o_old_fullscreen_img];
[o_fullscreen_btn setAlternateImage: o_old_fullscreen_on_img];
[[o_fullscreen_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
[[o_fullscreen_btn cell] setTag: 3];
[_fullscreenButton setImage: _oldFullscreenImage];
[_fullscreenButton setAlternateImage: _oldFullscreenHoverImage];
[[_fullscreenButton cell] setShowsBorderOnlyWhileMouseInside: YES];
[[_fullscreenButton cell] setTag: 3];
}
- (void)updateGreenButton
......@@ -184,20 +189,20 @@
if (!(OSX_YOSEMITE || OSX_EL_CAPITAN) || !b_nativeFullscreenMode || b_alt_pressed) {
if (b_mouse_over) {
[o_green_btn setImage: o_green_over_img];
[o_green_btn setAlternateImage: o_green_on_img];
[_greenButton setImage: _greenHoverImage];
[_greenButton setAlternateImage: _greenOnClickImage];
} else {
[o_green_btn setImage: o_green_img];
[o_green_btn setAlternateImage: o_green_on_img];
[_greenButton setImage: _greenImage];
[_greenButton setAlternateImage: _greenOnClickImage];
}
} else {
if (b_mouse_over) {
[o_green_btn setImage: o_fullscreen_over_img];
[o_green_btn setAlternateImage: o_fullscreen_on_img];
[_greenButton setImage: _fullscreenHoverImage];
[_greenButton setAlternateImage: _fullscreenOnClickImage];
} else {
[o_green_btn setImage: o_fullscreen_img];
[o_green_btn setAlternateImage: o_fullscreen_on_img];
[_greenButton setImage: _fullscreenImage];
[_greenButton setAlternateImage: _fullscreenOnClickImage];
}
}
}
......@@ -209,17 +214,17 @@
- (IBAction)buttonAction:(id)sender
{
if (sender == o_red_btn)
if (sender == _redButton)
[[self window] performClose: sender];
else if (sender == o_yellow_btn)
else if (sender == _yellowButton)
[[self window] miniaturize: sender];
else if (sender == o_green_btn) {
else if (sender == _greenButton) {
if ((OSX_YOSEMITE || OSX_EL_CAPITAN) && b_nativeFullscreenMode && !b_alt_pressed) {
[[self window] toggleFullScreen:self];
} else {
[[self window] performZoom: sender];
}
} else if (sender == o_fullscreen_btn) {
} else if (sender == _fullscreenButton) {
// same action as native fs button
[[self window] toggleFullScreen:self];
......@@ -232,30 +237,30 @@
- (void)setWindowTitle:(NSString *)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];
if (!_windowTitleShadow) {
_windowTitleShadow = [[NSShadow alloc] init];
[_windowTitleShadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]];
[_windowTitleShadow setShadowOffset:NSMakeSize(0.0, -1.5)];
[_windowTitleShadow setShadowBlurRadius:0.5];
}
NSMutableAttributedString *o_attributed_title = [[NSMutableAttributedString alloc] initWithString:title attributes: o_window_title_attributes_dict];
NSMutableAttributedString *attributedTitleString = [[NSMutableAttributedString alloc] initWithString:title attributes: _windowTitleAttributesDictionary];
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];
[attributedTitleString addAttribute:NSShadowAttributeName value:_windowTitleShadow range:NSMakeRange(0, i_titleLength)];
[attributedTitleString setAlignment: NSCenterTextAlignment range:NSMakeRange(0, i_titleLength)];
[_titleLabel setAttributedStringValue:attributedTitleString];
}
- (void)setWindowButtonOver:(BOOL)b_value
{
b_mouse_over = b_value;
if (b_value) {
[o_red_btn setImage: o_red_over_img];
[o_yellow_btn setImage: o_yellow_over_img];
[_redButton setImage: _redHoverImage];
[_yellowButton setImage: _yellowHoverImage];
} else {
[o_red_btn setImage: o_red_img];
[o_yellow_btn setImage: o_yellow_img];
[_redButton setImage: _redImage];
[_yellowButton setImage: _yellowImage];
}
[self updateGreenButton];
......@@ -264,9 +269,9 @@
- (void)setWindowFullscreenButtonOver:(BOOL)b_value
{
if (b_value)
[o_fullscreen_btn setImage: o_old_fullscreen_over_img];
[_fullscreenButton setImage: _oldFullscreenHoverImage];
else
[o_fullscreen_btn setImage: o_old_fullscreen_img];
[_fullscreenButton setImage: _oldFullscreenImage];
}
- (void)mouseDown:(NSEvent *)event
......@@ -287,17 +292,17 @@
- (NSButton*)closeButton
{
return o_red_btn;
return _redButton;
}
- (NSButton*)minimizeButton
{
return o_yellow_btn;
return _yellowButton;
}
- (NSButton*)zoomButton
{
return o_green_btn;
return _greenButton;
}
@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