mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-01 15:43:44 +02:00
CalcItemY is table-driven; stack Mute & Solo for NoteTrack too in DA
This commit is contained in:
parent
08fe53875a
commit
b8492d02d6
@ -5176,6 +5176,96 @@ void TrackPanel::OnContextMenu(wxContextMenuEvent & WXUNUSED(event))
|
|||||||
OnTrackMenu();
|
OnTrackMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
enum : unsigned {
|
||||||
|
// The sequence is not significant, just keep bits distinct
|
||||||
|
kItemBarButtons = 1 << 0,
|
||||||
|
kItemStatusInfo = 1 << 1,
|
||||||
|
kItemMute = 1 << 2,
|
||||||
|
kItemSolo = 1 << 3,
|
||||||
|
kItemGain = 1 << 4,
|
||||||
|
kItemPan = 1 << 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TCPLine {
|
||||||
|
unsigned items; // a bitwise OR of values of the enum above
|
||||||
|
int height;
|
||||||
|
int extraSpace;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_DA
|
||||||
|
|
||||||
|
#define TITLE_ITEMS(extra) \
|
||||||
|
{ kItemBarButtons, kTrackInfoBtnSize, 4 },
|
||||||
|
// DA: Does not have status information for a track.
|
||||||
|
#define STATUS_ITEMS
|
||||||
|
// DA: Has Mute and Solo on separate lines.
|
||||||
|
#define MUTE_SOLO_ITEMS(extra) \
|
||||||
|
{ kItemMute, kTrackInfoBtnSize + 1, 1 }, \
|
||||||
|
{ kItemSolo, kTrackInfoBtnSize + 1, extra },
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define TITLE_ITEMS(extra) \
|
||||||
|
{ kItemBarButtons, kTrackInfoBtnSize, extra },
|
||||||
|
#define STATUS_ITEMS \
|
||||||
|
{ kItemStatusInfo, 32, 0 },
|
||||||
|
#define MUTE_SOLO_ITEMS(extra) \
|
||||||
|
{ kItemMute | kItemSolo, kTrackInfoBtnSize + 1, extra },
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define COMMON_ITEMS(extra) \
|
||||||
|
TITLE_ITEMS(extra)
|
||||||
|
|
||||||
|
const TCPLine commonTrackTCPLines[] = {
|
||||||
|
COMMON_ITEMS(0)
|
||||||
|
{ 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const TCPLine waveTrackTCPLines[] = {
|
||||||
|
COMMON_ITEMS(0)
|
||||||
|
STATUS_ITEMS
|
||||||
|
MUTE_SOLO_ITEMS(2)
|
||||||
|
{ kItemGain, kTrackInfoSliderHeight, 5 },
|
||||||
|
{ kItemPan, kTrackInfoSliderHeight, 5 },
|
||||||
|
{ 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const TCPLine noteTrackTCPLines[] = {
|
||||||
|
COMMON_ITEMS(0)
|
||||||
|
MUTE_SOLO_ITEMS(0)
|
||||||
|
{ 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const TCPLine *getTCPLines( const Track &track )
|
||||||
|
{
|
||||||
|
#ifdef USE_MIDI
|
||||||
|
if ( track.GetKind() == Track::Note )
|
||||||
|
return noteTrackTCPLines;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( track.GetKind() == Track::Wave )
|
||||||
|
return waveTrackTCPLines;
|
||||||
|
|
||||||
|
return commonTrackTCPLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return y value and height
|
||||||
|
std::pair< int, int > CalcItemY( const TCPLine *pLines, unsigned iItem )
|
||||||
|
{
|
||||||
|
int y = 1;
|
||||||
|
while ( pLines->items &&
|
||||||
|
0 == (pLines->items & iItem) ) {
|
||||||
|
y += pLines->height + pLines->extraSpace;
|
||||||
|
++pLines;
|
||||||
|
}
|
||||||
|
return { y, pLines->height };
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// This handles when the user clicks on the "Label" area
|
/// This handles when the user clicks on the "Label" area
|
||||||
/// of a track, ie the part with all the buttons and the drop
|
/// of a track, ie the part with all the buttons and the drop
|
||||||
/// down menu, etc.
|
/// down menu, etc.
|
||||||
@ -9201,83 +9291,35 @@ int TrackInfo::GetTrackInfoWidth() const
|
|||||||
return kTrackInfoWidth;
|
return kTrackInfoWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TrackInfo::CalcItemY( int iItem ) const
|
|
||||||
{
|
|
||||||
int y = 1;
|
|
||||||
if( iItem == kItemBarButtons )
|
|
||||||
return y;
|
|
||||||
y+= kTrackInfoBtnSize +2;
|
|
||||||
if( iItem == kItemStatusInfo )
|
|
||||||
return y;
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
|
||||||
int y1=y;
|
|
||||||
if( iItem == kItemNoteMute )
|
|
||||||
return y;
|
|
||||||
if( iItem == kItemNoteSolo )
|
|
||||||
return y;
|
|
||||||
y=y1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// DA: Does not have status information for a track.
|
|
||||||
#ifndef EXPERIMENTAL_DA
|
|
||||||
y+= 30;
|
|
||||||
#else
|
|
||||||
y+= 2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( iItem == kItemMute )
|
|
||||||
return y;
|
|
||||||
|
|
||||||
// DA: Has Mute and Solo on separate lines.
|
|
||||||
#ifdef EXPERIMENTAL_DA
|
|
||||||
y+= kTrackInfoBtnSize + 2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( iItem == kItemSolo )
|
|
||||||
return y;
|
|
||||||
y+= kTrackInfoBtnSize + 3;
|
|
||||||
|
|
||||||
if( iItem == kItemGain )
|
|
||||||
return y;
|
|
||||||
y+= 30;
|
|
||||||
if( iItem == kItemPan )
|
|
||||||
return y;
|
|
||||||
y+= 30;
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackInfo::GetCloseBoxRect(const wxRect & rect, wxRect & dest) const
|
void TrackInfo::GetCloseBoxRect(const wxRect & rect, wxRect & dest) const
|
||||||
{
|
{
|
||||||
dest.x = rect.x+1;
|
dest.x = rect.x+1;
|
||||||
dest.y = rect.y + CalcItemY( kItemBarButtons );
|
auto results = CalcItemY( commonTrackTCPLines, kItemBarButtons );
|
||||||
|
dest.y = rect.y + results.first;
|
||||||
dest.width = kTrackInfoBtnSize;
|
dest.width = kTrackInfoBtnSize;
|
||||||
dest.height = kTrackInfoBtnSize;
|
dest.height = results.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackInfo::GetTitleBarRect(const wxRect & rect, wxRect & dest) const
|
void TrackInfo::GetTitleBarRect(const wxRect & rect, wxRect & dest) const
|
||||||
{
|
{
|
||||||
dest.x = rect.x + kTrackInfoBtnSize+2; // to right of CloseBoxRect
|
dest.x = rect.x + kTrackInfoBtnSize+2; // to right of CloseBoxRect
|
||||||
dest.y = rect.y + CalcItemY( kItemBarButtons );
|
auto results = CalcItemY( commonTrackTCPLines, kItemBarButtons );
|
||||||
|
dest.y = rect.y + results.first;
|
||||||
dest.width = kTrackInfoWidth - rect.x - kTrackInfoBtnSize-1; // to right of CloseBoxRect
|
dest.width = kTrackInfoWidth - rect.x - kTrackInfoBtnSize-1; // to right of CloseBoxRect
|
||||||
dest.height = kTrackInfoBtnSize;
|
dest.height = results.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackInfo::GetMuteSoloRect(const wxRect & rect, wxRect & dest, bool solo, bool bHasSoloButton, const Track *pTrack) const
|
void TrackInfo::GetMuteSoloRect(const wxRect & rect, wxRect & dest, bool solo, bool bHasSoloButton, const Track *pTrack) const
|
||||||
{
|
{
|
||||||
|
|
||||||
dest.height = kTrackInfoBtnSize +1;
|
|
||||||
dest.x = rect.x+1;
|
dest.x = rect.x+1;
|
||||||
|
|
||||||
int MuteSoloType = 0;
|
auto resultsM = CalcItemY( getTCPLines( *pTrack ), kItemMute );
|
||||||
|
auto resultsS = CalcItemY( getTCPLines( *pTrack ), kItemSolo );
|
||||||
|
dest.height = resultsS.second;
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
int yMute = resultsM.first;
|
||||||
if (pTrack->GetKind() == Track::Note)
|
int ySolo = resultsS.first;
|
||||||
MuteSoloType = kItemNoteMute - kItemMute;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int yMute = CalcItemY( kItemMute + MuteSoloType );
|
|
||||||
int ySolo = CalcItemY( kItemSolo + MuteSoloType );
|
|
||||||
|
|
||||||
bool bSameRow = ( yMute == ySolo );
|
bool bSameRow = ( yMute == ySolo );
|
||||||
bool bNarrow = bSameRow && bHasSoloButton;
|
bool bNarrow = bSameRow && bHasSoloButton;
|
||||||
@ -9306,15 +9348,17 @@ void TrackInfo::GetMuteSoloRect(const wxRect & rect, wxRect & dest, bool solo, b
|
|||||||
void TrackInfo::GetGainRect(const wxPoint &topleft, wxRect & dest) const
|
void TrackInfo::GetGainRect(const wxPoint &topleft, wxRect & dest) const
|
||||||
{
|
{
|
||||||
dest.x = topleft.x + 7;
|
dest.x = topleft.x + 7;
|
||||||
dest.y = topleft.y + CalcItemY( kItemGain );
|
auto results = CalcItemY( waveTrackTCPLines, kItemGain );
|
||||||
|
dest.y = topleft.y + results.first;
|
||||||
dest.width = 84;
|
dest.width = 84;
|
||||||
dest.height = 25;
|
dest.height = results.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackInfo::GetPanRect(const wxPoint &topleft, wxRect & dest) const
|
void TrackInfo::GetPanRect(const wxPoint &topleft, wxRect & dest) const
|
||||||
{
|
{
|
||||||
GetGainRect( topleft, dest );
|
GetGainRect( topleft, dest );
|
||||||
dest.y = topleft.y + CalcItemY( kItemPan );
|
auto results = CalcItemY( waveTrackTCPLines, kItemPan );
|
||||||
|
dest.y = topleft.y + results.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||||
|
@ -76,17 +76,6 @@ enum {
|
|||||||
kTimerInterval = 50, // milliseconds
|
kTimerInterval = 50, // milliseconds
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
kItemBarButtons = 0,
|
|
||||||
kItemStatusInfo = 1,
|
|
||||||
kItemMute = 2,
|
|
||||||
kItemSolo = 3,
|
|
||||||
kItemNoteMute = 4,
|
|
||||||
kItemNoteSolo = 5,
|
|
||||||
kItemGain = 6,
|
|
||||||
kItemPan = 7,
|
|
||||||
};
|
|
||||||
|
|
||||||
class AUDACITY_DLL_API TrackInfo
|
class AUDACITY_DLL_API TrackInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -95,7 +84,6 @@ public:
|
|||||||
void ReCreateSliders();
|
void ReCreateSliders();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int CalcItemY( int iItem ) const;
|
|
||||||
int GetTrackInfoWidth() const;
|
int GetTrackInfoWidth() const;
|
||||||
void SetTrackInfoFont(wxDC *dc) const;
|
void SetTrackInfoFont(wxDC *dc) const;
|
||||||
|
|
||||||
@ -934,7 +922,8 @@ enum : int {
|
|||||||
|
|
||||||
enum : int {
|
enum : int {
|
||||||
kTrackInfoWidth = 100,
|
kTrackInfoWidth = 100,
|
||||||
kTrackInfoBtnSize = 18 // widely used dimension, usually height
|
kTrackInfoBtnSize = 18, // widely used dimension, usually height
|
||||||
|
kTrackInfoSliderHeight = 25,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_MIDI
|
#ifdef USE_MIDI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user