Audacity  2.2.2
BackgroundCell.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 BackgroundCell.cpp
6 
7 Paul Licameli split from TrackPanel.cpp
8 
9 **********************************************************************/
10 
11 #include "../../Audacity.h"
12 #include "BackgroundCell.h"
13 
14 #include "../../HitTestResult.h"
15 #include "../../Project.h"
16 #include "../../RefreshCode.h"
17 #include "../../TrackPanelMouseEvent.h"
18 #include "../../UIHandle.h"
19 
20 #include <wx/cursor.h>
21 #include <wx/event.h>
22 
23 // Define this, just so the click to deselect can dispatch here
24 // This handle class, unlike most, doesn't associate with any particular cell.
25 class BackgroundHandle : public UIHandle
26 {
27  BackgroundHandle(const BackgroundHandle&) = delete;
29 
30 public:
32 
34  {
35  static wxCursor arrowCursor{ wxCURSOR_ARROW };
36  return { {}, &arrowCursor };
37  }
38 
40  {}
41 
43  (const TrackPanelMouseEvent &evt, AudacityProject *pProject) override
44  {
45  using namespace RefreshCode;
46  const wxMouseEvent &event = evt.event;
47  // Do not start a drag
48  Result result = Cancelled;
49 
50  // AS: If the user clicked outside all tracks, make nothing
51  // selected.
52  if ((event.ButtonDown() || event.ButtonDClick())) {
53  pProject->GetSelectionState().SelectNone
54  ( *pProject->GetTracks(), pProject->GetMixerBoard() );
55  result |= RefreshAll;
56  }
57 
58  return result;
59  }
60 
61  Result Drag
62  (const TrackPanelMouseEvent &, AudacityProject *) override
63  { return RefreshCode::RefreshNone; }
64 
66  (const TrackPanelMouseState &, const AudacityProject *) override
67  { return HitPreview(); }
68 
71  wxWindow *) override
72  { return RefreshCode::RefreshNone; }
73 
75  { return RefreshCode::RefreshNone; }
76 };
77 
79 {
80 }
81 
82 std::vector<UIHandlePtr> BackgroundCell::HitTest
84  const AudacityProject *)
85 {
86  std::vector<UIHandlePtr> results;
87  auto result = mHandle.lock();
88  if (!result)
89  result = std::make_shared<BackgroundHandle>();
90  results.push_back(result);
91  return results;
92 }
93 
94 std::shared_ptr<Track> BackgroundCell::FindTrack()
95 {
96  return {};
97 }
98 
BackgroundHandle & operator=(const BackgroundHandle &)=delete
virtual ~BackgroundCell()
std::shared_ptr< Track > FindTrack() override
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *) override
void SelectNone(TrackList &tracks, MixerBoard *pMixerBoard)
Result Click(const TrackPanelMouseEvent &evt, AudacityProject *pProject) override
Result Drag(const TrackPanelMouseEvent &, AudacityProject *) override
MixerBoard * GetMixerBoard()
Definition: Project.h:500
static HitTestPreview HitPreview()
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:158
unsigned Result
Definition: UIHandle.h:37
virtual ~BackgroundHandle()
SelectionState & GetSelectionState()
Definition: Project.h:291
HitTestPreview Preview(const TrackPanelMouseState &, const AudacityProject *) override
Result Release(const TrackPanelMouseEvent &, AudacityProject *, wxWindow *) override
Result Cancel(AudacityProject *) override
TrackList * GetTracks()
Definition: Project.h:174