Make AudioBox responsible for showing and hiding the karaoke bar, and make it shift the subs box down rather than shrink the audio display

Originally committed to SVN as r5678.
This commit is contained in:
Thomas Goyne 2011-09-29 05:33:10 +00:00
parent 094a6d081c
commit 08307674a0
3 changed files with 33 additions and 11 deletions

View file

@ -122,6 +122,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
MainSizer->Add(TopSizer,1,wxEXPAND|wxALL,3); MainSizer->Add(TopSizer,1,wxEXPAND|wxALL,3);
MainSizer->Add(toolbar::GetToolbar(panel, "audio", context, "Audio"),0,wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT,3); MainSizer->Add(toolbar::GetToolbar(panel, "audio", context, "Audio"),0,wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT,3);
MainSizer->Add(context->karaoke,0,wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT,3); MainSizer->Add(context->karaoke,0,wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT,3);
MainSizer->Show(context->karaoke, false);
MainSizer->AddSpacer(3); MainSizer->AddSpacer(3);
panel->SetSizer(MainSizer); panel->SetSizer(MainSizer);
@ -138,7 +139,7 @@ BEGIN_EVENT_TABLE(AudioBox,wxSashWindow)
EVT_COMMAND_SCROLL(Audio_Horizontal_Zoom, AudioBox::OnHorizontalZoom) EVT_COMMAND_SCROLL(Audio_Horizontal_Zoom, AudioBox::OnHorizontalZoom)
EVT_COMMAND_SCROLL(Audio_Vertical_Zoom, AudioBox::OnVerticalZoom) EVT_COMMAND_SCROLL(Audio_Vertical_Zoom, AudioBox::OnVerticalZoom)
EVT_COMMAND_SCROLL(Audio_Volume, AudioBox::OnVolume) EVT_COMMAND_SCROLL(Audio_Volume, AudioBox::OnVolume)
END_EVENT_TABLE() END_EVENT_TABLE();
void AudioBox::OnSashDrag(wxSashEvent &event) { void AudioBox::OnSashDrag(wxSashEvent &event) {
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
@ -146,9 +147,15 @@ void AudioBox::OnSashDrag(wxSashEvent &event) {
int new_height = std::min(event.GetDragRect().GetHeight(), GetParent()->GetSize().GetHeight() - 1); int new_height = std::min(event.GetDragRect().GetHeight(), GetParent()->GetSize().GetHeight() - 1);
OPT_SET("Audio/Display Height")->SetInt(new_height);
SetMinSize(wxSize(-1, new_height)); SetMinSize(wxSize(-1, new_height));
GetParent()->Layout(); GetParent()->Layout();
// Karaoke mode is always disabled when the audio box is first opened, so
// the initial height shouldn't include it
if (context->karaoke->IsEnabled())
new_height -= context->karaoke->GetSize().GetHeight() + 3;
OPT_SET("Audio/Display Height")->SetInt(new_height);
} }
void AudioBox::OnHorizontalZoom(wxScrollEvent &event) { void AudioBox::OnHorizontalZoom(wxScrollEvent &event) {
@ -181,3 +188,18 @@ void AudioBox::OnVerticalLink(agi::OptionValue const& opt) {
} }
VolumeBar->Enable(!opt.GetBool()); VolumeBar->Enable(!opt.GetBool());
} }
void AudioBox::ShowKaraokeBar(bool show) {
wxSizer *panel_sizer = panel->GetSizer();
int new_height = GetSize().GetHeight();
int kara_height = context->karaoke->GetSize().GetHeight() + 3;
if (panel_sizer->IsShown(context->karaoke))
new_height -= kara_height;
else
new_height += kara_height;
panel_sizer->Show(context->karaoke, show);
SetMinSize(wxSize(-1, new_height));
GetParent()->Layout();
}

View file

@ -87,5 +87,7 @@ public:
AudioBox(wxWindow *parent, agi::Context *context); AudioBox(wxWindow *parent, agi::Context *context);
~AudioBox(); ~AudioBox();
void ShowKaraokeBar(bool show);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View file

@ -42,11 +42,12 @@
#include "include/aegisub/context.h" #include "include/aegisub/context.h"
#include "audio_timing.h"
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "ass_karaoke.h" #include "ass_karaoke.h"
#include "ass_override.h" #include "ass_override.h"
#include "audio_box.h"
#include "audio_timing.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "main.h" #include "main.h"
#include "selection_controller.h" #include "selection_controller.h"
@ -101,7 +102,10 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
c->selectionController->AddSelectionListener(this); c->selectionController->AddSelectionListener(this);
SetEnabled(false); accept_button->Enable(false);
cancel_button->Enable(false);
enabled = false;
c->audioController->SetTimingController(CreateDialogueTimingController(c));
} }
AudioKaraoke::~AudioKaraoke() { AudioKaraoke::~AudioKaraoke() {
@ -124,25 +128,19 @@ void AudioKaraoke::OnFileChanged(int type) {
} }
void AudioKaraoke::SetEnabled(bool en) { void AudioKaraoke::SetEnabled(bool en) {
wxSize new_size;
if (en) { if (en) {
LoadFromLine(); LoadFromLine();
enabled = true; enabled = true;
c->audioController->SetTimingController(CreateKaraokeTimingController(c, kara.get(), file_changed)); c->audioController->SetTimingController(CreateKaraokeTimingController(c, kara.get(), file_changed));
new_size = wxSize(-1, accept_button->GetSize().GetHeight() + 4);
} }
else { else {
accept_button->Enable(false); accept_button->Enable(false);
cancel_button->Enable(false); cancel_button->Enable(false);
enabled = false; enabled = false;
c->audioController->SetTimingController(CreateDialogueTimingController(c)); c->audioController->SetTimingController(CreateDialogueTimingController(c));
new_size = wxSize(-1, 0);
} }
SetMinSize(new_size); c->audioBox->ShowKaraokeBar(en);
SetMaxSize(new_size);
SetSize(new_size);
GetParent()->Layout();
split_area->SetSize(GetSize().GetWidth(), -1); split_area->SetSize(GetSize().GetWidth(), -1);
if (en) if (en)