mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 16:39:30 +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 "widgets/ASlider.h"
|
||||
|
||||
namespace {
|
||||
|
||||
wxString gSoloPref;
|
||||
inline bool HasSoloButton()
|
||||
static wxString gSoloPref;
|
||||
bool TrackInfo::HasSoloButton()
|
||||
{
|
||||
return gSoloPref!=wxT("None");
|
||||
}
|
||||
@ -55,8 +53,6 @@ inline bool HasSoloButton()
|
||||
using TCPLine = TrackInfo::TCPLine;
|
||||
using TCPLines = TrackInfo::TCPLines;
|
||||
|
||||
}
|
||||
|
||||
static const TCPLines &commonTrackTCPLines()
|
||||
{
|
||||
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 {
|
||||
|
||||
wxFont gFont;
|
||||
@ -535,8 +418,6 @@ void TrackInfo::GetCloseBoxRect(const wxRect & rect, wxRect & dest)
|
||||
dest.height = results.second;
|
||||
}
|
||||
|
||||
static const int TitleSoloBorderOverlap = 1;
|
||||
|
||||
void TrackInfo::GetTitleBarHorizontalBounds( const wxRect & rect, wxRect &dest )
|
||||
{
|
||||
// to right of CloseBoxRect, plus a little more
|
||||
@ -554,61 +435,6 @@ void TrackInfo::GetTitleBarRect(const wxRect & rect, wxRect & dest)
|
||||
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 )
|
||||
{
|
||||
dest.x = topleft.x + 6;
|
||||
|
@ -28,6 +28,8 @@ class Track;
|
||||
struct TrackPanelDrawingContext;
|
||||
class WaveTrack;
|
||||
|
||||
static const int TitleSoloBorderOverlap = 1;
|
||||
|
||||
namespace TrackInfo
|
||||
{
|
||||
unsigned MinimumTrackHeight();
|
||||
@ -87,22 +89,6 @@ namespace TrackInfo
|
||||
( TrackPanelDrawingContext &context,
|
||||
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);
|
||||
|
||||
|
||||
@ -117,16 +103,6 @@ namespace TrackInfo
|
||||
void GetTitleBarHorizontalBounds( 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 GetMinimizeHorizontalBounds( const wxRect &rect, wxRect &dest );
|
||||
@ -144,6 +120,8 @@ namespace TrackInfo
|
||||
// Non-member, namespace function relying on TrackPanel to invoke it
|
||||
// when it handles preference update events
|
||||
void UpdatePrefs( wxWindow *pParent );
|
||||
|
||||
bool HasSoloButton();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -71,7 +71,7 @@ std::vector<UIHandlePtr> NoteTrackControls::HitTest
|
||||
}
|
||||
}
|
||||
|
||||
return CommonTrackControls::HitTest(st, pProject);
|
||||
return NoteTrackControlsBase::HitTest(st, pProject);
|
||||
}
|
||||
|
||||
class NoteTrackMenuTable : public PopupMenuTable
|
||||
@ -85,7 +85,7 @@ public:
|
||||
private:
|
||||
void InitMenu(Menu*, void *pUserData) override
|
||||
{
|
||||
mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
|
||||
mpData = static_cast<NoteTrackControlsBase::InitMenuData*>(pUserData);
|
||||
}
|
||||
|
||||
void DestroyMenu() override
|
||||
@ -93,7 +93,7 @@ private:
|
||||
mpData = nullptr;
|
||||
}
|
||||
|
||||
CommonTrackControls::InitMenuData *mpData;
|
||||
NoteTrackControlsBase::InitMenuData *mpData;
|
||||
|
||||
void OnChangeOctave(wxCommandEvent &);
|
||||
};
|
||||
@ -212,19 +212,8 @@ void MidiControlsDrawFunction
|
||||
static const struct NoteTrackTCPLines
|
||||
: TCPLines { NoteTrackTCPLines() {
|
||||
(TCPLines&)*this =
|
||||
CommonTrackControls::StaticTCPLines();
|
||||
NoteTrackControlsBase::StaticTCPLines();
|
||||
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,
|
||||
MidiControlsDrawFunction },
|
||||
{ TCPLine::kItemVelocity, kTrackInfoSliderHeight, kTrackInfoSliderExtra,
|
||||
|
@ -11,7 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#ifndef __AUDACITY_NOTE_TRACK_CONTROLS__
|
||||
#define __AUDACITY_NOTE_TRACK_CONTROLS__
|
||||
|
||||
#include "../../../ui/CommonTrackControls.h" // to inherit
|
||||
#include "../../ui/PlayableTrackControls.h" // to inherit
|
||||
class wxEvent;
|
||||
class LWSlider;
|
||||
class NoteTrack;
|
||||
@ -20,8 +20,19 @@ class SoloButtonHandle;
|
||||
class NoteTrackButtonHandle;
|
||||
class VelocitySliderHandle;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class NoteTrackControls : public CommonTrackControls
|
||||
#include "Audacity.h"
|
||||
#include "Experimental.h"
|
||||
|
||||
using NoteTrackControlsBase =
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
PlayableTrackControls
|
||||
#else
|
||||
CommonTrackControls
|
||||
#endif
|
||||
;
|
||||
|
||||
///////////////////////////////f////////////////////////////////////////////////
|
||||
class NoteTrackControls : public NoteTrackControlsBase
|
||||
{
|
||||
NoteTrackControls(const NoteTrackControls&) = delete;
|
||||
NoteTrackControls &operator=(const NoteTrackControls&) = delete;
|
||||
@ -34,7 +45,7 @@ class NoteTrackControls : public CommonTrackControls
|
||||
public:
|
||||
explicit
|
||||
NoteTrackControls( std::shared_ptr<Track> pTrack )
|
||||
: CommonTrackControls( pTrack ) {}
|
||||
: NoteTrackControlsBase( pTrack ) {}
|
||||
~NoteTrackControls();
|
||||
|
||||
std::vector<UIHandlePtr> HitTest
|
||||
|
@ -11,6 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../Audacity.h"
|
||||
#include "PlayableTrackButtonHandles.h"
|
||||
|
||||
#include "PlayableTrackControls.h"
|
||||
#include "../../../commands/CommandManager.h"
|
||||
#include "../../../Menus.h"
|
||||
#include "../../../Project.h"
|
||||
@ -61,7 +62,7 @@ UIHandlePtr MuteButtonHandle::HitTest
|
||||
{
|
||||
wxRect buttonRect;
|
||||
if ( pTrack )
|
||||
TrackInfo::GetMuteSoloRect(rect, buttonRect, false,
|
||||
PlayableTrackControls::GetMuteSoloRect(rect, buttonRect, false,
|
||||
!ProjectSettings::Get( *pProject ).IsSoloNone(), pTrack.get());
|
||||
if ( TrackInfo::HideTopItem( rect, buttonRect ) )
|
||||
return {};
|
||||
@ -117,7 +118,7 @@ UIHandlePtr SoloButtonHandle::HitTest
|
||||
{
|
||||
wxRect buttonRect;
|
||||
if ( pTrack )
|
||||
TrackInfo::GetMuteSoloRect(rect, buttonRect, true,
|
||||
PlayableTrackControls::GetMuteSoloRect(rect, buttonRect, true,
|
||||
!ProjectSettings::Get( *pProject ).IsSoloNone(), pTrack.get());
|
||||
|
||||
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 {
|
||||
@ -162,7 +162,7 @@ private:
|
||||
mpData = NULL;
|
||||
}
|
||||
|
||||
CommonTrackControls::InitMenuData *mpData;
|
||||
PlayableTrackControls::InitMenuData *mpData;
|
||||
|
||||
int IdOfWaveColor(int WaveColor);
|
||||
void OnWaveColorChange(wxCommandEvent & event);
|
||||
@ -176,7 +176,7 @@ WaveColorMenuTable &WaveColorMenuTable::Instance()
|
||||
|
||||
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);
|
||||
auto WaveColorId = IdOfWaveColor( pTrack->GetWaveColorIndex());
|
||||
SetMenuChecks(*pMenu, [=](int id){ return id == WaveColorId; });
|
||||
@ -255,7 +255,7 @@ private:
|
||||
mpData = NULL;
|
||||
}
|
||||
|
||||
CommonTrackControls::InitMenuData *mpData;
|
||||
PlayableTrackControls::InitMenuData *mpData;
|
||||
|
||||
int IdOfFormat(int format);
|
||||
|
||||
@ -270,7 +270,7 @@ FormatMenuTable &FormatMenuTable::Instance()
|
||||
|
||||
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);
|
||||
auto formatId = IdOfFormat(pTrack->GetSampleFormat());
|
||||
SetMenuChecks(*pMenu, [=](int id){ return id == formatId; });
|
||||
@ -372,7 +372,7 @@ private:
|
||||
mpData = NULL;
|
||||
}
|
||||
|
||||
CommonTrackControls::InitMenuData *mpData;
|
||||
PlayableTrackControls::InitMenuData *mpData;
|
||||
|
||||
int IdOfRate(int rate);
|
||||
void SetRate(WaveTrack * pTrack, double rate);
|
||||
@ -389,7 +389,7 @@ RateMenuTable &RateMenuTable::Instance()
|
||||
|
||||
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);
|
||||
const auto rateId = IdOfRate((int)pTrack->GetRate());
|
||||
SetMenuChecks(*pMenu, [=](int id){ return id == rateId; });
|
||||
@ -562,7 +562,7 @@ protected:
|
||||
|
||||
DECLARE_POPUP_MENU(WaveTrackMenuTable);
|
||||
|
||||
CommonTrackControls::InitMenuData *mpData;
|
||||
PlayableTrackControls::InitMenuData *mpData;
|
||||
|
||||
void OnSetDisplay(wxCommandEvent & event);
|
||||
void OnSpectrogramSettings(wxCommandEvent & event);
|
||||
@ -594,7 +594,7 @@ WaveTrackMenuTable &WaveTrackMenuTable::Instance( Track * pTrack )
|
||||
|
||||
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);
|
||||
|
||||
std::vector<int> checkedIds;
|
||||
@ -625,7 +625,7 @@ void WaveTrackMenuTable::InitMenu(Menu *pMenu, void *pUserData)
|
||||
|
||||
if ( isMono )
|
||||
{
|
||||
mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
|
||||
mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
|
||||
WaveTrack *const pTrack2 = static_cast<WaveTrack*>(mpData->pTrack);
|
||||
|
||||
auto next = * ++ tracks.Find(pTrack2);
|
||||
@ -1116,20 +1116,9 @@ using TCPLine = TrackInfo::TCPLine;
|
||||
static const struct WaveTrackTCPLines
|
||||
: TCPLines { WaveTrackTCPLines() {
|
||||
(TCPLines&)*this =
|
||||
CommonTrackControls::StaticTCPLines();
|
||||
PlayableTrackControls::StaticTCPLines();
|
||||
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,
|
||||
GainSliderDrawFunction },
|
||||
{ TCPLine::kItemPan, kTrackInfoSliderHeight, kTrackInfoSliderExtra,
|
||||
|
@ -11,7 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#ifndef __AUDACITY_WAVE_TRACK_CONTROLS__
|
||||
#define __AUDACITY_WAVE_TRACK_CONTROLS__
|
||||
|
||||
#include "../../../ui/CommonTrackControls.h" // to inherit
|
||||
#include "../../ui/PlayableTrackControls.h" // to inherit
|
||||
|
||||
class CellularPanel;
|
||||
class LWSlider;
|
||||
@ -23,7 +23,7 @@ class WaveTrack;
|
||||
class wxEvent;
|
||||
class wxWindow;
|
||||
|
||||
class WaveTrackControls final : public CommonTrackControls
|
||||
class WaveTrackControls final : public PlayableTrackControls
|
||||
{
|
||||
WaveTrackControls(const WaveTrackControls&) = delete;
|
||||
WaveTrackControls &operator=(const WaveTrackControls&) = delete;
|
||||
@ -31,7 +31,7 @@ class WaveTrackControls final : public CommonTrackControls
|
||||
public:
|
||||
explicit
|
||||
WaveTrackControls( std::shared_ptr<Track> pTrack )
|
||||
: CommonTrackControls( pTrack ) {}
|
||||
: PlayableTrackControls( pTrack ) {}
|
||||
~WaveTrackControls();
|
||||
|
||||
std::vector<UIHandlePtr> HitTest
|
||||
|
Loading…
x
Reference in New Issue
Block a user