1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 17:39:25 +02:00
audacity/src/tracks/ui/ButtonHandle.h
Paul Licameli b7fe62d170 Remove redundant #include-s from .h files...
Redundant, because transitively implied.  But don't do this for inclusions of
Audacity.h or Experimental.h.
2019-05-16 14:15:05 -04:00

77 lines
2.0 KiB
C++

/**********************************************************************
Audacity: A Digital Audio Editor
ButtonHandle.h
Paul Licameli
**********************************************************************/
#ifndef __AUDACITY_BUTTON_HANDLE__
#define __AUDACITY_BUTTON_HANDLE__
#include "../../UIHandle.h"
class wxMouseEvent;
class wxMouseState;
class Track;
/// \brief A UIHandle for a TrackPanel button, such as the Mute and Solo
/// buttons.
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 );
ButtonHandle &operator=(const ButtonHandle&) = default;
virtual ~ButtonHandle();
// This NEW abstract virtual simplifies the duties of further subclasses.
// This class will decide whether to refresh the clicked cell for button state
// change.
// Subclass can decide to refresh other things and the results will be ORed.
virtual Result CommitChanges
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) = 0;
// Define a message for the status bar and tooltip.
virtual wxString Tip(const wxMouseState &state) const = 0;
void Enter(bool forward) final override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject)
final override;
Result Drag
(const TrackPanelMouseEvent &event, AudacityProject *pProject)
final override;
HitTestPreview Preview
(const TrackPanelMouseState &state, const AudacityProject *pProject)
final override;
Result Release
(const TrackPanelMouseEvent &event, AudacityProject *pProject,
wxWindow *pParent) final override;
Result Cancel(AudacityProject *pProject) final override;
std::weak_ptr<Track> mpTrack;
wxRect mRect;
bool mWasIn{ true };
bool mIsClicked{};
};
#endif