1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +02:00

Make AdornedRulerPanel respect toolbar edit mode

AdornedRulerPanel also has a grabber, this commit makes it so that the grabber does not exist when edit mode is off.

Signed-off-by: abb128 <alexx128p@gmail.com>
This commit is contained in:
abb128 2021-07-15 21:06:04 +03:00
parent 534da8b617
commit 21614a390c
2 changed files with 28 additions and 7 deletions

View File

@ -926,6 +926,9 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* project,
mTracks = &TrackList::Get( *project );
mIsSnapped = false;
mEditMode = gPrefs->Read(wxT("/GUI/Toolbars/EditMode"), false);
mGrabber = nullptr;
mIsRecording = false;
@ -969,7 +972,13 @@ void AdornedRulerPanel::Refresh( bool eraseBackground, const wxRect *rect )
void AdornedRulerPanel::UpdatePrefs()
{
if (mNeedButtonUpdate) {
bool mode = gPrefs->Read(wxT("/GUI/Toolbars/EditMode"), false);
if ( mode != mEditMode )
{
mEditMode = mode;
ReCreateButtons();
}else if (mNeedButtonUpdate) {
// Visit this block once only in the lifetime of this panel
mNeedButtonUpdate = false;
// Do this first time setting of button status texts
@ -1009,6 +1018,12 @@ void AdornedRulerPanel::ReCreateButtons()
button = nullptr;
}
if ( mGrabber )
{
mGrabber->Destroy();
mGrabber = nullptr;
}
size_t iButton = 0;
// Make the short row of time ruler pushbottons.
// Don't bother with sizers. Their sizes and positions are fixed.
@ -1017,12 +1032,14 @@ void AdornedRulerPanel::ReCreateButtons()
wxPoint position( 1, 0 );
Grabber * pGrabber = safenew Grabber(this, this->GetId());
pGrabber->SetAsSpacer( true );
//pGrabber->SetSize( 10, 27 ); // default is 10,27
pGrabber->SetPosition( position );
position.x = 12;
if ( mEditMode )
{
mGrabber = safenew Grabber(this, this->GetId());
mGrabber->SetAsSpacer( true );
//mGrabber->SetSize( 10, 27 ); // default is 10,27
mGrabber->SetPosition( position );
position.x = 12;
}else position.x = 0;
auto size = theTheme.ImageSize( bmpRecoloredUpSmall );
size.y = std::min(size.y, GetRulerHeight(false));

View File

@ -13,6 +13,7 @@
#include "CellularPanel.h"
#include "widgets/Ruler.h" // member variable
#include "widgets/Grabber.h" // mGrabber
#include "Prefs.h"
#include "ViewInfo.h" // for PlayRegion
@ -142,6 +143,9 @@ private:
double mQuickPlayPos;
bool mIsSnapped;
bool mEditMode;
Grabber *mGrabber;
PlayRegion mOldPlayRegion;