Global slider instances for control panels out of TrackPanel.cpp...
... and updating of them is accomplished privately in implementation files, reducing intrusions into TrackPanel and ProjectWindow This removes #include-s from TrackInfo.cpp, leaving dependency cycles better than previously
This commit is contained in:
parent
627213cb74
commit
6a03e7c84a
|
@ -859,10 +859,8 @@ END_EVENT_TABLE()
|
|||
void ProjectWindow::ApplyUpdatedTheme()
|
||||
{
|
||||
auto &project = mProject;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
SetBackgroundColour(theTheme.Colour( clrMedium ));
|
||||
ClearBackground();// For wxGTK.
|
||||
trackPanel.ApplyUpdatedTheme();
|
||||
}
|
||||
|
||||
void ProjectWindow::RedrawProject(const bool bForceWaveTracks /*= false*/)
|
||||
|
|
|
@ -519,72 +519,6 @@ namespace {
|
|||
|
||||
wxFont gFont;
|
||||
|
||||
std::unique_ptr<LWSlider>
|
||||
gGainCaptured
|
||||
, gPanCaptured
|
||||
, gGain
|
||||
, gPan
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
, gVelocityCaptured
|
||||
, gVelocity
|
||||
#endif
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
#include "tracks/playabletrack/notetrack/ui/NoteTrackControls.h"
|
||||
#include "tracks/playabletrack/wavetrack/ui/WaveTrackControls.h"
|
||||
void TrackInfo::ReCreateSliders(){
|
||||
const wxPoint point{ 0, 0 };
|
||||
wxRect sliderRect;
|
||||
WaveTrackControls::GetGainRect(point, sliderRect);
|
||||
|
||||
float defPos = 1.0;
|
||||
/* i18n-hint: Title of the Gain slider, used to adjust the volume */
|
||||
gGain = std::make_unique<LWSlider>(nullptr, _("Gain"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
DB_SLIDER);
|
||||
gGain->SetDefaultValue(defPos);
|
||||
|
||||
gGainCaptured = std::make_unique<LWSlider>(nullptr, _("Gain"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
DB_SLIDER);
|
||||
gGainCaptured->SetDefaultValue(defPos);
|
||||
|
||||
WaveTrackControls::GetPanRect(point, sliderRect);
|
||||
|
||||
defPos = 0.0;
|
||||
/* i18n-hint: Title of the Pan slider, used to move the sound left or right */
|
||||
gPan = std::make_unique<LWSlider>(nullptr, _("Pan"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
PAN_SLIDER);
|
||||
gPan->SetDefaultValue(defPos);
|
||||
|
||||
gPanCaptured = std::make_unique<LWSlider>(nullptr, _("Pan"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
PAN_SLIDER);
|
||||
gPanCaptured->SetDefaultValue(defPos);
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
NoteTrackControls::GetVelocityRect(point, sliderRect);
|
||||
|
||||
/* i18n-hint: Title of the Velocity slider, used to adjust the volume of note tracks */
|
||||
gVelocity = std::make_unique<LWSlider>(nullptr, _("Velocity"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
VEL_SLIDER);
|
||||
gVelocity->SetDefaultValue(0.0);
|
||||
gVelocityCaptured = std::make_unique<LWSlider>(nullptr, _("Velocity"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
VEL_SLIDER);
|
||||
gVelocityCaptured->SetDefaultValue(0.0);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void TrackInfo::GetCloseBoxHorizontalBounds( const wxRect & rect, wxRect &dest )
|
||||
|
@ -852,59 +786,6 @@ unsigned TrackInfo::DefaultTrackHeight( const TCPLines &topLines )
|
|||
return (unsigned) std::max( needed, (int) TrackView::DefaultHeight );
|
||||
}
|
||||
|
||||
LWSlider * TrackInfo::GainSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float gain = t ? t->GetGain() : 1.0;
|
||||
|
||||
gGain->Move(pos);
|
||||
gGain->Set(gain);
|
||||
gGainCaptured->Move(pos);
|
||||
gGainCaptured->Set(gain);
|
||||
|
||||
auto slider = (captured ? gGainCaptured : gGain).get();
|
||||
slider->SetParent( pParent ? pParent :
|
||||
FindProjectFrame( ::GetActiveProject() ) );
|
||||
return slider;
|
||||
}
|
||||
|
||||
LWSlider * TrackInfo::PanSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float pan = t ? t->GetPan() : 0.0;
|
||||
|
||||
gPan->Move(pos);
|
||||
gPan->Set(pan);
|
||||
gPanCaptured->Move(pos);
|
||||
gPanCaptured->Set(pan);
|
||||
|
||||
auto slider = (captured ? gPanCaptured : gPan).get();
|
||||
slider->SetParent( pParent ? pParent :
|
||||
FindProjectFrame( ::GetActiveProject() ) );
|
||||
return slider;
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider * TrackInfo::VelocitySlider
|
||||
(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float velocity = t ? t->GetVelocity() : 0.0;
|
||||
|
||||
gVelocity->Move(pos);
|
||||
gVelocity->Set(velocity);
|
||||
gVelocityCaptured->Move(pos);
|
||||
gVelocityCaptured->Set(velocity);
|
||||
|
||||
auto slider = (captured ? gVelocityCaptured : gVelocity).get();
|
||||
slider->SetParent( pParent ? pParent :
|
||||
FindProjectFrame( ::GetActiveProject() ) );
|
||||
return slider;
|
||||
}
|
||||
#endif
|
||||
|
||||
void TrackInfo::UpdatePrefs( wxWindow *pParent )
|
||||
{
|
||||
gPrefs->Read(wxT("/GUI/Solo"), &gSoloPref, wxT("Simple"));
|
||||
|
|
|
@ -30,8 +30,6 @@ class WaveTrack;
|
|||
|
||||
namespace TrackInfo
|
||||
{
|
||||
void ReCreateSliders();
|
||||
|
||||
unsigned MinimumTrackHeight();
|
||||
|
||||
struct TCPLine {
|
||||
|
@ -143,19 +141,6 @@ namespace TrackInfo
|
|||
bool HideTopItem( const wxRect &rect, const wxRect &subRect,
|
||||
int allowance = 0 );
|
||||
|
||||
LWSlider * GainSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
LWSlider * PanSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider * VelocitySlider
|
||||
(const wxRect &sliderRect, const NoteTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
#endif
|
||||
|
||||
// Non-member, namespace function relying on TrackPanel to invoke it
|
||||
// when it handles preference update events
|
||||
void UpdatePrefs( wxWindow *pParent );
|
||||
|
|
|
@ -73,10 +73,8 @@ is time to refresh some aspect of the screen.
|
|||
#include "TrackInfo.h"
|
||||
#include "TrackPanelAx.h"
|
||||
#include "WaveTrack.h"
|
||||
#include "tracks/playabletrack/wavetrack/ui/WaveTrackControls.h"
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
#include "NoteTrack.h"
|
||||
#include "tracks/playabletrack/notetrack/ui/NoteTrackControls.h"
|
||||
#endif
|
||||
|
||||
#include "ondemand/ODManager.h"
|
||||
|
@ -260,7 +258,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
|
|||
#pragma warning( default: 4355 )
|
||||
#endif
|
||||
{
|
||||
TrackInfo::ReCreateSliders();
|
||||
TrackInfo::UpdatePrefs( this );
|
||||
|
||||
SetLayoutDirection(wxLayout_LeftToRight);
|
||||
|
@ -322,35 +319,6 @@ TrackPanel::~TrackPanel()
|
|||
ReleaseMouse();
|
||||
}
|
||||
|
||||
LWSlider *TrackPanel::GainSlider( const WaveTrack *wt )
|
||||
{
|
||||
auto pControls = &TrackControls::Get( *wt );
|
||||
auto rect = FindRect( *pControls );
|
||||
wxRect sliderRect;
|
||||
WaveTrackControls::GetGainRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::GainSlider(sliderRect, wt, false, this);
|
||||
}
|
||||
|
||||
LWSlider *TrackPanel::PanSlider( const WaveTrack *wt )
|
||||
{
|
||||
auto pControls = &TrackControls::Get( *wt );
|
||||
auto rect = FindRect( *pControls );
|
||||
wxRect sliderRect;
|
||||
WaveTrackControls::GetPanRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::PanSlider(sliderRect, wt, false, this);
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider *TrackPanel::VelocitySlider( const NoteTrack *nt )
|
||||
{
|
||||
auto pControls = &TrackControls::Get( *nt );
|
||||
auto rect = FindRect( *pControls );
|
||||
wxRect sliderRect;
|
||||
NoteTrackControls::GetVelocityRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::VelocitySlider(sliderRect, nt, false, this);
|
||||
}
|
||||
#endif
|
||||
|
||||
void TrackPanel::UpdatePrefs()
|
||||
{
|
||||
// All vertical rulers must be recalculated since the minimum and maximum
|
||||
|
@ -362,12 +330,6 @@ void TrackPanel::UpdatePrefs()
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void TrackPanel::ApplyUpdatedTheme()
|
||||
{
|
||||
TrackInfo::ReCreateSliders();
|
||||
}
|
||||
|
||||
|
||||
wxSize TrackPanel::GetTracksUsableArea() const
|
||||
{
|
||||
auto size = GetSize();
|
||||
|
|
|
@ -84,7 +84,6 @@ class AUDACITY_DLL_API TrackPanel final
|
|||
virtual ~ TrackPanel();
|
||||
|
||||
void UpdatePrefs() override;
|
||||
void ApplyUpdatedTheme();
|
||||
|
||||
void OnPaint(wxPaintEvent & event);
|
||||
void OnMouseEvent(wxMouseEvent & event);
|
||||
|
@ -218,12 +217,6 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
LWSlider *GainSlider( const WaveTrack *wt );
|
||||
LWSlider *PanSlider( const WaveTrack *wt );
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider *VelocitySlider( const NoteTrack *nt );
|
||||
#endif
|
||||
|
||||
protected:
|
||||
TrackPanelListener *mListener;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "../commands/CommandContext.h"
|
||||
#include "../commands/CommandManager.h"
|
||||
#include "../effects/EffectManager.h"
|
||||
#include "../tracks/playabletrack/wavetrack/ui/WaveTrackControls.h"
|
||||
#include "../widgets/ASlider.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/ProgressDialog.h"
|
||||
|
@ -1310,7 +1311,7 @@ void OnTrackPan(const CommandContext &context)
|
|||
|
||||
Track *const track = trackPanel.GetFocusedTrack();
|
||||
if (track) track->TypeSwitch( [&](WaveTrack *wt) {
|
||||
LWSlider *slider = trackPanel.PanSlider(wt);
|
||||
LWSlider *slider = WaveTrackControls::PanSlider( trackPanel, *wt );
|
||||
if (slider->ShowDialog())
|
||||
SetTrackPan(project, wt, slider);
|
||||
});
|
||||
|
@ -1323,7 +1324,7 @@ void OnTrackPanLeft(const CommandContext &context)
|
|||
|
||||
Track *const track = trackPanel.GetFocusedTrack();
|
||||
if (track) track->TypeSwitch( [&](WaveTrack *wt) {
|
||||
LWSlider *slider = trackPanel.PanSlider(wt);
|
||||
LWSlider *slider = WaveTrackControls::PanSlider( trackPanel, *wt );
|
||||
slider->Decrease(1);
|
||||
SetTrackPan(project, wt, slider);
|
||||
});
|
||||
|
@ -1336,7 +1337,7 @@ void OnTrackPanRight(const CommandContext &context)
|
|||
|
||||
Track *const track = trackPanel.GetFocusedTrack();
|
||||
if (track) track->TypeSwitch( [&](WaveTrack *wt) {
|
||||
LWSlider *slider = trackPanel.PanSlider(wt);
|
||||
LWSlider *slider = WaveTrackControls::PanSlider( trackPanel, *wt );
|
||||
slider->Increase(1);
|
||||
SetTrackPan(project, wt, slider);
|
||||
});
|
||||
|
@ -1350,7 +1351,7 @@ void OnTrackGain(const CommandContext &context)
|
|||
/// This will pop up the track gain dialog for specified track
|
||||
Track *const track = trackPanel.GetFocusedTrack();
|
||||
if (track) track->TypeSwitch( [&](WaveTrack *wt) {
|
||||
LWSlider *slider = trackPanel.GainSlider(wt);
|
||||
LWSlider *slider = WaveTrackControls::GainSlider( trackPanel, *wt );
|
||||
if (slider->ShowDialog())
|
||||
SetTrackGain(project, wt, slider);
|
||||
});
|
||||
|
@ -1363,7 +1364,7 @@ void OnTrackGainInc(const CommandContext &context)
|
|||
|
||||
Track *const track = trackPanel.GetFocusedTrack();
|
||||
if (track) track->TypeSwitch( [&](WaveTrack *wt) {
|
||||
LWSlider *slider = trackPanel.GainSlider(wt);
|
||||
LWSlider *slider = WaveTrackControls::GainSlider( trackPanel, *wt );
|
||||
slider->Increase(1);
|
||||
SetTrackGain(project, wt, slider);
|
||||
});
|
||||
|
@ -1376,7 +1377,7 @@ void OnTrackGainDec(const CommandContext &context)
|
|||
|
||||
Track *const track = trackPanel.GetFocusedTrack();
|
||||
if (track) track->TypeSwitch( [&](WaveTrack *wt) {
|
||||
LWSlider *slider = trackPanel.GainSlider(wt);
|
||||
LWSlider *slider = WaveTrackControls::GainSlider( trackPanel, *wt );
|
||||
slider->Decrease(1);
|
||||
SetTrackGain(project, wt, slider);
|
||||
});
|
||||
|
|
|
@ -26,6 +26,10 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "../../../../Project.h"
|
||||
#include "../../../../ProjectHistory.h"
|
||||
#include "../../../../RefreshCode.h"
|
||||
#include "../../../../prefs/ThemePrefs.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <wx/frame.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NoteTrackControls::~NoteTrackControls()
|
||||
|
@ -187,7 +191,7 @@ void VelocitySliderDrawFunction
|
|||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
bool captured = hit && target->IsClicked();
|
||||
SliderDrawFunction(
|
||||
&TrackInfo::VelocitySlider, dc, rect, pTrack, captured, hit);
|
||||
&NoteTrackControls::VelocitySlider, dc, rect, pTrack, captured, hit);
|
||||
}
|
||||
|
||||
void MidiControlsDrawFunction
|
||||
|
@ -256,3 +260,64 @@ const TCPLines &NoteTrackControls::GetTCPLines() const
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
std::unique_ptr<LWSlider>
|
||||
gVelocityCaptured
|
||||
, gVelocity
|
||||
;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider * NoteTrackControls::VelocitySlider
|
||||
(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
static std::once_flag flag;
|
||||
std::call_once( flag, [] {
|
||||
wxCommandEvent dummy;
|
||||
ReCreateVelocitySlider( dummy );
|
||||
wxTheApp->Bind(EVT_THEME_CHANGE, ReCreateVelocitySlider);
|
||||
} );
|
||||
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float velocity = t ? t->GetVelocity() : 0.0;
|
||||
|
||||
gVelocity->Move(pos);
|
||||
gVelocity->Set(velocity);
|
||||
gVelocityCaptured->Move(pos);
|
||||
gVelocityCaptured->Set(velocity);
|
||||
|
||||
auto slider = (captured ? gVelocityCaptured : gVelocity).get();
|
||||
slider->SetParent( pParent ? pParent :
|
||||
FindProjectFrame( ::GetActiveProject() ) );
|
||||
return slider;
|
||||
}
|
||||
#endif
|
||||
|
||||
void NoteTrackControls::ReCreateVelocitySlider( wxEvent &evt )
|
||||
{
|
||||
evt.Skip();
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
wxPoint point{ 0, 0 };
|
||||
wxRect sliderRect;
|
||||
GetVelocityRect(point, sliderRect);
|
||||
|
||||
/* i18n-hint: Title of the Velocity slider, used to adjust the volume of note tracks */
|
||||
gVelocity = std::make_unique<LWSlider>(nullptr, _("Velocity"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
VEL_SLIDER);
|
||||
gVelocity->SetDefaultValue(0.0);
|
||||
gVelocityCaptured = std::make_unique<LWSlider>(nullptr, _("Velocity"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
VEL_SLIDER);
|
||||
gVelocityCaptured->SetDefaultValue(0.0);
|
||||
#else
|
||||
pParent;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#define __AUDACITY_NOTE_TRACK_CONTROLS__
|
||||
|
||||
#include "../../../ui/CommonTrackControls.h" // to inherit
|
||||
|
||||
class wxEvent;
|
||||
class LWSlider;
|
||||
class NoteTrack;
|
||||
class MuteButtonHandle;
|
||||
class SoloButtonHandle;
|
||||
class NoteTrackButtonHandle;
|
||||
|
@ -46,6 +48,13 @@ public:
|
|||
static unsigned DefaultNoteTrackHeight();
|
||||
static void GetMidiControlsRect(const wxRect & rect, wxRect & dest);
|
||||
static void GetVelocityRect(const wxPoint &topleft, wxRect & dest);
|
||||
|
||||
static LWSlider * VelocitySlider
|
||||
(const wxRect &sliderRect, const NoteTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
|
||||
private:
|
||||
static void ReCreateVelocitySlider( wxEvent& );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,7 +86,7 @@ UIHandlePtr VelocitySliderHandle::HitTest
|
|||
if (sliderRect.Contains(state.m_x, state.m_y)) {
|
||||
auto sliderFn =
|
||||
[]( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
|
||||
return TrackInfo::VelocitySlider
|
||||
return NoteTrackControls::VelocitySlider
|
||||
(sliderRect, static_cast<NoteTrack*>( pTrack ), true,
|
||||
&TrackPanel::Get( *pProject ));
|
||||
};
|
||||
|
|
|
@ -31,11 +31,14 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "../../../../ondemand/ODManager.h"
|
||||
#include "../../../../prefs/PrefsDialog.h"
|
||||
#include "../../../../prefs/SpectrumPrefs.h"
|
||||
#include "../../../../prefs/ThemePrefs.h"
|
||||
#include "../../../../prefs/TracksBehaviorsPrefs.h"
|
||||
#include "../../../../prefs/WaveformPrefs.h"
|
||||
#include "../../../../widgets/AudacityMessageBox.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/sizer.h>
|
||||
|
||||
namespace
|
||||
|
@ -1042,7 +1045,7 @@ void PanSliderDrawFunction
|
|||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
bool captured = hit && target->IsClicked();
|
||||
SliderDrawFunction
|
||||
( &TrackInfo::PanSlider, dc, rect, pTrack, captured, hit);
|
||||
( &WaveTrackControls::PanSlider, dc, rect, pTrack, captured, hit);
|
||||
}
|
||||
|
||||
void GainSliderDrawFunction
|
||||
|
@ -1056,7 +1059,7 @@ void GainSliderDrawFunction
|
|||
hit=hit;
|
||||
bool captured = hit && target->IsClicked();
|
||||
SliderDrawFunction
|
||||
( &TrackInfo::GainSlider, dc, rect, pTrack, captured, hit);
|
||||
( &WaveTrackControls::GainSlider, dc, rect, pTrack, captured, hit);
|
||||
}
|
||||
|
||||
void StatusDrawFunction
|
||||
|
@ -1168,3 +1171,126 @@ const TCPLines &WaveTrackControls::GetTCPLines() const
|
|||
{
|
||||
return waveTrackTCPLines;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
std::unique_ptr<LWSlider>
|
||||
gGainCaptured
|
||||
, gPanCaptured
|
||||
, gGain
|
||||
, gPan;
|
||||
}
|
||||
|
||||
LWSlider *WaveTrackControls::GainSlider(
|
||||
CellularPanel &panel, const WaveTrack &wt )
|
||||
{
|
||||
auto &controls = TrackControls::Get( wt );
|
||||
auto rect = panel.FindRect( controls );
|
||||
wxRect sliderRect;
|
||||
GetGainRect( rect.GetTopLeft(), sliderRect );
|
||||
return GainSlider( sliderRect, &wt, false, &panel );
|
||||
}
|
||||
|
||||
LWSlider * WaveTrackControls::GainSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
static std::once_flag flag;
|
||||
std::call_once( flag, [] {
|
||||
wxCommandEvent dummy;
|
||||
ReCreateGainSlider( dummy );
|
||||
wxTheApp->Bind(EVT_THEME_CHANGE, ReCreateGainSlider);
|
||||
} );
|
||||
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float gain = t ? t->GetGain() : 1.0;
|
||||
|
||||
gGain->Move(pos);
|
||||
gGain->Set(gain);
|
||||
gGainCaptured->Move(pos);
|
||||
gGainCaptured->Set(gain);
|
||||
|
||||
auto slider = (captured ? gGainCaptured : gGain).get();
|
||||
slider->SetParent( pParent ? pParent :
|
||||
FindProjectFrame( ::GetActiveProject() ) );
|
||||
return slider;
|
||||
}
|
||||
|
||||
void WaveTrackControls::ReCreateGainSlider( wxEvent &event )
|
||||
{
|
||||
event.Skip();
|
||||
|
||||
const wxPoint point{ 0, 0 };
|
||||
wxRect sliderRect;
|
||||
GetGainRect(point, sliderRect);
|
||||
|
||||
float defPos = 1.0;
|
||||
/* i18n-hint: Title of the Gain slider, used to adjust the volume */
|
||||
gGain = std::make_unique<LWSlider>(nullptr, _("Gain"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
DB_SLIDER);
|
||||
gGain->SetDefaultValue(defPos);
|
||||
|
||||
gGainCaptured = std::make_unique<LWSlider>(nullptr, _("Gain"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
DB_SLIDER);
|
||||
gGainCaptured->SetDefaultValue(defPos);
|
||||
}
|
||||
|
||||
LWSlider *WaveTrackControls::PanSlider(
|
||||
CellularPanel &panel, const WaveTrack &wt )
|
||||
{
|
||||
auto &controls = TrackControls::Get( wt );
|
||||
auto rect = panel.FindRect( controls );
|
||||
wxRect sliderRect;
|
||||
GetPanRect( rect.GetTopLeft(), sliderRect );
|
||||
return PanSlider( sliderRect, &wt, false, &panel );
|
||||
}
|
||||
|
||||
LWSlider * WaveTrackControls::PanSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
static std::once_flag flag;
|
||||
std::call_once( flag, [] {
|
||||
wxCommandEvent dummy;
|
||||
ReCreatePanSlider( dummy );
|
||||
wxTheApp->Bind(EVT_THEME_CHANGE, ReCreatePanSlider);
|
||||
} );
|
||||
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float pan = t ? t->GetPan() : 0.0;
|
||||
|
||||
gPan->Move(pos);
|
||||
gPan->Set(pan);
|
||||
gPanCaptured->Move(pos);
|
||||
gPanCaptured->Set(pan);
|
||||
|
||||
auto slider = (captured ? gPanCaptured : gPan).get();
|
||||
slider->SetParent( pParent ? pParent :
|
||||
FindProjectFrame( ::GetActiveProject() ) );
|
||||
return slider;
|
||||
}
|
||||
|
||||
void WaveTrackControls::ReCreatePanSlider( wxEvent &event )
|
||||
{
|
||||
event.Skip();
|
||||
|
||||
const wxPoint point{ 0, 0 };
|
||||
wxRect sliderRect;
|
||||
GetPanRect(point, sliderRect);
|
||||
|
||||
float defPos = 0.0;
|
||||
/* i18n-hint: Title of the Pan slider, used to move the sound left or right */
|
||||
gPan = std::make_unique<LWSlider>(nullptr, _("Pan"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
PAN_SLIDER);
|
||||
gPan->SetDefaultValue(defPos);
|
||||
|
||||
gPanCaptured = std::make_unique<LWSlider>(nullptr, _("Pan"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
PAN_SLIDER);
|
||||
gPanCaptured->SetDefaultValue(defPos);
|
||||
}
|
||||
|
|
|
@ -13,10 +13,15 @@ Paul Licameli split from TrackPanel.cpp
|
|||
|
||||
#include "../../../ui/CommonTrackControls.h" // to inherit
|
||||
|
||||
class CellularPanel;
|
||||
class LWSlider;
|
||||
class MuteButtonHandle;
|
||||
class SoloButtonHandle;
|
||||
class GainSliderHandle;
|
||||
class PanSliderHandle;
|
||||
class WaveTrack;
|
||||
class wxEvent;
|
||||
class wxWindow;
|
||||
|
||||
class WaveTrackControls final : public CommonTrackControls
|
||||
{
|
||||
|
@ -41,7 +46,22 @@ public:
|
|||
static void GetGainRect(const wxPoint & topLeft, wxRect &dest);
|
||||
static void GetPanRect(const wxPoint & topLeft, wxRect &dest);
|
||||
|
||||
static LWSlider *GainSlider( CellularPanel &panel, const WaveTrack &wt );
|
||||
static LWSlider * GainSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
|
||||
static LWSlider *PanSlider( CellularPanel &panel, const WaveTrack &wt );
|
||||
static LWSlider * PanSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
|
||||
static void ReCreateSliders();
|
||||
|
||||
private:
|
||||
static void ReCreatePanSlider( wxEvent& );
|
||||
static void ReCreateGainSlider( wxEvent& );
|
||||
|
||||
std::weak_ptr<MuteButtonHandle> mMuteHandle;
|
||||
std::weak_ptr<SoloButtonHandle> mSoloHandle;
|
||||
std::weak_ptr<GainSliderHandle> mGainHandle;
|
||||
|
|
|
@ -81,7 +81,7 @@ UIHandlePtr GainSliderHandle::HitTest
|
|||
WaveTrackControls::GetGainRect(rect.GetTopLeft(), sliderRect2);
|
||||
auto sliderFn =
|
||||
[]( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
|
||||
return TrackInfo::GainSlider
|
||||
return WaveTrackControls::GainSlider
|
||||
(sliderRect, static_cast<WaveTrack*>( pTrack ), true,
|
||||
&TrackPanel::Get( *pProject ));
|
||||
};
|
||||
|
@ -158,7 +158,7 @@ UIHandlePtr PanSliderHandle::HitTest
|
|||
if (sliderRect.Contains(state.m_x, state.m_y)) {
|
||||
auto sliderFn =
|
||||
[]( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
|
||||
return TrackInfo::PanSlider
|
||||
return WaveTrackControls::PanSlider
|
||||
(sliderRect, static_cast<WaveTrack*>( pTrack ), true,
|
||||
&TrackPanel::Get( *pProject ));
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue