Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ToolManager Class Referencefinal

class ToolManager More...

#include <ToolManager.h>

Inheritance diagram for ToolManager:
[legend]
Collaboration diagram for ToolManager:
[legend]

Classes

struct  TopPanelHook
 

Public Member Functions

 ToolManager (AudacityProject *parent)
 
 ToolManager (const ToolManager &) PROHIBITED
 
ToolManageroperator= (const ToolManager &) PROHIBITED
 
 ~ToolManager ()
 
void CreateWindows ()
 
void LayoutToolBars ()
 
bool IsDocked (int type)
 
bool IsVisible (int type)
 
void ShowHide (int type)
 
void Expose (int type, bool show)
 
ToolBarGetToolBar (int type) const
 
ToolDockGetTopDock ()
 
const ToolDockGetTopDock () const
 
ToolDockGetBotDock ()
 
const ToolDockGetBotDock () const
 
void Reset ()
 
void Destroy ()
 
void RegenerateTooltips ()
 
int FilterEvent (wxEvent &event) override
 
bool RestoreFocus ()
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static ToolManagerGet (AudacityProject &project)
 
static const ToolManagerGet (const AudacityProject &project)
 
static void OnResetToolBars (const CommandContext &context)
 

Private Types

using FramePtr = Destroy_ptr< wxFrame >
 

Private Member Functions

ToolBarFloat (ToolBar *t, wxPoint &pos)
 
void OnTimer (wxTimerEvent &event)
 
void OnMouse (wxMouseEvent &event)
 
void OnCaptureLost (wxMouseCaptureLostEvent &event)
 
void UndockBar (wxPoint mp)
 
void OnGrabber (GrabberEvent &event)
 
void HandleEscapeKey ()
 
void DoneDragging ()
 
void OnIndicatorCreate (wxWindowCreateEvent &event)
 
void OnIndicatorPaint (wxPaintEvent &event)
 
void ReadConfig ()
 
void WriteConfig ()
 
void Updated ()
 

Private Attributes

AudacityProjectmParent
 
wxWindowRef mLastFocus {}
 
ToolFramemDragWindow
 
ToolDockmDragDock
 
ToolBarmDragBar {}
 
wxPoint mDragOffset
 
ToolBarConfiguration::Position mDragBefore {}
 
wxPoint mLastPos
 
wxRect mBarPos
 
FramePtr mIndicator
 
std::unique_ptr< wxRegion > mLeft
 
std::unique_ptr< wxRegion > mDown
 
wxRegion * mCurrent
 
wxTimer mTimer
 
bool mLastState
 
bool mTransition
 
ToolDockmTopDock {}
 
ToolDockmBotDock {}
 
ToolBar::Holder mBars [ToolBarCount]
 
wxPoint mPrevPosition {}
 
ToolDockmPrevDock {}
 
ToolBarConfiguration::Position mPrevSlot { ToolBarConfiguration::UnspecifiedPosition }
 
ToolBarConfiguration mPrevConfiguration
 
bool mDidDrag {}
 
bool mClicked {}
 

Detailed Description

class ToolManager

Manages the ToolDocks and handles the dragging, floating, and docking of ToolBars.

Definition at line 51 of file ToolManager.h.

Member Typedef Documentation

◆ FramePtr

using ToolManager::FramePtr = Destroy_ptr<wxFrame>
private

Definition at line 131 of file ToolManager.h.

Constructor & Destructor Documentation

◆ ToolManager() [1/2]

ToolManager::ToolManager ( AudacityProject parent)

Definition at line 354 of file ToolManager.cpp.

355: wxEvtHandler()
356{
357 wxPoint pt[ 3 ];
358
359#if defined(__WXMAC__)
360 // Save original transition
361 mTransition = wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION );
362#endif
363
364 // Initialize everything
365 mParent = parent;
366 mLastPos.x = mBarPos.x = -1;
367 mLastPos.y = mBarPos.y = -1;
368 mDragWindow = NULL;
369 mDragDock = NULL;
370 mDragBar = NULL;
371
372 // Create the down arrow
373 pt[ 0 ].x = 0;
374 pt[ 0 ].y = 0;
375 pt[ 1 ].x = 9;
376 pt[ 1 ].y = 9;
377 pt[ 2 ].x = 18;
378 pt[ 2 ].y = 0;
379
380 // Create the shaped region
381 mDown = std::make_unique<wxRegion>( 3, &pt[0] );
382
383 // Create the down arrow
384 pt[ 0 ].x = 9;
385 pt[ 0 ].y = 0;
386 pt[ 1 ].x = 0;
387 pt[ 1 ].y = 9;
388 pt[ 2 ].x = 9;
389 pt[ 2 ].y = 18;
390
391 // Create the shaped region
392 mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
393
394 // Create the indicator frame
395 // parent is null but FramePtr ensures destruction
396 mIndicator = FramePtr{ safenew wxFrame( NULL,
397 wxID_ANY,
398 wxEmptyString,
399 wxDefaultPosition,
400 wxSize( 32, 32 ),
401 wxFRAME_TOOL_WINDOW |
402 wxFRAME_SHAPED |
403 wxNO_BORDER |
404 wxFRAME_NO_TASKBAR |
405 wxSTAY_ON_TOP )
406 };
407
408 // Hook the creation event...only needed on GTK, but doesn't hurt for all
409 mIndicator->Bind( wxEVT_CREATE,
411 this );
412
413 // Hook the paint event...needed for all
414 mIndicator->Bind( wxEVT_PAINT,
416 this );
417
418 // It's a little shy
419 mIndicator->Hide();
420}
#define safenew
Definition: MemoryX.h:10
void OnIndicatorCreate(wxWindowCreateEvent &event)
ToolBar * mDragBar
Definition: ToolManager.h:124
bool mTransition
Definition: ToolManager.h:140
ToolFrame * mDragWindow
Definition: ToolManager.h:122
std::unique_ptr< wxRegion > mLeft
Definition: ToolManager.h:133
AudacityProject * mParent
Definition: ToolManager.h:119
void OnIndicatorPaint(wxPaintEvent &event)
std::unique_ptr< wxRegion > mDown
Definition: ToolManager.h:133
ToolDock * mDragDock
Definition: ToolManager.h:123
Destroy_ptr< wxFrame > FramePtr
Definition: ToolManager.h:131
wxRect mBarPos
Definition: ToolManager.h:129
FramePtr mIndicator
Definition: ToolManager.h:132
wxPoint mLastPos
Definition: ToolManager.h:128

References mBarPos, mDown, mDragBar, mDragDock, mDragWindow, mIndicator, mLastPos, mLeft, mParent, mTransition, OnIndicatorCreate(), OnIndicatorPaint(), and safenew.

Here is the call graph for this function:

◆ ToolManager() [2/2]

ToolManager::ToolManager ( const ToolManager )

◆ ~ToolManager()

ToolManager::~ToolManager ( )

Definition at line 497 of file ToolManager.cpp.

498{
499 Destroy();
500}
void Destroy()

References Destroy().

Here is the call graph for this function:

Member Function Documentation

◆ CreateWindows()

void ToolManager::CreateWindows ( )

Definition at line 422 of file ToolManager.cpp.

