mirror of https://github.com/odrling/Aegisub
Move the audio box height management code from FrameMain to AudioBox
Originally committed to SVN as r5677.
This commit is contained in:
parent
c211975b65
commit
094a6d081c
|
@ -40,6 +40,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/slider.h>
|
||||
#include <wx/scrolbar.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/slider.h>
|
||||
|
@ -68,25 +69,29 @@
|
|||
#include "selection_controller.h"
|
||||
#include "utils.h"
|
||||
|
||||
enum AudioBoxControlIDs {
|
||||
enum {
|
||||
Audio_Horizontal_Zoom = 1600,
|
||||
Audio_Vertical_Zoom,
|
||||
Audio_Volume,
|
||||
};
|
||||
|
||||
AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
|
||||
: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxBORDER_RAISED)
|
||||
, audioDisplay(new AudioDisplay(this, context->audioController, context))
|
||||
: wxSashWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxSW_3D | wxCLIP_CHILDREN)
|
||||
, controller(context->audioController)
|
||||
, context(context)
|
||||
, panel(new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_RAISED))
|
||||
, audioDisplay(new AudioDisplay(panel, context->audioController, context))
|
||||
, HorizontalZoom(new wxSlider(panel, Audio_Horizontal_Zoom, 0, -50, 30, wxDefaultPosition, wxSize(-1, 20), wxSL_VERTICAL|wxSL_BOTH))
|
||||
, VerticalZoom(new wxSlider(panel, Audio_Vertical_Zoom, 50, 0, 100, wxDefaultPosition, wxSize(-1, 20), wxSL_VERTICAL|wxSL_BOTH|wxSL_INVERSE))
|
||||
, VolumeBar(new wxSlider(panel, Audio_Volume, 50, 0, 100, wxDefaultPosition, wxSize(-1, 20), wxSL_VERTICAL|wxSL_BOTH|wxSL_INVERSE))
|
||||
{
|
||||
// Zoom
|
||||
HorizontalZoom = new wxSlider(this,Audio_Horizontal_Zoom,0,-50,30,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL|wxSL_BOTH);
|
||||
SetSashVisible(wxSASH_BOTTOM, true);
|
||||
Bind(wxEVT_SASH_DRAGGED, &AudioBox::OnSashDrag, this);
|
||||
|
||||
HorizontalZoom->SetToolTip(_("Horizontal zoom"));
|
||||
VerticalZoom = new wxSlider(this,Audio_Vertical_Zoom,50,0,100,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL|wxSL_BOTH|wxSL_INVERSE);
|
||||
VerticalZoom->SetToolTip(_("Vertical zoom"));
|
||||
VolumeBar = new wxSlider(this,Audio_Volume,50,0,100,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL|wxSL_BOTH|wxSL_INVERSE);
|
||||
VolumeBar->SetToolTip(_("Audio Volume"));
|
||||
|
||||
bool link = OPT_GET("Audio/Link")->GetBool();
|
||||
if (link) {
|
||||
VolumeBar->SetValue(VerticalZoom->GetValue());
|
||||
|
@ -100,7 +105,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
|
|||
wxSizer *VertVolArea = new wxBoxSizer(wxVERTICAL);
|
||||
VertVolArea->Add(VertVol,1,wxEXPAND,0);
|
||||
|
||||
ToggleBitmap *link_btn = new ToggleBitmap(this, context, "audio/opt/vertical_link", 16, "Audio", wxSize(20, -1));
|
||||
ToggleBitmap *link_btn = new ToggleBitmap(panel, context, "audio/opt/vertical_link", 16, "Audio", wxSize(20, -1));
|
||||
VertVolArea->Add(link_btn, 0, wxRIGHT | wxALIGN_CENTER | wxEXPAND, 0);
|
||||
OPT_SUB("Audio/Link", &AudioBox::OnVerticalLink, this);
|
||||
|
||||
|
@ -110,25 +115,42 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
|
|||
TopSizer->Add(HorizontalZoom,0,wxEXPAND,0);
|
||||
TopSizer->Add(VertVolArea,0,wxEXPAND,0);
|
||||
|
||||
context->karaoke = new AudioKaraoke(this, context);
|
||||
context->karaoke = new AudioKaraoke(panel, context);
|
||||
|
||||
// Main sizer
|
||||
wxBoxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
MainSizer->Add(TopSizer,1,wxEXPAND|wxALL,3);
|
||||
MainSizer->Add(toolbar::GetToolbar(this, "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->AddSpacer(3);
|
||||
SetSizer(MainSizer);
|
||||
panel->SetSizer(MainSizer);
|
||||
|
||||
wxSizer *audioSashSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
audioSashSizer->Add(panel, 1, wxEXPAND);
|
||||
SetSizerAndFit(audioSashSizer);
|
||||
SetMinSize(wxSize(-1, OPT_GET("Audio/Display Height")->GetInt()));
|
||||
SetMinimumSizeY(panel->GetSize().GetHeight());
|
||||
}
|
||||
|
||||
AudioBox::~AudioBox() { }
|
||||
|
||||
BEGIN_EVENT_TABLE(AudioBox,wxPanel)
|
||||
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()
|
||||
|
||||
void AudioBox::OnSashDrag(wxSashEvent &event) {
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void AudioBox::OnHorizontalZoom(wxScrollEvent &event) {
|
||||
// Negate the value, we want zoom out to be on bottom and zoom in on top,
|
||||
// but the control doesn't want negative on bottom and positive on top.
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
///
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sashwin.h>
|
||||
#endif
|
||||
|
||||
namespace agi {
|
||||
|
@ -54,16 +54,20 @@ class wxSlider;
|
|||
|
||||
/// @class AudioBox
|
||||
/// @brief Panel with audio playback and timing controls, also containing an AudioDisplay
|
||||
class AudioBox : public wxPanel {
|
||||
/// The audio display in the box
|
||||
AudioDisplay *audioDisplay;
|
||||
|
||||
class AudioBox : public wxSashWindow {
|
||||
/// The controller controlling this audio box
|
||||
AudioController *controller;
|
||||
|
||||
/// Project context this operates on
|
||||
agi::Context *context;
|
||||
|
||||
|
||||
/// Panel containing the children
|
||||
wxPanel *panel;
|
||||
|
||||
/// The audio display in the box
|
||||
AudioDisplay *audioDisplay;
|
||||
|
||||
/// DOCME
|
||||
wxSlider *HorizontalZoom;
|
||||
|
||||
|
@ -77,9 +81,9 @@ class AudioBox : public wxPanel {
|
|||
void OnVerticalZoom(wxScrollEvent &event);
|
||||
void OnVolume(wxScrollEvent &event);
|
||||
void OnVerticalLink(agi::OptionValue const& opt);
|
||||
void OnSashDrag(wxSashEvent &event);
|
||||
|
||||
public:
|
||||
|
||||
AudioBox(wxWindow *parent, agi::Context *context);
|
||||
~AudioBox();
|
||||
|
||||
|
|
|
@ -254,18 +254,8 @@ void FrameMain::InitContents() {
|
|||
context->selectionController = context->subsGrid;
|
||||
Search.context = context.get();
|
||||
|
||||
StartupLog("Create tool area splitter window");
|
||||
audioSash = new wxSashWindow(Panel, ID_SASH_MAIN_AUDIO, wxDefaultPosition, wxDefaultSize, wxSW_3D|wxCLIP_CHILDREN);
|
||||
audioSash->SetSashVisible(wxSASH_BOTTOM, true);
|
||||
|
||||
StartupLog("Create audio box");
|
||||
context->audioBox = audioBox = new AudioBox(audioSash, context.get());
|
||||
|
||||
wxSizer *audioSashSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
audioSashSizer->Add(audioBox, 1, wxEXPAND);
|
||||
audioSash->SetSizerAndFit(audioSashSizer);
|
||||
audioSash->SetMinSize(wxSize(-1, OPT_GET("Audio/Display Height")->GetInt()));
|
||||
audioSash->SetMinimumSizeY(audioBox->GetSize().GetHeight());
|
||||
context->audioBox = audioBox = new AudioBox(Panel, context.get());
|
||||
|
||||
StartupLog("Create subtitle editing box");
|
||||
EditBox = new SubsEditBox(Panel, context.get());
|
||||
|
@ -273,7 +263,7 @@ void FrameMain::InitContents() {
|
|||
|
||||
StartupLog("Arrange main sizers");
|
||||
ToolsSizer = new wxBoxSizer(wxVERTICAL);
|
||||
ToolsSizer->Add(audioSash, 0, wxEXPAND);
|
||||
ToolsSizer->Add(audioBox, 0, wxEXPAND);
|
||||
ToolsSizer->Add(EditBox, 1, wxEXPAND);
|
||||
TopSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
TopSizer->Add(videoSizer, 0, wxEXPAND, 0);
|
||||
|
@ -372,7 +362,7 @@ void FrameMain::SetDisplayMode(int video, int audio) {
|
|||
context->videoController->Stop();
|
||||
|
||||
TopSizer->Show(videoBox, showVideo, true);
|
||||
ToolsSizer->Show(audioSash, showAudio, true);
|
||||
ToolsSizer->Show(audioBox, showAudio, true);
|
||||
|
||||
MainSizer->CalcMin();
|
||||
MainSizer->RecalcSizes();
|
||||
|
@ -566,8 +556,6 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
|||
|
||||
EVT_CLOSE(FrameMain::OnCloseWindow)
|
||||
|
||||
EVT_SASH_DRAGGED(ID_SASH_MAIN_AUDIO, FrameMain::OnAudioBoxResize)
|
||||
|
||||
EVT_KEY_DOWN(FrameMain::OnKeyDown)
|
||||
|
||||
#ifdef __WXMAC__
|
||||
|
@ -636,17 +624,6 @@ void FrameMain::OnStatusClear(wxTimerEvent &) {
|
|||
SetStatusText("",1);
|
||||
}
|
||||
|
||||
void FrameMain::OnAudioBoxResize(wxSashEvent &event) {
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
|
||||
int new_height = std::min(event.GetDragRect().GetHeight(), Panel->GetSize().GetHeight() - 1);
|
||||
|
||||
OPT_SET("Audio/Display Height")->SetInt(new_height);
|
||||
audioSash->SetMinSize(wxSize(-1, new_height));
|
||||
Panel->Layout();
|
||||
}
|
||||
|
||||
void FrameMain::OnAudioOpen(AudioProvider *provider) {
|
||||
SetDisplayMode(-1, 1);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include <wx/menu.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/sashwin.h>
|
||||
#include <wx/timer.h>
|
||||
#endif
|
||||
|
||||
|
@ -100,7 +99,6 @@ class FrameMain: public wxFrame {
|
|||
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
|
||||
void OnAudioBoxResize(wxSashEvent &event);
|
||||
/// @brief Autosave the currently open file, if any
|
||||
void OnAutoSave(wxTimerEvent &event);
|
||||
void OnStatusClear(wxTimerEvent &event);
|
||||
|
@ -122,7 +120,6 @@ class FrameMain: public wxFrame {
|
|||
|
||||
SubtitlesGrid *SubsGrid; ///< The subtitle editing area
|
||||
SubsEditBox *EditBox; ///< The subtitle editing textbox
|
||||
wxSashWindow *audioSash; ///< Sash for resizing the audio area
|
||||
AudioBox *audioBox; ///< The audio area
|
||||
VideoBox *videoBox; ///< The video area
|
||||
|
||||
|
|
Loading…
Reference in New Issue