forked from mia/Aegisub
Detangle FrameMain and DialogDetachedVideo
Originally committed to SVN as r5530.
This commit is contained in:
parent
3f50ce6d46
commit
65368c5f35
|
@ -238,7 +238,13 @@ struct video_detach : public validator_video_loaded {
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
wxGetApp().frame->DetachVideo(!c->detachedVideo);
|
if (!c->detachedVideo) {
|
||||||
|
c->detachedVideo = new DialogDetachedVideo(c, c->videoBox->videoDisplay->GetClientSize());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
c->detachedVideo->Destroy();
|
||||||
|
c->detachedVideo = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,39 +38,35 @@
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
#include <wx/settings.h>
|
|
||||||
#include <wx/display.h> /// Must be included last.
|
#include <wx/display.h> /// Must be included last.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "include/aegisub/context.h"
|
|
||||||
#include "dialog_detached_video.h"
|
#include "dialog_detached_video.h"
|
||||||
#include "frame_main.h"
|
|
||||||
|
#include "include/aegisub/context.h"
|
||||||
|
#include "include/aegisub/hotkey.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "persist_location.h"
|
#include "persist_location.h"
|
||||||
#include "video_box.h"
|
#include "video_box.h"
|
||||||
#include "video_context.h"
|
#include "video_context.h"
|
||||||
#include "video_display.h"
|
#include "video_display.h"
|
||||||
#include "video_slider.h"
|
|
||||||
|
|
||||||
/// @brief Constructor
|
DialogDetachedVideo::DialogDetachedVideo(agi::Context *context, const wxSize &initialDisplaySize)
|
||||||
/// @param par FrameMain this was spawned from
|
: wxDialog(context->parent, -1, "Detached Video", wxDefaultPosition, wxSize(400,300), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxWANTS_CHARS)
|
||||||
/// @param initialDisplaySize Initial size of the window
|
, context(context)
|
||||||
DialogDetachedVideo::DialogDetachedVideo(FrameMain *parent, agi::Context *context, const wxSize &initialDisplaySize)
|
, video_open(context->videoController->AddVideoOpenListener(&DialogDetachedVideo::OnVideoOpen, this))
|
||||||
: wxDialog(parent,-1,_T("Detached Video"),wxDefaultPosition,wxSize(400,300),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxWANTS_CHARS)
|
|
||||||
, parent(parent)
|
|
||||||
{
|
{
|
||||||
// Set obscure stuff
|
// Set obscure stuff
|
||||||
SetExtraStyle((GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS) | wxWS_EX_PROCESS_UI_UPDATES);
|
SetExtraStyle((GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS) | wxWS_EX_PROCESS_UI_UPDATES);
|
||||||
|
|
||||||
// Set title
|
SetTitle(wxString::Format(_("Video: %s"), wxFileName(context->videoController->videoName).GetFullName()));
|
||||||
wxFileName fn(context->videoController->videoName);
|
|
||||||
SetTitle(wxString::Format(_("Video: %s"),fn.GetFullName().c_str()));
|
|
||||||
|
|
||||||
// Set a background panel
|
// Set a background panel
|
||||||
wxPanel *panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
|
wxPanel *panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
|
||||||
|
|
||||||
// Video area;
|
// Video area;
|
||||||
videoBox = new VideoBox(panel, true, context);
|
VideoBox *videoBox = new VideoBox(panel, true, context);
|
||||||
videoBox->videoDisplay->SetClientSize(initialDisplaySize);
|
videoBox->videoDisplay->SetClientSize(initialDisplaySize);
|
||||||
|
|
||||||
// Set sizer
|
// Set sizer
|
||||||
|
@ -95,35 +91,23 @@ DialogDetachedVideo::DialogDetachedVideo(FrameMain *parent, agi::Context *contex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
parent->SetDisplayMode(0, -1);
|
|
||||||
OPT_SET("Video/Detached/Enabled")->SetBool(true);
|
OPT_SET("Video/Detached/Enabled")->SetBool(true);
|
||||||
|
|
||||||
// Copy the main accelerator table to this dialog
|
Bind(wxEVT_CLOSE_WINDOW, &DialogDetachedVideo::OnClose, this);
|
||||||
wxAcceleratorTable *table = parent->GetAcceleratorTable();
|
Bind(wxEVT_ICONIZE, &DialogDetachedVideo::OnMinimize, this);
|
||||||
SetAcceleratorTable(*table);
|
Bind(wxEVT_KEY_DOWN, &DialogDetachedVideo::OnKeyDown, this);
|
||||||
|
|
||||||
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Destructor
|
DialogDetachedVideo::~DialogDetachedVideo() { }
|
||||||
DialogDetachedVideo::~DialogDetachedVideo() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event table
|
void DialogDetachedVideo::OnClose(wxCloseEvent&) {
|
||||||
BEGIN_EVENT_TABLE(DialogDetachedVideo,wxDialog)
|
context->detachedVideo = 0;
|
||||||
EVT_CLOSE(DialogDetachedVideo::OnClose)
|
|
||||||
EVT_ICONIZE(DialogDetachedVideo::OnMinimize)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
/// @brief Close window
|
|
||||||
/// @param event UNUSED
|
|
||||||
void DialogDetachedVideo::OnClose(wxCloseEvent &WXUNUSED(event)) {
|
|
||||||
OPT_SET("Video/Detached/Enabled")->SetBool(false);
|
OPT_SET("Video/Detached/Enabled")->SetBool(false);
|
||||||
Destroy();
|
Destroy();
|
||||||
parent->context->detachedVideo = 0;
|
|
||||||
parent->SetDisplayMode(1,-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Minimize event handler
|
|
||||||
/// @param event
|
|
||||||
void DialogDetachedVideo::OnMinimize(wxIconizeEvent &event) {
|
void DialogDetachedVideo::OnMinimize(wxIconizeEvent &event) {
|
||||||
if (event.IsIconized()) {
|
if (event.IsIconized()) {
|
||||||
// Force the video display to repaint as otherwise the last displayed
|
// Force the video display to repaint as otherwise the last displayed
|
||||||
|
@ -132,3 +116,15 @@ void DialogDetachedVideo::OnMinimize(wxIconizeEvent &event) {
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogDetachedVideo::OnKeyDown(wxKeyEvent &evt) {
|
||||||
|
evt.StopPropagation();
|
||||||
|
hotkey::check("Video Display", evt.GetKeyCode(), evt.GetUnicodeKey(), evt.GetModifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogDetachedVideo::OnVideoOpen() {
|
||||||
|
if (!context->videoController->IsLoaded()) {
|
||||||
|
context->detachedVideo = 0;
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -34,16 +34,14 @@
|
||||||
/// @ingroup main_ui
|
/// @ingroup main_ui
|
||||||
///
|
///
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <wx/dialog.h>
|
#include <wx/dialog.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <libaegisub/scoped_ptr.h>
|
#include <libaegisub/scoped_ptr.h>
|
||||||
|
#include <libaegisub/signal.h>
|
||||||
|
|
||||||
namespace agi { struct Context; }
|
namespace agi { struct Context; }
|
||||||
class FrameMain;
|
|
||||||
class PersistLocation;
|
class PersistLocation;
|
||||||
class VideoBox;
|
class VideoBox;
|
||||||
|
|
||||||
|
@ -53,20 +51,21 @@ class VideoBox;
|
||||||
///
|
///
|
||||||
/// DOCME
|
/// DOCME
|
||||||
class DialogDetachedVideo : public wxDialog {
|
class DialogDetachedVideo : public wxDialog {
|
||||||
|
agi::Context *context;
|
||||||
|
agi::signal::Connection video_open;
|
||||||
agi::scoped_ptr<PersistLocation> persist;
|
agi::scoped_ptr<PersistLocation> persist;
|
||||||
|
|
||||||
/// DOCME
|
void OnClose(wxCloseEvent &);
|
||||||
VideoBox *videoBox;
|
/// Minimize event handler to hack around a wx bug
|
||||||
|
void OnMinimize(wxIconizeEvent &evt);
|
||||||
/// DOCME
|
void OnKeyDown(wxKeyEvent &evt);
|
||||||
FrameMain *parent;
|
void OnVideoOpen();
|
||||||
|
|
||||||
void OnClose(wxCloseEvent &event);
|
|
||||||
void OnMinimize(wxIconizeEvent &event);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogDetachedVideo(FrameMain *parent, agi::Context *context, const wxSize &initialDisplaySize);
|
/// @brief Constructor
|
||||||
|
/// @param context Project context
|
||||||
|
/// @param initialDisplaySize Initial size of the window
|
||||||
|
DialogDetachedVideo(agi::Context *context, const wxSize &initialDisplaySize);
|
||||||
|
/// Destructor
|
||||||
~DialogDetachedVideo();
|
~DialogDetachedVideo();
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,6 @@
|
||||||
#endif
|
#endif
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "command/command.h"
|
#include "command/command.h"
|
||||||
#include "dialog_detached_video.h"
|
|
||||||
#include "dialog_search_replace.h"
|
#include "dialog_search_replace.h"
|
||||||
#include "dialog_styling_assistant.h"
|
#include "dialog_styling_assistant.h"
|
||||||
#include "dialog_version_check.h"
|
#include "dialog_version_check.h"
|
||||||
|
@ -183,6 +182,7 @@ FrameMain::FrameMain (wxArrayString args)
|
||||||
context->detachedVideo = 0;
|
context->detachedVideo = 0;
|
||||||
context->stylingAssistant = 0;
|
context->stylingAssistant = 0;
|
||||||
InitContents();
|
InitContents();
|
||||||
|
OPT_SUB("Video/Detached/Enabled", &FrameMain::OnVideoDetach, this, agi::signal::_1);
|
||||||
|
|
||||||
StartupLog("Complete context initialization");
|
StartupLog("Complete context initialization");
|
||||||
context->videoController->SetContext(context.get());
|
context->videoController->SetContext(context.get());
|
||||||
|
@ -224,7 +224,6 @@ FrameMain::FrameMain (wxArrayString args)
|
||||||
FrameMain::~FrameMain () {
|
FrameMain::~FrameMain () {
|
||||||
context->videoController->SetVideo("");
|
context->videoController->SetVideo("");
|
||||||
context->audioController->CloseAudio();
|
context->audioController->CloseAudio();
|
||||||
if (context->detachedVideo) context->detachedVideo->Destroy();
|
|
||||||
if (context->stylingAssistant) context->stylingAssistant->Destroy();
|
if (context->stylingAssistant) context->stylingAssistant->Destroy();
|
||||||
SubsGrid->ClearMaps();
|
SubsGrid->ClearMaps();
|
||||||
delete audioBox;
|
delete audioBox;
|
||||||
|
@ -440,7 +439,6 @@ void FrameMain::UpdateTitle() {
|
||||||
void FrameMain::OnVideoOpen() {
|
void FrameMain::OnVideoOpen() {
|
||||||
if (!context->videoController->IsLoaded()) {
|
if (!context->videoController->IsLoaded()) {
|
||||||
SetDisplayMode(0, -1);
|
SetDisplayMode(0, -1);
|
||||||
DetachVideo(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,22 +479,16 @@ void FrameMain::OnVideoOpen() {
|
||||||
|
|
||||||
SetDisplayMode(1,-1);
|
SetDisplayMode(1,-1);
|
||||||
|
|
||||||
DetachVideo(OPT_GET("Video/Detached/Enabled")->GetBool());
|
if (OPT_GET("Video/Detached/Enabled")->GetBool())
|
||||||
|
cmd::call("video/detach", context.get());
|
||||||
Thaw();
|
Thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameMain::DetachVideo(bool detach) {
|
void FrameMain::OnVideoDetach(agi::OptionValue const& opt) {
|
||||||
if (detach) {
|
if (opt.GetBool())
|
||||||
if (!context->detachedVideo) {
|
SetDisplayMode(0, -1);
|
||||||
context->detachedVideo = new DialogDetachedVideo(this, context.get(), videoBox->videoDisplay->GetClientSize());
|
else if (context->videoController->IsLoaded())
|
||||||
context->detachedVideo->Show();
|
SetDisplayMode(1, -1);
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (context->detachedVideo) {
|
|
||||||
context->detachedVideo->Destroy();
|
|
||||||
context->detachedVideo = 0;
|
|
||||||
SetDisplayMode(1,-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameMain::StatusTimeout(wxString text,int ms) {
|
void FrameMain::StatusTimeout(wxString text,int ms) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ class VideoDisplay;
|
||||||
class VideoSlider;
|
class VideoSlider;
|
||||||
class VideoZoomSlider;
|
class VideoZoomSlider;
|
||||||
|
|
||||||
namespace agi { struct Context; }
|
namespace agi { struct Context; class OptionValue; }
|
||||||
namespace Automation4 { class FeatureMacro; class ScriptManager; }
|
namespace Automation4 { class FeatureMacro; class ScriptManager; }
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
|
@ -84,7 +84,6 @@ public:
|
||||||
/// @param audio -1: leave unchanged; 0: hide; 1: show
|
/// @param audio -1: leave unchanged; 0: hide; 1: show
|
||||||
void SetDisplayMode(int showVid, int showAudio);
|
void SetDisplayMode(int showVid, int showAudio);
|
||||||
void LoadSubtitles(wxString filename,wxString charset="");
|
void LoadSubtitles(wxString filename,wxString charset="");
|
||||||
void DetachVideo(bool detach=true);
|
|
||||||
|
|
||||||
agi::scoped_ptr<agi::Context> context;
|
agi::scoped_ptr<agi::Context> context;
|
||||||
|
|
||||||
|
@ -139,6 +138,7 @@ private:
|
||||||
void OnAudioClose();
|
void OnAudioClose();
|
||||||
|
|
||||||
void OnVideoOpen();
|
void OnVideoOpen();
|
||||||
|
void OnVideoDetach(agi::OptionValue const& opt);
|
||||||
|
|
||||||
void OnSubtitlesOpen();
|
void OnSubtitlesOpen();
|
||||||
void OnSubtitlesSave();
|
void OnSubtitlesSave();
|
||||||
|
|
Loading…
Reference in a new issue