423{
424 auto parent = mParent;
425 auto &window = GetProjectFrame( *parent );
426
427 // Hook the parents mouse events...using the parent helps greatly
428 // under GTK
429 window.Bind( wxEVT_LEFT_UP,
431 this );
432 window.Bind( wxEVT_MOTION,
434 this );
435 window.Bind( wxEVT_MOUSE_CAPTURE_LOST,
437 this );
438
439 wxWindow *topDockParent = TopPanelHook::Call( window );
440 wxASSERT(topDockParent);
441
442 // Create the top and bottom docks
443 mTopDock = safenew ToolDock( this, topDockParent, TopDockID );
444 mBotDock = safenew ToolDock( this, &window, BotDockID );
445
446 // Create all of the toolbars
447 // All have the project as parent window
448 wxASSERT(parent);
449
450 size_t ii = 0;
451 for (const auto &factory : RegisteredToolbarFactory::GetFactories()) {
452 if (factory) {
453 mBars[ii] = factory( *parent );
454 }
455 else
456 wxASSERT( false );
457 ++ii;
458 }
459
460 // We own the timer
461 mTimer.SetOwner( this );
462
463 // Process the toolbar config settings
464 ReadConfig();
465
466 wxEvtHandler::AddFilter(this);
467}
static RegisteredToolbarFactory factory
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
@ BotDockID
Definition: ToolDock.h:43
@ TopDockID
Definition: ToolDock.h:42
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
void ReadConfig()
void OnCaptureLost(wxMouseCaptureLostEvent &event)
ToolDock * mTopDock
Definition: ToolManager.h:143
wxTimer mTimer
Definition: ToolManager.h:136
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:146
void OnMouse(wxMouseEvent &event)
ToolDock * mBotDock
Definition: ToolManager.h:144
static const Functions & GetFactories()
Definition: ToolBar.cpp:1026

References BotDockID, GlobalHook< TopPanelHook, wxWindow *(wxWindow &) >::Call(), factory, RegisteredToolbarFactory::GetFactories(), GetProjectFrame(), mBars, mBotDock, mParent, mTimer, mTopDock, OnCaptureLost(), OnMouse(), ReadConfig(), safenew, and TopDockID.

Referenced by InitProjectWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Destroy()

void ToolManager::Destroy ( )

Definition at line 473 of file ToolManager.cpp.

474{
475 if ( mTopDock || mBotDock ) { // destroy at most once
476 wxEvtHandler::RemoveFilter(this);
477
478 // Save the toolbar states
479 WriteConfig();
480
481 // This function causes the toolbars to be destroyed, so
482 // clear the configuration of the ToolDocks which refer to
483 // these toolbars. This change was needed to stop Audacity
484 // crashing when running with Jaws on Windows 10 1703.
487
488 mTopDock = mBotDock = nullptr; // indicate that it has been destroyed
489
490 for ( size_t ii = 0; ii < ToolBarCount; ++ii )
491 mBars[ii].reset();
492
493 mIndicator.reset();
494 }
495}
@ ToolBarCount
Definition: ToolBar.h:87
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:309
void WriteConfig()

References ToolBarConfiguration::Clear(), ToolDock::GetConfiguration(), mBars, mBotDock, mIndicator, mTopDock, ToolBarCount, and WriteConfig().

Referenced by ProjectManager::OnCloseWindow(), and ~ToolManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoneDragging()

void ToolManager::DoneDragging ( )
private

Definition at line 1519 of file ToolManager.cpp.

1520{
1521 // Done dragging - ensure grabber button isn't pushed
1522 if( mDragBar )
1523 {
1524 mDragBar->SetDocked( mDragBar->GetDock(), false );
1525 }
1526
1527 // Release capture
1528 auto &window = GetProjectFrame( *mParent );
1529 if( window.HasCapture() )
1530 {
1531 window.ReleaseMouse();
1532 }
1533
1534 // Hide the indicator
1535 mIndicator->Hide();
1536
1537 mDragWindow = NULL;
1538 mDragDock = NULL;
1539 mDragBar = NULL;
1540 mPrevDock = NULL;
1543 mLastPos.x = mBarPos.x = -1;
1544 mLastPos.y = mBarPos.y = -1;
1545 mTimer.Stop();
1546 mDidDrag = false;
1547 mClicked = false;
1548
1549 RestoreFocus();
1550}
static const Position UnspecifiedPosition
Definition: ToolDock.h:105
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:638
ToolDock * GetDock()
Definition: ToolBar.cpp:630
ToolBarConfiguration mPrevConfiguration
Definition: ToolManager.h:152
ToolDock * mPrevDock
Definition: ToolManager.h:149
ToolBarConfiguration::Position mPrevSlot
Definition: ToolManager.h:151
bool RestoreFocus()

References ToolBarConfiguration::Clear(), ToolBar::GetDock(), GetProjectFrame(), mBarPos, mClicked, mDidDrag, mDragBar, mDragDock, mDragWindow, mIndicator, mLastPos, mParent, mPrevConfiguration, mPrevDock, mPrevSlot, mTimer, RestoreFocus(), ToolBar::SetDocked(), and ToolBarConfiguration::UnspecifiedPosition.

Referenced by HandleEscapeKey(), and OnMouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Expose()

void ToolManager::Expose ( int  type,
bool  show 
)

Definition at line 1102 of file ToolManager.cpp.

1103{
1104 ToolBar *t = mBars[ type ].get();
1105
1106 // Handle docked and floaters differently
1107 if( t->IsDocked() )
1108 {
1109 t->GetDock()->Expose( type, show );
1110 }
1111 else
1112 {
1113 t->Expose( show );
1114 }
1115}
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:98
bool IsDocked() const
Definition: ToolBar.cpp:423
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:444
void Expose(int type, bool show)
Definition: ToolDock.cpp:834

References ToolBar::Expose(), ToolDock::Expose(), ToolBar::GetDock(), ToolBar::IsDocked(), and mBars.

Referenced by ReadConfig(), Reset(), and ShowHide().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FilterEvent()

int ToolManager::FilterEvent ( wxEvent &  event)
override

Definition at line 683 of file ToolManager.cpp.

684{
685 // Snoop the global event stream for changes of focused window. Remember
686 // the last one of our own that is not a grabber.
687
688 if (event.GetEventType() == wxEVT_KILL_FOCUS) {
689 auto &focusEvent = static_cast<wxFocusEvent&>(event);
690 auto window = focusEvent.GetWindow();
691 auto top = wxGetTopLevelParent(window);
692 if(auto toolFrame = dynamic_cast<ToolFrame*>(top))
693 top = toolFrame->GetParent();
694 // window is that which will GET the focus
695 if ( window &&
696 !dynamic_cast<Grabber*>( window ) &&
697 !dynamic_cast<ToolFrame*>( window ) &&
698 top == FindProjectFrame( mParent ) )
699 // Note this is a dangle-proof wxWindowRef:
700 mLastFocus = window;
701 }
702
703 return Event_Skip;
704}
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
The widget to the left of a ToolBar that allows it to be dragged around to NEW positions.
Definition: Grabber.h:103
class ToolFrame
Definition: ToolManager.h:168
wxWindowRef mLastFocus
Definition: ToolManager.h:120

References FindProjectFrame(), mLastFocus, and mParent.

Here is the call graph for this function:

◆ Float()

ToolBar * ToolManager::Float ( ToolBar t,
wxPoint &  pos 
)
private

◆ Get() [1/2]

ToolManager & ToolManager::Get ( AudacityProject project)
static

Definition at line 341 of file ToolManager.cpp.

