mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-13 14:50:27 +02:00
Manage ruler status messages and tooltips in CellularPanel base class
This commit is contained in:
parent
ba4ae4f7bd
commit
a70e2284b0
@ -2048,11 +2048,15 @@ public:
|
|||||||
{
|
{
|
||||||
// May come here when recording is in progress, so hit tests are turned
|
// May come here when recording is in progress, so hit tests are turned
|
||||||
// off.
|
// off.
|
||||||
|
wxString tooltip;
|
||||||
|
if (mParent->mTimelineToolTip)
|
||||||
|
tooltip = _("Timeline actions disabled during recording");
|
||||||
|
|
||||||
static wxCursor cursor{ wxCURSOR_DEFAULT };
|
static wxCursor cursor{ wxCURSOR_DEFAULT };
|
||||||
return {
|
return {
|
||||||
{},
|
{},
|
||||||
&cursor,
|
&cursor,
|
||||||
{},
|
tooltip,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2384,7 +2388,7 @@ void AdornedRulerPanel::UpdatePrefs()
|
|||||||
UpdateRects();
|
UpdateRects();
|
||||||
SetPanelSize();
|
SetPanelSize();
|
||||||
|
|
||||||
RegenerateTooltips(mPrevZone);
|
RegenerateTooltips();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::ReCreateButtons()
|
void AdornedRulerPanel::ReCreateButtons()
|
||||||
@ -2518,39 +2522,9 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::RegenerateTooltips(StatusChoice choice)
|
void AdornedRulerPanel::RegenerateTooltips()
|
||||||
{
|
{
|
||||||
#if wxUSE_TOOLTIPS
|
CallAfter( [this]{ HandleCursorForPresentMouseState(); } );
|
||||||
if (mTimelineToolTip) {
|
|
||||||
if (mIsRecording) {
|
|
||||||
this->SetToolTip(_("Timeline actions disabled during recording"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
switch(choice) {
|
|
||||||
case StatusChoice::EnteringQP :
|
|
||||||
if (!mQuickPlayEnabled) {
|
|
||||||
this->SetToolTip(_("Quick-Play disabled"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->SetToolTip(_("Quick-Play enabled"));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case StatusChoice::EnteringScrubZone :
|
|
||||||
{
|
|
||||||
const auto message = ScrubbingMessage(mProject->GetScrubber());
|
|
||||||
this->SetToolTip(message);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this->SetToolTip(NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->SetToolTip(NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::OnRecordStartStop(wxCommandEvent & evt)
|
void AdornedRulerPanel::OnRecordStartStop(wxCommandEvent & evt)
|
||||||
@ -2573,9 +2547,7 @@ void AdornedRulerPanel::OnRecordStartStop(wxCommandEvent & evt)
|
|||||||
UpdateButtonStates();
|
UpdateButtonStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
CallAfter( [this]{ HandleCursorForPresentMouseState(); } );
|
RegenerateTooltips();
|
||||||
|
|
||||||
RegenerateTooltips(mPrevZone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
void AdornedRulerPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
||||||
@ -2724,7 +2696,6 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
|
|||||||
? StatusChoice::EnteringQP
|
? StatusChoice::EnteringQP
|
||||||
: StatusChoice::NoChange;
|
: StatusChoice::NoChange;
|
||||||
const bool changeInZone = (zone != mPrevZone);
|
const bool changeInZone = (zone != mPrevZone);
|
||||||
const bool changing = evt.Leaving() || evt.Entering() || changeInZone;
|
|
||||||
|
|
||||||
wxCoord xx = evt.GetX();
|
wxCoord xx = evt.GetX();
|
||||||
wxCoord mousePosX = xx;
|
wxCoord mousePosX = xx;
|
||||||
@ -2737,9 +2708,6 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
|
|||||||
mQuickPlayPos = std::min(t1, mQuickPlayPos);
|
mQuickPlayPos = std::min(t1, mQuickPlayPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle status bar messages
|
|
||||||
UpdateStatusBarAndTooltips (changing ? zone : StatusChoice::NoChange);
|
|
||||||
|
|
||||||
mPrevZone = zone;
|
mPrevZone = zone;
|
||||||
|
|
||||||
auto &scrubber = mProject->GetScrubber();
|
auto &scrubber = mProject->GetScrubber();
|
||||||
@ -2788,7 +2756,6 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
|
|||||||
// mouse going up => we shift to scrubbing.
|
// mouse going up => we shift to scrubbing.
|
||||||
scrubber.MarkScrubStart(evt.m_x,
|
scrubber.MarkScrubStart(evt.m_x,
|
||||||
TracksPrefs::GetPinnedHeadPreference(), false);
|
TracksPrefs::GetPinnedHeadPreference(), false);
|
||||||
UpdateStatusBarAndTooltips(StatusChoice::EnteringScrubZone);
|
|
||||||
DrawBothOverlays();
|
DrawBothOverlays();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2799,8 +2766,7 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
|
|||||||
scrubber.mInOneShotMode = !scrubber.IsScrubbing();
|
scrubber.mInOneShotMode = !scrubber.IsScrubbing();
|
||||||
scrubber.MarkScrubStart(evt.m_x,
|
scrubber.MarkScrubStart(evt.m_x,
|
||||||
TracksPrefs::GetPinnedHeadPreference(), false);
|
TracksPrefs::GetPinnedHeadPreference(), false);
|
||||||
UpdateStatusBarAndTooltips(StatusChoice::EnteringScrubZone);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
DrawBothOverlays();
|
DrawBothOverlays();
|
||||||
return;
|
return;
|
||||||
@ -2975,13 +2941,39 @@ auto AdornedRulerPanel::ScrubbingHandle::Preview
|
|||||||
(const TrackPanelMouseState &state, const AudacityProject *pProject)
|
(const TrackPanelMouseState &state, const AudacityProject *pProject)
|
||||||
-> HitTestPreview
|
-> HitTestPreview
|
||||||
{
|
{
|
||||||
return {};
|
const auto &scrubber = pProject->GetScrubber();
|
||||||
|
auto message = ScrubbingMessage(scrubber);
|
||||||
|
|
||||||
|
return {
|
||||||
|
message,
|
||||||
|
{},
|
||||||
|
// Tooltip is same as status message, or blank
|
||||||
|
((mParent && mParent->mTimelineToolTip) ? message : wxString{}),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto AdornedRulerPanel::QPHandle::Preview
|
auto AdornedRulerPanel::QPHandle::Preview
|
||||||
(const TrackPanelMouseState &state, const AudacityProject *pProject)
|
(const TrackPanelMouseState &state, const AudacityProject *pProject)
|
||||||
-> HitTestPreview
|
-> HitTestPreview
|
||||||
{
|
{
|
||||||
|
wxString tooltip;
|
||||||
|
if (mParent && mParent->mTimelineToolTip) {
|
||||||
|
if (!mParent->mQuickPlayEnabled)
|
||||||
|
tooltip = _("Quick-Play disabled");
|
||||||
|
else
|
||||||
|
tooltip = _("Quick-Play enabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString message;
|
||||||
|
const auto &scrubber = pProject->GetScrubber();
|
||||||
|
const bool scrubbing = scrubber.HasMark();
|
||||||
|
if (scrubbing)
|
||||||
|
// Don't distinguish zones
|
||||||
|
message = ScrubbingMessage(scrubber);
|
||||||
|
else
|
||||||
|
// message = Insert timeline status bar message here
|
||||||
|
;
|
||||||
|
|
||||||
static wxCursor cursorHand{ wxCURSOR_HAND };
|
static wxCursor cursorHand{ wxCURSOR_HAND };
|
||||||
static wxCursor cursorSizeWE{ wxCURSOR_SIZEWE };
|
static wxCursor cursorSizeWE{ wxCURSOR_SIZEWE };
|
||||||
|
|
||||||
@ -2995,9 +2987,9 @@ auto AdornedRulerPanel::QPHandle::Preview
|
|||||||
state.state.m_x, mParent->mOldPlayRegionEnd);
|
state.state.m_x, mParent->mOldPlayRegionEnd);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{},
|
message,
|
||||||
showArrows ? &cursorSizeWE : &cursorHand,
|
showArrows ? &cursorSizeWE : &cursorHand,
|
||||||
{},
|
tooltip,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3136,42 +3128,6 @@ void AdornedRulerPanel::StartQPPlay(bool looped, bool cutPreview)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::UpdateStatusBarAndTooltips(StatusChoice choice)
|
|
||||||
{
|
|
||||||
if (choice == StatusChoice::NoChange)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wxString message {};
|
|
||||||
|
|
||||||
const auto &scrubber = mProject->GetScrubber();
|
|
||||||
const bool scrubbing = scrubber.HasMark();
|
|
||||||
if (scrubbing && choice != StatusChoice::Leaving)
|
|
||||||
// Don't distinguish zones
|
|
||||||
choice = StatusChoice::EnteringScrubZone;
|
|
||||||
|
|
||||||
switch (choice) {
|
|
||||||
case StatusChoice::EnteringQP:
|
|
||||||
{
|
|
||||||
// message = Insert timeline status bar message here
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case StatusChoice::EnteringScrubZone:
|
|
||||||
{
|
|
||||||
message = ScrubbingMessage(scrubber);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display a message, or empty message
|
|
||||||
mProject->TP_DisplayStatusMessage(message);
|
|
||||||
|
|
||||||
RegenerateTooltips(choice);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This version toggles ruler state indirectly via the scrubber
|
// This version toggles ruler state indirectly via the scrubber
|
||||||
// to ensure that all the places where the state is shown update.
|
// to ensure that all the places where the state is shown update.
|
||||||
// For example buttons and menus must update.
|
// For example buttons and menus must update.
|
||||||
@ -3319,7 +3275,7 @@ void AdornedRulerPanel::OnToggleQuickPlay(wxCommandEvent&)
|
|||||||
mQuickPlayEnabled = (mQuickPlayEnabled)? false : true;
|
mQuickPlayEnabled = (mQuickPlayEnabled)? false : true;
|
||||||
gPrefs->Write(wxT("/QuickPlay/QuickPlayEnabled"), mQuickPlayEnabled);
|
gPrefs->Write(wxT("/QuickPlay/QuickPlayEnabled"), mQuickPlayEnabled);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
RegenerateTooltips(mPrevZone);
|
RegenerateTooltips();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::OnSyncSelToQuickPlay(wxCommandEvent&)
|
void AdornedRulerPanel::OnSyncSelToQuickPlay(wxCommandEvent&)
|
||||||
@ -3351,9 +3307,7 @@ void AdornedRulerPanel::OnTimelineToolTips(wxCommandEvent&)
|
|||||||
mTimelineToolTip = (mTimelineToolTip)? false : true;
|
mTimelineToolTip = (mTimelineToolTip)? false : true;
|
||||||
gPrefs->Write(wxT("/QuickPlay/ToolTips"), mTimelineToolTip);
|
gPrefs->Write(wxT("/QuickPlay/ToolTips"), mTimelineToolTip);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
#if wxUSE_TOOLTIPS
|
RegenerateTooltips();
|
||||||
RegenerateTooltips(mPrevZone);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::OnAutoScroll(wxCommandEvent&)
|
void AdornedRulerPanel::OnAutoScroll(wxCommandEvent&)
|
||||||
@ -3725,9 +3679,9 @@ void AdornedRulerPanel::ProcessUIHandleResult
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::UpdateStatusMessage( const wxString & )
|
void AdornedRulerPanel::UpdateStatusMessage( const wxString &message )
|
||||||
{
|
{
|
||||||
|
GetProject()->TP_DisplayStatusMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::CreateOverlays()
|
void AdornedRulerPanel::CreateOverlays()
|
||||||
|
@ -353,7 +353,7 @@ public:
|
|||||||
NoChange
|
NoChange
|
||||||
};
|
};
|
||||||
|
|
||||||
void RegenerateTooltips(StatusChoice choice);
|
void RegenerateTooltips();
|
||||||
|
|
||||||
void UpdateQuickPlayPos(wxCoord &mousPosX);
|
void UpdateQuickPlayPos(wxCoord &mousPosX);
|
||||||
|
|
||||||
@ -376,8 +376,6 @@ private:
|
|||||||
void HandleQPRelease(wxMouseEvent &event);
|
void HandleQPRelease(wxMouseEvent &event);
|
||||||
void StartQPPlay(bool looped, bool cutPreview);
|
void StartQPPlay(bool looped, bool cutPreview);
|
||||||
|
|
||||||
void UpdateStatusBarAndTooltips(StatusChoice choice);
|
|
||||||
|
|
||||||
void OnCaptureLost(wxMouseCaptureLostEvent &evt);
|
void OnCaptureLost(wxMouseCaptureLostEvent &evt);
|
||||||
|
|
||||||
void DoDrawBackground(wxDC * dc);
|
void DoDrawBackground(wxDC * dc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user