osx: Add the full screen button to the main window

Originally committed to SVN as r6879.
This commit is contained in:
Thomas Goyne 2012-05-26 20:16:08 +00:00
parent 1da7502d6e
commit cde9a34425
5 changed files with 49 additions and 1 deletions

View File

@ -18,7 +18,7 @@ LIBS += $(LIBS_UCHARDET)
LDFLAGS += $(LDFLAGS_CCMALLOC)
ifdef BUILD_DARWIN
ifeq (yes, $(BUILD_DARWIN))
LIBS += -lz
SRC += osx_utils.mm
endif

View File

@ -200,6 +200,7 @@ FrameMain::FrameMain (wxArrayString args)
context->ass->LoadDefault();
StartupLog("Display main window");
AddFullScreenButton(this);
Show();
SetDisplayMode(1, 1);

38
aegisub/src/osx_utils.mm Normal file
View File

@ -0,0 +1,38 @@
// Copyright (c) 2012, Thomas Goyne <plorkyeran@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// Aegisub Project http://www.aegisub.org/
//
// $Id$
/// @file osx_utils.mm
/// @see utils.h
/// @ingroup utils
///
#include "config.h"
#include <wx/window.h>
#import <AppKit/AppKit.h>
void AddFullScreenButton(wxWindow *window) {
NSWindow *nsWindow = [window->GetHandle() window];
if (![nsWindow respondsToSelector:@selector(toggleFullScreen:)])
return;
NSWindowCollectionBehavior collectionBehavior = [nsWindow collectionBehavior];
collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
[nsWindow setCollectionBehavior:collectionBehavior];
}

View File

@ -421,3 +421,9 @@ void CleanCache(wxString const& directory, wxString const& file_type, int64_t ma
LOG_D("utils/clean_cache") << "thread started successfully";
}
// OS X implementation in osx_utils.mm
#ifndef __WXOSX_COCOA__
void AddFullScreenButton(wxWindow *window) {
}
#endif

View File

@ -94,6 +94,9 @@ int AegiStringToFix(const wxString &str,size_t decimalPlaces,int start=0,int end
/// running process.
void RestartAegisub();
/// Add the OS X 10.7+ full-screen button to a window
void AddFullScreenButton(wxWindow *window);
/// Forward a mouse wheel event to the window under the mouse if needed
/// @param source The initial target of the wheel event
/// @param evt The event