342{
343 return project.AttachedObjects::Get< ToolManager >( key );
344}
static const AudacityProject::AttachedObjects::RegisteredFactory key
Methods for ToolManager.
class ToolManager
Definition: ToolManager.h:55

References key.

Referenced by ScreenshotCommand::Apply(), ControlToolBar::Find(), AudioSetupToolBar::Get(), ControlToolBar::Get(), DeviceToolBar::Get(), ScrubbingToolBar::Get(), SelectionBar::Get(), TimeToolBar::Get(), ToolsToolBar::Get(), TranscriptionToolBar::Get(), MeterToolBar::Get(), Get(), InitProjectWindow(), MenuManager::ModifyToolbarMenus(), ProjectManager::New(), anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame(), ProjectWindow::OnActivate(), ProjectManager::OnCloseWindow(), OnResetToolBars(), AttachedToolBarMenuItem::OnShowToolBar(), ProjectWindow::OnThemeChange(), ProjectAudioManager::Stop(), and ProjectWindow::UpdateLayout().

Here is the caller graph for this function:

◆ Get() [2/2]

const ToolManager & ToolManager::Get ( const AudacityProject project)
static

Definition at line 346 of file ToolManager.cpp.

347{
348 return Get( const_cast< AudacityProject & >( project ) );
349}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
static ToolManager & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ GetBotDock() [1/2]

ToolDock * ToolManager::GetBotDock ( )

Definition at line 1039 of file ToolManager.cpp.

1040{
1041 return mBotDock;
1042}

References mBotDock.

◆ GetBotDock() [2/2]

const ToolDock * ToolManager::GetBotDock ( ) const

Definition at line 1044 of file ToolManager.cpp.

1045{
1046 return mBotDock;
1047}

References mBotDock.

◆ GetToolBar()

ToolBar * ToolManager::GetToolBar ( int  type) const

Definition at line 1018 of file ToolManager.cpp.

1019{
1020 return mBars[ type ].get();
1021}

References mBars.

Referenced by ScreenshotCommand::CaptureToolbar(), and ProjectAudioManager::Stop().

Here is the caller graph for this function:

◆ GetTopDock() [1/2]

ToolDock * ToolManager::GetTopDock ( )

Definition at line 1026 of file ToolManager.cpp.

1027{
1028 return mTopDock;
1029}

References mTopDock.

◆ GetTopDock() [2/2]

const ToolDock * ToolManager::GetTopDock ( ) const

Definition at line 1031 of file ToolManager.cpp.

1032{
1033 return mTopDock;
1034}

References mTopDock.

◆ HandleEscapeKey()

void ToolManager::HandleEscapeKey ( )
private

Definition at line 1490 of file ToolManager.cpp.

1491{
1492 if (mDragBar) {
1493 if(mPrevDock) {
1494 // Sheriff John Stone,
1495 // Why don't you leave me alone?
1496 // Well, I feel so break up
1497 // I want to go home.
1499 mPrevDock->Dock( mDragBar, true, mPrevSlot );
1500 Updated();
1501
1502 // Done with the floater
1504 mDragWindow->Destroy();
1505 mDragWindow = nullptr;
1506 mDragBar->Refresh(false);
1507 }
1508 else {
1509 // Floater remains, and returns to where it begain
1510 auto parent = mDragBar->GetParent();
1511 parent->SetPosition(mPrevPosition);
1512 mDragBar->SetDocked(NULL, false);
1513 }
1514
1515 DoneDragging();
1516 }
1517}
void RestoreConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:824
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:415
void ClearBar()
Definition: ToolManager.h:176
wxPoint mPrevPosition
Definition: ToolManager.h:148
void DoneDragging()

References ToolFrame::ClearBar(), ToolDock::Dock(), DoneDragging(), mDragBar, mDragWindow, mPrevConfiguration, mPrevDock, mPrevPosition, mPrevSlot, ToolDock::RestoreConfiguration(), ToolBar::SetDocked(), and Updated().

Referenced by OnGrabber().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsDocked()

bool ToolManager::IsDocked ( int  type)

Definition at line 1063 of file ToolManager.cpp.

1064{
1065 return mBars[ type ]->IsDocked();
1066}

References mBars.

◆ IsVisible()

bool ToolManager::IsVisible ( int  type)

Definition at line 1071 of file ToolManager.cpp.

1072{
1073 ToolBar *t = mBars[ type ].get();
1074
1075 return t && t->IsVisible();
1076
1077#if 0
1078 // If toolbar is floating
1079 if( !t->IsDocked() )
1080 {
1081 // Must return state of floater window
1082 return t->GetParent()->IsShown();
1083 }
1084
1085 // Return state of docked toolbar
1086 return t->IsShown();
1087#endif
1088}
bool IsVisible() const
Definition: ToolBar.cpp:431

References ToolBar::IsDocked(), ToolBar::IsVisible(), and mBars.

Referenced by ScreenshotCommand::CaptureToolbar(), and ShowHide().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LayoutToolBars()

void ToolManager::LayoutToolBars ( )

Definition at line 1120 of file ToolManager.cpp.

1121{
1122 // Update the layout
1123 if (mTopDock)
1124 {
1126 }
1127
1128 if (mBotDock)
1129 {
1131 }
1132}
void LayoutToolBars()
Definition: ToolDock.cpp:663

References ToolDock::LayoutToolBars(), mBotDock, and mTopDock.

Referenced by InitProjectWindow(), and OnMouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnCaptureLost()

void ToolManager::OnCaptureLost ( wxMouseCaptureLostEvent &  event)
private

Definition at line 1324 of file ToolManager.cpp.

1325{
1326 // Can't do anything if we're not dragging. This also prevents
1327 // us from intercepting events that don't belong to us from the
1328 // parent since we're Connect()ed to a couple.
1329 if( !mDragWindow )
1330 {
1331 event.Skip();
1332 return;
1333 }
1334
1335 // Simulate button up
1336 wxMouseEvent e(wxEVT_LEFT_UP);
1337 e.SetEventObject(mParent);
1338 OnMouse(e);
1339}

References mDragWindow, mParent, and OnMouse().

Referenced by CreateWindows().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnGrabber()

void ToolManager::OnGrabber ( GrabberEvent event)
private

Definition at line 1442 of file ToolManager.cpp.

1443{
1444 // No need to propagate any further
1445 event.Skip( false );
1446
1447 if(event.IsEscaping())
1448 return HandleEscapeKey();
1449
1450 // Remember which bar we're dragging
1451 mDragBar = mBars[ event.GetId() ].get();
1452
1453 // Remember state, in case of ESCape key later
1454 if (mDragBar->IsDocked()) {
1455 mPrevDock = dynamic_cast<ToolDock*>(mDragBar->GetParent());
1456 wxASSERT(mPrevDock);
1459 }
1460 else
1461 mPrevPosition = mDragBar->GetParent()->GetPosition();
1462
1463 // Calculate the drag offset
1464 wxPoint mp = event.GetPosition();
1465 mDragOffset = mp -
1466 mDragBar->GetParent()->ClientToScreen( mDragBar->GetPosition() ) +
1467 wxPoint( 1, 1 );
1468
1469 mClicked = true;
1470 if( mPrevDock )
1471 {
1472 mDragWindow = nullptr;
1473 }
1474 else
1475 {
1476 mDragWindow = (ToolFrame *) mDragBar->GetParent();
1477 }
1478
1479 // We want all mouse events from this point on
1480 auto &window = GetProjectFrame( *mParent );
1481 if( !window.HasCapture() )
1482 window.CaptureMouse();
1483
1484 // Start monitoring shift key changes
1485 mLastState = wxGetKeyState( WXK_SHIFT );
1486 mTimer.Start( 100 );
1487}
bool IsEscaping() const
Definition: Grabber.h:74
Position Find(const ToolBar *bar) const
Definition: ToolDock.cpp:89
void WrapConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:817
bool mLastState
Definition: ToolManager.h:137
void HandleEscapeKey()
wxPoint mDragOffset
Definition: ToolManager.h:125

