mirror of https://github.com/odrling/Aegisub
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:
parent
094a6d081c
commit
08307674a0
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -87,5 +87,7 @@ public:
|
|||
AudioBox(wxWindow *parent, agi::Context *context);
|
||||
~AudioBox();
|
||||
|
||||
void ShowKaraokeBar(bool show);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue