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

macosx: prove-of-concept of a styled window title bar

current lacks support for zooming and therefore behaves incorrectly when using Lion's native fullscreen mode
(cherry picked from commit b40f9cee)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 78931a83
......@@ -269,6 +269,8 @@
8EDAC3430440F72D0059A3A7 /* README.MacOSX.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = README.MacOSX.rtf; sourceTree = SOURCE_ROOT; };
8EE1AF9F044465080059A3A7 /* about.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = about.h; path = ../../../modules/gui/macosx/about.h; sourceTree = SOURCE_ROOT; };
8EE1AFA0044465080059A3A7 /* about.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = about.m; path = ../../../modules/gui/macosx/about.m; sourceTree = SOURCE_ROOT; };
CC017A0B14A4C8AF00C09A4F /* MainWindowTitle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MainWindowTitle.h; path = ../../../modules/gui/macosx/MainWindowTitle.h; sourceTree = "<group>"; };
CC017A0C14A4C8AF00C09A4F /* MainWindowTitle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MainWindowTitle.m; path = ../../../modules/gui/macosx/MainWindowTitle.m; sourceTree = "<group>"; };
CC04321113B246DF00D7D52E /* back_dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = back_dark.png; path = Resources/mainwindow_dark/back_dark.png; sourceTree = "<group>"; };
CC04321213B246DF00D7D52E /* back-pressed_dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "back-pressed_dark.png"; path = "Resources/mainwindow_dark/back-pressed_dark.png"; sourceTree = "<group>"; };
CC04321313B246DF00D7D52E /* effects-double-buttons_dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "effects-double-buttons_dark.png"; path = "Resources/mainwindow_dark/effects-double-buttons_dark.png"; sourceTree = "<group>"; };
......@@ -622,8 +624,6 @@
8ED6C27B03E2EB1C0059A3A7 /* controls.m */,
8E6BC6F6041643860059A3A7 /* applescript.h */,
8E6BC6F7041643860059A3A7 /* applescript.m */,
8ED6C27F03E2EB1C0059A3A7 /* misc.h */,
8ED6C28003E2EB1C0059A3A7 /* misc.m */,
8EE1AF9F044465080059A3A7 /* about.h */,
8EE1AFA0044465080059A3A7 /* about.m */,
8ED6C28103E2EB1C0059A3A7 /* open.h */,
......@@ -656,6 +656,7 @@
CC707EC4137464CD0003010A /* TrackSynchronization.m */,
CCCE366D13817E4500694F2A /* VideoEffects.h */,
CCCE366E13817E4500694F2A /* VideoEffects.m */,
CC017A0E14A4C8B600C09A4F /* custom UI code */,
CC0CD0E513DE0FC600B0D90D /* Imported Code */,
);
name = Classes;
......@@ -721,6 +722,17 @@
name = fileicons;
sourceTree = "<group>";
};
CC017A0E14A4C8B600C09A4F /* custom UI code */ = {
isa = PBXGroup;
children = (
8ED6C27F03E2EB1C0059A3A7 /* misc.h */,
8ED6C28003E2EB1C0059A3A7 /* misc.m */,
CC017A0B14A4C8AF00C09A4F /* MainWindowTitle.h */,
CC017A0C14A4C8AF00C09A4F /* MainWindowTitle.m */,
);
name = "custom UI code";
sourceTree = "<group>";
};
CC0430EE13B2461A00D7D52E /* 10th anniversary ui */ = {
isa = PBXGroup;
children = (
......
......@@ -68,6 +68,7 @@
IBOutlet id o_dropzone_lbl;
IBOutlet VLCFSPanel *o_fspanel;
IBOutlet id o_titlebar_view;
BOOL b_dark_interface;
BOOL b_nativeFullscreenMode;
......@@ -128,6 +129,7 @@
- (IBAction)fullscreen:(id)sender;
- (IBAction)dropzoneButtonAction:(id)sender;
- (void)setTitle:(NSString *)title;
- (void)showDropZone;
- (void)hideDropZone;
- (void)updateTimeSlider;
......
......@@ -33,6 +33,7 @@
#import "open.h"
#import "controls.h" // TODO: remove me
#import "SideBarItem.h"
#import "MainWindowTitle.h"
#import <vlc_playlist.h>
#import <vlc_aout_intf.h>
#import <vlc_url.h>
......@@ -69,10 +70,20 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
backing:(NSBackingStoreType)backingType defer:(BOOL)flag
{
// styleMask ^= NSTexturedBackgroundWindowMask;
b_dark_interface = config_GetInt( VLCIntf, "macosx-interfacestyle" );
self = [super initWithContentRect:contentRect styleMask:styleMask //& ~NSTitledWindowMask
backing:backingType defer:flag];
if (b_dark_interface)
{
styleMask = NSBorderlessWindowMask;
self = [super initWithContentRect:contentRect styleMask:styleMask
backing:backingType defer:flag];
}
else
{
self = [super initWithContentRect:contentRect styleMask:styleMask
backing:backingType defer:flag];
}
[[VLCMain sharedInstance] updateTogglePlaylistState];
......@@ -106,7 +117,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)awakeFromNib
{
/* setup the styled interface */
b_dark_interface = config_GetInt( VLCIntf, "macosx-interfacestyle" );
b_nativeFullscreenMode = config_GetInt( VLCIntf, "macosx-nativefullscreenmode" );
i_lastShownVolume = -1;
......@@ -173,7 +183,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
}
else
{
/* TODO: we also need to change the window style here... */
[o_bottombar_view setImage: [NSImage imageNamed:@"bottom-background_dark"]];
[o_bwd_btn setImage: [NSImage imageNamed:@"back_dark"]];
[o_bwd_btn setAlternateImage: [NSImage imageNamed:@"back-pressed_dark"]];
......@@ -233,7 +242,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
[self setContentMinSize:NSMakeSize(500., 288.)];
[self setTitle: _NS("VLC media player")];
[o_playlist_btn setEnabled:NO];
[o_video_view setFrame: [o_split_view frame]];
o_temp_view = [[NSView alloc] init];
[o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
[o_dropzone_view setFrame: [o_playlist_table frame]];
......@@ -376,6 +384,27 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_sidebar_view reloadData];
[o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:YES];
if( b_dark_interface )
{
NSRect winrect;
CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
winrect = [self frame];
[o_titlebar_view setFrame: NSMakeRect( 0, winrect.size.height - f_titleBarHeight,
winrect.size.width, f_titleBarHeight )];
[[self contentView] addSubview: o_titlebar_view];
winrect.size.height = winrect.size.height + f_titleBarHeight;
[self setFrame: winrect display:NO animate:NO];
winrect = [o_split_view frame];
winrect.size.height = winrect.size.height - f_titleBarHeight;
[o_split_view setFrame: winrect];
[o_video_view setFrame: winrect];
[self display];
}
else
[o_video_view setFrame: [o_split_view frame]];
}
#pragma mark -
......@@ -630,6 +659,24 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[[VLCMain sharedInstance] open] openFileGeneric];
}
#pragma mark -
#pragma mark overwritten default functionality
- (BOOL)canBecomeKeyWindow
{
return YES;
}
- (void)setTitle:(NSString *)title
{
[o_titlebar_view setWindowTitle: title];
[super setTitle: title];
}
- (void)performZoom:(id)sender
{
[super zoom: sender];
}
#pragma mark -
#pragma mark Update interface and respond to foreign events
- (void)showDropZone
......@@ -869,7 +916,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
if ([o_video_view window] != self)
{
[o_video_view removeFromSuperviewWithoutNeedingDisplay];
[o_video_view setFrame: [o_split_view frame]];
[o_video_view setFrame: [o_right_split_view frame]];
[[self contentView] addSubview:o_video_view positioned:NSWindowAbove relativeTo:nil];
}
b_nonembedded = NO;
......@@ -943,7 +990,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
/* Calculate the window's new size */
new_frame.size.width = [self frame].size.width - [o_video_view frame].size.width + nativeVideoSize.width;
new_frame.size.height = [self frame].size.height - [o_video_view frame].size.height + nativeVideoSize.height;
if (b_dark_interface)
new_frame.size.height = [self frame].size.height - [o_video_view frame].size.height + nativeVideoSize.height + [o_titlebar_view frame].size.height;
else
new_frame.size.height = [self frame].size.height - [o_video_view frame].size.height + nativeVideoSize.height;
new_frame.origin.x = topleftscreen.x;
new_frame.origin.y = topleftscreen.y - new_frame.size.height;
......
/*****************************************************************************
* MainWindowTitle.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2011 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
/*****************************************************************************
* VLCMainWindowTitleView
*****************************************************************************/
@interface VLCMainWindowTitleView : NSImageView
{
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;
}
- (IBAction)buttonAction:(id)sender;
- (void)setWindowTitle:(NSString *)title;
@end
/*****************************************************************************
* MainWindowTitle.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2011 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <vlc_common.h>
#import "intf.h"
#import "MainWindowTitle.h"
#import "CoreInteraction.h"
/*****************************************************************************
* VLCMainWindowTitleView
*****************************************************************************/
@implementation VLCMainWindowTitleView
- (void)awakeFromNib
{
[self setImageScaling: NSScaleToFit];
[self setImageFrameStyle: NSImageFrameNone];
[self setImageAlignment: NSImageAlignCenter];
[self setImage: [NSImage imageNamed:@"bottom-background_dark"]];
[self setAutoresizesSubviews: YES];
/* TODO: icon setters */
}
- (BOOL)mouseDownCanMoveWindow
{
return YES;
}
- (IBAction)buttonAction:(id)sender
{
if (sender == o_red_btn)
[[self window] orderOut: sender];
else if (sender == o_yellow_btn)
[[self window] miniaturize: sender];
else if (sender == o_green_btn)
[[self window] performZoom: sender];
else if (sender == o_fullscreen_btn)
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
else
msg_Err( VLCIntf, "unknown button action sender" );
}
- (void)setWindowTitle:(NSString *)title
{
[o_title_lbl setStringValue: title];
}
@end
......@@ -66,5 +66,7 @@ SOURCES_macosx = \
eyetv.m \
VideoView.h \
VideoView.m \
MainWindowTitle.h \
MainWindowTitle.m \
$(NULL)
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