References ToolBarConfiguration::Find(), ToolDock::GetConfiguration(), GetProjectFrame(), HandleEscapeKey(), ToolBar::IsDocked(), GrabberEvent::IsEscaping(), mBars, mClicked, mDragBar, mDragOffset, mDragWindow, mLastState, mParent, mPrevConfiguration, mPrevDock, mPrevPosition, mPrevSlot, mTimer, and ToolDock::WrapConfiguration().

Here is the call graph for this function:

◆ OnIndicatorCreate()

void ToolManager::OnIndicatorCreate ( wxWindowCreateEvent &  event)
private

Definition at line 1401 of file ToolManager.cpp.

1402{
1403#if defined(__WXGTK__)
1404 mIndicator->SetShape( *mCurrent );
1405#endif
1406 event.Skip();
1407}
wxRegion * mCurrent
Definition: ToolManager.h:134

References mCurrent, and mIndicator.

Referenced by ToolManager().

Here is the caller graph for this function:

◆ OnIndicatorPaint()

void ToolManager::OnIndicatorPaint ( wxPaintEvent &  event)
private

Definition at line 1384 of file ToolManager.cpp.

1385{
1386 // TODO: Better to use a bitmap than a triangular region.
1387 wxWindow *w = (wxWindow *)event.GetEventObject();
1388 wxPaintDC dc( w );
1389 // TODO: Better (faster) to use the existing spare brush.
1390 wxBrush brush( theTheme.Colour( clrTrackPanelText ) );
1391 dc.SetBackground( brush );
1392 dc.Clear();
1393}
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), and theTheme.

Referenced by ToolManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnMouse()

void ToolManager::OnMouse ( wxMouseEvent &  event)
private

Definition at line 1137 of file ToolManager.cpp.

1138{
1139 // Go ahead and set the event to propagate
1140 event.Skip();
1141
1142 // Can't do anything if we're not dragging. This also prevents
1143 // us from intercepting events that don't belong to us from the
1144 // parent since we're Connect()ed to a couple.
1145 if( !mClicked )
1146 {
1147 return;
1148 }
1149
1150#if defined(__WXMAC__)
1151 // Disable window animation
1152 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1153#endif
1154
1155 // Retrieve the event position
1156 wxPoint pos =
1157 ( (wxWindow *)event.GetEventObject() )->ClientToScreen( event.GetPosition() ) - mDragOffset;
1158
1159
1160 if( !event.LeftIsDown() )
1161 {
1162 // Button was released...finish the drag
1163 // Transition the bar to a dock
1164 if (!mDidDrag) {
1165 if (mPrevDock)
1167 DoneDragging();
1168 return;
1169 }
1170 else if( mDragDock && !event.ShiftDown() )
1171 {
1172 // Trip over...everyone ashore that's going ashore...
1174 Updated();
1176
1177 // Done with the floater
1178 mDragWindow->Destroy();
1179 mDragWindow = nullptr;
1180 mDragBar->Refresh(false);
1181 }
1182 else
1183 {
1184 // Calling SetDocked() to force the grabber button to popup
1185 mDragBar->SetDocked( NULL, false );
1186 }
1187
1188 DoneDragging();
1189 }
1190 else if( event.Dragging() && pos != mLastPos )
1191 {
1192 if (!mDidDrag) {
1193 // Must set the bar afloat if it's currently docked
1194 mDidDrag = true;
1195 wxPoint mp = event.GetPosition();
1196 mp = GetProjectFrame( *mParent ).ClientToScreen(mp);
1197 if (!mDragWindow) {
1198 // We no longer have control
1199 if (mPrevDock)
1201 UndockBar(mp);
1202 // Rearrange the remaining toolbars before trying to re-insert this one.
1204 }
1205 }
1206
1207 // Make toolbar follow the mouse
1208 mDragWindow->Move( pos );
1209
1210 // Remember to prevent excessive movement
1211 mLastPos = pos;
1212
1213 // Calc the top dock hittest rectangle
1214 wxRect tr = mTopDock->GetRect();
1215 tr.SetBottom( tr.GetBottom() + 10 );
1216 tr.SetPosition( mTopDock->GetParent()->ClientToScreen( tr.GetPosition() ) );
1217
1218 // Calc the bottom dock hittest rectangle
1219 wxRect br = mBotDock->GetRect();
1220 br.SetTop( br.GetTop() - 10 );
1221 br.SetBottom( br.GetBottom() + 20 );
1222 br.SetPosition( mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
1223
1224
1225 // Add half the bar height. We could use the actual bar height, but that would be confusing as a
1226 // bar removed at a place might not dock back there if just let go.
1227 // Also add 5 pixels in horizontal direction, so that a click without a move (or a very small move)
1228 // lands back where we started.
1229 pos += wxPoint( 5, 20 );
1230
1231
1232 // To find which dock, rather than test against pos, test against the whole dragger rect.
1233 // This means it is enough to overlap the dock to dock with it.
1234 wxRect barRect = mDragWindow->GetRect();
1235 ToolDock *dock = NULL;
1236 if( tr.Intersects( barRect ) )
1237 dock = mTopDock;
1238 else if( br.Intersects( barRect ) )
1239 dock = mBotDock;
1240
1241 // Looks like we have a winner...
1242 if( dock )
1243 {
1244 wxPoint p;
1245 wxRect r;
1246
1247 // Calculate where the bar would be placed
1248 mDragBefore = dock->PositionBar( mDragBar, pos, r );
1249
1250 // If different than the last time, the indicator must be moved
1251 if( r != mBarPos )
1252 {
1253 wxRect dr = dock->GetRect();
1254
1255 // Hide the indicator before changing the shape
1256 mIndicator->Hide();
1257
1258 // Decide which direction the arrow should point
1259 if( r.GetTop() >= dr.GetHeight() )
1260 {
1261 const auto &box = mDown->GetBox();
1262 p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
1263 - (box.GetWidth() / 2);
1264 p.y = dr.GetBottom() - box.GetHeight();
1265 mCurrent = mDown.get();
1266 }
1267 else
1268 {
1269 // r is the rectangle of the toolbar being dragged.
1270 // A tall undocked toolbar will become at most 2 tbs
1271 // high when docked, so the triangular drop indicator
1272 // needs to use that height, h, not the bar height
1273 // for calculating where to be drawn.
1274 const int tbs = toolbarSingle + toolbarGap;
1275 int h = wxMin(r.GetHeight(), 2*tbs-1);
1276 p.x = dr.GetLeft() + r.GetLeft();
1277 p.y = dr.GetTop() + r.GetTop() +
1278 ( ( h - mLeft->GetBox().GetHeight() ) / 2 );
1279 mCurrent = mLeft.get();
1280 }
1281
1282 // Change the shape while hidden and then show it if okay
1283 mIndicator->SetShape( *mCurrent );
1284 if( !event.ShiftDown() )
1285 {
1286 mIndicator->Show();
1287 mIndicator->Update();
1288 }
1289
1290 // Move it into position
1291 // LL: Do this after the Show() since KDE doesn't move the window
1292 // if it's not shown. (Do it outside if the previous IF as well)
1293 mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
1294
1295 // Remember for next go round
1296 mBarPos = r;
1297 }
1298 }
1299 else
1300 {
1301 // Hide the indicator if it's still shown
1302 if( mBarPos.x != -1 )
1303 {
1304 // Hide any
1305 mIndicator->Hide();
1306 mBarPos.x = -1;
1307 mBarPos.y = -1;
1308 }
1309 }
1310
1311 // Remember to which dock the drag bar belongs.
1312 mDragDock = dock;
1313 }
1314
1315#if defined(__WXMAC__)
1316 // Reinstate original transition
1317 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1318#endif
1319}
#define toolbarSingle
Definition: ToolBar.h:59
#define toolbarGap
Definition: ToolBar.h:64
void Remove(const ToolBar *bar)
Definition: ToolDock.cpp:212
ToolBarConfiguration::Position PositionBar(ToolBar *t, const wxPoint &pos, wxRect &rect)
Definition: ToolDock.cpp:720
void UndockBar(wxPoint mp)
void LayoutToolBars()
ToolBarConfiguration::Position mDragBefore
Definition: ToolManager.h:126

References ToolFrame::ClearBar(), ToolDock::Dock(), DoneDragging(), ToolDock::GetConfiguration(), GetProjectFrame(), LayoutToolBars(), mBarPos, mBotDock, mClicked, mCurrent, mDidDrag, mDown, mDragBar, mDragBefore, mDragDock, mDragOffset, mDragWindow, mIndicator, mLastPos, mLeft, mPrevConfiguration, mPrevDock, mTopDock, mTransition, ToolDock::PositionBar(), ToolBarConfiguration::Remove(), ToolDock::RestoreConfiguration(), ToolBar::SetDocked(), toolbarGap, toolbarSingle, UndockBar(), and Updated().

Referenced by CreateWindows(), and OnCaptureLost().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnResetToolBars()

void ToolManager::OnResetToolBars ( const CommandContext context)
static

Definition at line 548 of file ToolManager.cpp.

549{
550 auto &project = context.project;
551 auto &toolManager = ToolManager::Get( project );
552
553 toolManager.Reset();
554 MenuManager::Get(project).ModifyToolbarMenus(project);
555}
AudacityProject & project
static void ModifyToolbarMenus(AudacityProject &project)
Definition: Menus.cpp:600
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:71

References MenuManager::Get(), Get(), MenuManager::ModifyToolbarMenus(), and CommandContext::project.

Referenced by PluginActions::Handler::OnResetConfig(), and ToolbarActions::Handler::OnResetToolBars().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnTimer()

void ToolManager::OnTimer ( wxTimerEvent &  event)
private

Definition at line 1344 of file ToolManager.cpp.

1345{
1346 // Go ahead and set the event to propagate
1347 event.Skip();
1348
1349 // Can't do anything if we're not dragging. This also prevents
1350 // us from intercepting events that don't belong to us from the
1351 // parent since we're Connect()ed to a couple.
1352 if( !mDragWindow )
1353 {
1354 return;
1355 }
1356
1357 bool state = wxGetKeyState( WXK_SHIFT );
1358 if( mLastState != state )
1359 {
1360 mLastState = state;
1361
1362#if defined(__WXMAC__)
1363 // Disable window animation
1364 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1365#endif
1366
1367 mIndicator->Show( !state );
1368
1369#if defined(__WXMAC__)
1370 // Disable window animation
1371 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1372#endif
1373 }
1374
1375 return;
1376}

References mDragWindow, mIndicator, mLastState, and mTransition.

◆ operator=()

ToolManager & ToolManager::operator= ( const ToolManager )

◆ ReadConfig()

void ToolManager::ReadConfig ( )
private

Definition at line 709 of file ToolManager.cpp.

710{
711 wxString oldpath = gPrefs->GetPath();
712 std::vector<int> unordered[ DockCount ];
713 std::vector<ToolBar*> dockedAndHidden;
714 bool show[ ToolBarCount ];
715 int width[ ToolBarCount ];
716 int height[ ToolBarCount ];
717 int x, y;
718 int dock, ndx;
719 bool someFound { false };
720
721#if defined(__WXMAC__)
722 // Disable window animation
723 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
724#endif
725
726 // Change to the bar root
727 gPrefs->SetPath( wxT("/GUI/ToolBars") );
728
729 ToolBarConfiguration::Legacy topLegacy, botLegacy;
730
731 int vMajor, vMinor, vMicro;
732 gPrefs->GetVersionKeysInit(vMajor, vMinor, vMicro);
733 bool useLegacyDock = false;
734 // note that vMajor, vMinor, and vMicro will all be zero if either it's a new audacity.cfg file
735 // or the version is less than 1.3.13 (when there were no version keys according to the comments in
736 // InitPreferences()). So for new audacity.cfg
737 // file useLegacyDock will be true, but this doesn't matter as there are no Dock or DockV2 keys in the file yet.
738 if (vMajor <= 1 ||
739 (vMajor == 2 && (vMinor <= 1 || (vMinor == 2 && vMicro <= 1)))) // version <= 2.2.1
740 useLegacyDock = true;
741
742
743 // Load and apply settings for each bar
744 for( ndx = 0; ndx < ToolBarCount; ndx++ )
745 {
746 ToolBar *bar = mBars[ ndx ].get();
747 //wxPoint Center = mParent->GetPosition() + (mParent->GetSize() * 0.33);
748 //wxPoint Center(
749 // wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) /2 ,
750 // wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) /2 );
751
752 // Change to the bar subkey
753 gPrefs->SetPath( bar->GetSection() );
754
755 bool bShownByDefault = true;
756 int defaultDock = TopDockID;
757
758 if( ndx == SelectionBarID )
759 defaultDock = BotDockID;
760 if( ndx == MeterBarID )
761 bShownByDefault = false;
762 if( ndx == ScrubbingBarID )
763 bShownByDefault = false;
764 if( ndx == DeviceBarID )
765 bShownByDefault = false;
766 if( ndx == TimeBarID )
767 defaultDock = BotDockID;
768
769#ifdef EXPERIMENTAL_SPECTRAL_EDITING
770 if( ndx == SpectralSelectionBarID ){
771 defaultDock = BotDockID;
772 bShownByDefault = false; // Only show if asked for.
773 }
774#endif
775
776 // Read in all the settings
777
778 if (useLegacyDock)
779 gPrefs->Read( wxT("Dock"), &dock, -1); // legacy version of DockV2
780 else
781 gPrefs->Read( wxT("DockV2"), &dock, -1);
782
783 const bool found = (dock != -1);
784 if (found)
785 someFound = true;
786 if (!found)
787 dock = defaultDock;
788
789 ToolDock *d;
791 switch(dock)
792 {
793 case TopDockID: d = mTopDock; pLegacy = &topLegacy; break;
794 case BotDockID: d = mBotDock; pLegacy = &botLegacy; break;
795 default: d = nullptr; pLegacy = nullptr; break;
796 }
797
798 bool ordered = ToolBarConfiguration::Read(
799 d ? &d->GetConfiguration() : nullptr,
800 pLegacy,
801 bar, show[ ndx ], bShownByDefault)
802 && found;
803
804 gPrefs->Read( wxT("X"), &x, -1 );
805 gPrefs->Read( wxT("Y"), &y, -1 );
806 gPrefs->Read( wxT("W"), &width[ ndx ], -1 );
807 gPrefs->Read( wxT("H"), &height[ ndx ], -1 );
808
809 bar->SetVisible( show[ ndx ] );
810
811 // Docked or floating?
812 if( dock )
813 {
814 // Default to top dock if the ID isn't valid
815 if( dock < NoDockID || dock > DockCount ) {
816 dock = TopDockID;
817 }
818
819 // Create the bar with the correct parent
820 if( dock == TopDockID )
821 {
822 bar->Create( mTopDock );
823 }
824 else
825 {
826 bar->Create( mBotDock );
827 }
828
829 // Set the width and height
830 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
831 {
832 wxSize sz( width[ ndx ], height[ ndx ] );
833 bar->SetSize( sz );
834 bar->ResizingDone();
835 }
836
837#ifdef EXPERIMENTAL_SYNC_LOCK
838 // Set the width
839 if( width[ ndx ] >= bar->GetSize().x )
840 {
841 wxSize sz( width[ ndx ], bar->GetSize().y );
842 bar->SetSize( sz );
843 bar->Layout();
844 }
845#else
846 // note that this section is here because if you had been using sync-lock and now you aren't,
847 // the space for the extra button is stored in audacity.cfg, and so you get an extra space
848 // in the EditToolbar.
849 // It is needed so that the meterToolbar size gets preserved.
850 // Longer-term we should find a better fix for this.
851 wxString thisBar = bar->GetSection();
852 if( thisBar != wxT("Edit"))
853 {
854 // Set the width
855 if( width[ ndx ] >= bar->GetSize().x )
856 {
857 wxSize sz( width[ ndx ], bar->GetSize().y );
858 bar->SetSize( sz );
859 bar->Layout();
860 }
861 }
862#endif
863 // make a note of docked and hidden toolbars
864 if (!show[ndx])
865 dockedAndHidden.push_back(bar);
866
867 if (!ordered)
868 {
869 // These must go at the end
870 unordered[ dock - 1 ].push_back( ndx );
871 }
872 }
873 else
874 {
875 // Create the bar (with the top dock being temporary parent)
876 bar->Create( mTopDock );
877
878 // Construct a NEW floater
879 wxASSERT(mParent);
880 ToolFrame *f = safenew ToolFrame( mParent, this, bar, wxPoint( x, y ) );
881
882 // Set the width and height
883 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
884 {
885 wxSize sz( width[ ndx ], height[ ndx ] );
886 f->SetSizeHints( sz );
887 f->SetSize( sz );
888 f->Layout();
889 if( (x!=-1) && (y!=-1) )
890 bar->SetPositioned();
891 }
892
893 // Required on Linux Xfce
894 wxSize msz(width[ndx],height[ndx]-1);
895 bar->GetParent()->SetMinSize(msz);
896
897 // Inform toolbar of change
898 bar->SetDocked( NULL, false );
899
900 // Show or hide it
901 Expose( ndx, show[ ndx ] );
902 }
903
904 // Change back to the bar root
905 //gPrefs->SetPath( wxT("..") ); <-- Causes a warning...
906 // May or may not have gone into a subdirectory,
907 // so use an absolute path.
908 gPrefs->SetPath( wxT("/GUI/ToolBars") );
909 }
910
911 mTopDock->GetConfiguration().PostRead(topLegacy);
912 mBotDock->GetConfiguration().PostRead(botLegacy);
913
914 // Add all toolbars to their target dock
915 for( dock = 0; dock < DockCount; dock++ )
916 {
917 ToolDock *d = ( dock + 1 == TopDockID ? mTopDock : mBotDock );
918
919 d->LoadConfig();
920
921 // Add all unordered toolbars
922 for( int ord = 0; ord < (int) unordered[ dock ].size(); ord++ )
923 {
924 ToolBar *t = mBars[ unordered[ dock ][ ord ] ].get();
925
926 // Dock it
927 d->Dock( t, false );
928
929 // Show or hide the bar
930 Expose( t->GetId(), show[ t->GetId() ] );
931 }
932 }
933
934 // hidden docked toolbars
935 for (auto bar : dockedAndHidden) {
936 bar->SetVisible(false );
937 bar->GetDock()->Dock(bar, false);
938 bar->Expose(false);
939 }
940
941 // Restore original config path
942 gPrefs->SetPath( oldpath );
943
944#if defined(__WXMAC__)
945 // Reinstate original transition
946 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
947#endif
948
949 if (!someFound)
950 Reset();
951}
FileConfig * gPrefs
Definition: Prefs.cpp:71
@ ScrubbingBarID
Definition: ToolBar.h:79
@ DeviceBarID
Definition: ToolBar.h:80
@ SelectionBarID
Definition: ToolBar.h:81
@ TimeBarID
Definition: ToolBar.h:86
@ MeterBarID
Definition: ToolBar.h:74
@ DockCount
Definition: ToolDock.h:44
void GetVersionKeysInit(int &major, int &minor, int &micro) const
Definition: FileConfig.h:56
virtual const wxString & GetPath() const wxOVERRIDE
Definition: FileConfig.cpp:98
virtual void SetPath(const wxString &strPath) wxOVERRIDE
Definition: FileConfig.cpp:93
static bool Read(ToolBarConfiguration *pConfiguration, Legacy *pLegacy, ToolBar *bar, bool &visible, bool defaultVisible)
Definition: ToolDock.cpp:255
void PostRead(Legacy &legacy)
Definition: ToolDock.cpp:310
void SetVisible(bool bVisible)
Definition: ToolBar.cpp:436
wxString GetSection()
Definition: ToolBar.cpp:382
virtual void ResizingDone()
Definition: ToolBar.h:196
void SetPositioned()
Definition: ToolBar.h:139
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:475
void LoadConfig()
Definition: ToolDock.cpp:443
void Expose(int type, bool show)

References BotDockID, ToolBar::Create(), DeviceBarID, ToolDock::Dock(), DockCount, Expose(), ToolDock::GetConfiguration(), FileConfig::GetPath(), ToolBar::GetSection(), FileConfig::GetVersionKeysInit(), gPrefs, ToolDock::LoadConfig(), mBars, mBotDock, MeterBarID, mParent, mTopDock, mTransition, ToolBarConfiguration::PostRead(), ToolBarConfiguration::Read(), Reset(), ToolBar::ResizingDone(), safenew, ScrubbingBarID, SelectionBarID, ToolBar::SetDocked(), FileConfig::SetPath(), ToolBar::SetPositioned(), ToolBar::SetVisible(), size, TimeBarID, ToolBarCount, and TopDockID.

Referenced by CreateWindows().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegenerateTooltips()

void ToolManager::RegenerateTooltips ( )

Definition at line 675 of file ToolManager.cpp.

676{
677 for (const auto &bar : mBars) {
678 if (bar)
679 bar->RegenerateTooltips();
680 }
681}

References mBars.

Referenced by ProjectManager::New().

Here is the caller graph for this function:

◆ Reset()

void ToolManager::Reset ( )

Definition at line 558 of file ToolManager.cpp.

559{
560 // Disconnect all docked bars
561 for ( const auto &entry : DefaultConfigTable )
562 {
563 int ndx = entry.barID;
564 ToolBar *bar = mBars[ ndx ].get();
565
567 (entry.rightOf == NoBarID) ? nullptr : mBars[ entry.rightOf ].get(),
568 (entry.below == NoBarID) ? nullptr : mBars[ entry.below ].get()
569 };
570 bar->SetSize( 20,20 );
571
572 wxWindow *floater;
573 ToolDock *dock;
574 bool expose = true;
575
576 // Disconnect the bar
577 if( bar->IsDocked() )
578 {
579 bar->GetDock()->Undock( bar );
580 floater = NULL;
581 }
582 else
583 {
584 floater = bar->GetParent();
585 }
586
587 // Decide which dock.
588 if (ndx == SelectionBarID
589#ifdef EXPERIMENTAL_SPECTRAL_EDITING
590 || ndx == SpectralSelectionBarID
591#endif
592 || ndx == TimeBarID
593 || ndx == TranscriptionBarID
594 )
595 dock = mBotDock;
596 else
597 dock = mTopDock;
598
599 // PRL: Destroy the tool frame before recreating buttons.
600 // This fixes some subtle sizing problems on macOs.
601 bar->Reparent( dock );
602 //OK (and good) to DELETE floater, as bar is no longer in it.
603 if( floater )
604 floater->Destroy();
605
606 // Recreate bar buttons (and resize it)
607 bar->SetToDefaultSize();
608 bar->ReCreateButtons();
610
611#if 0
612 if( bar->IsResizable() )
613 {
614 bar->SetSize(bar->GetBestFittingSize());
615 }
616#endif
617
618 // Hide some bars.
619 if( ndx == MeterBarID
620#ifdef EXPERIMENTAL_SPECTRAL_EDITING
621 || ndx == SpectralSelectionBarID
622#endif
623 || ndx == ScrubbingBarID
624 || ndx == DeviceBarID
625// DA: Hides two more toolbars.
626#ifdef EXPERIMENTAL_DA
627 || ndx == TranscriptionBarID
628 || ndx == SelectionBarID
629#endif
630 )
631 expose = false;
632
633 // Next condition will always (?) be true, as the reset configuration is
634 // with no floating toolbars.
635 if( dock != NULL )
636 {
637 // when we dock, we reparent, so bar is no longer a child of floater.
638 dock->Dock( bar, false, position );
639 Expose( ndx, expose );
640 }
641 else
642 {
643 // The (tool)bar has a dragger window round it, the floater.
644 // in turn floater will have mParent (the entire App) as its
645 // parent.
646
647 // Maybe construct a NEW floater
648 // this happens if we have just been bounced out of a dock.
649 if( floater == NULL ) {
650 wxASSERT(mParent);
651 floater = safenew ToolFrame( mParent, this, bar, wxPoint(-1,-1) );
652 bar->Reparent( floater );
653 }
654
655 // This bar is undocked and invisible.
656 // We are doing a reset toolbars, so even the invisible undocked bars should
657 // be moved somewhere sensible. Put bar near center of window.
658 // If there were multiple hidden toobars the ndx * 10 adjustment means
659 // they won't overlap too much.
660 floater->CentreOnParent( );
661 floater->Move( floater->GetPosition() + wxSize( ndx * 10 - 200, ndx * 10 ));
662 bar->SetDocked( NULL, false );
663 Expose( ndx, false );
664 }
665
666 }
667 // TODO:??
668 // If audio was playing, we stopped the VU meters,
669 // It would be nice to show them again, but hardly essential as
670 // they will show up again on the next play.
671 // SetVUMeters(AudacityProject *p);
672 Updated();
673}
static ProjectFileIORegistry::AttributeWriterEntry entry
@ NoBarID
Definition: ToolBar.h:71
@ TranscriptionBarID
Definition: ToolBar.h:78
static struct DefaultConfigEntry DefaultConfigTable[]
virtual void EnableDisableButtons()=0
virtual void ReCreateButtons()
Definition: ToolBar.cpp:516
bool IsResizable() const
Definition: ToolBar.cpp:415
virtual void SetToDefaultSize()
Definition: ToolBar.cpp:496
void Undock(ToolBar *bar)
Definition: ToolDock.cpp:403

