From 08307674a06475423ae3517b4b7a8cbf46613c78 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 29 Sep 2011 05:33:10 +0000 Subject: [PATCH] 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. --- aegisub/src/audio_box.cpp | 26 ++++++++++++++++++++++++-- aegisub/src/audio_box.h | 2 ++ aegisub/src/audio_karaoke.cpp | 16 +++++++--------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/aegisub/src/audio_box.cpp b/aegisub/src/audio_box.cpp index c8cfc14a7..6451b0845 100644 --- a/aegisub/src/audio_box.cpp +++ b/aegisub/src/audio_box.cpp @@ -122,6 +122,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context) MainSizer->Add(TopSizer,1,wxEXPAND|wxALL,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->Show(context->karaoke, false); MainSizer->AddSpacer(3); panel->SetSizer(MainSizer); @@ -138,7 +139,7 @@ BEGIN_EVENT_TABLE(AudioBox,wxSashWindow) EVT_COMMAND_SCROLL(Audio_Horizontal_Zoom, AudioBox::OnHorizontalZoom) EVT_COMMAND_SCROLL(Audio_Vertical_Zoom, AudioBox::OnVerticalZoom) EVT_COMMAND_SCROLL(Audio_Volume, AudioBox::OnVolume) -END_EVENT_TABLE() +END_EVENT_TABLE(); void AudioBox::OnSashDrag(wxSashEvent &event) { 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); - OPT_SET("Audio/Display Height")->SetInt(new_height); SetMinSize(wxSize(-1, new_height)); 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) { @@ -181,3 +188,18 @@ void AudioBox::OnVerticalLink(agi::OptionValue const& opt) { } 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(); +} diff --git a/aegisub/src/audio_box.h b/aegisub/src/audio_box.h index da79b96f0..57bddc7eb 100644 --- a/aegisub/src/audio_box.h +++ b/aegisub/src/audio_box.h @@ -87,5 +87,7 @@ public: AudioBox(wxWindow *parent, agi::Context *context); ~AudioBox(); + void ShowKaraokeBar(bool show); + DECLARE_EVENT_TABLE() }; diff --git a/aegisub/src/audio_karaoke.cpp b/aegisub/src/audio_karaoke.cpp index aab45cf68..66e383e21 100644 --- a/aegisub/src/audio_karaoke.cpp +++ b/aegisub/src/audio_karaoke.cpp @@ -42,11 +42,12 @@ #include "include/aegisub/context.h" -#include "audio_timing.h" #include "ass_dialogue.h" #include "ass_file.h" #include "ass_karaoke.h" #include "ass_override.h" +#include "audio_box.h" +#include "audio_timing.h" #include "libresrc/libresrc.h" #include "main.h" #include "selection_controller.h" @@ -101,7 +102,10 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c) c->selectionController->AddSelectionListener(this); - SetEnabled(false); + accept_button->Enable(false); + cancel_button->Enable(false); + enabled = false; + c->audioController->SetTimingController(CreateDialogueTimingController(c)); } AudioKaraoke::~AudioKaraoke() { @@ -124,25 +128,19 @@ void AudioKaraoke::OnFileChanged(int type) { } void AudioKaraoke::SetEnabled(bool en) { - wxSize new_size; if (en) { LoadFromLine(); enabled = true; c->audioController->SetTimingController(CreateKaraokeTimingController(c, kara.get(), file_changed)); - new_size = wxSize(-1, accept_button->GetSize().GetHeight() + 4); } else { accept_button->Enable(false); cancel_button->Enable(false); enabled = false; c->audioController->SetTimingController(CreateDialogueTimingController(c)); - new_size = wxSize(-1, 0); } - SetMinSize(new_size); - SetMaxSize(new_size); - SetSize(new_size); - GetParent()->Layout(); + c->audioBox->ShowKaraokeBar(en); split_area->SetSize(GetSize().GetWidth(), -1); if (en)