mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Tooltips for TCP buttons
This commit is contained in:
parent
812fd2adea
commit
42921b7e55
@ -11,6 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../Audacity.h"
|
||||
#include "PlayableTrackButtonHandles.h"
|
||||
|
||||
#include "../../../commands/CommandManager.h"
|
||||
#include "../../../HitTestResult.h"
|
||||
#include "../../../Project.h"
|
||||
#include "../../../RefreshCode.h"
|
||||
@ -37,6 +38,22 @@ UIHandle::Result MuteButtonHandle::CommitChanges
|
||||
return RefreshCode::RefreshNone;
|
||||
}
|
||||
|
||||
wxString MuteButtonHandle::Tip(const wxMouseState &) const
|
||||
{
|
||||
auto name = _("Mute");
|
||||
auto project = ::GetActiveProject();
|
||||
auto focused =
|
||||
project->GetTrackPanel()->GetFocusedTrack() == GetTrack().get();
|
||||
if (!focused)
|
||||
return name;
|
||||
|
||||
auto commandManager = project->GetCommandManager();
|
||||
std::vector<wxString> commands;
|
||||
commands.push_back(name);
|
||||
commands.push_back(wxT("TrackMute"));
|
||||
return commandManager->DescribeCommandsAndShortcuts(commands);
|
||||
}
|
||||
|
||||
UIHandlePtr MuteButtonHandle::HitTest
|
||||
(std::weak_ptr<MuteButtonHandle> &holder,
|
||||
const wxMouseState &state, const wxRect &rect,
|
||||
@ -79,6 +96,22 @@ UIHandle::Result SoloButtonHandle::CommitChanges
|
||||
return RefreshCode::RefreshNone;
|
||||
}
|
||||
|
||||
wxString SoloButtonHandle::Tip(const wxMouseState &) const
|
||||
{
|
||||
auto name = _("Solo");
|
||||
auto project = ::GetActiveProject();
|
||||
auto focused =
|
||||
project->GetTrackPanel()->GetFocusedTrack() == GetTrack().get();
|
||||
if (!focused)
|
||||
return name;
|
||||
|
||||
auto commandManager = project->GetCommandManager();
|
||||
std::vector<wxString> commands;
|
||||
commands.push_back(name);
|
||||
commands.push_back(wxT("TrackSolo"));
|
||||
return commandManager->DescribeCommandsAndShortcuts(commands);
|
||||
}
|
||||
|
||||
UIHandlePtr SoloButtonHandle::HitTest
|
||||
(std::weak_ptr<SoloButtonHandle> &holder,
|
||||
const wxMouseState &state, const wxRect &rect,
|
||||
|
@ -31,6 +31,8 @@ protected:
|
||||
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
|
||||
override;
|
||||
|
||||
wxString Tip(const wxMouseState &state) const override;
|
||||
|
||||
bool StopsOnKeystroke () override { return true; }
|
||||
|
||||
public:
|
||||
@ -59,6 +61,8 @@ protected:
|
||||
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
|
||||
override;
|
||||
|
||||
wxString Tip(const wxMouseState &state) const override;
|
||||
|
||||
bool StopsOnKeystroke () override { return true; }
|
||||
|
||||
public:
|
||||
|
@ -75,10 +75,11 @@ UIHandle::Result ButtonHandle::Drag
|
||||
}
|
||||
|
||||
HitTestPreview ButtonHandle::Preview
|
||||
(const TrackPanelMouseState &, const AudacityProject *)
|
||||
(const TrackPanelMouseState &st, const AudacityProject *)
|
||||
{
|
||||
// No special message or cursor
|
||||
return {};
|
||||
// No special cursor
|
||||
auto message = Tip(st.state);
|
||||
return { message, {}, message };
|
||||
}
|
||||
|
||||
UIHandle::Result ButtonHandle::Release
|
||||
|
@ -15,6 +15,7 @@ Paul Licameli
|
||||
#include "../../MemoryX.h"
|
||||
|
||||
class wxMouseEvent;
|
||||
class wxMouseState;
|
||||
#include <wx/gdicmn.h>
|
||||
|
||||
class Track;
|
||||
@ -42,6 +43,9 @@ protected:
|
||||
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
|
||||
|
@ -48,6 +48,12 @@ UIHandle::Result MinimizeButtonHandle::CommitChanges
|
||||
return RefreshNone;
|
||||
}
|
||||
|
||||
wxString MinimizeButtonHandle::Tip(const wxMouseState &) const
|
||||
{
|
||||
auto pTrack = GetTrack();
|
||||
return pTrack->GetMinimized() ? _("Expand") : _("Collapse");
|
||||
}
|
||||
|
||||
UIHandlePtr MinimizeButtonHandle::HitTest
|
||||
(std::weak_ptr<MinimizeButtonHandle> &holder,
|
||||
const wxMouseState &state, const wxRect &rect, TrackPanelCell *pCell)
|
||||
@ -99,6 +105,22 @@ UIHandle::Result CloseButtonHandle::CommitChanges
|
||||
return result;
|
||||
}
|
||||
|
||||
wxString CloseButtonHandle::Tip(const wxMouseState &) const
|
||||
{
|
||||
auto name = _("Close");
|
||||
auto project = ::GetActiveProject();
|
||||
auto focused =
|
||||
project->GetTrackPanel()->GetFocusedTrack() == GetTrack().get();
|
||||
if (!focused)
|
||||
return name;
|
||||
|
||||
auto commandManager = project->GetCommandManager();
|
||||
std::vector<wxString> commands;
|
||||
commands.push_back(name);
|
||||
commands.push_back(wxT("TrackClose"));
|
||||
return commandManager->DescribeCommandsAndShortcuts(commands);
|
||||
}
|
||||
|
||||
UIHandlePtr CloseButtonHandle::HitTest
|
||||
(std::weak_ptr<CloseButtonHandle> &holder,
|
||||
const wxMouseState &state, const wxRect &rect, TrackPanelCell *pCell)
|
||||
@ -138,6 +160,11 @@ UIHandle::Result MenuButtonHandle::CommitChanges
|
||||
return pCell->DoContextMenu(mRect, pParent, NULL);
|
||||
}
|
||||
|
||||
wxString MenuButtonHandle::Tip(const wxMouseState &) const
|
||||
{
|
||||
return _("More Commands...");
|
||||
}
|
||||
|
||||
UIHandlePtr MenuButtonHandle::HitTest
|
||||
(std::weak_ptr<MenuButtonHandle> &holder,
|
||||
const wxMouseState &state, const wxRect &rect,
|
||||
|
@ -24,6 +24,8 @@ protected:
|
||||
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
|
||||
override;
|
||||
|
||||
wxString Tip(const wxMouseState &state) const override;
|
||||
|
||||
public:
|
||||
explicit MinimizeButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect );
|
||||
@ -48,6 +50,8 @@ protected:
|
||||
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
|
||||
override;
|
||||
|
||||
wxString Tip(const wxMouseState &state) const override;
|
||||
|
||||
bool StopsOnKeystroke () override { return true; }
|
||||
|
||||
public:
|
||||
@ -77,6 +81,8 @@ protected:
|
||||
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
|
||||
override;
|
||||
|
||||
wxString Tip(const wxMouseState &state) const override;
|
||||
|
||||
public:
|
||||
explicit MenuButtonHandle
|
||||
( const std::shared_ptr<TrackPanelCell> &pCell,
|
||||
|
Loading…
x
Reference in New Issue
Block a user