mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Bug 625 - Track Pan / Gain sliders don't show tool tip on hover
This commit is contained in:
parent
046ee21e72
commit
a7bd7331ac
@ -83,6 +83,8 @@ struct CellularPanel::State
|
||||
std::vector<UIHandlePtr> mTargets;
|
||||
size_t mTarget {};
|
||||
unsigned mMouseOverUpdateFlags{};
|
||||
|
||||
wxString mToolTip;
|
||||
|
||||
int mMouseMostRecentX;
|
||||
int mMouseMostRecentY;
|
||||
@ -373,10 +375,11 @@ void CellularPanel::HandleMotion
|
||||
UpdateStatusMessage(status);
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
if (tooltip.Translation() != GetToolTipText()) {
|
||||
if (tooltip.Translation() != state.mToolTip) {
|
||||
// Unset first, by analogy with AButton
|
||||
UnsetToolTip();
|
||||
SetToolTip(tooltip);
|
||||
state.mToolTip = tooltip.Translation();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -815,8 +818,12 @@ catch( ... )
|
||||
|
||||
void CellularPanel::HandleClick( const TrackPanelMouseEvent &tpmEvent )
|
||||
{
|
||||
auto pCell = tpmEvent.pCell;
|
||||
#if wxUSE_TOOLTIPS
|
||||
// Any click should cancel the tooltip
|
||||
UnsetToolTip();
|
||||
#endif
|
||||
|
||||
auto pCell = tpmEvent.pCell;
|
||||
// Do hit test once more, in case the button really pressed was not the
|
||||
// one "anticipated."
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "../../../../RefreshCode.h"
|
||||
#include "../../../../TrackInfo.h"
|
||||
#include "../../../../TrackPanel.h"
|
||||
#include "../../../../TrackPanelAx.h"
|
||||
#include "../../../../UndoManager.h"
|
||||
#include "../../../../NoteTrack.h"
|
||||
#include "../../../../ViewInfo.h"
|
||||
@ -34,7 +35,7 @@ VelocitySliderHandle::~VelocitySliderHandle()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<NoteTrack> VelocitySliderHandle::GetNoteTrack()
|
||||
std::shared_ptr<NoteTrack> VelocitySliderHandle::GetNoteTrack() const
|
||||
{
|
||||
return std::static_pointer_cast<NoteTrack>(mpTrack.lock());
|
||||
}
|
||||
@ -69,7 +70,29 @@ UIHandle::Result VelocitySliderHandle::CommitChanges
|
||||
return RefreshCode::RefreshCell;
|
||||
}
|
||||
|
||||
TranslatableString VelocitySliderHandle::Tip(
|
||||
const wxMouseState &, AudacityProject &project) const
|
||||
{
|
||||
TranslatableString val;
|
||||
float value = 0;
|
||||
|
||||
auto pTrack = GetNoteTrack();
|
||||
if (pTrack)
|
||||
value = pTrack->GetVelocity();
|
||||
|
||||
// LLL: Can't access the slider since Tip() is a const method and getting the slider
|
||||
// is not, so duplicate what LWSlider does.
|
||||
|
||||
if (value > 0.0f)
|
||||
// Signed
|
||||
val = Verbatim("%+d").Format((int)value);
|
||||
else
|
||||
// Zero, or signed negative
|
||||
val = Verbatim("%d").Format((int)value);
|
||||
|
||||
/* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
|
||||
return XO("%s: %s").Format(XO("Velocity"), val);
|
||||
}
|
||||
|
||||
UIHandlePtr VelocitySliderHandle::HitTest
|
||||
(std::weak_ptr<VelocitySliderHandle> &holder,
|
||||
|
@ -24,7 +24,7 @@ class VelocitySliderHandle final : public SliderHandle
|
||||
{
|
||||
VelocitySliderHandle(const VelocitySliderHandle&) = delete;
|
||||
|
||||
std::shared_ptr<NoteTrack> GetNoteTrack();
|
||||
std::shared_ptr<NoteTrack> GetNoteTrack() const;
|
||||
|
||||
public:
|
||||
explicit VelocitySliderHandle
|
||||
@ -42,6 +42,9 @@ protected:
|
||||
Result CommitChanges
|
||||
(const wxMouseEvent &event, AudacityProject *pProject) override;
|
||||
|
||||
TranslatableString Tip(
|
||||
const wxMouseState &state, AudacityProject &) const override;
|
||||
|
||||
bool StopsOnKeystroke () override { return true; }
|
||||
|
||||
public:
|
||||
|
@ -16,6 +16,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../../RefreshCode.h"
|
||||
#include "../../../../TrackInfo.h"
|
||||
#include "../../../../TrackPanel.h"
|
||||
#include "../../../../TrackPanelAx.h"
|
||||
#include "../../../../UndoManager.h"
|
||||
#include "../../../../WaveTrack.h"
|
||||
|
||||
@ -28,7 +29,7 @@ GainSliderHandle::~GainSliderHandle()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<WaveTrack> GainSliderHandle::GetWaveTrack()
|
||||
std::shared_ptr<WaveTrack> GainSliderHandle::GetWaveTrack() const
|
||||
{
|
||||
return std::static_pointer_cast<WaveTrack>(mpTrack.lock());
|
||||
}
|
||||
@ -64,6 +65,26 @@ UIHandle::Result GainSliderHandle::CommitChanges
|
||||
return RefreshCode::RefreshCell;
|
||||
}
|
||||
|
||||
TranslatableString GainSliderHandle::Tip(
|
||||
const wxMouseState &, AudacityProject &project) const
|
||||
{
|
||||
TranslatableString val;
|
||||
float value = 0;
|
||||
|
||||
auto pTrack = GetWaveTrack();
|
||||
if (pTrack)
|
||||
value = pTrack->GetGain();
|
||||
|
||||
// LLL: Can't access the slider since Tip() is a const method and getting the slider
|
||||
// is not, so duplicate what LWSlider does.
|
||||
|
||||
/* i18n-hint dB abbreviates decibels */
|
||||
val = XO("%+.1f dB").Format(LINEAR_TO_DB(value));
|
||||
|
||||
/* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
|
||||
return XO("%s: %s").Format(XO("Gain"), val);
|
||||
}
|
||||
|
||||
UIHandlePtr GainSliderHandle::HitTest
|
||||
(std::weak_ptr<GainSliderHandle> &holder,
|
||||
const wxMouseState &state, const wxRect &rect,
|
||||
@ -106,7 +127,7 @@ PanSliderHandle::~PanSliderHandle()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<WaveTrack> PanSliderHandle::GetWaveTrack()
|
||||
std::shared_ptr<WaveTrack> PanSliderHandle::GetWaveTrack() const
|
||||
{
|
||||
return std::static_pointer_cast<WaveTrack>(mpTrack.lock());
|
||||
}
|
||||
@ -143,6 +164,38 @@ UIHandle::Result PanSliderHandle::CommitChanges
|
||||
return RefreshCode::RefreshCell;
|
||||
}
|
||||
|
||||
TranslatableString PanSliderHandle::Tip(
|
||||
const wxMouseState &, AudacityProject &project) const
|
||||
{
|
||||
TranslatableString val;
|
||||
float value = 0.0;
|
||||
|
||||
auto pTrack = GetWaveTrack();
|
||||
if (pTrack)
|
||||
value = pTrack->GetPan();
|
||||
|
||||
// LLL: Can't access the slider since Tip() is a const method and getting the slider
|
||||
// is not, so duplicate what LWSlider does.
|
||||
|
||||
if (value == 0.0)
|
||||
{
|
||||
val = XO("Center");
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto v = 100.0f * fabsf(value);
|
||||
if (value < 0.0)
|
||||
/* i18n-hint: Stereo pan setting */
|
||||
val = XO("%.0f%% Left").Format(v);
|
||||
else
|
||||
/* i18n-hint: Stereo pan setting */
|
||||
val = XO("%.0f%% Right").Format(v);
|
||||
}
|
||||
|
||||
/* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
|
||||
return XO("%s: %s").Format(XO("Pan"), val);
|
||||
}
|
||||
|
||||
UIHandlePtr PanSliderHandle::HitTest
|
||||
(std::weak_ptr<PanSliderHandle> &holder,
|
||||
const wxMouseState &state, const wxRect &rect,
|
||||
|
@ -20,7 +20,7 @@ class GainSliderHandle final : public SliderHandle
|
||||
{
|
||||
GainSliderHandle(const GainSliderHandle&) = delete;
|
||||
|
||||
std::shared_ptr<WaveTrack> GetWaveTrack();
|
||||
std::shared_ptr<WaveTrack> GetWaveTrack() const;
|
||||
|
||||
public:
|
||||
explicit GainSliderHandle
|
||||
@ -38,6 +38,9 @@ protected:
|
||||
Result CommitChanges
|
||||
(const wxMouseEvent &event, AudacityProject *pProject) override;
|
||||
|
||||
TranslatableString Tip(
|
||||
const wxMouseState &state, AudacityProject &) const override;
|
||||
|
||||
bool StopsOnKeystroke () override { return true; }
|
||||
|
||||
public:
|
||||
@ -53,7 +56,7 @@ class PanSliderHandle final : public SliderHandle
|
||||
{
|
||||
PanSliderHandle(const PanSliderHandle&) = delete;
|
||||
|
||||
std::shared_ptr<WaveTrack> GetWaveTrack();
|
||||
std::shared_ptr<WaveTrack> GetWaveTrack() const;
|
||||
|
||||
public:
|
||||
explicit PanSliderHandle
|
||||
@ -70,6 +73,9 @@ protected:
|
||||
Result CommitChanges
|
||||
(const wxMouseEvent &event, AudacityProject *pProject) override;
|
||||
|
||||
TranslatableString Tip(
|
||||
const wxMouseState &state, AudacityProject &) const override;
|
||||
|
||||
bool StopsOnKeystroke () override { return true; }
|
||||
|
||||
public:
|
||||
|
@ -74,10 +74,13 @@ UIHandle::Result SliderHandle::Drag
|
||||
}
|
||||
|
||||
HitTestPreview SliderHandle::Preview
|
||||
(const TrackPanelMouseState &, AudacityProject *)
|
||||
(const TrackPanelMouseState &st, AudacityProject *project)
|
||||
{
|
||||
// No special message or cursor
|
||||
return {};
|
||||
// No special cursor
|
||||
TranslatableString message;
|
||||
if (project)
|
||||
message = Tip(st.state, *project);
|
||||
return { message, {}, message };
|
||||
}
|
||||
|
||||
UIHandle::Result SliderHandle::Release
|
||||
|
@ -45,6 +45,10 @@ protected:
|
||||
virtual Result CommitChanges
|
||||
(const wxMouseEvent &event, AudacityProject *pProject) = 0;
|
||||
|
||||
// Define a message for the status bar and tooltip.
|
||||
virtual TranslatableString Tip(
|
||||
const wxMouseState &state, AudacityProject &project) const = 0;
|
||||
|
||||
void Enter(bool forward, AudacityProject *) override;
|
||||
|
||||
Result Click
|
||||
|
@ -943,7 +943,7 @@ TranslatableString LWSlider::GetTip(float value) const
|
||||
switch(mStyle)
|
||||
{
|
||||
case FRAC_SLIDER:
|
||||
Verbatim("%.2f").Format( value );
|
||||
val = Verbatim("%.2f").Format( value );
|
||||
break;
|
||||
|
||||
case DB_SLIDER:
|
||||
@ -977,10 +977,10 @@ TranslatableString LWSlider::GetTip(float value) const
|
||||
case VEL_SLIDER:
|
||||
if (value > 0.0f)
|
||||
// Signed
|
||||
Verbatim("%+d").Format( (int) value );
|
||||
val = Verbatim("%+d").Format( (int) value );
|
||||
else
|
||||
// Zero, or signed negative
|
||||
Verbatim("%d").Format( (int) value );
|
||||
val = Verbatim("%d").Format( (int) value );
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user