From cde9a3442548742714544563f4f74f51b8671d10 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 26 May 2012 20:16:08 +0000 Subject: [PATCH] osx: Add the full screen button to the main window Originally committed to SVN as r6879. --- aegisub/src/Makefile | 2 +- aegisub/src/frame_main.cpp | 1 + aegisub/src/osx_utils.mm | 38 ++++++++++++++++++++++++++++++++++++++ aegisub/src/utils.cpp | 6 ++++++ aegisub/src/utils.h | 3 +++ 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 aegisub/src/osx_utils.mm diff --git a/aegisub/src/Makefile b/aegisub/src/Makefile index 9547ecff6..795a6691e 100644 --- a/aegisub/src/Makefile +++ b/aegisub/src/Makefile @@ -18,7 +18,7 @@ LIBS += $(LIBS_UCHARDET) LDFLAGS += $(LDFLAGS_CCMALLOC) -ifdef BUILD_DARWIN +ifeq (yes, $(BUILD_DARWIN)) LIBS += -lz SRC += osx_utils.mm endif diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 4d072e93d..58bb1a3c5 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -200,6 +200,7 @@ FrameMain::FrameMain (wxArrayString args) context->ass->LoadDefault(); StartupLog("Display main window"); + AddFullScreenButton(this); Show(); SetDisplayMode(1, 1); diff --git a/aegisub/src/osx_utils.mm b/aegisub/src/osx_utils.mm new file mode 100644 index 000000000..76da12f39 --- /dev/null +++ b/aegisub/src/osx_utils.mm @@ -0,0 +1,38 @@ +// Copyright (c) 2012, Thomas Goyne +// +// 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 + +#import + +void AddFullScreenButton(wxWindow *window) { + NSWindow *nsWindow = [window->GetHandle() window]; + if (![nsWindow respondsToSelector:@selector(toggleFullScreen:)]) + return; + + NSWindowCollectionBehavior collectionBehavior = [nsWindow collectionBehavior]; + collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary; + [nsWindow setCollectionBehavior:collectionBehavior]; +} diff --git a/aegisub/src/utils.cpp b/aegisub/src/utils.cpp index d9e704b51..4ea11593b 100644 --- a/aegisub/src/utils.cpp +++ b/aegisub/src/utils.cpp @@ -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 diff --git a/aegisub/src/utils.h b/aegisub/src/utils.h index b1a69a9bc..bf45723a8 100644 --- a/aegisub/src/utils.h +++ b/aegisub/src/utils.h @@ -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