mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +02:00
Scrubber holds preference, AdornedRulerPanel updates in idle time...
... removing two uses of AdornedRulerPanel in Scrubbing
This commit is contained in:
parent
3c858dd343
commit
9faa746d4d
@ -744,7 +744,7 @@ private:
|
|||||||
bool canScrub =
|
bool canScrub =
|
||||||
scrubber.CanScrub() &&
|
scrubber.CanScrub() &&
|
||||||
mParent &&
|
mParent &&
|
||||||
mParent->mShowScrubbing;
|
mParent->ShowingScrubRuler();
|
||||||
|
|
||||||
if (!canScrub)
|
if (!canScrub)
|
||||||
return RefreshCode::Cancelled;
|
return RefreshCode::Cancelled;
|
||||||
@ -948,25 +948,6 @@ AdornedRulerPanel::~AdornedRulerPanel()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
namespace {
|
|
||||||
static const wxChar *scrubEnabledPrefName = wxT("/QuickPlay/ScrubbingEnabled");
|
|
||||||
|
|
||||||
bool ReadScrubEnabledPref()
|
|
||||||
{
|
|
||||||
bool result {};
|
|
||||||
gPrefs->Read(scrubEnabledPrefName, &result, false);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WriteScrubEnabledPref(bool value)
|
|
||||||
{
|
|
||||||
gPrefs->Write(scrubEnabledPrefName, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void AdornedRulerPanel::UpdatePrefs()
|
void AdornedRulerPanel::UpdatePrefs()
|
||||||
{
|
{
|
||||||
if (mNeedButtonUpdate) {
|
if (mNeedButtonUpdate) {
|
||||||
@ -990,11 +971,6 @@ void AdornedRulerPanel::UpdatePrefs()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mShowScrubbing = ReadScrubEnabledPref();
|
|
||||||
// Affected by the last
|
|
||||||
UpdateRects();
|
|
||||||
SetPanelSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::ReCreateButtons()
|
void AdornedRulerPanel::ReCreateButtons()
|
||||||
@ -1134,6 +1110,9 @@ void AdornedRulerPanel::OnIdle( wxIdleEvent &evt )
|
|||||||
{
|
{
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
|
|
||||||
|
UpdateRects();
|
||||||
|
SetPanelSize();
|
||||||
|
|
||||||
auto &project = *mProject;
|
auto &project = *mProject;
|
||||||
auto &viewInfo = ViewInfo::Get( project );
|
auto &viewInfo = ViewInfo::Get( project );
|
||||||
const auto &selectedRegion = viewInfo.selectedRegion;
|
const auto &selectedRegion = viewInfo.selectedRegion;
|
||||||
@ -1220,7 +1199,7 @@ void AdornedRulerPanel::UpdateRects()
|
|||||||
auto top = &mInner;
|
auto top = &mInner;
|
||||||
auto bottom = &mInner;
|
auto bottom = &mInner;
|
||||||
|
|
||||||
if (mShowScrubbing) {
|
if (ShowingScrubRuler()) {
|
||||||
mScrubZone = mInner;
|
mScrubZone = mInner;
|
||||||
auto scrubHeight = std::min(mScrubZone.height, (int)(ScrubHeight));
|
auto scrubHeight = std::min(mScrubZone.height, (int)(ScrubHeight));
|
||||||
|
|
||||||
@ -1245,7 +1224,7 @@ void AdornedRulerPanel::UpdateRects()
|
|||||||
|
|
||||||
bottom->height -= BottomMargin;
|
bottom->height -= BottomMargin;
|
||||||
|
|
||||||
if (!mShowScrubbing)
|
if (!ShowingScrubRuler())
|
||||||
mScrubZone = mInner;
|
mScrubZone = mInner;
|
||||||
|
|
||||||
mRuler.SetBounds(mInner.GetLeft(),
|
mRuler.SetBounds(mInner.GetLeft(),
|
||||||
@ -1677,20 +1656,15 @@ void AdornedRulerPanel::OnToggleScrubRulerFromMenu(wxCommandEvent&)
|
|||||||
scrubber.OnToggleScrubRuler(*mProject);
|
scrubber.OnToggleScrubRuler(*mProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::OnToggleScrubRuler(/*wxCommandEvent&*/)
|
|
||||||
{
|
|
||||||
mShowScrubbing = !mShowScrubbing;
|
|
||||||
WriteScrubEnabledPref(mShowScrubbing);
|
|
||||||
gPrefs->Flush();
|
|
||||||
SetPanelSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdornedRulerPanel::SetPanelSize()
|
void AdornedRulerPanel::SetPanelSize()
|
||||||
{
|
{
|
||||||
wxSize size { GetSize().GetWidth(), GetRulerHeight(mShowScrubbing) };
|
const auto oldSize = GetSize();
|
||||||
SetSize(size);
|
wxSize size { oldSize.GetWidth(), GetRulerHeight(ShowingScrubRuler()) };
|
||||||
SetMinSize(size);
|
if ( size != oldSize ) {
|
||||||
GetParent()->PostSizeEventToParent();
|
SetSize(size);
|
||||||
|
SetMinSize(size);
|
||||||
|
GetParent()->PostSizeEventToParent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::DrawBothOverlays()
|
void AdornedRulerPanel::DrawBothOverlays()
|
||||||
@ -1801,7 +1775,7 @@ void AdornedRulerPanel::ShowMenu(const wxPoint & pos)
|
|||||||
prlitem->Enable( playRegion.Locked() || !playRegion.Empty() );
|
prlitem->Enable( playRegion.Locked() || !playRegion.Empty() );
|
||||||
|
|
||||||
wxMenuItem *ruleritem;
|
wxMenuItem *ruleritem;
|
||||||
if (mShowScrubbing)
|
if (ShowingScrubRuler())
|
||||||
ruleritem = rulerMenu.Append(OnScrubRulerID, _("Disable Scrub Ruler"));
|
ruleritem = rulerMenu.Append(OnScrubRulerID, _("Disable Scrub Ruler"));
|
||||||
else
|
else
|
||||||
ruleritem = rulerMenu.Append(OnScrubRulerID, _("Enable Scrub Ruler"));
|
ruleritem = rulerMenu.Append(OnScrubRulerID, _("Enable Scrub Ruler"));
|
||||||
@ -1975,7 +1949,7 @@ void AdornedRulerPanel::DoDrawBackground(wxDC * dc)
|
|||||||
AColor::UseThemeColour( dc, clrTrackInfo );
|
AColor::UseThemeColour( dc, clrTrackInfo );
|
||||||
dc->DrawRectangle( mInner );
|
dc->DrawRectangle( mInner );
|
||||||
|
|
||||||
if (mShowScrubbing) {
|
if (ShowingScrubRuler()) {
|
||||||
// Let's distinguish the scrubbing area by using a themable
|
// Let's distinguish the scrubbing area by using a themable
|
||||||
// colour and a line to set it off.
|
// colour and a line to set it off.
|
||||||
AColor::UseThemeColour(dc, clrScrubRuler, clrTrackPanelText );
|
AColor::UseThemeColour(dc, clrScrubRuler, clrTrackPanelText );
|
||||||
@ -2060,7 +2034,7 @@ void AdornedRulerPanel::DoDrawIndicator
|
|||||||
const int TriangleWidth = width * 3 / 8;
|
const int TriangleWidth = width * 3 / 8;
|
||||||
|
|
||||||
// Double-double headed, left-right
|
// Double-double headed, left-right
|
||||||
auto yy = mShowScrubbing
|
auto yy = ShowingScrubRuler()
|
||||||
? mScrubZone.y
|
? mScrubZone.y
|
||||||
: (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
|
: (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
|
||||||
tri[ 0 ].x = xx - IndicatorOffset;
|
tri[ 0 ].x = xx - IndicatorOffset;
|
||||||
@ -2091,7 +2065,7 @@ void AdornedRulerPanel::DoDrawIndicator
|
|||||||
const int IndicatorHalfWidth = width / 2;
|
const int IndicatorHalfWidth = width / 2;
|
||||||
|
|
||||||
// Double headed, left-right
|
// Double headed, left-right
|
||||||
auto yy = mShowScrubbing
|
auto yy = ShowingScrubRuler()
|
||||||
? mScrubZone.y
|
? mScrubZone.y
|
||||||
: (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
|
: (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
|
||||||
tri[ 0 ].x = xx - IndicatorOffset;
|
tri[ 0 ].x = xx - IndicatorOffset;
|
||||||
@ -2180,7 +2154,7 @@ struct AdornedRulerPanel::Subgroup final : TrackPanelGroup {
|
|||||||
explicit Subgroup( const AdornedRulerPanel &ruler ) : mRuler{ ruler } {}
|
explicit Subgroup( const AdornedRulerPanel &ruler ) : mRuler{ ruler } {}
|
||||||
Subdivision Children( const wxRect & ) override
|
Subdivision Children( const wxRect & ) override
|
||||||
{
|
{
|
||||||
return { Axis::Y, ( mRuler.mShowScrubbing )
|
return { Axis::Y, ( mRuler.ShowingScrubRuler() )
|
||||||
? Refinement{
|
? Refinement{
|
||||||
{ mRuler.mInner.GetTop(), mRuler.mQPCell },
|
{ mRuler.mInner.GetTop(), mRuler.mQPCell },
|
||||||
{ mRuler.mScrubZone.GetTop(), mRuler.mScrubbingCell },
|
{ mRuler.mScrubZone.GetTop(), mRuler.mScrubbingCell },
|
||||||
@ -2207,6 +2181,12 @@ struct AdornedRulerPanel::MainGroup final : TrackPanelGroup {
|
|||||||
const AdornedRulerPanel &mRuler;
|
const AdornedRulerPanel &mRuler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool AdornedRulerPanel::ShowingScrubRuler() const
|
||||||
|
{
|
||||||
|
auto &scrubber = Scrubber::Get( *GetProject() );
|
||||||
|
return scrubber.ShowsBar();
|
||||||
|
}
|
||||||
|
|
||||||
// CellularPanel implementation
|
// CellularPanel implementation
|
||||||
std::shared_ptr<TrackPanelNode> AdornedRulerPanel::Root()
|
std::shared_ptr<TrackPanelNode> AdornedRulerPanel::Root()
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
void SetFocusFromKbd() override;
|
void SetFocusFromKbd() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int GetRulerHeight() { return GetRulerHeight(mShowScrubbing); }
|
int GetRulerHeight() { return GetRulerHeight( ShowingScrubRuler() ); }
|
||||||
static int GetRulerHeight(bool showScrubBar);
|
static int GetRulerHeight(bool showScrubBar);
|
||||||
wxRect GetInnerRect() const { return mInner; }
|
wxRect GetInnerRect() const { return mInner; }
|
||||||
|
|
||||||
@ -67,8 +67,7 @@ public:
|
|||||||
|
|
||||||
void UpdateQuickPlayPos(wxCoord &mousePosX, bool shiftDown);
|
void UpdateQuickPlayPos(wxCoord &mousePosX, bool shiftDown);
|
||||||
|
|
||||||
bool ShowingScrubRuler() const { return mShowScrubbing; }
|
bool ShowingScrubRuler() const;
|
||||||
void OnToggleScrubRuler(/*wxCommandEvent& */);
|
|
||||||
void OnToggleScrubRulerFromMenu(wxCommandEvent& );
|
void OnToggleScrubRulerFromMenu(wxCommandEvent& );
|
||||||
void SetPanelSize();
|
void SetPanelSize();
|
||||||
|
|
||||||
@ -170,8 +169,6 @@ private:
|
|||||||
double mLeftDownClick; // click position in seconds
|
double mLeftDownClick; // click position in seconds
|
||||||
bool mIsDragging;
|
bool mIsDragging;
|
||||||
|
|
||||||
bool mShowScrubbing { false };
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
wxWindow *mButtons[3];
|
wxWindow *mButtons[3];
|
||||||
|
@ -233,6 +233,8 @@ Scrubber::Scrubber(AudacityProject *project)
|
|||||||
&Scrubber::OnActivateOrDeactivateApp, this);
|
&Scrubber::OnActivateOrDeactivateApp, this);
|
||||||
if (mWindow)
|
if (mWindow)
|
||||||
mWindow->PushEventHandler(&mForwarder);
|
mWindow->PushEventHandler(&mForwarder);
|
||||||
|
|
||||||
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
Scrubber::~Scrubber()
|
Scrubber::~Scrubber()
|
||||||
@ -749,7 +751,7 @@ void Scrubber::StopScrubbing()
|
|||||||
|
|
||||||
bool Scrubber::ShowsBar() const
|
bool Scrubber::ShowsBar() const
|
||||||
{
|
{
|
||||||
return AdornedRulerPanel::Get( *mProject ).ShowingScrubRuler();
|
return mShowScrubbing;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scrubber::IsScrubbing() const
|
bool Scrubber::IsScrubbing() const
|
||||||
@ -1113,10 +1115,35 @@ void Scrubber::OnSeek(const CommandContext&)
|
|||||||
CheckMenuItems();
|
CheckMenuItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
namespace {
|
||||||
|
static const wxChar *scrubEnabledPrefName = wxT("/QuickPlay/ScrubbingEnabled");
|
||||||
|
|
||||||
|
bool ReadScrubEnabledPref()
|
||||||
|
{
|
||||||
|
bool result {};
|
||||||
|
gPrefs->Read(scrubEnabledPrefName, &result, false);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteScrubEnabledPref(bool value)
|
||||||
|
{
|
||||||
|
gPrefs->Write(scrubEnabledPrefName, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Scrubber::UpdatePrefs()
|
||||||
|
{
|
||||||
|
mShowScrubbing = ReadScrubEnabledPref();
|
||||||
|
}
|
||||||
|
|
||||||
void Scrubber::OnToggleScrubRuler(const CommandContext&)
|
void Scrubber::OnToggleScrubRuler(const CommandContext&)
|
||||||
{
|
{
|
||||||
auto &ruler = AdornedRulerPanel::Get( *mProject );
|
mShowScrubbing = !mShowScrubbing;
|
||||||
ruler.OnToggleScrubRuler();
|
WriteScrubEnabledPref(mShowScrubbing);
|
||||||
|
gPrefs->Flush();
|
||||||
const auto toolbar =
|
const auto toolbar =
|
||||||
ToolManager::Get( *mProject ).GetToolBar( ScrubbingBarID );
|
ToolManager::Get( *mProject ).GetToolBar( ScrubbingBarID );
|
||||||
toolbar->EnableDisableButtons();
|
toolbar->EnableDisableButtons();
|
||||||
|
@ -17,7 +17,8 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include <wx/longlong.h>
|
#include <wx/longlong.h>
|
||||||
|
|
||||||
#include "../../AudioIOBase.h" // for ScrubbingOptions
|
#include "../../AudioIOBase.h" // for ScrubbingOptions
|
||||||
#include "../../ClientData.h"
|
#include "../../ClientData.h" // to inherit
|
||||||
|
#include "../../Prefs.h" // to inherit
|
||||||
#include "../../widgets/Overlay.h" // to inherit
|
#include "../../widgets/Overlay.h" // to inherit
|
||||||
#include "../../commands/CommandContext.h"
|
#include "../../commands/CommandContext.h"
|
||||||
#include "../../commands/CommandManager.h" // for MenuTable
|
#include "../../commands/CommandManager.h" // for MenuTable
|
||||||
@ -39,6 +40,7 @@ extern AudacityProject *GetActiveProject();
|
|||||||
class Scrubber final
|
class Scrubber final
|
||||||
: public wxEvtHandler
|
: public wxEvtHandler
|
||||||
, public ClientData::Base
|
, public ClientData::Base
|
||||||
|
, private PrefsListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Scrubber &Get( AudacityProject &project );
|
static Scrubber &Get( AudacityProject &project );
|
||||||
@ -130,6 +132,8 @@ public:
|
|||||||
bool IsTransportingPinned() const;
|
bool IsTransportingPinned() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void UpdatePrefs() override;
|
||||||
|
|
||||||
void StartPolling();
|
void StartPolling();
|
||||||
void StopPolling();
|
void StopPolling();
|
||||||
void DoScrub(bool seek);
|
void DoScrub(bool seek);
|
||||||
@ -185,6 +189,8 @@ private:
|
|||||||
|
|
||||||
ScrubbingOptions mOptions;
|
ScrubbingOptions mOptions;
|
||||||
double mMaxSpeed { 1.0 };
|
double mMaxSpeed { 1.0 };
|
||||||
|
|
||||||
|
bool mShowScrubbing { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
// Specialist in drawing the scrub speed, and listening for certain events
|
// Specialist in drawing the scrub speed, and listening for certain events
|
||||||
|
Loading…
x
Reference in New Issue
Block a user