Made the styling assistant modeless so the user can access other controls within aegisub without having to close the styling assistant, fixes #397

Originally committed to SVN as r2921.
This commit is contained in:
harukalover 2009-05-14 07:02:01 +00:00
parent ffa5a2021d
commit f4808b82a0
5 changed files with 47 additions and 9 deletions

View File

@ -59,7 +59,7 @@
/////////////// ///////////////
// Constructor // Constructor
DialogStyling::DialogStyling (wxWindow *parent,SubtitlesGrid *_grid) : DialogStyling::DialogStyling (wxWindow *parent,SubtitlesGrid *_grid) :
wxDialog (parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxRESIZE_BORDER) wxDialog (parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX)
{ {
// Set icon // Set icon
SetIcon(BitmapToIcon(wxBITMAP(styling_toolbutton))); SetIcon(BitmapToIcon(wxBITMAP(styling_toolbutton)));
@ -115,10 +115,8 @@ wxDialog (parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize,
RightMiddle->AddStretchSpacer(1); RightMiddle->AddStretchSpacer(1);
// Rest of right sizer // Rest of right sizer
wxButton *PlayVideoButton = new wxButton(this,BUTTON_PLAY_VIDEO,_("Play Video")); PlayVideoButton = new wxButton(this,BUTTON_PLAY_VIDEO,_("Play Video"));
wxButton *PlayAudioButton = new wxButton(this,BUTTON_PLAY_AUDIO,_("Play Audio")); PlayAudioButton = new wxButton(this,BUTTON_PLAY_AUDIO,_("Play Audio"));
PlayVideoButton->Enable(video->IsLoaded());
PlayAudioButton->Enable(audio->loaded);
RightBottom->AddStretchSpacer(1); RightBottom->AddStretchSpacer(1);
RightBottom->Add(PlayAudioButton,0,wxLEFT | wxRIGHT | wxBOTTOM,5); RightBottom->Add(PlayAudioButton,0,wxLEFT | wxRIGHT | wxBOTTOM,5);
RightBottom->Add(PlayVideoButton,0,wxBOTTOM | wxRIGHT,5); RightBottom->Add(PlayVideoButton,0,wxBOTTOM | wxRIGHT,5);
@ -179,7 +177,6 @@ DialogStyling::~DialogStyling () {
// Jump to line // Jump to line
void DialogStyling::JumpToLine(int n) { void DialogStyling::JumpToLine(int n) {
// Check stuff // Check stuff
if (linen == n) return;
if (n == -1) return; if (n == -1) return;
// Get line // Get line
@ -195,7 +192,14 @@ void DialogStyling::JumpToLine(int n) {
// Set focus // Set focus
TypeBox->SetFocus(); TypeBox->SetFocus();
if (TypeBox->GetValue().IsEmpty()) TypeBox->SetValue(Styles->GetString(0)); bool matched = false;
for (size_t i = 0; i < Styles->GetCount(); i++) {
if (TypeBox->GetValue().IsSameAs(Styles->GetString(i),true)) {
matched = true;
break;
}
}
if (!matched || TypeBox->GetValue().IsEmpty()) TypeBox->SetValue(Styles->GetString(0));
TypeBox->SetSelection(0,TypeBox->GetValue().Length()); TypeBox->SetSelection(0,TypeBox->GetValue().Length());
// Update grid // Update grid
@ -234,6 +238,7 @@ void DialogStyling::SetStyle (wxString curName, bool jump) {
/////////////// ///////////////
// Event table // Event table
BEGIN_EVENT_TABLE(DialogStyling,wxDialog) BEGIN_EVENT_TABLE(DialogStyling,wxDialog)
EVT_ACTIVATE(DialogStyling::OnActivate)
EVT_BUTTON(BUTTON_PLAY_VIDEO, DialogStyling::OnPlayVideoButton) EVT_BUTTON(BUTTON_PLAY_VIDEO, DialogStyling::OnPlayVideoButton)
EVT_BUTTON(BUTTON_PLAY_AUDIO, DialogStyling::OnPlayAudioButton) EVT_BUTTON(BUTTON_PLAY_AUDIO, DialogStyling::OnPlayAudioButton)
//EVT_TEXT_ENTER(ENTER_STYLE_BOX, DialogStyling::OnStyleBoxEnter) //EVT_TEXT_ENTER(ENTER_STYLE_BOX, DialogStyling::OnStyleBoxEnter)
@ -243,6 +248,31 @@ BEGIN_EVENT_TABLE(DialogStyling,wxDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
///////////////////////////
// Dialog was De/Activated
void DialogStyling::OnActivate(wxActivateEvent &event) {
// Dialog lost focus
if (!event.GetActive()) {
if (!PreviewCheck->IsChecked()) {
grid->ass->FlagAsModified(_("styling assistant"));
grid->CommitChanges();
}
return;
}
// Enable/disable play video/audio buttons
PlayVideoButton->Enable(video->IsLoaded());
PlayAudioButton->Enable(audio->loaded);
// Update grid
if (grid->ass != AssFile::top)
grid->LoadFromAss(AssFile::top,false,true);
// Fix style list
Styles->Set(grid->ass->GetStyles());
// Fix line selection
linen = grid->GetFirstSelRow();
JumpToLine(linen);
}
/////////////// ///////////////
// Key pressed // Key pressed
void DialogStyling::OnKeyDown(wxKeyEvent &event) { void DialogStyling::OnKeyDown(wxKeyEvent &event) {

View File

@ -86,6 +86,8 @@ private:
wxListBox *Styles; wxListBox *Styles;
StyleEditBox *TypeBox; StyleEditBox *TypeBox;
wxCheckBox *PreviewCheck; wxCheckBox *PreviewCheck;
wxButton *PlayVideoButton;
wxButton *PlayAudioButton;
void OnStyleBoxModified (wxCommandEvent &event); void OnStyleBoxModified (wxCommandEvent &event);
void OnStyleBoxEnter (wxCommandEvent &event); void OnStyleBoxEnter (wxCommandEvent &event);
@ -93,6 +95,7 @@ private:
void OnKeyDown(wxKeyEvent &event); void OnKeyDown(wxKeyEvent &event);
void OnPlayVideoButton(wxCommandEvent &event); void OnPlayVideoButton(wxCommandEvent &event);
void OnPlayAudioButton(wxCommandEvent &event); void OnPlayAudioButton(wxCommandEvent &event);
void OnActivate(wxActivateEvent &event);
void SetStyle (wxString curName,bool jump=true); void SetStyle (wxString curName,bool jump=true);

View File

@ -76,6 +76,7 @@
#include "standard_paths.h" #include "standard_paths.h"
#include "keyframe.h" #include "keyframe.h"
#include "help_button.h" #include "help_button.h"
#include "dialog_styling_assistant.h"
#ifdef WITH_AUTOMATION #ifdef WITH_AUTOMATION
#include "auto4_base.h" #include "auto4_base.h"
#endif #endif
@ -133,6 +134,7 @@ FrameMain::FrameMain (wxArrayString args)
showVideo = true; showVideo = true;
showAudio = true; showAudio = true;
detachedVideo = NULL; detachedVideo = NULL;
stylingAssistant = NULL;
InitContents(); InitContents();
Show(); Show();
@ -578,6 +580,7 @@ void FrameMain::InitContents() {
// Deinitialize controls // Deinitialize controls
void FrameMain::DeInitContents() { void FrameMain::DeInitContents() {
if (detachedVideo) detachedVideo->Destroy(); if (detachedVideo) detachedVideo->Destroy();
if (stylingAssistant) stylingAssistant->Destroy();
AssFile::StackReset(); AssFile::StackReset();
delete AssFile::top; delete AssFile::top;
delete EditBox; delete EditBox;

View File

@ -62,6 +62,7 @@ class SubsEditBox;
class AudioBox; class AudioBox;
class VideoBox; class VideoBox;
class DialogDetachedVideo; class DialogDetachedVideo;
class DialogStyling;
class AegisubFileDropTarget; class AegisubFileDropTarget;
namespace Automation4 { class FeatureMacro; class ScriptManager; }; namespace Automation4 { class FeatureMacro; class ScriptManager; };
@ -268,6 +269,7 @@ public:
AudioBox *audioBox; AudioBox *audioBox;
VideoBox *videoBox; VideoBox *videoBox;
DialogDetachedVideo *detachedVideo; DialogDetachedVideo *detachedVideo;
DialogStyling *stylingAssistant;
wxBoxSizer *MainSizer; wxBoxSizer *MainSizer;
wxBoxSizer *TopSizer; wxBoxSizer *TopSizer;

View File

@ -1491,8 +1491,8 @@ void FrameMain::OnSort (wxCommandEvent &event) {
// Open styling assistant // Open styling assistant
void FrameMain::OnOpenStylingAssistant (wxCommandEvent &event) { void FrameMain::OnOpenStylingAssistant (wxCommandEvent &event) {
VideoContext::Get()->Stop(); VideoContext::Get()->Stop();
DialogStyling styling(this,SubsBox); if (!stylingAssistant) stylingAssistant = new DialogStyling(this,SubsBox);
styling.ShowModal(); stylingAssistant->Show(true);
} }