mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 08:59:28 +02:00
Move code to PlayableTrackControls...
... eliminating some duplication in tables for Wave and Note track controls, and freeing PlayableTrackButtonHandles from the big s.c.c, though in a cycle yet with PlayableTrackControls
This commit is contained in:
parent
674b66128d
commit
87ef97abe2
@ -43,10 +43,8 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "tracks/ui/TrackView.h"
|
#include "tracks/ui/TrackView.h"
|
||||||
#include "widgets/ASlider.h"
|
#include "widgets/ASlider.h"
|
||||||
|
|
||||||
namespace {
|
static wxString gSoloPref;
|
||||||
|
bool TrackInfo::HasSoloButton()
|
||||||
wxString gSoloPref;
|
|
||||||
inline bool HasSoloButton()
|
|
||||||
{
|
{
|
||||||
return gSoloPref!=wxT("None");
|
return gSoloPref!=wxT("None");
|
||||||
}
|
}
|
||||||
@ -55,8 +53,6 @@ inline bool HasSoloButton()
|
|||||||
using TCPLine = TrackInfo::TCPLine;
|
using TCPLine = TrackInfo::TCPLine;
|
||||||
using TCPLines = TrackInfo::TCPLines;
|
using TCPLines = TrackInfo::TCPLines;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static const TCPLines &commonTrackTCPLines()
|
static const TCPLines &commonTrackTCPLines()
|
||||||
{
|
{
|
||||||
static const TCPLines theLines{
|
static const TCPLines theLines{
|
||||||
@ -402,119 +398,6 @@ void TrackInfo::MinimizeSyncLockDrawFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackInfo::MuteOrSoloDrawFunction
|
|
||||||
( wxDC *dc, const wxRect &bev, const Track *pTrack, bool down,
|
|
||||||
bool WXUNUSED(captured),
|
|
||||||
bool solo, bool hit )
|
|
||||||
{
|
|
||||||
//bev.Inflate(-1, -1);
|
|
||||||
bool selected = pTrack ? pTrack->GetSelected() : true;
|
|
||||||
auto pt = dynamic_cast<const PlayableTrack *>(pTrack);
|
|
||||||
bool value = pt ? (solo ? pt->GetSolo() : pt->GetMute()) : false;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
AColor::MediumTrackInfo( dc, t->GetSelected());
|
|
||||||
if( solo )
|
|
||||||
{
|
|
||||||
if( pt && pt->GetSolo() )
|
|
||||||
{
|
|
||||||
AColor::Solo(dc, pt->GetSolo(), t->GetSelected());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( pt && pt->GetMute() )
|
|
||||||
{
|
|
||||||
AColor::Mute(dc, pt->GetMute(), t->GetSelected(), pt->GetSolo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//(solo) ? AColor::Solo(dc, t->GetSolo(), t->GetSelected()) :
|
|
||||||
// AColor::Mute(dc, t->GetMute(), t->GetSelected(), t->GetSolo());
|
|
||||||
dc->SetPen( *wxTRANSPARENT_PEN );//No border!
|
|
||||||
dc->DrawRectangle(bev);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxCoord textWidth, textHeight;
|
|
||||||
wxString str = (solo) ?
|
|
||||||
/* i18n-hint: This is on a button that will silence all the other tracks.*/
|
|
||||||
_("Solo") :
|
|
||||||
/* i18n-hint: This is on a button that will silence this track.*/
|
|
||||||
_("Mute");
|
|
||||||
|
|
||||||
AColor::Bevel2(
|
|
||||||
*dc,
|
|
||||||
value == down,
|
|
||||||
bev,
|
|
||||||
selected, hit
|
|
||||||
);
|
|
||||||
|
|
||||||
SetTrackInfoFont(dc);
|
|
||||||
dc->GetTextExtent(str, &textWidth, &textHeight);
|
|
||||||
dc->DrawText(str, bev.x + (bev.width - textWidth) / 2, bev.y + (bev.height - textHeight) / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "tracks/playabletrack/ui/PlayableTrackButtonHandles.h"
|
|
||||||
void TrackInfo::WideMuteDrawFunction
|
|
||||||
( TrackPanelDrawingContext &context,
|
|
||||||
const wxRect &rect, const Track *pTrack )
|
|
||||||
{
|
|
||||||
auto dc = &context.dc;
|
|
||||||
wxRect bev = rect;
|
|
||||||
GetWideMuteSoloHorizontalBounds( rect, bev );
|
|
||||||
auto target = dynamic_cast<MuteButtonHandle*>( context.target.get() );
|
|
||||||
bool hit = target && target->GetTrack().get() == pTrack;
|
|
||||||
bool captured = hit && target->IsClicked();
|
|
||||||
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
|
||||||
MuteOrSoloDrawFunction( dc, bev, pTrack, down, captured, false, hit );
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackInfo::WideSoloDrawFunction
|
|
||||||
( TrackPanelDrawingContext &context,
|
|
||||||
const wxRect &rect, const Track *pTrack )
|
|
||||||
{
|
|
||||||
auto dc = &context.dc;
|
|
||||||
wxRect bev = rect;
|
|
||||||
GetWideMuteSoloHorizontalBounds( rect, bev );
|
|
||||||
auto target = dynamic_cast<SoloButtonHandle*>( context.target.get() );
|
|
||||||
bool hit = target && target->GetTrack().get() == pTrack;
|
|
||||||
bool captured = hit && target->IsClicked();
|
|
||||||
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
|
||||||
MuteOrSoloDrawFunction( dc, bev, pTrack, down, captured, true, hit );
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackInfo::MuteAndSoloDrawFunction
|
|
||||||
( TrackPanelDrawingContext &context,
|
|
||||||
const wxRect &rect, const Track *pTrack )
|
|
||||||
{
|
|
||||||
auto dc = &context.dc;
|
|
||||||
bool bHasSoloButton = HasSoloButton();
|
|
||||||
|
|
||||||
wxRect bev = rect;
|
|
||||||
if ( bHasSoloButton )
|
|
||||||
GetNarrowMuteHorizontalBounds( rect, bev );
|
|
||||||
else
|
|
||||||
GetWideMuteSoloHorizontalBounds( rect, bev );
|
|
||||||
{
|
|
||||||
auto target = dynamic_cast<MuteButtonHandle*>( context.target.get() );
|
|
||||||
bool hit = target && target->GetTrack().get() == pTrack;
|
|
||||||
bool captured = hit && target->IsClicked();
|
|
||||||
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
|
||||||
MuteOrSoloDrawFunction( dc, bev, pTrack, down, captured, false, hit );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !bHasSoloButton )
|
|
||||||
return;
|
|
||||||
|
|
||||||
GetNarrowSoloHorizontalBounds( rect, bev );
|
|
||||||
{
|
|
||||||
auto target = dynamic_cast<SoloButtonHandle*>( context.target.get() );
|
|
||||||
bool hit = target && target->GetTrack().get() == pTrack;
|
|
||||||
bool captured = hit && target->IsClicked();
|
|
||||||
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
|
||||||
MuteOrSoloDrawFunction( dc, bev, pTrack, down, captured, true, hit );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
wxFont gFont;
|
wxFont gFont;
|
||||||
@ -535,8 +418,6 @@ void TrackInfo::GetCloseBoxRect(const wxRect & rect, wxRect & dest)
|
|||||||
dest.height = results.second;
|
dest.height = results.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int TitleSoloBorderOverlap = 1;
|
|
||||||
|
|
||||||
void TrackInfo::GetTitleBarHorizontalBounds( const wxRect & rect, wxRect &dest )
|
void TrackInfo::GetTitleBarHorizontalBounds( const wxRect & rect, wxRect &dest )
|
||||||
{
|
{
|
||||||
// to right of CloseBoxRect, plus a little more
|
// to right of CloseBoxRect, plus a little more
|
||||||
@ -554,61 +435,6 @@ void TrackInfo::GetTitleBarRect(const wxRect & rect, wxRect & dest)
|
|||||||
dest.height = results.second;
|
dest.height = results.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackInfo::GetNarrowMuteHorizontalBounds( const wxRect & rect, wxRect &dest )
|
|
||||||
{
|
|
||||||
dest.x = rect.x;
|
|
||||||
dest.width = rect.width / 2 + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackInfo::GetNarrowSoloHorizontalBounds( const wxRect & rect, wxRect &dest )
|
|
||||||
{
|
|
||||||
wxRect muteRect;
|
|
||||||
GetNarrowMuteHorizontalBounds( rect, muteRect );
|
|
||||||
dest.x = rect.x + muteRect.width;
|
|
||||||
dest.width = rect.width - muteRect.width + TitleSoloBorderOverlap;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackInfo::GetWideMuteSoloHorizontalBounds( const wxRect & rect, wxRect &dest )
|
|
||||||
{
|
|
||||||
// Larger button, symmetrically placed intended.
|
|
||||||
// On windows this gives 15 pixels each side.
|
|
||||||
dest.width = rect.width - 2 * kTrackInfoBtnSize + 6;
|
|
||||||
dest.x = rect.x + kTrackInfoBtnSize -3;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackInfo::GetMuteSoloRect
|
|
||||||
(const wxRect & rect, wxRect & dest, bool solo, bool bHasSoloButton,
|
|
||||||
const Track *pTrack)
|
|
||||||
{
|
|
||||||
auto &trackControl = static_cast<const CommonTrackControls&>(
|
|
||||||
TrackControls::Get( *pTrack ) );
|
|
||||||
auto resultsM = CalcItemY( trackControl.GetTCPLines(), TCPLine::kItemMute );
|
|
||||||
auto resultsS = CalcItemY( trackControl.GetTCPLines(), TCPLine::kItemSolo );
|
|
||||||
dest.height = resultsS.second;
|
|
||||||
|
|
||||||
int yMute = resultsM.first;
|
|
||||||
int ySolo = resultsS.first;
|
|
||||||
|
|
||||||
bool bSameRow = ( yMute == ySolo );
|
|
||||||
bool bNarrow = bSameRow && bHasSoloButton;
|
|
||||||
|
|
||||||
if( bNarrow )
|
|
||||||
{
|
|
||||||
if( solo )
|
|
||||||
GetNarrowSoloHorizontalBounds( rect, dest );
|
|
||||||
else
|
|
||||||
GetNarrowMuteHorizontalBounds( rect, dest );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
GetWideMuteSoloHorizontalBounds( rect, dest );
|
|
||||||
|
|
||||||
if( bSameRow || !solo )
|
|
||||||
dest.y = rect.y + yMute;
|
|
||||||
else
|
|
||||||
dest.y = rect.y + ySolo;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackInfo::GetSliderHorizontalBounds( const wxPoint &topleft, wxRect &dest )
|
void TrackInfo::GetSliderHorizontalBounds( const wxPoint &topleft, wxRect &dest )
|
||||||
{
|
{
|
||||||
dest.x = topleft.x + 6;
|
dest.x = topleft.x + 6;
|
||||||
|
@ -28,6 +28,8 @@ class Track;
|
|||||||
struct TrackPanelDrawingContext;
|
struct TrackPanelDrawingContext;
|
||||||
class WaveTrack;
|
class WaveTrack;
|
||||||
|
|
||||||
|
static const int TitleSoloBorderOverlap = 1;
|
||||||
|
|
||||||
namespace TrackInfo
|
namespace TrackInfo
|
||||||
{
|
{
|
||||||
unsigned MinimumTrackHeight();
|
unsigned MinimumTrackHeight();
|
||||||
@ -87,22 +89,6 @@ namespace TrackInfo
|
|||||||
( TrackPanelDrawingContext &context,
|
( TrackPanelDrawingContext &context,
|
||||||
const wxRect &rect, const Track *pTrack );
|
const wxRect &rect, const Track *pTrack );
|
||||||
|
|
||||||
void MuteOrSoloDrawFunction
|
|
||||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, bool down,
|
|
||||||
bool captured, bool solo, bool hit );
|
|
||||||
|
|
||||||
void WideMuteDrawFunction
|
|
||||||
( TrackPanelDrawingContext &context,
|
|
||||||
const wxRect &rect, const Track *pTrack );
|
|
||||||
|
|
||||||
void WideSoloDrawFunction
|
|
||||||
( TrackPanelDrawingContext &context,
|
|
||||||
const wxRect &rect, const Track *pTrack );
|
|
||||||
|
|
||||||
void MuteAndSoloDrawFunction
|
|
||||||
( TrackPanelDrawingContext &context,
|
|
||||||
const wxRect &rect, const Track *pTrack );
|
|
||||||
|
|
||||||
void SetTrackInfoFont(wxDC *dc);
|
void SetTrackInfoFont(wxDC *dc);
|
||||||
|
|
||||||
|
|
||||||
@ -117,16 +103,6 @@ namespace TrackInfo
|
|||||||
void GetTitleBarHorizontalBounds( const wxRect & rect, wxRect &dest );
|
void GetTitleBarHorizontalBounds( const wxRect & rect, wxRect &dest );
|
||||||
void GetTitleBarRect(const wxRect & rect, wxRect &dest);
|
void GetTitleBarRect(const wxRect & rect, wxRect &dest);
|
||||||
|
|
||||||
void GetNarrowMuteHorizontalBounds
|
|
||||||
( const wxRect & rect, wxRect &dest );
|
|
||||||
void GetNarrowSoloHorizontalBounds
|
|
||||||
( const wxRect & rect, wxRect &dest );
|
|
||||||
void GetWideMuteSoloHorizontalBounds
|
|
||||||
( const wxRect & rect, wxRect &dest );
|
|
||||||
void GetMuteSoloRect
|
|
||||||
(const wxRect & rect, wxRect &dest, bool solo, bool bHasSoloButton,
|
|
||||||
const Track *pTrack);
|
|
||||||
|
|
||||||
void GetSliderHorizontalBounds( const wxPoint &topleft, wxRect &dest );
|
void GetSliderHorizontalBounds( const wxPoint &topleft, wxRect &dest );
|
||||||
|
|
||||||
void GetMinimizeHorizontalBounds( const wxRect &rect, wxRect &dest );
|
void GetMinimizeHorizontalBounds( const wxRect &rect, wxRect &dest );
|
||||||
@ -144,6 +120,8 @@ namespace TrackInfo
|
|||||||
// Non-member, namespace function relying on TrackPanel to invoke it
|
// Non-member, namespace function relying on TrackPanel to invoke it
|
||||||
// when it handles preference update events
|
// when it handles preference update events
|
||||||
void UpdatePrefs( wxWindow *pParent );
|
void UpdatePrefs( wxWindow *pParent );
|
||||||
|
|
||||||
|
bool HasSoloButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,7 +71,7 @@ std::vector<UIHandlePtr> NoteTrackControls::HitTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommonTrackControls::HitTest(st, pProject);
|
return NoteTrackControlsBase::HitTest(st, pProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
class NoteTrackMenuTable : public PopupMenuTable
|
class NoteTrackMenuTable : public PopupMenuTable
|
||||||
@ -85,7 +85,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void InitMenu(Menu*, void *pUserData) override
|
void InitMenu(Menu*, void *pUserData) override
|
||||||
{
|
{
|
||||||
mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
|
mpData = static_cast<NoteTrackControlsBase::InitMenuData*>(pUserData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyMenu() override
|
void DestroyMenu() override
|
||||||
@ -93,7 +93,7 @@ private:
|
|||||||
mpData = nullptr;
|
mpData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonTrackControls::InitMenuData *mpData;
|
NoteTrackControlsBase::InitMenuData *mpData;
|
||||||
|
|
||||||
void OnChangeOctave(wxCommandEvent &);
|
void OnChangeOctave(wxCommandEvent &);
|
||||||
};
|
};
|
||||||
@ -212,19 +212,8 @@ void MidiControlsDrawFunction
|
|||||||
static const struct NoteTrackTCPLines
|
static const struct NoteTrackTCPLines
|
||||||
: TCPLines { NoteTrackTCPLines() {
|
: TCPLines { NoteTrackTCPLines() {
|
||||||
(TCPLines&)*this =
|
(TCPLines&)*this =
|
||||||
CommonTrackControls::StaticTCPLines();
|
NoteTrackControlsBase::StaticTCPLines();
|
||||||
insert( end(), {
|
insert( end(), {
|
||||||
#ifdef EXPERIMENTAL_DA
|
|
||||||
// DA: Has Mute and Solo on separate lines.
|
|
||||||
{ TCPLine::kItemMute, kTrackInfoBtnSize + 1, 1,
|
|
||||||
TrackInfo::WideMuteDrawFunction },
|
|
||||||
{ TCPLine::kItemSolo, kTrackInfoBtnSize + 1, 0,
|
|
||||||
TrackInfo::WideSoloDrawFunction },
|
|
||||||
#else
|
|
||||||
{ TCPLine::kItemMute | TCPLine::kItemSolo, kTrackInfoBtnSize + 1, 0,
|
|
||||||
TrackInfo::MuteAndSoloDrawFunction },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{ TCPLine::kItemMidiControlsRect, kMidiCellHeight * 4, 0,
|
{ TCPLine::kItemMidiControlsRect, kMidiCellHeight * 4, 0,
|
||||||
MidiControlsDrawFunction },
|
MidiControlsDrawFunction },
|
||||||
{ TCPLine::kItemVelocity, kTrackInfoSliderHeight, kTrackInfoSliderExtra,
|
{ TCPLine::kItemVelocity, kTrackInfoSliderHeight, kTrackInfoSliderExtra,
|
||||||
|
@ -11,7 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#ifndef __AUDACITY_NOTE_TRACK_CONTROLS__
|
#ifndef __AUDACITY_NOTE_TRACK_CONTROLS__
|
||||||
#define __AUDACITY_NOTE_TRACK_CONTROLS__
|
#define __AUDACITY_NOTE_TRACK_CONTROLS__
|
||||||
|
|
||||||
#include "../../../ui/CommonTrackControls.h" // to inherit
|
#include "../../ui/PlayableTrackControls.h" // to inherit
|
||||||
class wxEvent;
|
class wxEvent;
|
||||||
class LWSlider;
|
class LWSlider;
|
||||||
class NoteTrack;
|
class NoteTrack;
|
||||||
@ -20,8 +20,19 @@ class SoloButtonHandle;
|
|||||||
class NoteTrackButtonHandle;
|
class NoteTrackButtonHandle;
|
||||||
class VelocitySliderHandle;
|
class VelocitySliderHandle;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
#include "Audacity.h"
|
||||||
class NoteTrackControls : public CommonTrackControls
|
#include "Experimental.h"
|
||||||
|
|
||||||
|
using NoteTrackControlsBase =
|
||||||
|
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||||
|
PlayableTrackControls
|
||||||
|
#else
|
||||||
|
CommonTrackControls
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
///////////////////////////////f////////////////////////////////////////////////
|
||||||
|
class NoteTrackControls : public NoteTrackControlsBase
|
||||||
{
|
{
|
||||||
NoteTrackControls(const NoteTrackControls&) = delete;
|
NoteTrackControls(const NoteTrackControls&) = delete;
|
||||||
NoteTrackControls &operator=(const NoteTrackControls&) = delete;
|
NoteTrackControls &operator=(const NoteTrackControls&) = delete;
|
||||||
@ -34,7 +45,7 @@ class NoteTrackControls : public CommonTrackControls
|
|||||||
public:
|
public:
|
||||||
explicit
|
explicit
|
||||||
NoteTrackControls( std::shared_ptr<Track> pTrack )
|
NoteTrackControls( std::shared_ptr<Track> pTrack )
|
||||||
: CommonTrackControls( pTrack ) {}
|
: NoteTrackControlsBase( pTrack ) {}
|
||||||
~NoteTrackControls();
|
~NoteTrackControls();
|
||||||
|
|
||||||
std::vector<UIHandlePtr> HitTest
|
std::vector<UIHandlePtr> HitTest
|
||||||
|
@ -11,6 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../../Audacity.h"
|
#include "../../../Audacity.h"
|
||||||
#include "PlayableTrackButtonHandles.h"
|
#include "PlayableTrackButtonHandles.h"
|
||||||
|
|
||||||
|
#include "PlayableTrackControls.h"
|
||||||
#include "../../../commands/CommandManager.h"
|
#include "../../../commands/CommandManager.h"
|
||||||
#include "../../../Menus.h"
|
#include "../../../Menus.h"
|
||||||
#include "../../../Project.h"
|
#include "../../../Project.h"
|
||||||
@ -61,7 +62,7 @@ UIHandlePtr MuteButtonHandle::HitTest
|
|||||||
{
|
{
|
||||||
wxRect buttonRect;
|
wxRect buttonRect;
|
||||||
if ( pTrack )
|
if ( pTrack )
|
||||||
TrackInfo::GetMuteSoloRect(rect, buttonRect, false,
|
PlayableTrackControls::GetMuteSoloRect(rect, buttonRect, false,
|
||||||
!ProjectSettings::Get( *pProject ).IsSoloNone(), pTrack.get());
|
!ProjectSettings::Get( *pProject ).IsSoloNone(), pTrack.get());
|
||||||
if ( TrackInfo::HideTopItem( rect, buttonRect ) )
|
if ( TrackInfo::HideTopItem( rect, buttonRect ) )
|
||||||
return {};
|
return {};
|
||||||
@ -117,7 +118,7 @@ UIHandlePtr SoloButtonHandle::HitTest
|
|||||||
{
|
{
|
||||||
wxRect buttonRect;
|
wxRect buttonRect;
|
||||||
if ( pTrack )
|
if ( pTrack )
|
||||||
TrackInfo::GetMuteSoloRect(rect, buttonRect, true,
|
PlayableTrackControls::GetMuteSoloRect(rect, buttonRect, true,
|
||||||
!ProjectSettings::Get( *pProject ).IsSoloNone(), pTrack.get());
|
!ProjectSettings::Get( *pProject ).IsSoloNone(), pTrack.get());
|
||||||
|
|
||||||
if ( TrackInfo::HideTopItem( rect, buttonRect ) )
|
if ( TrackInfo::HideTopItem( rect, buttonRect ) )
|
||||||
|
@ -0,0 +1,219 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
PlayableTrackControls.cpp
|
||||||
|
|
||||||
|
Paul Licameli split from TrackInfo.cpp
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "PlayableTrackControls.h"
|
||||||
|
|
||||||
|
#include "../../../Audacity.h"
|
||||||
|
#include "../../../Experimental.h"
|
||||||
|
|
||||||
|
#include "PlayableTrackButtonHandles.h"
|
||||||
|
#include "../../../AColor.h"
|
||||||
|
#include "../../../Track.h"
|
||||||
|
#include "../../../TrackInfo.h"
|
||||||
|
#include "../../../TrackPanelDrawingContext.h"
|
||||||
|
#include "../../../ViewInfo.h"
|
||||||
|
|
||||||
|
#include <wx/dc.h>
|
||||||
|
|
||||||
|
using TCPLine = TrackInfo::TCPLine;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void GetNarrowMuteHorizontalBounds( const wxRect & rect, wxRect &dest )
|
||||||
|
{
|
||||||
|
dest.x = rect.x;
|
||||||
|
dest.width = rect.width / 2 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetNarrowSoloHorizontalBounds( const wxRect & rect, wxRect &dest )
|
||||||
|
{
|
||||||
|
wxRect muteRect;
|
||||||
|
GetNarrowMuteHorizontalBounds( rect, muteRect );
|
||||||
|
dest.x = rect.x + muteRect.width;
|
||||||
|
dest.width = rect.width - muteRect.width + TitleSoloBorderOverlap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetWideMuteSoloHorizontalBounds( const wxRect & rect, wxRect &dest )
|
||||||
|
{
|
||||||
|
// Larger button, symmetrically placed intended.
|
||||||
|
// On windows this gives 15 pixels each side.
|
||||||
|
dest.width = rect.width - 2 * kTrackInfoBtnSize + 6;
|
||||||
|
dest.x = rect.x + kTrackInfoBtnSize -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MuteOrSoloDrawFunction
|
||||||
|
( wxDC *dc, const wxRect &bev, const Track *pTrack, bool down,
|
||||||
|
bool WXUNUSED(captured),
|
||||||
|
bool solo, bool hit )
|
||||||
|
{
|
||||||
|
//bev.Inflate(-1, -1);
|
||||||
|
bool selected = pTrack ? pTrack->GetSelected() : true;
|
||||||
|
auto pt = dynamic_cast<const PlayableTrack *>(pTrack);
|
||||||
|
bool value = pt ? (solo ? pt->GetSolo() : pt->GetMute()) : false;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
AColor::MediumTrackInfo( dc, t->GetSelected());
|
||||||
|
if( solo )
|
||||||
|
{
|
||||||
|
if( pt && pt->GetSolo() )
|
||||||
|
{
|
||||||
|
AColor::Solo(dc, pt->GetSolo(), t->GetSelected());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( pt && pt->GetMute() )
|
||||||
|
{
|
||||||
|
AColor::Mute(dc, pt->GetMute(), t->GetSelected(), pt->GetSolo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//(solo) ? AColor::Solo(dc, t->GetSolo(), t->GetSelected()) :
|
||||||
|
// AColor::Mute(dc, t->GetMute(), t->GetSelected(), t->GetSolo());
|
||||||
|
dc->SetPen( *wxTRANSPARENT_PEN );//No border!
|
||||||
|
dc->DrawRectangle(bev);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxCoord textWidth, textHeight;
|
||||||
|
wxString str = (solo) ?
|
||||||
|
/* i18n-hint: This is on a button that will silence all the other tracks.*/
|
||||||
|
_("Solo") :
|
||||||
|
/* i18n-hint: This is on a button that will silence this track.*/
|
||||||
|
_("Mute");
|
||||||
|
|
||||||
|
AColor::Bevel2(
|
||||||
|
*dc,
|
||||||
|
value == down,
|
||||||
|
bev,
|
||||||
|
selected, hit
|
||||||
|
);
|
||||||
|
|
||||||
|
TrackInfo::SetTrackInfoFont(dc);
|
||||||
|
dc->GetTextExtent(str, &textWidth, &textHeight);
|
||||||
|
dc->DrawText(str, bev.x + (bev.width - textWidth) / 2, bev.y + (bev.height - textHeight) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WideMuteDrawFunction
|
||||||
|
( TrackPanelDrawingContext &context,
|
||||||
|
const wxRect &rect, const Track *pTrack )
|
||||||
|
{
|
||||||
|
auto dc = &context.dc;
|
||||||
|
wxRect bev = rect;
|
||||||
|
GetWideMuteSoloHorizontalBounds( rect, bev );
|
||||||
|
auto target = dynamic_cast<MuteButtonHandle*>( context.target.get() );
|
||||||
|
bool hit = target && target->GetTrack().get() == pTrack;
|
||||||
|
bool captured = hit && target->IsClicked();
|
||||||
|
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
||||||
|
MuteOrSoloDrawFunction( dc, bev, pTrack, down, captured, false, hit );
|
||||||
|
}
|
||||||
|
|
||||||
|
void WideSoloDrawFunction
|
||||||
|
( TrackPanelDrawingContext &context,
|
||||||
|
const wxRect &rect, const Track *pTrack )
|
||||||
|
{
|
||||||
|
auto dc = &context.dc;
|
||||||
|
wxRect bev = rect;
|
||||||
|
GetWideMuteSoloHorizontalBounds( rect, bev );
|
||||||
|
auto target = dynamic_cast<SoloButtonHandle*>( context.target.get() );
|
||||||
|
bool hit = target && target->GetTrack().get() == pTrack;
|
||||||
|
bool captured = hit && target->IsClicked();
|
||||||
|
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
||||||
|
MuteOrSoloDrawFunction( dc, bev, pTrack, down, captured, true, hit );
|
||||||
|
}
|
||||||
|
|
||||||
|
void MuteAndSoloDrawFunction
|
||||||
|
( TrackPanelDrawingContext &context,
|
||||||
|
const wxRect &rect, const Track *pTrack )
|
||||||
|
{
|
||||||
|
auto dc = &context.dc;
|
||||||
|
bool bHasSoloButton = TrackInfo::HasSoloButton();
|
||||||
|
|
||||||
|
wxRect bev = rect;
|
||||||
|
if ( bHasSoloButton )
|
||||||
|
GetNarrowMuteHorizontalBounds( rect, bev );
|
||||||
|
else
|
||||||
|
GetWideMuteSoloHorizontalBounds( rect, bev );
|
||||||
|
{
|
||||||
|
auto target = dynamic_cast<MuteButtonHandle*>( context.target.get() );
|
||||||
|
bool hit = target && target->GetTrack().get() == pTrack;
|
||||||
|
bool captured = hit && target->IsClicked();
|
||||||
|
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
||||||
|
MuteOrSoloDrawFunction( dc, bev, pTrack, down, captured, false, hit );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !bHasSoloButton )
|
||||||
|
return;
|
||||||
|
|
||||||
|
GetNarrowSoloHorizontalBounds( rect, bev );
|
||||||
|
{
|
||||||
|
auto target = dynamic_cast<SoloButtonHandle*>( context.target.get() );
|
||||||
|
bool hit = target && target->GetTrack().get() == pTrack;
|
||||||
|
bool captured = hit && target->IsClicked();
|
||||||
|
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
||||||
|
MuteOrSoloDrawFunction( dc, bev, pTrack, down, captured, true, hit );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayableTrackControls::GetMuteSoloRect
|
||||||
|
(const wxRect & rect, wxRect & dest, bool solo, bool bHasSoloButton,
|
||||||
|
const Track *pTrack)
|
||||||
|
{
|
||||||
|
auto &trackControl = static_cast<const CommonTrackControls&>(
|
||||||
|
TrackControls::Get( *pTrack ) );
|
||||||
|
auto resultsM = TrackInfo::CalcItemY( trackControl.GetTCPLines(), TCPLine::kItemMute );
|
||||||
|
auto resultsS = TrackInfo::CalcItemY( trackControl.GetTCPLines(), TCPLine::kItemSolo );
|
||||||
|
dest.height = resultsS.second;
|
||||||
|
|
||||||
|
int yMute = resultsM.first;
|
||||||
|
int ySolo = resultsS.first;
|
||||||
|
|
||||||
|
bool bSameRow = ( yMute == ySolo );
|
||||||
|
bool bNarrow = bSameRow && bHasSoloButton;
|
||||||
|
|
||||||
|
if( bNarrow )
|
||||||
|
{
|
||||||
|
if( solo )
|
||||||
|
GetNarrowSoloHorizontalBounds( rect, dest );
|
||||||
|
else
|
||||||
|
GetNarrowMuteHorizontalBounds( rect, dest );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
GetWideMuteSoloHorizontalBounds( rect, dest );
|
||||||
|
|
||||||
|
if( bSameRow || !solo )
|
||||||
|
dest.y = rect.y + yMute;
|
||||||
|
else
|
||||||
|
dest.y = rect.y + ySolo;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const TCPLines& PlayableTrackControls::StaticTCPLines()
|
||||||
|
{
|
||||||
|
static const struct PlayableTrackTCPLines
|
||||||
|
: TCPLines { PlayableTrackTCPLines() {
|
||||||
|
(TCPLines&)*this =
|
||||||
|
CommonTrackControls::StaticTCPLines();
|
||||||
|
insert( end(), {
|
||||||
|
#ifdef EXPERIMENTAL_DA
|
||||||
|
// DA: Has Mute and Solo on separate lines.
|
||||||
|
{ TCPLine::kItemMute, kTrackInfoBtnSize + 1, 1,
|
||||||
|
WideMuteDrawFunction },
|
||||||
|
{ TCPLine::kItemSolo, kTrackInfoBtnSize + 1, 0,
|
||||||
|
WideSoloDrawFunction },
|
||||||
|
#else
|
||||||
|
{ TCPLine::kItemMute | TCPLine::kItemSolo, kTrackInfoBtnSize + 1, 0,
|
||||||
|
MuteAndSoloDrawFunction },
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} );
|
||||||
|
} } playableTrackTCPLines;
|
||||||
|
return playableTrackTCPLines;
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
PlayableTrackControls.cpp
|
||||||
|
|
||||||
|
Paul Licameli split from TrackInfo.cpp
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef __AUDACITY_PLAYABLE_TRACK_CONTROLS__
|
||||||
|
#define __AUDACITY_PLAYABLE_TRACK_CONTROLS__
|
||||||
|
|
||||||
|
#include "../../ui/CommonTrackControls.h"
|
||||||
|
|
||||||
|
class wxRect;
|
||||||
|
class Track;
|
||||||
|
|
||||||
|
class PlayableTrackControls /* not final */ : public CommonTrackControls
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// To help subclasses define GetTCPLines
|
||||||
|
static const TCPLines& StaticTCPLines();
|
||||||
|
|
||||||
|
static void GetMuteSoloRect(
|
||||||
|
const wxRect & rect, wxRect & dest, bool solo, bool bHasSoloButton,
|
||||||
|
const Track *pTrack);
|
||||||
|
|
||||||
|
using CommonTrackControls::CommonTrackControls;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -98,7 +98,7 @@ std::vector<UIHandlePtr> WaveTrackControls::HitTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommonTrackControls::HitTest(st, pProject);
|
return PlayableTrackControls::HitTest(st, pProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -162,7 +162,7 @@ private:
|
|||||||
mpData = NULL;
|
mpData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonTrackControls::InitMenuData *mpData;
|
PlayableTrackControls::InitMenuData *mpData;
|
||||||
|
|
||||||
int IdOfWaveColor(int WaveColor);
|
int IdOfWaveColor(int WaveColor);
|
||||||
void OnWaveColorChange(wxCommandEvent & event);
|
void OnWaveColorChange(wxCommandEvent & event);
|
||||||
@ -176,7 +176,7 @@ WaveColorMenuTable &WaveColorMenuTable::Instance()
|
|||||||
|
|
||||||
void WaveColorMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
void WaveColorMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
||||||
{
|
{
|
||||||
mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
|
mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
|
||||||
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
||||||
auto WaveColorId = IdOfWaveColor( pTrack->GetWaveColorIndex());
|
auto WaveColorId = IdOfWaveColor( pTrack->GetWaveColorIndex());
|
||||||
SetMenuChecks(*pMenu, [=](int id){ return id == WaveColorId; });
|
SetMenuChecks(*pMenu, [=](int id){ return id == WaveColorId; });
|
||||||
@ -255,7 +255,7 @@ private:
|
|||||||
mpData = NULL;
|
mpData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonTrackControls::InitMenuData *mpData;
|
PlayableTrackControls::InitMenuData *mpData;
|
||||||
|
|
||||||
int IdOfFormat(int format);
|
int IdOfFormat(int format);
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ FormatMenuTable &FormatMenuTable::Instance()
|
|||||||
|
|
||||||
void FormatMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
void FormatMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
||||||
{
|
{
|
||||||
mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
|
mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
|
||||||
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
||||||
auto formatId = IdOfFormat(pTrack->GetSampleFormat());
|
auto formatId = IdOfFormat(pTrack->GetSampleFormat());
|
||||||
SetMenuChecks(*pMenu, [=](int id){ return id == formatId; });
|
SetMenuChecks(*pMenu, [=](int id){ return id == formatId; });
|
||||||
@ -372,7 +372,7 @@ private:
|
|||||||
mpData = NULL;
|
mpData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonTrackControls::InitMenuData *mpData;
|
PlayableTrackControls::InitMenuData *mpData;
|
||||||
|
|
||||||
int IdOfRate(int rate);
|
int IdOfRate(int rate);
|
||||||
void SetRate(WaveTrack * pTrack, double rate);
|
void SetRate(WaveTrack * pTrack, double rate);
|
||||||
@ -389,7 +389,7 @@ RateMenuTable &RateMenuTable::Instance()
|
|||||||
|
|
||||||
void RateMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
void RateMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
||||||
{
|
{
|
||||||
mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
|
mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
|
||||||
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
||||||
const auto rateId = IdOfRate((int)pTrack->GetRate());
|
const auto rateId = IdOfRate((int)pTrack->GetRate());
|
||||||
SetMenuChecks(*pMenu, [=](int id){ return id == rateId; });
|
SetMenuChecks(*pMenu, [=](int id){ return id == rateId; });
|
||||||
@ -562,7 +562,7 @@ protected:
|
|||||||
|
|
||||||
DECLARE_POPUP_MENU(WaveTrackMenuTable);
|
DECLARE_POPUP_MENU(WaveTrackMenuTable);
|
||||||
|
|
||||||
CommonTrackControls::InitMenuData *mpData;
|
PlayableTrackControls::InitMenuData *mpData;
|
||||||
|
|
||||||
void OnSetDisplay(wxCommandEvent & event);
|
void OnSetDisplay(wxCommandEvent & event);
|
||||||
void OnSpectrogramSettings(wxCommandEvent & event);
|
void OnSpectrogramSettings(wxCommandEvent & event);
|
||||||
@ -594,7 +594,7 @@ WaveTrackMenuTable &WaveTrackMenuTable::Instance( Track * pTrack )
|
|||||||
|
|
||||||
void WaveTrackMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
void WaveTrackMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
||||||
{
|
{
|
||||||
mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
|
mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
|
||||||
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
||||||
|
|
||||||
std::vector<int> checkedIds;
|
std::vector<int> checkedIds;
|
||||||
@ -625,7 +625,7 @@ void WaveTrackMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
|||||||
|
|
||||||
if ( isMono )
|
if ( isMono )
|
||||||
{
|
{
|
||||||
mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
|
mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
|
||||||
WaveTrack *const pTrack2 = static_cast<WaveTrack*>(mpData->pTrack);
|
WaveTrack *const pTrack2 = static_cast<WaveTrack*>(mpData->pTrack);
|
||||||
|
|
||||||
auto next = * ++ tracks.Find(pTrack2);
|
auto next = * ++ tracks.Find(pTrack2);
|
||||||
@ -1116,20 +1116,9 @@ using TCPLine = TrackInfo::TCPLine;
|
|||||||
static const struct WaveTrackTCPLines
|
static const struct WaveTrackTCPLines
|
||||||
: TCPLines { WaveTrackTCPLines() {
|
: TCPLines { WaveTrackTCPLines() {
|
||||||
(TCPLines&)*this =
|
(TCPLines&)*this =
|
||||||
CommonTrackControls::StaticTCPLines();
|
PlayableTrackControls::StaticTCPLines();
|
||||||
insert( end(), {
|
insert( end(), {
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_DA
|
|
||||||
// DA: Has Mute and Solo on separate lines.
|
|
||||||
{ TCPLine::kItemMute, kTrackInfoBtnSize + 1, 1,
|
|
||||||
TrackInfo::WideMuteDrawFunction },
|
|
||||||
{ TCPLine::kItemSolo, kTrackInfoBtnSize + 1, 2,
|
|
||||||
TrackInfo::WideSoloDrawFunction },
|
|
||||||
#else
|
|
||||||
{ TCPLine::kItemMute | TCPLine::kItemSolo, kTrackInfoBtnSize + 1, 2,
|
|
||||||
TrackInfo::MuteAndSoloDrawFunction },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{ TCPLine::kItemGain, kTrackInfoSliderHeight, kTrackInfoSliderExtra,
|
{ TCPLine::kItemGain, kTrackInfoSliderHeight, kTrackInfoSliderExtra,
|
||||||
GainSliderDrawFunction },
|
GainSliderDrawFunction },
|
||||||
{ TCPLine::kItemPan, kTrackInfoSliderHeight, kTrackInfoSliderExtra,
|
{ TCPLine::kItemPan, kTrackInfoSliderHeight, kTrackInfoSliderExtra,
|
||||||
|
@ -11,7 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#ifndef __AUDACITY_WAVE_TRACK_CONTROLS__
|
#ifndef __AUDACITY_WAVE_TRACK_CONTROLS__
|
||||||
#define __AUDACITY_WAVE_TRACK_CONTROLS__
|
#define __AUDACITY_WAVE_TRACK_CONTROLS__
|
||||||
|
|
||||||
#include "../../../ui/CommonTrackControls.h" // to inherit
|
#include "../../ui/PlayableTrackControls.h" // to inherit
|
||||||
|
|
||||||
class CellularPanel;
|
class CellularPanel;
|
||||||
class LWSlider;
|
class LWSlider;
|
||||||
@ -23,7 +23,7 @@ class WaveTrack;
|
|||||||
class wxEvent;
|
class wxEvent;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
|
|
||||||
class WaveTrackControls final : public CommonTrackControls
|
class WaveTrackControls final : public PlayableTrackControls
|
||||||
{
|
{
|
||||||
WaveTrackControls(const WaveTrackControls&) = delete;
|
WaveTrackControls(const WaveTrackControls&) = delete;
|
||||||
WaveTrackControls &operator=(const WaveTrackControls&) = delete;
|
WaveTrackControls &operator=(const WaveTrackControls&) = delete;
|
||||||
@ -31,7 +31,7 @@ class WaveTrackControls final : public CommonTrackControls
|
|||||||
public:
|
public:
|
||||||
explicit
|
explicit
|
||||||
WaveTrackControls( std::shared_ptr<Track> pTrack )
|
WaveTrackControls( std::shared_ptr<Track> pTrack )
|
||||||
: CommonTrackControls( pTrack ) {}
|
: PlayableTrackControls( pTrack ) {}
|
||||||
~WaveTrackControls();
|
~WaveTrackControls();
|
||||||
|
|
||||||
std::vector<UIHandlePtr> HitTest
|
std::vector<UIHandlePtr> HitTest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user