mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-08 08:01:19 +02:00
More fixes for track controls layouts
Compute default WaveTrack height analogously to NoteTrack... Default MIDI track height is enough to display velocity slider... Make gain slider again visible in default sized WaveTrack EXPERIMENTAL_MIDI_OUT off -- then no invisible channel buttons...
This commit is contained in:
commit
2fe5731de7
@ -36,6 +36,8 @@
|
||||
|
||||
#include "InconsistencyException.h"
|
||||
|
||||
#include "TrackPanel.h" // For TrackInfo
|
||||
|
||||
#ifdef SONIFY
|
||||
#include "../lib-src/portmidi/pm_common/portmidi.h"
|
||||
|
||||
@ -110,6 +112,8 @@ NoteTrack::NoteTrack(const std::shared_ptr<DirManager> &projDirManager)
|
||||
SetDefaultName(_("Note Track"));
|
||||
SetName(GetDefaultName());
|
||||
|
||||
SetHeight( TrackInfo::DefaultNoteTrackHeight() );
|
||||
|
||||
mSeq = NULL;
|
||||
mSerializationLength = 0;
|
||||
|
||||
|
@ -52,7 +52,7 @@ Track::Track(const std::shared_ptr<DirManager> &projDirManager)
|
||||
mLinked = false;
|
||||
|
||||
mY = 0;
|
||||
mHeight = 150;
|
||||
mHeight = DefaultHeight;
|
||||
mIndex = 0;
|
||||
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
|
||||
mYv = mHeight;
|
||||
|
@ -167,6 +167,8 @@ class AUDACITY_DLL_API Track /* not final */ : public XMLTagHandler
|
||||
All
|
||||
};
|
||||
|
||||
enum : unsigned { DefaultHeight = 150 };
|
||||
|
||||
Track(const std::shared_ptr<DirManager> &projDirManager);
|
||||
Track(const Track &orig);
|
||||
|
||||
|
@ -5246,19 +5246,31 @@ const TCPLine waveTrackTCPLines[] = {
|
||||
COMMON_ITEMS(2)
|
||||
STATUS_ITEMS
|
||||
MUTE_SOLO_ITEMS(2)
|
||||
{ kItemGain, kTrackInfoSliderHeight, 5 },
|
||||
{ kItemPan, kTrackInfoSliderHeight, 5 },
|
||||
{ kItemGain, kTrackInfoSliderHeight, kTrackInfoSliderExtra },
|
||||
{ kItemPan, kTrackInfoSliderHeight, kTrackInfoSliderExtra },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
const TCPLine noteTrackTCPLines[] = {
|
||||
COMMON_ITEMS(0)
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
MUTE_SOLO_ITEMS(0)
|
||||
{ kItemMidiControlsRect, kMidiCellHeight * 4, 0 },
|
||||
{ kItemVelocity, kTrackInfoSliderHeight, 5 },
|
||||
{ kItemVelocity, kTrackInfoSliderHeight, kTrackInfoSliderExtra },
|
||||
#endif
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
int totalTCPLines( const TCPLine *pLines )
|
||||
{
|
||||
int total = 0;
|
||||
while ( pLines->items ) {
|
||||
total += pLines->height + pLines->extraSpace;
|
||||
++pLines;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
const TCPLine *getTCPLines( const Track &track )
|
||||
{
|
||||
#ifdef USE_MIDI
|
||||
@ -5306,12 +5318,13 @@ std::pair< int, int > CalcBottomItemY
|
||||
return { y - (pLines->height + pLines->extraSpace ), pLines->height };
|
||||
}
|
||||
|
||||
bool HideTopItem( const wxRect &rect, const wxRect &subRect ) {
|
||||
bool HideTopItem( const wxRect &rect, const wxRect &subRect,
|
||||
int allowance = 0 ) {
|
||||
auto limit = CalcBottomItemY
|
||||
( commonTrackTCPBottomLines, kHighestBottomItem, rect.height).first;
|
||||
// Return true if the rectangle is even touching the limit
|
||||
// without an overlap. That was the behavior as of 2.1.3.
|
||||
return subRect.y + subRect.height >= rect.y + limit;
|
||||
return subRect.y + subRect.height - allowance >= rect.y + limit;
|
||||
}
|
||||
|
||||
}
|
||||
@ -5375,7 +5388,6 @@ void TrackPanel::HandleLabelClick(wxMouseEvent & event)
|
||||
|
||||
if (isleft && VelocityFunc(t, rect, event, event.m_x, event.m_y))
|
||||
return;
|
||||
#endif
|
||||
wxRect midiRect;
|
||||
mTrackInfo.GetMidiControlsRect(rect, midiRect);
|
||||
|
||||
@ -5388,6 +5400,7 @@ void TrackPanel::HandleLabelClick(wxMouseEvent & event)
|
||||
Refresh(false);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // USE_MIDI
|
||||
|
||||
@ -5519,7 +5532,7 @@ bool TrackPanel::GainFunc(Track * t, wxRect rect, wxMouseEvent &event,
|
||||
{
|
||||
wxRect sliderRect;
|
||||
mTrackInfo.GetGainRect(rect.GetTopLeft(), sliderRect);
|
||||
if ( HideTopItem( rect, sliderRect ) )
|
||||
if ( HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
|
||||
return false;
|
||||
if (!sliderRect.Contains(x, y))
|
||||
return false;
|
||||
@ -5536,7 +5549,7 @@ bool TrackPanel::PanFunc(Track * t, wxRect rect, wxMouseEvent &event,
|
||||
{
|
||||
wxRect sliderRect;
|
||||
mTrackInfo.GetPanRect(rect.GetTopLeft(), sliderRect);
|
||||
if ( HideTopItem( rect, sliderRect ) )
|
||||
if ( HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
|
||||
return false;
|
||||
if (!sliderRect.Contains(x, y))
|
||||
return false;
|
||||
@ -5554,7 +5567,7 @@ bool TrackPanel::VelocityFunc(Track * t, wxRect rect, wxMouseEvent &event,
|
||||
{
|
||||
wxRect sliderRect;
|
||||
mTrackInfo.GetVelocityRect(rect.GetTopLeft(), sliderRect);
|
||||
if ( HideTopItem( rect, sliderRect ) )
|
||||
if ( HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
|
||||
return false;
|
||||
if (!sliderRect.Contains(x, y))
|
||||
return false;
|
||||
@ -9746,11 +9759,11 @@ void TrackInfo::DrawSliders(wxDC *dc, WaveTrack *t, wxRect rect, bool captured)
|
||||
wxRect sliderRect;
|
||||
|
||||
GetGainRect(rect.GetTopLeft(), sliderRect);
|
||||
if ( !HideTopItem( rect, sliderRect ) )
|
||||
if ( !HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
|
||||
GainSlider(t, captured)->OnPaint(*dc);
|
||||
|
||||
GetPanRect(rect.GetTopLeft(), sliderRect);
|
||||
if ( !HideTopItem( rect, sliderRect ) )
|
||||
if ( !HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
|
||||
PanSlider(t, captured)->OnPaint(*dc);
|
||||
}
|
||||
|
||||
@ -9759,13 +9772,35 @@ void TrackInfo::DrawVelocitySlider(wxDC *dc, NoteTrack *t, wxRect rect, bool cap
|
||||
{
|
||||
wxRect sliderRect;
|
||||
|
||||
GetVelocityRect(rect.GetTopLeft(), sliderRect);
|
||||
if ( !HideTopItem( rect, sliderRect ) ) {
|
||||
GetVelocityRect( rect.GetTopLeft(), sliderRect );
|
||||
if ( !HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) ) {
|
||||
VelocitySlider(t, captured)->OnPaint(*dc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned TrackInfo::DefaultNoteTrackHeight()
|
||||
{
|
||||
// Just high enough that the velocity slider is just above the Minimize
|
||||
// button, as for default sized Wave track
|
||||
int needed =
|
||||
kTopMargin + kBottomMargin +
|
||||
totalTCPLines( noteTrackTCPLines ) +
|
||||
totalTCPLines( commonTrackTCPBottomLines ) -
|
||||
kTrackInfoSliderExtra;
|
||||
return (unsigned) std::max( needed, (int) Track::DefaultHeight );
|
||||
}
|
||||
|
||||
unsigned TrackInfo::DefaultWaveTrackHeight()
|
||||
{
|
||||
int needed =
|
||||
kTopMargin + kBottomMargin +
|
||||
totalTCPLines( waveTrackTCPLines ) +
|
||||
totalTCPLines( commonTrackTCPBottomLines ) -
|
||||
kTrackInfoSliderExtra;
|
||||
return (unsigned) std::max( needed, (int) Track::DefaultHeight );
|
||||
}
|
||||
|
||||
LWSlider * TrackInfo::GainSlider(WaveTrack *t, bool captured) const
|
||||
{
|
||||
wxPoint topLeft{
|
||||
|
@ -118,6 +118,9 @@ private:
|
||||
#endif
|
||||
|
||||
public:
|
||||
static unsigned DefaultNoteTrackHeight();
|
||||
static unsigned DefaultWaveTrackHeight();
|
||||
|
||||
LWSlider * GainSlider(WaveTrack *t, bool captured = false) const;
|
||||
LWSlider * PanSlider(WaveTrack *t, bool captured = false) const;
|
||||
|
||||
@ -919,6 +922,8 @@ enum : int {
|
||||
kTrackInfoBtnSize = 18, // widely used dimension, usually height
|
||||
kTrackInfoSliderHeight = 25,
|
||||
kTrackInfoSliderWidth = 84,
|
||||
kTrackInfoSliderAllowance = 5,
|
||||
kTrackInfoSliderExtra = 5,
|
||||
};
|
||||
|
||||
#ifdef USE_MIDI
|
||||
|
@ -59,6 +59,8 @@ Track classes.
|
||||
|
||||
#include "Experimental.h"
|
||||
|
||||
#include "TrackPanel.h" // for TrackInfo
|
||||
|
||||
using std::max;
|
||||
|
||||
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
|
||||
@ -113,6 +115,8 @@ WaveTrack::WaveTrack(const std::shared_ptr<DirManager> &projDirManager, sampleFo
|
||||
mLastScaleType = -1;
|
||||
mLastdBRange = -1;
|
||||
mAutoSaveIdent = 0;
|
||||
|
||||
SetHeight( TrackInfo::DefaultWaveTrackHeight() );
|
||||
}
|
||||
|
||||
WaveTrack::WaveTrack(const WaveTrack &orig):
|
||||
|
Loading…
x
Reference in New Issue
Block a user