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 6a42e17409
commit d8e6d94754
5 changed files with 47 additions and 9 deletions

View file

@ -59,7 +59,7 @@
///////////////
// Constructor
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
SetIcon(BitmapToIcon(wxBITMAP(styling_toolbutton)));
@ -115,10 +115,8 @@ wxDialog (parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize,
RightMiddle->AddStretchSpacer(1);
// Rest of right sizer
wxButton *PlayVideoButton = new wxButton(this,BUTTON_PLAY_VIDEO,_("Play Video"));
wxButton *PlayAudioButton = new wxButton(this,BUTTON_PLAY_AUDIO,_("Play Audio"));
PlayVideoButton->Enable(video->IsLoaded());
PlayAudioButton->Enable(audio->loaded);
PlayVideoButton = new wxButton(this,BUTTON_PLAY_VIDEO,_("Play Video"));
PlayAudioButton = new wxButton(this,BUTTON_PLAY_AUDIO,_("Play Audio"));
RightBottom->AddStretchSpacer(1);
RightBottom->Add(PlayAudioButton,0,wxLEFT | wxRIGHT | wxBOTTOM,5);
RightBottom->Add(PlayVideoButton,0,wxBOTTOM | wxRIGHT,5);
@ -179,7 +177,6 @@ DialogStyling::~DialogStyling () {
// Jump to line
void DialogStyling::JumpToLine(int n) {
// Check stuff
if (linen == n) return;
if (n == -1) return;
// Get line
@ -195,7 +192,14 @@ void DialogStyling::JumpToLine(int n) {
// Set focus
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());
// Update grid
@ -234,6 +238,7 @@ void DialogStyling::SetStyle (wxString curName, bool jump) {
///////////////
// Event table
BEGIN_EVENT_TABLE(DialogStyling,wxDialog)
EVT_ACTIVATE(DialogStyling::OnActivate)
EVT_BUTTON(BUTTON_PLAY_VIDEO, DialogStyling::OnPlayVideoButton)
EVT_BUTTON(BUTTON_PLAY_AUDIO, DialogStyling::OnPlayAudioButton)
//EVT_TEXT_ENTER(ENTER_STYLE_BOX, DialogStyling::OnStyleBoxEnter)
@ -243,6 +248,31 @@ BEGIN_EVENT_TABLE(DialogStyling,wxDialog)
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
void DialogStyling::OnKeyDown(wxKeyEvent &event) {

View file

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

View file

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

View file

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

View file

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