mirror of https://github.com/odrling/Aegisub
Store the video display and slider in the context directly rather than going through the video box. Fxes a crash when detaching video.
Originally committed to SVN as r5845.
This commit is contained in:
parent
0b742ef3c1
commit
feb752c24c
|
@ -143,7 +143,7 @@ struct video_aspect_custom : public validator_video_loaded {
|
|||
wxString denum = value.Mid(pos+1);
|
||||
if (num.ToDouble(&a) && denum.ToDouble(&b) && b!=0) {
|
||||
numval = a/b;
|
||||
if (scale) c->videoBox->videoDisplay->SetZoom(b / c->videoController->GetHeight());
|
||||
if (scale) c->videoDisplay->SetZoom(b / c->videoController->GetHeight());
|
||||
}
|
||||
}
|
||||
else numval = 0.0;
|
||||
|
@ -238,7 +238,7 @@ struct video_copy_coordinates : public validator_video_loaded {
|
|||
|
||||
void operator()(agi::Context *c) {
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->SetData(new wxTextDataObject(c->videoBox->videoDisplay->GetMousePosition().Str()));
|
||||
wxTheClipboard->SetData(new wxTextDataObject(c->videoDisplay->GetMousePosition().Str()));
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ struct video_detach : public validator_video_loaded {
|
|||
|
||||
void operator()(agi::Context *c) {
|
||||
if (!c->detachedVideo) {
|
||||
c->detachedVideo = new DialogDetachedVideo(c, c->videoBox->videoDisplay->GetClientSize());
|
||||
c->detachedVideo = new DialogDetachedVideo(c, c->videoDisplay->GetClientSize());
|
||||
}
|
||||
else {
|
||||
c->detachedVideo->Close();
|
||||
|
@ -288,12 +288,12 @@ struct video_focus_seek : public validator_video_loaded {
|
|||
|
||||
void operator()(agi::Context *c) {
|
||||
wxWindow *curFocus = wxWindow::FindFocus();
|
||||
if (curFocus == c->videoBox->videoSlider) {
|
||||
if (curFocus == c->videoSlider) {
|
||||
if (c->previousFocus) c->previousFocus->SetFocus();
|
||||
}
|
||||
else {
|
||||
c->previousFocus = curFocus;
|
||||
c->videoBox->videoSlider->SetFocus();
|
||||
c->videoSlider->SetFocus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -510,7 +510,7 @@ struct video_jump : public validator_video_loaded {
|
|||
c->videoController->Stop();
|
||||
if (c->videoController->IsLoaded()) {
|
||||
DialogJumpTo(c).ShowModal();
|
||||
c->videoBox->videoSlider->SetFocus();
|
||||
c->videoSlider->SetFocus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -632,7 +632,7 @@ struct video_show_overscan : public validator_video_loaded {
|
|||
|
||||
void operator()(agi::Context *c) {
|
||||
OPT_SET("Video/Overscan Mask")->SetBool(!OPT_GET("Video/Overscan Mask")->GetBool());
|
||||
c->videoBox->videoDisplay->Render();
|
||||
c->videoDisplay->Render();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -646,12 +646,12 @@ public:
|
|||
CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO)
|
||||
|
||||
bool IsActive(const agi::Context *c) {
|
||||
return c->videoBox->videoDisplay->GetZoom() == 1.;
|
||||
return c->videoDisplay->GetZoom() == 1.;
|
||||
}
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoController->Stop();
|
||||
c->videoBox->videoDisplay->SetZoom(1.);
|
||||
c->videoDisplay->SetZoom(1.);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -678,12 +678,12 @@ public:
|
|||
CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO)
|
||||
|
||||
bool IsActive(const agi::Context *c) {
|
||||
return c->videoBox->videoDisplay->GetZoom() == 2.;
|
||||
return c->videoDisplay->GetZoom() == 2.;
|
||||
}
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoController->Stop();
|
||||
c->videoBox->videoDisplay->SetZoom(2.);
|
||||
c->videoDisplay->SetZoom(2.);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -697,12 +697,12 @@ public:
|
|||
CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO)
|
||||
|
||||
bool IsActive(const agi::Context *c) {
|
||||
return c->videoBox->videoDisplay->GetZoom() == .5;
|
||||
return c->videoDisplay->GetZoom() == .5;
|
||||
}
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoController->Stop();
|
||||
c->videoBox->videoDisplay->SetZoom(.5);
|
||||
c->videoDisplay->SetZoom(.5);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -714,7 +714,7 @@ struct video_zoom_in : public validator_video_attached {
|
|||
STR_HELP("Zoom video in.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetZoom(c->videoBox->videoDisplay->GetZoom() + .125);
|
||||
c->videoDisplay->SetZoom(c->videoDisplay->GetZoom() + .125);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -726,7 +726,7 @@ struct video_zoom_out : public validator_video_attached {
|
|||
STR_HELP("Zoom video out.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetZoom(c->videoBox->videoDisplay->GetZoom() - .125);
|
||||
c->videoDisplay->SetZoom(c->videoDisplay->GetZoom() - .125);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace {
|
|||
STR_HELP("Standard mode, double click sets position.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetTool(new VisualToolCross(c->videoBox->videoDisplay, c));
|
||||
c->videoDisplay->SetTool(new VisualToolCross(c->videoDisplay, c));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@ namespace {
|
|||
STR_HELP("Drag subtitles.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetTool(new VisualToolDrag(c->videoBox->videoDisplay, c));
|
||||
c->videoDisplay->SetTool(new VisualToolDrag(c->videoDisplay, c));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -78,7 +78,7 @@ namespace {
|
|||
STR_HELP("Rotate subtitles on their Z axis.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetTool(new VisualToolRotateZ(c->videoBox->videoDisplay, c));
|
||||
c->videoDisplay->SetTool(new VisualToolRotateZ(c->videoDisplay, c));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace {
|
|||
STR_HELP("Rotate subtitles on their X and Y axes.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetTool(new VisualToolRotateXY(c->videoBox->videoDisplay, c));
|
||||
c->videoDisplay->SetTool(new VisualToolRotateXY(c->videoDisplay, c));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace {
|
|||
STR_HELP("Scale subtitles on X and Y axes.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetTool(new VisualToolScale(c->videoBox->videoDisplay, c));
|
||||
c->videoDisplay->SetTool(new VisualToolScale(c->videoDisplay, c));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace {
|
|||
STR_HELP("Clip subtitles to a rectangle.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetTool(new VisualToolClip(c->videoBox->videoDisplay, c));
|
||||
c->videoDisplay->SetTool(new VisualToolClip(c->videoDisplay, c));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -122,7 +122,7 @@ namespace {
|
|||
STR_HELP("Clip subtitles to a vectorial arean.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->videoBox->videoDisplay->SetTool(new VisualToolVectorClip(c->videoBox->videoDisplay, c));
|
||||
c->videoDisplay->SetTool(new VisualToolVectorClip(c->videoDisplay, c));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
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)
|
||||
, old_display(context->videoDisplay)
|
||||
, old_slider(context->videoSlider)
|
||||
, video_open(context->videoController->AddVideoOpenListener(&DialogDetachedVideo::OnVideoOpen, this))
|
||||
{
|
||||
// Set obscure stuff
|
||||
|
@ -104,6 +106,8 @@ DialogDetachedVideo::~DialogDetachedVideo() { }
|
|||
|
||||
void DialogDetachedVideo::OnClose(wxCloseEvent&) {
|
||||
context->detachedVideo = 0;
|
||||
context->videoDisplay = old_display;
|
||||
context->videoSlider = old_slider;
|
||||
OPT_SET("Video/Detached/Enabled")->SetBool(false);
|
||||
Destroy();
|
||||
}
|
||||
|
@ -125,6 +129,8 @@ void DialogDetachedVideo::OnKeyDown(wxKeyEvent &evt) {
|
|||
void DialogDetachedVideo::OnVideoOpen() {
|
||||
if (!context->videoController->IsLoaded()) {
|
||||
context->detachedVideo = 0;
|
||||
context->videoDisplay = old_display;
|
||||
context->videoSlider = old_slider;
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
namespace agi { struct Context; }
|
||||
class PersistLocation;
|
||||
class VideoBox;
|
||||
class VideoDisplay;
|
||||
|
||||
/// DOCME
|
||||
/// @class DialogDetachedVideo
|
||||
|
@ -52,6 +53,8 @@ class VideoBox;
|
|||
/// DOCME
|
||||
class DialogDetachedVideo : public wxDialog {
|
||||
agi::Context *context;
|
||||
VideoDisplay *old_display;
|
||||
wxWindow *old_slider;
|
||||
agi::signal::Connection video_open;
|
||||
agi::scoped_ptr<PersistLocation> persist;
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ void FrameMain::InitContents() {
|
|||
Search.context = context.get();
|
||||
|
||||
StartupLog("Create video box");
|
||||
context->videoBox = videoBox = new VideoBox(Panel, false, context.get());
|
||||
videoBox = new VideoBox(Panel, false, context.get());
|
||||
|
||||
StartupLog("Create audio box");
|
||||
context->audioBox = audioBox = new AudioBox(Panel, context.get());
|
||||
|
|
|
@ -9,8 +9,8 @@ class DialogTranslation;
|
|||
template<class T> class SelectionController;
|
||||
class SubsTextEditCtrl;
|
||||
class SubtitlesGrid;
|
||||
class VideoBox;
|
||||
class VideoContext;
|
||||
class VideoDisplay;
|
||||
class wxWindow;
|
||||
namespace Automation4 { class ScriptManager; }
|
||||
|
||||
|
@ -29,6 +29,7 @@ struct Context {
|
|||
// Things that should probably be in some sort of UI-context-model
|
||||
wxWindow *parent;
|
||||
wxWindow *previousFocus;
|
||||
wxWindow *videoSlider;
|
||||
|
||||
// Views (i.e. things that should eventually not be here at all)
|
||||
AudioBox *audioBox;
|
||||
|
@ -38,7 +39,7 @@ struct Context {
|
|||
DialogTranslation *translationAssistant;
|
||||
SubsTextEditCtrl *editBox;
|
||||
SubtitlesGrid *subsGrid;
|
||||
VideoBox *videoBox;
|
||||
VideoDisplay *videoDisplay;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -137,6 +137,8 @@ VideoDisplay::VideoDisplay(
|
|||
|
||||
SetCursor(wxNullCursor);
|
||||
|
||||
c->videoDisplay = this;
|
||||
|
||||
if (con->videoController->IsLoaded())
|
||||
OnVideoOpen();
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ VideoSlider::VideoSlider (wxWindow* parent, agi::Context *c)
|
|||
slots.push_back(c->videoController->AddVideoOpenListener(&VideoSlider::VideoOpened, this));
|
||||
slots.push_back(c->videoController->AddKeyframesListener(&VideoSlider::KeyframesChanged, this));
|
||||
|
||||
c->videoSlider = this;
|
||||
|
||||
if (c->videoController->IsLoaded()) {
|
||||
VideoOpened();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue