mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-17 00:57:40 +02:00
TCP draw use hit target for button, slider state; remove hacky global
This commit is contained in:
parent
3d7471a612
commit
f09a7be3dc
@ -1066,11 +1066,9 @@ void TrackPanel::OnContextMenu(wxContextMenuEvent & WXUNUSED(event))
|
||||
|
||||
struct TrackInfo::TCPLine {
|
||||
using DrawFunction = void (*)(
|
||||
wxDC *dc,
|
||||
TrackPanelDrawingContext &context,
|
||||
const wxRect &rect,
|
||||
const Track *maybeNULL,
|
||||
int pressed, // a value from MouseCaptureEnum; TODO: make it bool
|
||||
bool captured
|
||||
const Track *maybeNULL
|
||||
);
|
||||
|
||||
unsigned items; // a bitwise OR of values of the enum above
|
||||
@ -1696,6 +1694,8 @@ void TrackPanel::Refresh(bool eraseBackground /* = TRUE */,
|
||||
DisplaySelection();
|
||||
}
|
||||
|
||||
#include "TrackPanelDrawingContext.h"
|
||||
|
||||
/// Draw the actual track areas. We only draw the borders
|
||||
/// and the little buttons and menues and whatnot here, the
|
||||
/// actual contents of each track are drawn by the TrackArtist.
|
||||
@ -1856,20 +1856,21 @@ void TrackPanel::DrawEverythingElse(wxDC * dc,
|
||||
#include "tracks/ui/TrackControls.h"
|
||||
|
||||
void TrackInfo::DrawItems
|
||||
( wxDC *dc, const wxRect &rect, const Track &track,
|
||||
int mouseCapture, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track &track )
|
||||
{
|
||||
const auto topLines = getTCPLines( track );
|
||||
const auto bottomLines = commonTrackTCPBottomLines;
|
||||
DrawItems
|
||||
( dc, rect, &track, topLines, bottomLines, mouseCapture, captured );
|
||||
( context, rect, &track, topLines, bottomLines );
|
||||
}
|
||||
|
||||
void TrackInfo::DrawItems
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack,
|
||||
const std::vector<TCPLine> &topLines, const std::vector<TCPLine> &bottomLines,
|
||||
int mouseCapture, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack,
|
||||
const std::vector<TCPLine> &topLines, const std::vector<TCPLine> &bottomLines )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
TrackInfo::SetTrackInfoFont(dc);
|
||||
dc->SetTextForeground(theTheme.Colour(clrTrackPanelText));
|
||||
|
||||
@ -1882,7 +1883,7 @@ void TrackInfo::DrawItems
|
||||
};
|
||||
if ( !TrackInfo::HideTopItem( rect, itemRect ) &&
|
||||
line.drawFunction )
|
||||
line.drawFunction( dc, itemRect, pTrack, mouseCapture, captured );
|
||||
line.drawFunction( context, itemRect, pTrack );
|
||||
yy += line.height + line.extraSpace;
|
||||
}
|
||||
}
|
||||
@ -1895,20 +1896,26 @@ void TrackInfo::DrawItems
|
||||
rect.x, rect.y + yy,
|
||||
rect.width, line.height
|
||||
};
|
||||
line.drawFunction( dc, itemRect, pTrack, mouseCapture, captured );
|
||||
line.drawFunction( context, itemRect, pTrack );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "tracks/ui/TrackButtonHandles.h"
|
||||
void TrackInfo::CloseTitleDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
bool selected = pTrack ? pTrack->GetSelected() : true;
|
||||
{
|
||||
bool down = captured && (pressed == TrackPanel::IsClosing);
|
||||
wxRect bev = rect;
|
||||
GetCloseBoxHorizontalBounds( rect, bev );
|
||||
auto target = dynamic_cast<CloseButtonHandle*>( context.target.get() );
|
||||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
bool captured = hit && target->IsClicked();
|
||||
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
||||
AColor::Bevel2(*dc, !down, bev, selected );
|
||||
|
||||
#ifdef EXPERIMENTAL_THEMING
|
||||
@ -1935,12 +1942,15 @@ void TrackInfo::CloseTitleDrawFunction
|
||||
}
|
||||
|
||||
{
|
||||
wxRect bev = rect;
|
||||
GetTitleBarHorizontalBounds( rect, bev );
|
||||
auto target = dynamic_cast<MenuButtonHandle*>( context.target.get() );
|
||||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
bool captured = hit && target->IsClicked();
|
||||
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
||||
wxString titleStr =
|
||||
pTrack ? pTrack->GetName() : _("Name");
|
||||
|
||||
bool down = captured && (pressed == TrackPanel::IsPopping);
|
||||
wxRect bev = rect;
|
||||
GetTitleBarHorizontalBounds( rect, bev );
|
||||
//bev.Inflate(-1, -1);
|
||||
AColor::Bevel2(*dc, !down, bev, selected);
|
||||
|
||||
@ -1993,15 +2003,20 @@ void TrackInfo::CloseTitleDrawFunction
|
||||
}
|
||||
|
||||
void TrackInfo::MinimizeSyncLockDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
bool selected = pTrack ? pTrack->GetSelected() : true;
|
||||
bool syncLockSelected = pTrack ? pTrack->IsSyncLockSelected() : true;
|
||||
bool minimized = pTrack ? pTrack->GetMinimized() : false;
|
||||
{
|
||||
bool down = captured && (pressed == TrackPanel::IsMinimizing);
|
||||
wxRect bev = rect;
|
||||
GetMinimizeHorizontalBounds(rect, bev);
|
||||
auto target = dynamic_cast<MinimizeButtonHandle*>( context.target.get() );
|
||||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
bool captured = hit && target->IsClicked();
|
||||
bool down = captured && bev.Contains( context.lastState.GetPosition());
|
||||
|
||||
// Clear background to get rid of previous arrow
|
||||
//AColor::MediumTrackInfo(dc, t->GetSelected());
|
||||
@ -2040,13 +2055,15 @@ void TrackInfo::MinimizeSyncLockDrawFunction
|
||||
}
|
||||
|
||||
void TrackInfo::MidiControlsDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int, bool )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
auto &dc = context.dc;
|
||||
wxRect midiRect = rect;
|
||||
GetMidiControlsHorizontalBounds(rect, midiRect);
|
||||
NoteTrack::DrawLabelControls
|
||||
( static_cast<const NoteTrack *>(pTrack), *dc, midiRect );
|
||||
( static_cast<const NoteTrack *>(pTrack), dc, midiRect );
|
||||
#endif // EXPERIMENTAL_MIDI_OUT
|
||||
}
|
||||
|
||||
@ -2062,35 +2079,50 @@ void TrackInfo::SliderDrawFunction
|
||||
Selector( sliderRect, wt, captured, nullptr )->OnPaint(*dc, false);
|
||||
}
|
||||
|
||||
#include "tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.h"
|
||||
void TrackInfo::PanSliderDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto target = dynamic_cast<PanSliderHandle*>( context.target.get() );
|
||||
auto dc = &context.dc;
|
||||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
bool captured = hit && target->IsClicked();
|
||||
SliderDrawFunction<WaveTrack>
|
||||
( &TrackInfo::PanSlider, dc, rect, pTrack, captured);
|
||||
}
|
||||
|
||||
void TrackInfo::GainSliderDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto target = dynamic_cast<GainSliderHandle*>( context.target.get() );
|
||||
auto dc = &context.dc;
|
||||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
bool captured = hit && target->IsClicked();
|
||||
SliderDrawFunction<WaveTrack>
|
||||
( &TrackInfo::GainSlider, dc, rect, pTrack, captured);
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
#include "tracks/playabletrack/notetrack/ui/NoteTrackSliderHandles.h"
|
||||
void TrackInfo::VelocitySliderDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
auto target = dynamic_cast<VelocitySliderHandle*>( context.target.get() );
|
||||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
bool captured = hit && target->IsClicked();
|
||||
SliderDrawFunction<NoteTrack>
|
||||
( &TrackInfo::VelocitySlider, dc, rect, pTrack, captured);
|
||||
}
|
||||
#endif
|
||||
|
||||
void TrackInfo::MuteOrSoloDrawFunction
|
||||
( wxDC *dc, const wxRect &bev, const Track *pTrack, int pressed, bool captured,
|
||||
( wxDC *dc, const wxRect &bev, const Track *pTrack, bool down, bool captured,
|
||||
bool solo )
|
||||
{
|
||||
bool down = captured &&
|
||||
(pressed == ( solo ? TrackPanel::IsSoloing : TrackPanel::IsMuting ));
|
||||
//bev.Inflate(-1, -1);
|
||||
bool selected = pTrack ? pTrack->GetSelected() : true;
|
||||
auto pt = dynamic_cast<const PlayableTrack *>(pTrack);
|
||||
@ -2137,25 +2169,40 @@ void TrackInfo::MuteOrSoloDrawFunction
|
||||
dc->DrawText(str, bev.x + (bev.width - textWidth) / 2, bev.y + (bev.height - textHeight) / 2);
|
||||
}
|
||||
|
||||
#include "tracks/playabletrack/ui/PlayableTrackButtonHandles.h"
|
||||
void TrackInfo::WideMuteDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
wxRect bev = rect;
|
||||
GetWideMuteSoloHorizontalBounds( rect, bev );
|
||||
MuteOrSoloDrawFunction( dc, bev, pTrack, pressed, captured, false );
|
||||
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 );
|
||||
}
|
||||
|
||||
void TrackInfo::WideSoloDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
wxRect bev = rect;
|
||||
GetWideMuteSoloHorizontalBounds( rect, bev );
|
||||
MuteOrSoloDrawFunction( dc, bev, pTrack, pressed, captured, true );
|
||||
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 );
|
||||
}
|
||||
|
||||
void TrackInfo::MuteAndSoloDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed, bool captured )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
bool bHasSoloButton = TrackPanel::HasSoloButton();
|
||||
|
||||
wxRect bev = rect;
|
||||
@ -2163,13 +2210,25 @@ void TrackInfo::MuteAndSoloDrawFunction
|
||||
GetNarrowMuteHorizontalBounds( rect, bev );
|
||||
else
|
||||
GetWideMuteSoloHorizontalBounds( rect, bev );
|
||||
MuteOrSoloDrawFunction( dc, bev, pTrack, pressed, captured, false );
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
if( !bHasSoloButton )
|
||||
return;
|
||||
|
||||
GetNarrowSoloHorizontalBounds( rect, bev );
|
||||
MuteOrSoloDrawFunction( dc, bev, pTrack, pressed, captured, true );
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
void TrackInfo::StatusDrawFunction
|
||||
@ -2180,8 +2239,10 @@ void TrackInfo::StatusDrawFunction
|
||||
}
|
||||
|
||||
void TrackInfo::Status1DrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int, bool )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
auto wt = static_cast<const WaveTrack*>(pTrack);
|
||||
|
||||
/// Returns the string to be displayed in the track label
|
||||
@ -2208,8 +2269,10 @@ void TrackInfo::Status1DrawFunction
|
||||
}
|
||||
|
||||
void TrackInfo::Status2DrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int, bool )
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack )
|
||||
{
|
||||
auto dc = &context.dc;
|
||||
auto wt = static_cast<const WaveTrack*>(pTrack);
|
||||
auto format = wt ? wt->GetSampleFormat() : floatSample;
|
||||
auto s = GetSampleFormatStr(format);
|
||||
@ -2256,16 +2319,8 @@ void TrackPanel::DrawOutside(Track * t, wxDC * dc, const wxRect & rec)
|
||||
rect.y += kTopMargin;
|
||||
rect.height -= (kBottomMargin + kTopMargin);
|
||||
|
||||
// Need to know which button, if any, to draw as pressed.
|
||||
const MouseCaptureEnum mouseCapture =
|
||||
// This public global variable is a hack for now, which should go away
|
||||
// when TrackPanelCell gets a virtual function into which we move this
|
||||
// drawing code.
|
||||
MouseCaptureEnum(TrackControls::gCaptureState);
|
||||
auto pClickedTrack = GetTracks()->Lock(mpClickedTrack);
|
||||
const bool captured = (t == pClickedTrack.get());
|
||||
|
||||
TrackInfo::DrawItems( dc, rect, *t, mouseCapture, captured );
|
||||
TrackPanelDrawingContext context{ *dc, Target(), mLastMouseState };
|
||||
TrackInfo::DrawItems( context, rect, *t );
|
||||
|
||||
//mTrackInfo.DrawBordersWithin( dc, rect, *t );
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ using UIHandlePtr = std::shared_ptr<UIHandle>;
|
||||
// Declared elsewhere, to reduce compilation dependencies
|
||||
class TrackPanelListener;
|
||||
|
||||
struct TrackPanelDrawingContext;
|
||||
|
||||
enum class UndoPush : unsigned char;
|
||||
|
||||
// JKC Nov 2011: Disabled warning C4251 which is to do with DLL linkage
|
||||
@ -93,26 +95,26 @@ public:
|
||||
struct TCPLine;
|
||||
|
||||
static void DrawItems
|
||||
( wxDC *dc, const wxRect &rect, const Track &track, int mouseCapture,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track &track );
|
||||
|
||||
static void DrawItems
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack,
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack,
|
||||
const std::vector<TCPLine> &topLines,
|
||||
const std::vector<TCPLine> &bottomLines,
|
||||
int mouseCapture, bool captured );
|
||||
const std::vector<TCPLine> &bottomLines );
|
||||
|
||||
static void CloseTitleDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
static void MinimizeSyncLockDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
static void MidiControlsDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
template<typename TrackClass>
|
||||
static void SliderDrawFunction
|
||||
@ -122,45 +124,45 @@ public:
|
||||
wxDC *dc, const wxRect &rect, const Track *pTrack, bool captured );
|
||||
|
||||
static void PanSliderDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
static void GainSliderDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
static void VelocitySliderDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
#endif
|
||||
|
||||
static void MuteOrSoloDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, bool down,
|
||||
bool captured, bool solo );
|
||||
|
||||
static void WideMuteDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
static void WideSoloDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
static void MuteAndSoloDrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
static void StatusDrawFunction
|
||||
( const wxString &string, wxDC *dc, const wxRect &rect );
|
||||
|
||||
static void Status1DrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
static void Status2DrawFunction
|
||||
( wxDC *dc, const wxRect &rect, const Track *pTrack, int pressed,
|
||||
bool captured );
|
||||
( TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, const Track *pTrack );
|
||||
|
||||
public:
|
||||
int GetTrackInfoWidth() const;
|
||||
@ -492,20 +494,6 @@ protected:
|
||||
int mMouseMostRecentX;
|
||||
int mMouseMostRecentY;
|
||||
|
||||
public:
|
||||
// Old enumeration of click-and-drag states, which will shrink and disappear
|
||||
// as UIHandle subclasses take over the repsonsibilities.
|
||||
enum MouseCaptureEnum
|
||||
{
|
||||
IsUncaptured = 0,
|
||||
IsClosing,
|
||||
IsMuting,
|
||||
IsSoloing,
|
||||
IsMinimizing,
|
||||
IsPopping,
|
||||
};
|
||||
|
||||
protected:
|
||||
friend class TrackPanelAx;
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
|
@ -20,7 +20,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
MuteButtonHandle::MuteButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
|
||||
: ButtonHandle{ pTrack, rect, TrackPanel::IsMuting }
|
||||
: ButtonHandle{ pTrack, rect }
|
||||
{}
|
||||
|
||||
MuteButtonHandle::~MuteButtonHandle()
|
||||
@ -62,7 +62,7 @@ UIHandlePtr MuteButtonHandle::HitTest
|
||||
|
||||
SoloButtonHandle::SoloButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
|
||||
: ButtonHandle{ pTrack, rect, TrackPanel::IsSoloing }
|
||||
: ButtonHandle{ pTrack, rect }
|
||||
{}
|
||||
|
||||
SoloButtonHandle::~SoloButtonHandle()
|
||||
|
@ -12,8 +12,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#define __AUDACITY_PLAYABLE_TRACK_BUTTON_HANDLES__
|
||||
|
||||
#include "../../ui/ButtonHandle.h"
|
||||
#include "../../../TrackPanel.h"
|
||||
|
||||
class wxMouseState;
|
||||
|
||||
class MuteButtonHandle final : public ButtonHandle
|
||||
@ -50,7 +48,7 @@ class SoloButtonHandle final : public ButtonHandle
|
||||
|
||||
public:
|
||||
explicit SoloButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect );
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect );
|
||||
|
||||
SoloButtonHandle &operator=(const SoloButtonHandle&) = default;
|
||||
|
||||
|
@ -21,10 +21,9 @@ Paul Licameli
|
||||
#include "../ui/TrackControls.h"
|
||||
|
||||
ButtonHandle::ButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect, int dragCode )
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
|
||||
: mpTrack{ pTrack }
|
||||
, mRect{ rect }
|
||||
, mDragCode{ dragCode }
|
||||
{}
|
||||
|
||||
ButtonHandle::~ButtonHandle()
|
||||
@ -45,7 +44,8 @@ UIHandle::Result ButtonHandle::Click
|
||||
|
||||
// Come here for left click or double click
|
||||
if (mRect.Contains(event.m_x, event.m_y)) {
|
||||
TrackControls::gCaptureState = mDragCode;
|
||||
mWasIn = true;
|
||||
mIsClicked = true;
|
||||
// Toggle visible button state
|
||||
return RefreshCell;
|
||||
}
|
||||
@ -62,14 +62,10 @@ UIHandle::Result ButtonHandle::Drag
|
||||
if (!pTrack)
|
||||
return Cancelled;
|
||||
|
||||
const int newState =
|
||||
mRect.Contains(event.m_x, event.m_y) ? mDragCode : 0;
|
||||
if (TrackControls::gCaptureState == newState)
|
||||
return RefreshNone;
|
||||
else {
|
||||
TrackControls::gCaptureState = newState;
|
||||
return RefreshCell;
|
||||
}
|
||||
auto isIn = mRect.Contains(event.m_x, event.m_y);
|
||||
auto result = (isIn == mWasIn) ? RefreshNone : RefreshCell;
|
||||
mWasIn = isIn;
|
||||
return result;
|
||||
}
|
||||
|
||||
HitTestPreview ButtonHandle::Preview
|
||||
@ -90,22 +86,13 @@ UIHandle::Result ButtonHandle::Release
|
||||
|
||||
Result result = RefreshNone;
|
||||
const wxMouseEvent &event = evt.event;
|
||||
if (TrackControls::gCaptureState) {
|
||||
TrackControls::gCaptureState = 0;
|
||||
result = RefreshCell;
|
||||
}
|
||||
if (pTrack && mRect.Contains(event.m_x, event.m_y))
|
||||
result |= CommitChanges(event, pProject, pParent);
|
||||
result |= RefreshCell | CommitChanges(event, pProject, pParent);
|
||||
return result;
|
||||
}
|
||||
|
||||
UIHandle::Result ButtonHandle::Cancel(AudacityProject *pProject)
|
||||
{
|
||||
using namespace RefreshCode;
|
||||
if (TrackControls::gCaptureState) {
|
||||
TrackControls::gCaptureState = 0;
|
||||
return RefreshCell;
|
||||
}
|
||||
else
|
||||
return RefreshNone;
|
||||
return RefreshCell; // perhaps unnecessarily if pointer is out of the box
|
||||
}
|
||||
|
@ -23,9 +23,13 @@ class ButtonHandle /* not final */ : public UIHandle
|
||||
{
|
||||
ButtonHandle(const ButtonHandle&) = delete;
|
||||
|
||||
public:
|
||||
std::shared_ptr<Track> GetTrack() const { return mpTrack.lock(); }
|
||||
bool IsClicked() const { return mIsClicked; }
|
||||
|
||||
protected:
|
||||
explicit ButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect, int dragCode );
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect );
|
||||
|
||||
ButtonHandle &operator=(const ButtonHandle&) = default;
|
||||
|
||||
@ -56,7 +60,8 @@ protected:
|
||||
|
||||
std::weak_ptr<Track> mpTrack;
|
||||
wxRect mRect;
|
||||
int mDragCode;
|
||||
bool mWasIn{ true };
|
||||
bool mIsClicked{};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -44,8 +44,10 @@ UIHandle::Result SliderHandle::Click
|
||||
// Just did a modal dialog in OnMouseEvent
|
||||
// Do not start a drag
|
||||
return RefreshCell | Cancelled;
|
||||
else
|
||||
else {
|
||||
mIsClicked = true;
|
||||
return RefreshCell;
|
||||
}
|
||||
}
|
||||
|
||||
UIHandle::Result SliderHandle::Drag
|
||||
|
@ -32,6 +32,9 @@ public:
|
||||
|
||||
SliderHandle &operator=(const SliderHandle&) = default;
|
||||
|
||||
std::shared_ptr<Track> GetTrack() const { return mpTrack.lock(); }
|
||||
bool IsClicked() const { return mIsClicked; }
|
||||
|
||||
protected:
|
||||
virtual ~SliderHandle();
|
||||
|
||||
@ -67,6 +70,8 @@ protected:
|
||||
LWSlider *GetSlider( AudacityProject *pProject );
|
||||
|
||||
float mStartingValue {};
|
||||
|
||||
bool mIsClicked{};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
MinimizeButtonHandle::MinimizeButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
|
||||
: ButtonHandle{ pTrack, rect, TrackPanel::IsMinimizing }
|
||||
: ButtonHandle{ pTrack, rect }
|
||||
{}
|
||||
|
||||
MinimizeButtonHandle::~MinimizeButtonHandle()
|
||||
@ -69,7 +69,7 @@ UIHandlePtr MinimizeButtonHandle::HitTest
|
||||
|
||||
CloseButtonHandle::CloseButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
|
||||
: ButtonHandle{ pTrack, rect, TrackPanel::IsClosing }
|
||||
: ButtonHandle{ pTrack, rect }
|
||||
{}
|
||||
|
||||
CloseButtonHandle::~CloseButtonHandle()
|
||||
@ -121,7 +121,7 @@ UIHandlePtr CloseButtonHandle::HitTest
|
||||
MenuButtonHandle::MenuButtonHandle
|
||||
( const std::shared_ptr<TrackPanelCell> &pCell,
|
||||
const std::shared_ptr<Track> &pTrack, const wxRect &rect )
|
||||
: ButtonHandle{ pTrack, rect, TrackPanel::IsPopping }
|
||||
: ButtonHandle{ pTrack, rect }
|
||||
, mpCell{ pCell }
|
||||
{}
|
||||
|
||||
|
@ -12,7 +12,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#define __AUDACITY_TRACK_BUTTON_HANDLES__
|
||||
|
||||
#include "../ui/ButtonHandle.h"
|
||||
#include "../../TrackPanel.h"
|
||||
|
||||
class wxMouseState;
|
||||
|
||||
|
@ -21,8 +21,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../Track.h"
|
||||
#include <wx/textdlg.h>
|
||||
|
||||
int TrackControls::gCaptureState;
|
||||
|
||||
TrackControls::TrackControls( std::shared_ptr<Track> pTrack )
|
||||
: mwTrack{ pTrack }
|
||||
{
|
||||
|
@ -42,9 +42,6 @@ public:
|
||||
unsigned result;
|
||||
};
|
||||
|
||||
// Make this hack go away! See TrackPanel::DrawOutside
|
||||
static int gCaptureState;
|
||||
|
||||
protected:
|
||||
// An override is supplied for derived classes to call through but it is
|
||||
// still marked pure virtual
|
||||
|
Loading…
x
Reference in New Issue
Block a user