1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 17:14:07 +01:00

Define BackgoundCell, move some things into it

This commit is contained in:
Paul Licameli
2017-06-10 15:02:10 -04:00
parent 674ccc5e15
commit 8ef5f696d8
9 changed files with 173 additions and 19 deletions

View File

@@ -0,0 +1,109 @@
/**********************************************************************
Audacity: A Digital Audio Editor
BackgroundCell.cpp
Paul Licameli split from TrackPanel.cpp
**********************************************************************/
#include "../../Audacity.h"
#include "BackgroundCell.h"
#include "../../HitTestResult.h"
#include "../../Project.h"
#include "../../RefreshCode.h"
#include "../../TrackPanelMouseEvent.h"
#include "../../UIHandle.h"
#include <wx/cursor.h>
#include <wx/event.h>
namespace
{
// Define this, just so the click to deselect can dispatch here
class BackgroundHandle : public UIHandle
{
BackgroundHandle() {}
BackgroundHandle(const BackgroundHandle&) = delete;
BackgroundHandle &operator=(const BackgroundHandle&) = delete;
public:
static BackgroundHandle& Instance()
{
static BackgroundHandle instance;
return instance;
}
static HitTestPreview HitPreview()
{
static wxCursor arrowCursor{ wxCURSOR_ARROW };
return { {}, &arrowCursor };
}
static HitTestResult HitAnywhere()
{
return {
HitPreview(),
&BackgroundHandle::Instance()
};
}
virtual ~BackgroundHandle()
{}
Result Click
(const TrackPanelMouseEvent &evt, AudacityProject *pProject) override
{
using namespace RefreshCode;
const wxMouseEvent &event = evt.event;
// Do not start a drag
Result result = Cancelled;
// AS: If the user clicked outside all tracks, make nothing
// selected.
if ((event.ButtonDown() || event.ButtonDClick())) {
pProject->GetSelectionState().SelectNone
( *pProject->GetTracks(), pProject->GetMixerBoard() );
result |= RefreshAll;
}
return result;
}
Result Drag
(const TrackPanelMouseEvent &, AudacityProject *) override
{ return RefreshCode::RefreshNone; }
HitTestPreview Preview
(const TrackPanelMouseEvent &, const AudacityProject *) override
{ return HitPreview(); }
Result Release
(const TrackPanelMouseEvent &, AudacityProject *,
wxWindow *) override
{ return RefreshCode::RefreshNone; }
Result Cancel(AudacityProject *) override
{ return RefreshCode::RefreshNone; }
};
}
BackgroundCell::~BackgroundCell()
{
}
HitTestResult BackgroundCell::HitTest
(const TrackPanelMouseEvent &,
const AudacityProject *)
{
return BackgroundHandle::HitAnywhere();
}
Track *BackgroundCell::FindTrack()
{
return nullptr;
}

View File

@@ -0,0 +1,38 @@
/**********************************************************************
Audacity: A Digital Audio Editor
BackgroundCell.h
Paul Licameli split from TrackPanel.cpp
**********************************************************************/
#ifndef __AUDACITY_BACKGROUND_CELL__
#define __AUDACITY_BACKGROUND_CELL__
#include "CommonTrackPanelCell.h"
class AudacityProject;
class BackgroundCell final : public CommonTrackPanelCell
{
public:
BackgroundCell(AudacityProject *pProject)
: mpProject(pProject)
{}
virtual ~BackgroundCell();
protected:
HitTestResult HitTest
(const TrackPanelMouseEvent &event,
const AudacityProject *) override;
Track *FindTrack() override;
private:
AudacityProject *mpProject;
};
#endif