2007-01-23 05:42:08 +01:00
|
|
|
// Copyright (c) 2007, Rodrigo Braz Monteiro
|
2006-04-15 00:37:05 +02:00
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2006-04-15 00:37:05 +02:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file dialog_detached_video.cpp
|
|
|
|
/// @brief Detached video window
|
|
|
|
/// @ingroup main_ui
|
|
|
|
///
|
2006-04-15 00:37:05 +02:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2007-07-27 07:25:51 +02:00
|
|
|
#include <wx/filename.h>
|
2012-01-22 06:59:23 +01:00
|
|
|
#include <wx/sizer.h>
|
2009-11-15 21:53:31 +01:00
|
|
|
#include <wx/display.h> /// Must be included last.
|
2009-09-10 15:06:40 +02:00
|
|
|
#endif
|
|
|
|
|
2007-01-23 05:42:08 +01:00
|
|
|
#include "dialog_detached_video.h"
|
2011-07-30 01:16:36 +02:00
|
|
|
|
|
|
|
#include "include/aegisub/context.h"
|
|
|
|
#include "include/aegisub/hotkey.h"
|
|
|
|
|
2010-05-21 03:13:36 +02:00
|
|
|
#include "main.h"
|
2011-07-27 07:36:02 +02:00
|
|
|
#include "persist_location.h"
|
2007-01-23 05:42:08 +01:00
|
|
|
#include "video_box.h"
|
|
|
|
#include "video_context.h"
|
2007-01-23 07:32:16 +01:00
|
|
|
#include "video_display.h"
|
2011-07-30 01:16:36 +02:00
|
|
|
|
|
|
|
DialogDetachedVideo::DialogDetachedVideo(agi::Context *context, const wxSize &initialDisplaySize)
|
|
|
|
: wxDialog(context->parent, -1, "Detached Video", wxDefaultPosition, wxSize(400,300), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxWANTS_CHARS)
|
|
|
|
, context(context)
|
2011-11-12 02:23:18 +01:00
|
|
|
, old_display(context->videoDisplay)
|
|
|
|
, old_slider(context->videoSlider)
|
2011-07-30 01:16:36 +02:00
|
|
|
, video_open(context->videoController->AddVideoOpenListener(&DialogDetachedVideo::OnVideoOpen, this))
|
2007-01-23 05:42:08 +01:00
|
|
|
{
|
2008-01-11 06:44:00 +01:00
|
|
|
// Set obscure stuff
|
2009-09-02 10:23:18 +02:00
|
|
|
SetExtraStyle((GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS) | wxWS_EX_PROCESS_UI_UPDATES);
|
2008-01-11 06:44:00 +01:00
|
|
|
|
2011-12-06 01:17:54 +01:00
|
|
|
SetTitle(wxString::Format(_("Video: %s"), wxFileName(context->videoController->GetVideoName()).GetFullName()));
|
2007-07-27 07:25:51 +02:00
|
|
|
|
2007-01-23 05:42:08 +01:00
|
|
|
// Video area;
|
2011-12-22 22:31:57 +01:00
|
|
|
VideoBox *videoBox = new VideoBox(this, true, context);
|
2011-11-12 02:23:29 +01:00
|
|
|
context->videoDisplay->SetMinClientSize(initialDisplaySize);
|
2011-08-17 07:32:15 +02:00
|
|
|
videoBox->Layout();
|
2006-04-15 00:37:05 +02:00
|
|
|
|
2007-01-23 05:42:08 +01:00
|
|
|
// Set sizer
|
|
|
|
wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
mainSizer->Add(videoBox,1,wxEXPAND | wxALL,5);
|
2011-12-22 22:31:57 +01:00
|
|
|
SetSizerAndFit(mainSizer);
|
2006-04-15 00:37:05 +02:00
|
|
|
|
2009-06-06 16:36:22 +02:00
|
|
|
// Ensure we can grow smaller, without these the window is locked to at least the initial size
|
2011-11-12 02:23:29 +01:00
|
|
|
context->videoDisplay->SetMinSize(wxSize(1,1));
|
2009-06-06 16:36:22 +02:00
|
|
|
videoBox->SetMinSize(wxSize(1,1));
|
|
|
|
SetMinSize(wxSize(1,1));
|
|
|
|
|
2011-07-27 07:36:02 +02:00
|
|
|
persist.reset(new PersistLocation(this, "Video/Detached"));
|
|
|
|
|
2009-11-14 01:42:55 +01:00
|
|
|
int display_index = wxDisplay::GetFromWindow(this);
|
2011-07-27 07:36:02 +02:00
|
|
|
// Ensure that the dialog is no larger than the screen
|
|
|
|
if (display_index != wxNOT_FOUND) {
|
2009-11-14 01:42:55 +01:00
|
|
|
wxRect bounds_rect = GetRect();
|
|
|
|
wxRect disp_rect = wxDisplay(display_index).GetClientArea();
|
2011-07-27 07:36:02 +02:00
|
|
|
SetSize(std::min(bounds_rect.width, disp_rect.width), std::min(bounds_rect.height, disp_rect.height));
|
2009-11-14 01:42:55 +01:00
|
|
|
}
|
|
|
|
|
2010-05-21 03:13:36 +02:00
|
|
|
OPT_SET("Video/Detached/Enabled")->SetBool(true);
|
2006-04-15 00:37:05 +02:00
|
|
|
|
2011-07-30 01:16:36 +02:00
|
|
|
Bind(wxEVT_CLOSE_WINDOW, &DialogDetachedVideo::OnClose, this);
|
|
|
|
Bind(wxEVT_ICONIZE, &DialogDetachedVideo::OnMinimize, this);
|
|
|
|
Bind(wxEVT_KEY_DOWN, &DialogDetachedVideo::OnKeyDown, this);
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-07-30 01:16:36 +02:00
|
|
|
Show();
|
2007-01-23 05:42:08 +01:00
|
|
|
}
|
2007-07-27 06:05:18 +02:00
|
|
|
|
2011-07-30 01:16:36 +02:00
|
|
|
DialogDetachedVideo::~DialogDetachedVideo() { }
|
2007-07-27 06:05:18 +02:00
|
|
|
|
2011-07-30 01:16:36 +02:00
|
|
|
void DialogDetachedVideo::OnClose(wxCloseEvent&) {
|
|
|
|
context->detachedVideo = 0;
|
2011-11-12 02:23:18 +01:00
|
|
|
context->videoDisplay = old_display;
|
|
|
|
context->videoSlider = old_slider;
|
2010-05-21 03:13:36 +02:00
|
|
|
OPT_SET("Video/Detached/Enabled")->SetBool(false);
|
2012-01-09 21:31:47 +01:00
|
|
|
context->videoController->Reload();
|
2008-01-11 05:48:11 +01:00
|
|
|
Destroy();
|
2008-01-12 04:29:45 +01:00
|
|
|
}
|
|
|
|
|
2009-10-13 06:10:55 +02:00
|
|
|
void DialogDetachedVideo::OnMinimize(wxIconizeEvent &event) {
|
|
|
|
if (event.IsIconized()) {
|
|
|
|
// Force the video display to repaint as otherwise the last displayed
|
|
|
|
// frame stays visible even though the dialog is minimized
|
|
|
|
Hide();
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
}
|
2011-07-30 01:16:36 +02:00
|
|
|
|
|
|
|
void DialogDetachedVideo::OnKeyDown(wxKeyEvent &evt) {
|
2012-01-25 06:48:53 +01:00
|
|
|
if (!hotkey::check("Video Display", context, evt.GetKeyCode(), evt.GetUnicodeKey(), evt.GetModifiers()))
|
|
|
|
evt.Skip();
|
2011-07-30 01:16:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DialogDetachedVideo::OnVideoOpen() {
|
|
|
|
if (!context->videoController->IsLoaded()) {
|
|
|
|
context->detachedVideo = 0;
|
2011-11-12 02:23:18 +01:00
|
|
|
context->videoDisplay = old_display;
|
|
|
|
context->videoSlider = old_slider;
|
2012-01-09 21:31:47 +01:00
|
|
|
context->videoController->Reload();
|
2011-07-30 01:16:36 +02:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
}
|