References DefaultConfigTable, DeviceBarID, ToolDock::Dock(), ToolBar::EnableDisableButtons(), entry, Expose(), ToolBar::GetDock(), ToolBar::IsDocked(), ToolBar::IsResizable(), mBars, mBotDock, MeterBarID, mParent, mTopDock, NoBarID, ToolBar::ReCreateButtons(), safenew, ScrubbingBarID, SelectionBarID, ToolBar::SetDocked(), ToolBar::SetToDefaultSize(), TimeBarID, TranscriptionBarID, ToolDock::Undock(), and Updated().

Referenced by ReadConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RestoreFocus()

bool ToolManager::RestoreFocus ( )

Definition at line 1552 of file ToolManager.cpp.

1553{
1554 if (mLastFocus) {
1555 auto temp1 = AButton::TemporarilyAllowFocus();
1556 auto temp2 = ASlider::TemporarilyAllowFocus();
1558 mLastFocus->SetFocus();
1559 return true;
1560 }
1561 return false;
1562}
static TempAllowFocus TemporarilyAllowFocus()
Definition: AButton.cpp:636
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1833
static TempAllowFocus TemporarilyAllowFocus()

References mLastFocus, AButton::TemporarilyAllowFocus(), ASlider::TemporarilyAllowFocus(), and MeterPanelBase::TemporarilyAllowFocus().

Referenced by DoneDragging().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowHide()

void ToolManager::ShowHide ( int  type)

Definition at line 1093 of file ToolManager.cpp.

1094{
1095 Expose( type, !mBars[ type ]->IsVisible() );
1096 Updated();
1097}
bool IsVisible(int type)

References Expose(), IsVisible(), mBars, and Updated().

Referenced by ScreenshotCommand::CaptureToolbar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UndockBar()

void ToolManager::UndockBar ( wxPoint  mp)
private

Definition at line 1409 of file ToolManager.cpp.

1410{
1411#if defined(__WXMAC__)
1412 // Disable window animation
1413 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1414#endif
1415
1416 // Adjust the starting position
1417 mp -= mDragOffset;
1418
1419 // Inform toolbar of change
1420 mDragBar->SetDocked( NULL, true );
1422
1423 // Construct a NEW floater
1424 wxASSERT(mParent);
1426 mDragWindow->SetLayoutDirection(wxLayout_LeftToRight);
1427 // Make sure the ferry is visible
1428 mDragWindow->Show();
1429
1430 // Notify parent of change
1431 Updated();
1432
1433#if defined(__WXMAC__)
1434 // Reinstate original transition
1435 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1436#endif
1437}

References mDragBar, mDragOffset, mDragWindow, mParent, mTransition, safenew, ToolBar::SetDocked(), ToolBar::SetPositioned(), and Updated().

Referenced by OnMouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Updated()

void ToolManager::Updated ( )
private

Definition at line 1053 of file ToolManager.cpp.

1054{
1055 // Queue an update event
1056 wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1057 GetProjectFrame( *mParent ).GetEventHandler()->AddPendingEvent( e );
1058}

References GetProjectFrame().

Referenced by HandleEscapeKey(), OnMouse(), Reset(), ShowHide(), and UndockBar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteConfig()

void ToolManager::WriteConfig ( )
private

Definition at line 956 of file ToolManager.cpp.

957{
958 if( !gPrefs )
959 {
960 return;
961 }
962
963 wxString oldpath = gPrefs->GetPath();
964 int ndx;
965
966 // Change to the bar root
967 gPrefs->SetPath( wxT("/GUI/ToolBars") );
968
969 // Save state of each bar
970 for( ndx = 0; ndx < ToolBarCount; ndx++ )
971 {
972 ToolBar *bar = mBars[ ndx ].get();
973
974 // Change to the bar subkey
975 gPrefs->SetPath( bar->GetSection() );
976
977 // Search both docks for toolbar order
978 bool to = mTopDock->GetConfiguration().Contains( bar );
979 bool bo = mBotDock->GetConfiguration().Contains( bar );
980
981 // Save
982 // Note that DockV2 was introduced in 2.2.2 to fix bug #1554. Dock is retained so that
983 // the toolbar layout is not changed when opening a version before 2.2.2, and in particular
984 // its value is compatible with versions 2.1.3 to 2.2.1 which have this bug.
985 ToolDock* dock = bar->GetDock(); // dock for both shown and hidden toolbars
986 gPrefs->Write( wxT("DockV2"), static_cast<int>(dock == mTopDock ? TopDockID : dock == mBotDock ? BotDockID : NoDockID ));
987
988 gPrefs->Write( wxT("Dock"), static_cast<int>( to ? TopDockID : bo ? BotDockID : NoDockID));
989
990 dock = to ? mTopDock : bo ? mBotDock : nullptr; // dock for shown toolbars
992 (dock ? &dock->GetConfiguration() : nullptr, bar);
993
994 wxPoint pos( -1, -1 );
995 wxSize sz = bar->GetSize();
996 if( !bar->IsDocked() && bar->IsPositioned() )
997 {
998 pos = bar->GetParent()->GetPosition();
999 sz = bar->GetParent()->GetSize();
1000 }
1001 gPrefs->Write( wxT("X"), pos.x );
1002 gPrefs->Write( wxT("Y"), pos.y );
1003 gPrefs->Write( wxT("W"), sz.x );
1004 gPrefs->Write( wxT("H"), sz.y );
1005
1006 // Change back to the bar root
1007 gPrefs->SetPath( wxT("..") );
1008 }
1009
1010 // Restore original config path
1011 gPrefs->SetPath( oldpath );
1012 gPrefs->Flush();
1013}
@ NoDockID
Definition: ToolDock.h:41
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
bool Contains(const ToolBar *bar) const
Definition: ToolDock.h:233
static void Write(const ToolBarConfiguration *pConfiguration, const ToolBar *bar)
Definition: ToolDock.cpp:331
bool IsPositioned()
Definition: ToolBar.h:137

References BotDockID, ToolBarConfiguration::Contains(), FileConfig::Flush(), ToolDock::GetConfiguration(), ToolBar::GetDock(), FileConfig::GetPath(), ToolBar::GetSection(), gPrefs, ToolBar::IsDocked(), ToolBar::IsPositioned(), mBars, mBotDock, mTopDock, NoDockID, FileConfig::SetPath(), ToolBarCount, TopDockID, and ToolBarConfiguration::Write().

Referenced by Destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mBarPos

wxRect ToolManager::mBarPos
private

Definition at line 129 of file ToolManager.h.

Referenced by DoneDragging(), OnMouse(), and ToolManager().

◆ mBars

ToolBar::Holder ToolManager::mBars[ToolBarCount]
private

◆ mBotDock

ToolDock* ToolManager::mBotDock {}
private

◆ mClicked

bool ToolManager::mClicked {}
private

Definition at line 154 of file ToolManager.h.

Referenced by DoneDragging(), OnGrabber(), and OnMouse().

◆ mCurrent

wxRegion* ToolManager::mCurrent
private

Definition at line 134 of file ToolManager.h.

Referenced by OnIndicatorCreate(), and OnMouse().

◆ mDidDrag

bool ToolManager::mDidDrag {}
private

Definition at line 153 of file ToolManager.h.

Referenced by DoneDragging(), and OnMouse().

◆ mDown

std::unique_ptr<wxRegion> ToolManager::mDown
private

Definition at line 133 of file ToolManager.h.

Referenced by OnMouse(), and ToolManager().

◆ mDragBar

ToolBar* ToolManager::mDragBar {}
private

Definition at line 124 of file ToolManager.h.

Referenced by DoneDragging(), HandleEscapeKey(), OnGrabber(), OnMouse(), ToolManager(), and UndockBar().

◆ mDragBefore

ToolBarConfiguration::Position ToolManager::mDragBefore {}
private

Definition at line 126 of file ToolManager.h.

Referenced by OnMouse().

◆ mDragDock

ToolDock* ToolManager::mDragDock
private

Definition at line 123 of file ToolManager.h.

Referenced by DoneDragging(), OnMouse(), and ToolManager().

◆ mDragOffset

wxPoint ToolManager::mDragOffset
private

Definition at line 125 of file ToolManager.h.

Referenced by OnGrabber(), OnMouse(), and UndockBar().

◆ mDragWindow

ToolFrame* ToolManager::mDragWindow
private

◆ mIndicator

FramePtr ToolManager::mIndicator
private

Definition at line 132 of file ToolManager.h.

Referenced by Destroy(), DoneDragging(), OnIndicatorCreate(), OnMouse(), OnTimer(), and ToolManager().

◆ mLastFocus

wxWindowRef ToolManager::mLastFocus {}
private

Definition at line 120 of file ToolManager.h.

Referenced by FilterEvent(), and RestoreFocus().

◆ mLastPos

wxPoint ToolManager::mLastPos
private

Definition at line 128 of file ToolManager.h.

Referenced by DoneDragging(), OnMouse(), and ToolManager().

◆ mLastState

bool ToolManager::mLastState
private

Definition at line 137 of file ToolManager.h.

Referenced by OnGrabber(), and OnTimer().

◆ mLeft

std::unique_ptr<wxRegion> ToolManager::mLeft
private

Definition at line 133 of file ToolManager.h.

Referenced by OnMouse(), and ToolManager().

◆ mParent

AudacityProject* ToolManager::mParent
private

◆ mPrevConfiguration

ToolBarConfiguration ToolManager::mPrevConfiguration
private

Definition at line 152 of file ToolManager.h.

Referenced by DoneDragging(), HandleEscapeKey(), OnGrabber(), and OnMouse().

◆ mPrevDock

ToolDock* ToolManager::mPrevDock {}
private

Definition at line 149 of file ToolManager.h.

Referenced by DoneDragging(), HandleEscapeKey(), OnGrabber(), and OnMouse().

◆ mPrevPosition

wxPoint ToolManager::mPrevPosition {}
private

Definition at line 148 of file ToolManager.h.

Referenced by HandleEscapeKey(), and OnGrabber().

◆ mPrevSlot

Definition at line 150 of file ToolManager.h.

Referenced by DoneDragging(), HandleEscapeKey(), and OnGrabber().

◆ mTimer

wxTimer ToolManager::mTimer
private

Definition at line 136 of file ToolManager.h.

Referenced by CreateWindows(), DoneDragging(), and OnGrabber().

◆ mTopDock

ToolDock* ToolManager::mTopDock {}
private

◆ mTransition

bool ToolManager::mTransition
private

Definition at line 140 of file ToolManager.h.

Referenced by OnMouse(), OnTimer(), ReadConfig(), ToolManager(), and UndockBar().


The documentation for this class was generated from the following files: