mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +02:00
Add toolbar edit mode
This adds an edit mode checkbox under View > Toolbars > Edit Mode, which hides the toolbar grabbers when off Signed-off-by: abb128 <alexx128p@gmail.com>
This commit is contained in:
parent
faa23d1b2b
commit
1ac8eeee94
@ -21,6 +21,19 @@ void OnResetToolBars(const CommandContext &context)
|
||||
ToolManager::OnResetToolBars(context);
|
||||
}
|
||||
|
||||
void OnEditMode(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
auto &commandManager = CommandManager::Get( project );
|
||||
|
||||
bool checked = !gPrefs->Read(wxT("/GUI/Toolbars/EditMode"), false);
|
||||
gPrefs->Write(wxT("/GUI/Toolbars/EditMode"), checked);
|
||||
gPrefs->Flush();
|
||||
commandManager.Check(wxT("EditMode"), checked);
|
||||
|
||||
wxTheApp->AddPendingEvent(wxCommandEvent{ EVT_PREFS_UPDATE });
|
||||
}
|
||||
|
||||
}; // struct Handler
|
||||
|
||||
|
||||
@ -48,8 +61,11 @@ BaseItemSharedPtr ToolbarsMenu()
|
||||
( FinderScope{ findCommandHandler },
|
||||
Section( wxT("Toolbars"),
|
||||
Menu( wxT("Toolbars"), XXO("&Toolbars"),
|
||||
Section( "Reset",
|
||||
Section( "Manage",
|
||||
/* i18n-hint: (verb)*/
|
||||
Command( wxT("EditMode"), XXO("&Edit Mode (on/off)"),
|
||||
FN(OnEditMode), AlwaysEnabledFlag,
|
||||
Options{}.CheckTest( wxT("/GUI/Toolbars/EditMode"), false ) ),
|
||||
Command( wxT("ResetToolbars"), XXO("Reset Toolb&ars"),
|
||||
FN(OnResetToolBars), AlwaysEnabledFlag )
|
||||
),
|
||||
|
@ -346,6 +346,7 @@ ToolBar::ToolBar( AudacityProject &project,
|
||||
mHSizer = NULL;
|
||||
mVisible = false;
|
||||
mPositioned = false;
|
||||
mEditMode = false;
|
||||
|
||||
mGrabber = NULL;
|
||||
mResizer = NULL;
|
||||
@ -538,10 +539,14 @@ void ToolBar::ReCreateButtons()
|
||||
// Create the main sizer
|
||||
auto ms = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
|
||||
|
||||
// Grabber is created only when editing, or when it's undocked
|
||||
// (as otherwise the undocked toolbar can't be moved around)
|
||||
if (mEditMode || !IsDocked())
|
||||
{
|
||||
// Create the grabber and add it to the main sizer
|
||||
mGrabber = safenew Grabber(this, mType);
|
||||
ms->Add(mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1);
|
||||
|
||||
}
|
||||
// Use a box sizer for laying out controls
|
||||
ms->Add((mHSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
|
||||
|
||||
@ -549,7 +554,7 @@ void ToolBar::ReCreateButtons()
|
||||
Populate();
|
||||
|
||||
// Add some space for the resize border
|
||||
if (IsResizable())
|
||||
if (mEditMode && IsResizable())
|
||||
{
|
||||
// Create the resizer and add it to the main sizer
|
||||
mResizer = safenew ToolBarResizer(this);
|
||||
@ -621,6 +626,21 @@ void ToolBar::UpdatePrefs()
|
||||
}
|
||||
#endif
|
||||
|
||||
bool updated = false;
|
||||
bool editing = gPrefs->Read(wxT("/GUI/Toolbars/EditMode"), false);
|
||||
|
||||
if ( editing != mEditMode )
|
||||
{
|
||||
mEditMode = editing;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if ( updated )
|
||||
{
|
||||
ReCreateButtons();
|
||||
Updated();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -632,6 +652,15 @@ ToolDock *ToolBar::GetDock()
|
||||
return dynamic_cast<ToolDock*>(GetParent());
|
||||
}
|
||||
|
||||
//
|
||||
// Returns whether or not edit mode is enabled
|
||||
//
|
||||
bool ToolBar::GetEditMode()
|
||||
{
|
||||
return mEditMode;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Toggle the docked/floating state
|
||||
//
|
||||
@ -640,6 +669,8 @@ void ToolBar::SetDocked( ToolDock *dock, bool pushed )
|
||||
// Remember it
|
||||
// mDock = dock;
|
||||
|
||||
if ( mGrabber )
|
||||
{
|
||||
// Change the tooltip of the grabber
|
||||
#if wxUSE_TOOLTIPS
|
||||
mGrabber->SetToolTip( GetTitle() );
|
||||
@ -647,6 +678,7 @@ void ToolBar::SetDocked( ToolDock *dock, bool pushed )
|
||||
|
||||
// Set the grabber button state
|
||||
mGrabber->PushButton( pushed );
|
||||
}
|
||||
|
||||
if (mResizer)
|
||||
{
|
||||
|
@ -121,6 +121,7 @@ class AUDACITY_DLL_API ToolBar /* not final */
|
||||
TranslatableString GetLabel();
|
||||
wxString GetSection();
|
||||
ToolDock *GetDock();
|
||||
bool GetEditMode();
|
||||
|
||||
private:
|
||||
void SetLabel(const wxString & label) override;
|
||||
@ -249,6 +250,7 @@ public:
|
||||
bool mVisible;
|
||||
bool mResizable;
|
||||
bool mPositioned; // true if position floating determined.
|
||||
bool mEditMode;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -1177,7 +1177,7 @@ void ToolManager::OnMouse( wxMouseEvent & event )
|
||||
DoneDragging();
|
||||
return;
|
||||
}
|
||||
else if( mDragDock && !event.ShiftDown() )
|
||||
else if( mDragDock && !event.ShiftDown() && mDragBar->GetEditMode() )
|
||||
{
|
||||
// Trip over...everyone ashore that's going ashore...
|
||||
mDragDock->Dock( mDragBar, true, mDragBefore );
|
||||
@ -1249,7 +1249,7 @@ void ToolManager::OnMouse( wxMouseEvent & event )
|
||||
dock = mBotDock;
|
||||
|
||||
// Looks like we have a winner...
|
||||
if( dock )
|
||||
if( dock && mDragBar->GetEditMode() )
|
||||
{
|
||||
wxPoint p;
|
||||
wxRect r;
|
||||
|
Loading…
x
Reference in New Issue
Block a user