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
4 changed files with 47 additions and 47 deletions
|
@ -40,6 +40,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <wx/bmpbuttn.h>
|
#include <wx/bmpbuttn.h>
|
||||||
|
#include <wx/slider.h>
|
||||||
#include <wx/scrolbar.h>
|
#include <wx/scrolbar.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/slider.h>
|
#include <wx/slider.h>
|
||||||
|
@ -68,25 +69,29 @@
|
||||||
#include "selection_controller.h"
|
#include "selection_controller.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
enum AudioBoxControlIDs {
|
enum {
|
||||||
Audio_Horizontal_Zoom = 1600,
|
Audio_Horizontal_Zoom = 1600,
|
||||||
Audio_Vertical_Zoom,
|
Audio_Vertical_Zoom,
|
||||||
Audio_Volume,
|
Audio_Volume,
|
||||||
};
|
};
|
||||||
|
|
||||||
AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
|
AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
|
||||||
: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxBORDER_RAISED)
|
: wxSashWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxSW_3D | wxCLIP_CHILDREN)
|
||||||
, audioDisplay(new AudioDisplay(this, context->audioController, context))
|
|
||||||
, controller(context->audioController)
|
, controller(context->audioController)
|
||||||
, context(context)
|
, 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
|
SetSashVisible(wxSASH_BOTTOM, true);
|
||||||
HorizontalZoom = new wxSlider(this,Audio_Horizontal_Zoom,0,-50,30,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL|wxSL_BOTH);
|
Bind(wxEVT_SASH_DRAGGED, &AudioBox::OnSashDrag, this);
|
||||||
|
|
||||||
HorizontalZoom->SetToolTip(_("Horizontal zoom"));
|
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"));
|
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"));
|
VolumeBar->SetToolTip(_("Audio Volume"));
|
||||||
|
|
||||||
bool link = OPT_GET("Audio/Link")->GetBool();
|
bool link = OPT_GET("Audio/Link")->GetBool();
|
||||||
if (link) {
|
if (link) {
|
||||||
VolumeBar->SetValue(VerticalZoom->GetValue());
|
VolumeBar->SetValue(VerticalZoom->GetValue());
|
||||||
|
@ -100,7 +105,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
|
||||||
wxSizer *VertVolArea = new wxBoxSizer(wxVERTICAL);
|
wxSizer *VertVolArea = new wxBoxSizer(wxVERTICAL);
|
||||||
VertVolArea->Add(VertVol,1,wxEXPAND,0);
|
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);
|
VertVolArea->Add(link_btn, 0, wxRIGHT | wxALIGN_CENTER | wxEXPAND, 0);
|
||||||
OPT_SUB("Audio/Link", &AudioBox::OnVerticalLink, this);
|
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(HorizontalZoom,0,wxEXPAND,0);
|
||||||
TopSizer->Add(VertVolArea,0,wxEXPAND,0);
|
TopSizer->Add(VertVolArea,0,wxEXPAND,0);
|
||||||
|
|
||||||
context->karaoke = new AudioKaraoke(this, context);
|
context->karaoke = new AudioKaraoke(panel, context);
|
||||||
|
|
||||||
// Main sizer
|
// Main sizer
|
||||||
wxBoxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
MainSizer->Add(TopSizer,1,wxEXPAND|wxALL,3);
|
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->Add(context->karaoke,0,wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT,3);
|
||||||
MainSizer->AddSpacer(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() { }
|
AudioBox::~AudioBox() { }
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(AudioBox,wxPanel)
|
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) {
|
||||||
|
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) {
|
void AudioBox::OnHorizontalZoom(wxScrollEvent &event) {
|
||||||
// Negate the value, we want zoom out to be on bottom and zoom in on top,
|
// 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.
|
// but the control doesn't want negative on bottom and positive on top.
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
///
|
///
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <wx/panel.h>
|
#include <wx/sashwin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace agi {
|
namespace agi {
|
||||||
|
@ -54,16 +54,20 @@ class wxSlider;
|
||||||
|
|
||||||
/// @class AudioBox
|
/// @class AudioBox
|
||||||
/// @brief Panel with audio playback and timing controls, also containing an AudioDisplay
|
/// @brief Panel with audio playback and timing controls, also containing an AudioDisplay
|
||||||
class AudioBox : public wxPanel {
|
class AudioBox : public wxSashWindow {
|
||||||
/// The audio display in the box
|
|
||||||
AudioDisplay *audioDisplay;
|
|
||||||
|
|
||||||
/// The controller controlling this audio box
|
/// The controller controlling this audio box
|
||||||
AudioController *controller;
|
AudioController *controller;
|
||||||
|
|
||||||
/// Project context this operates on
|
/// Project context this operates on
|
||||||
agi::Context *context;
|
agi::Context *context;
|
||||||
|
|
||||||
|
|
||||||
|
/// Panel containing the children
|
||||||
|
wxPanel *panel;
|
||||||
|
|
||||||
|
/// The audio display in the box
|
||||||
|
AudioDisplay *audioDisplay;
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
wxSlider *HorizontalZoom;
|
wxSlider *HorizontalZoom;
|
||||||
|
|
||||||
|
@ -77,9 +81,9 @@ class AudioBox : public wxPanel {
|
||||||
void OnVerticalZoom(wxScrollEvent &event);
|
void OnVerticalZoom(wxScrollEvent &event);
|
||||||
void OnVolume(wxScrollEvent &event);
|
void OnVolume(wxScrollEvent &event);
|
||||||
void OnVerticalLink(agi::OptionValue const& opt);
|
void OnVerticalLink(agi::OptionValue const& opt);
|
||||||
|
void OnSashDrag(wxSashEvent &event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AudioBox(wxWindow *parent, agi::Context *context);
|
AudioBox(wxWindow *parent, agi::Context *context);
|
||||||
~AudioBox();
|
~AudioBox();
|
||||||
|
|
||||||
|
|
|
@ -254,18 +254,8 @@ void FrameMain::InitContents() {
|
||||||
context->selectionController = context->subsGrid;
|
context->selectionController = context->subsGrid;
|
||||||
Search.context = context.get();
|
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");
|
StartupLog("Create audio box");
|
||||||
context->audioBox = audioBox = new AudioBox(audioSash, context.get());
|
context->audioBox = audioBox = new AudioBox(Panel, 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());
|
|
||||||
|
|
||||||
StartupLog("Create subtitle editing box");
|
StartupLog("Create subtitle editing box");
|
||||||
EditBox = new SubsEditBox(Panel, context.get());
|
EditBox = new SubsEditBox(Panel, context.get());
|
||||||
|
@ -273,7 +263,7 @@ void FrameMain::InitContents() {
|
||||||
|
|
||||||
StartupLog("Arrange main sizers");
|
StartupLog("Arrange main sizers");
|
||||||
ToolsSizer = new wxBoxSizer(wxVERTICAL);
|
ToolsSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
ToolsSizer->Add(audioSash, 0, wxEXPAND);
|
ToolsSizer->Add(audioBox, 0, wxEXPAND);
|
||||||
ToolsSizer->Add(EditBox, 1, wxEXPAND);
|
ToolsSizer->Add(EditBox, 1, wxEXPAND);
|
||||||
TopSizer = new wxBoxSizer(wxHORIZONTAL);
|
TopSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
TopSizer->Add(videoSizer, 0, wxEXPAND, 0);
|
TopSizer->Add(videoSizer, 0, wxEXPAND, 0);
|
||||||
|
@ -372,7 +362,7 @@ void FrameMain::SetDisplayMode(int video, int audio) {
|
||||||
context->videoController->Stop();
|
context->videoController->Stop();
|
||||||
|
|
||||||
TopSizer->Show(videoBox, showVideo, true);
|
TopSizer->Show(videoBox, showVideo, true);
|
||||||
ToolsSizer->Show(audioSash, showAudio, true);
|
ToolsSizer->Show(audioBox, showAudio, true);
|
||||||
|
|
||||||
MainSizer->CalcMin();
|
MainSizer->CalcMin();
|
||||||
MainSizer->RecalcSizes();
|
MainSizer->RecalcSizes();
|
||||||
|
@ -566,8 +556,6 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
||||||
|
|
||||||
EVT_CLOSE(FrameMain::OnCloseWindow)
|
EVT_CLOSE(FrameMain::OnCloseWindow)
|
||||||
|
|
||||||
EVT_SASH_DRAGGED(ID_SASH_MAIN_AUDIO, FrameMain::OnAudioBoxResize)
|
|
||||||
|
|
||||||
EVT_KEY_DOWN(FrameMain::OnKeyDown)
|
EVT_KEY_DOWN(FrameMain::OnKeyDown)
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
|
@ -636,17 +624,6 @@ void FrameMain::OnStatusClear(wxTimerEvent &) {
|
||||||
SetStatusText("",1);
|
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) {
|
void FrameMain::OnAudioOpen(AudioProvider *provider) {
|
||||||
SetDisplayMode(-1, 1);
|
SetDisplayMode(-1, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/sashwin.h>
|
|
||||||
#include <wx/timer.h>
|
#include <wx/timer.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -100,7 +99,6 @@ class FrameMain: public wxFrame {
|
||||||
|
|
||||||
void OnKeyDown(wxKeyEvent &event);
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
|
|
||||||
void OnAudioBoxResize(wxSashEvent &event);
|
|
||||||
/// @brief Autosave the currently open file, if any
|
/// @brief Autosave the currently open file, if any
|
||||||
void OnAutoSave(wxTimerEvent &event);
|
void OnAutoSave(wxTimerEvent &event);
|
||||||
void OnStatusClear(wxTimerEvent &event);
|
void OnStatusClear(wxTimerEvent &event);
|
||||||
|
@ -122,7 +120,6 @@ class FrameMain: public wxFrame {
|
||||||
|
|
||||||
SubtitlesGrid *SubsGrid; ///< The subtitle editing area
|
SubtitlesGrid *SubsGrid; ///< The subtitle editing area
|
||||||
SubsEditBox *EditBox; ///< The subtitle editing textbox
|
SubsEditBox *EditBox; ///< The subtitle editing textbox
|
||||||
wxSashWindow *audioSash; ///< Sash for resizing the audio area
|
|
||||||
AudioBox *audioBox; ///< The audio area
|
AudioBox *audioBox; ///< The audio area
|
||||||
VideoBox *videoBox; ///< The video area
|
VideoBox *videoBox; ///< The video area
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue