From 8a6f04512ba3480494219454a1c497d2decb3806 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 12 Jan 2008 03:29:45 +0000 Subject: [PATCH] Made detached video window remember its last position/maximized state - #492 Originally committed to SVN as r1692. --- aegisub/dialog_detached_video.cpp | 21 +++++++++++++++++++-- aegisub/dialog_detached_video.h | 1 + aegisub/options.cpp | 5 ++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/aegisub/dialog_detached_video.cpp b/aegisub/dialog_detached_video.cpp index 7ec562bc2..ff12b1a2c 100644 --- a/aegisub/dialog_detached_video.cpp +++ b/aegisub/dialog_detached_video.cpp @@ -55,6 +55,12 @@ DialogDetachedVideo::DialogDetachedVideo(FrameMain *par) // Set parent parent = par; + // Set up window + int x = Options.AsInt(_T("Detached video last x")); + int y = Options.AsInt(_T("Detached video last y")); + if (x != -1 && y != -1) SetPosition(wxPoint(x,y)); + if (Options.AsBool(_T("Detached video maximized"))) Maximize(); + // Set obscure stuff SetExtraStyle(GetExtraStyle() & (~wxWS_EX_BLOCK_EVENTS) | wxWS_EX_PROCESS_UI_UPDATES); @@ -85,6 +91,8 @@ DialogDetachedVideo::DialogDetachedVideo(FrameMain *par) ///////////// // Destructor DialogDetachedVideo::~DialogDetachedVideo() { + Options.SetBool(_T("Detached video maximized"),IsMaximized()); + Options.Save(); } @@ -93,6 +101,7 @@ DialogDetachedVideo::~DialogDetachedVideo() { BEGIN_EVENT_TABLE(DialogDetachedVideo,wxDialog) EVT_KEY_DOWN(DialogDetachedVideo::OnKey) EVT_CLOSE(DialogDetachedVideo::OnClose) + EVT_MOVE(DialogDetachedVideo::OnMove) END_EVENT_TABLE() @@ -109,9 +118,17 @@ void DialogDetachedVideo::OnKey(wxKeyEvent &event) { // Close window void DialogDetachedVideo::OnClose(wxCloseEvent &event) { FrameMain *par = parent; + Options.SetBool(_T("Detached video"),false); Destroy(); par->detachedVideo = NULL; par->SetDisplayMode(-1,-1); - Options.SetBool(_T("Detached video"),false); - Options.Save(); +} + + +/////////////// +// Move window +void DialogDetachedVideo::OnMove(wxMoveEvent &event) { + wxPoint pos = event.GetPosition(); + Options.SetInt(_T("Detached video last x"),pos.x); + Options.SetInt(_T("Detached video last y"),pos.y); } diff --git a/aegisub/dialog_detached_video.h b/aegisub/dialog_detached_video.h index 1629ffee6..e999d5688 100644 --- a/aegisub/dialog_detached_video.h +++ b/aegisub/dialog_detached_video.h @@ -55,6 +55,7 @@ private: void OnKey(wxKeyEvent &event); void OnClose(wxCloseEvent &event); + void OnMove(wxMoveEvent &event); public: DialogDetachedVideo(FrameMain *parent); diff --git a/aegisub/options.cpp b/aegisub/options.cpp index 37e26addf..67d08f462 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -148,7 +148,6 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) { SetModificationType(MOD_VIDEO); SetBool(_T("Show keyframes on video slider"),true); SetBool(_T("Show overscan mask"),false); - SetBool(_T("Detached video"),false); // Video Provider (Advanced) SetModificationType(MOD_VIDEO_RELOAD); @@ -333,6 +332,10 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) { SetInt(_T("Audio Sample Rate"),0); SetBool(_T("Video Visual Realtime"),true); + SetBool(_T("Detached video"),false); + SetInt(_T("Detached video last x"),-1); + SetInt(_T("Detached video last y"),-1); + SetBool(_T("Detached video maximized"),false); SetInt(_T("Timing processor key start before thres"),5); SetInt(_T("Timing processor key start after thres"),4);