1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-16 08:34:10 +02:00
audacity/src/tracks/ui/ButtonHandle.h
Paul Licameli d7738c403f Handles mark need for highlight in new Enter() method not ctor...
... So this can be called more than once in its lifetime, in response to
TAB key rotation.
2017-07-12 13:03:14 -04:00

70 lines
1.8 KiB
C++

/**********************************************************************
Audacity: A Digital Audio Editor
ButtonHandle.h
Paul Licameli
**********************************************************************/
#ifndef __AUDACITY_BUTTON_HANDLE__
#define __AUDACITY_BUTTON_HANDLE__
#include "../../UIHandle.h"
#include "../../MemoryX.h"
class wxMouseEvent;
#include <wx/gdicmn.h>
class Track;
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;
void Enter() override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
Result Drag
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
HitTestPreview Preview
(const TrackPanelMouseState &state, const AudacityProject *pProject)
override;
Result Release
(const TrackPanelMouseEvent &event, AudacityProject *pProject,
wxWindow *pParent) override;
Result Cancel(AudacityProject *pProject) override;
std::weak_ptr<Track> mpTrack;
wxRect mRect;
bool mWasIn{ true };
bool mIsClicked{};
};
#endif