mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 08:09:32 +02:00
Each cell can define cursor, status, and tooltip in default of hit tests
This commit is contained in:
parent
98514194a4
commit
d76777bef7
@ -937,8 +937,21 @@ void TrackPanel::HandleMotion
|
||||
refreshCode |= code;
|
||||
mMouseOverUpdateFlags |= code;
|
||||
}
|
||||
if (newCell &&
|
||||
(!pCursor || status.empty() || tooltip.empty())) {
|
||||
// Defaulting of cursor, tooltip, and status if there is no handle,
|
||||
// or if the handle does not specify them
|
||||
const auto preview = newCell->DefaultPreview( tpmState, GetProject() );
|
||||
if (!pCursor)
|
||||
pCursor = preview.cursor;
|
||||
if (status.empty())
|
||||
status = preview.message;
|
||||
if (tooltip.empty())
|
||||
tooltip = preview.tooltip;
|
||||
}
|
||||
if (!pCursor) {
|
||||
static wxCursor defaultCursor{ wxCURSOR_ARROW };
|
||||
// Ultimate default cursor
|
||||
static wxCursor defaultCursor{ wxCURSOR_DEFAULT };
|
||||
pCursor = &defaultCursor;
|
||||
}
|
||||
|
||||
@ -946,11 +959,15 @@ void TrackPanel::HandleMotion
|
||||
/* i18n-hint Esc is a key on the keyboard */
|
||||
status += wxT(" "), status += _("(Esc to cancel)");
|
||||
mListener->TP_DisplayStatusMessage(status);
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
if (tooltip != GetToolTipText()) {
|
||||
// Unset first, by analogy with AButton
|
||||
UnsetToolTip();
|
||||
SetToolTip(tooltip);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pCursor)
|
||||
SetCursor( *pCursor );
|
||||
|
||||
@ -3531,6 +3548,12 @@ TrackPanelCell::~TrackPanelCell()
|
||||
{
|
||||
}
|
||||
|
||||
HitTestPreview TrackPanelCell::DefaultPreview
|
||||
(const TrackPanelMouseState &, const AudacityProject *)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
unsigned TrackPanelCell::HandleWheelRotation
|
||||
(const TrackPanelMouseEvent &, AudacityProject *)
|
||||
{
|
||||
|
@ -14,6 +14,7 @@ Paul Licameli
|
||||
#include "MemoryX.h"
|
||||
|
||||
class AudacityProject;
|
||||
struct HitTestPreview;
|
||||
struct TrackPanelMouseEvent;
|
||||
struct TrackPanelMouseState;
|
||||
class ViewInfo;
|
||||
@ -34,6 +35,11 @@ class AUDACITY_DLL_API TrackPanelCell /* not final */
|
||||
public:
|
||||
virtual ~TrackPanelCell () = 0;
|
||||
|
||||
// May supply default cursor, status message, and tooltip, when there is no
|
||||
// handle to hit at the mouse position, or the handle does not supply them.
|
||||
virtual HitTestPreview DefaultPreview
|
||||
(const TrackPanelMouseState &state, const AudacityProject *pProject);
|
||||
|
||||
// Return pointers to objects that can be queried for a status
|
||||
// bar message and cursor appropriate to the point, and that dispatch
|
||||
// mouse button events.
|
||||
|
@ -24,6 +24,13 @@ CommonTrackPanelCell::~CommonTrackPanelCell()
|
||||
{
|
||||
}
|
||||
|
||||
HitTestPreview CommonTrackPanelCell::DefaultPreview
|
||||
(const TrackPanelMouseState &, const AudacityProject *)
|
||||
{
|
||||
static wxCursor defaultCursor{ wxCURSOR_ARROW };
|
||||
return { {}, &defaultCursor, {} };
|
||||
}
|
||||
|
||||
unsigned CommonTrackPanelCell::HandleWheelRotation
|
||||
(const TrackPanelMouseEvent &evt, AudacityProject *pProject)
|
||||
{
|
||||
|
@ -27,6 +27,10 @@ public:
|
||||
|
||||
virtual ~CommonTrackPanelCell() = 0;
|
||||
|
||||
// Default to the arrow cursor
|
||||
HitTestPreview DefaultPreview
|
||||
(const TrackPanelMouseState &, const AudacityProject *) override;
|
||||
|
||||
virtual std::shared_ptr<Track> FindTrack() = 0;
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user