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}
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 RegisteredToolbarFactory factory
static const Functions & GetFactories()
Definition: ToolBar.cpp:1035

References BotDockID, GlobalHook< TopPanelHook, wxWindow *(wxWindow &) >::Call(), cloud::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:90
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 1524 of file ToolManager.cpp.

1525{
1526 // Done dragging - ensure grabber button isn't pushed
1527 if( mDragBar )
1528 {
1529 mDragBar->SetDocked( mDragBar->GetDock(), false );
1530 }
1531
1532 // Release capture
1533 auto &window = GetProjectFrame( *mParent );
1534 if( window.HasCapture() )
1535 {
1536 window.ReleaseMouse();
1537 }
1538
1539 // Hide the indicator
1540 mIndicator->Hide();
1541
1542 mDragWindow = NULL;
1543 mDragDock = NULL;
1544 mDragBar = NULL;
1545 mPrevDock = NULL;
1548 mLastPos.x = mBarPos.x = -1;
1549 mLastPos.y = mBarPos.y = -1;
1550 mTimer.Stop();
1551 mDidDrag = false;
1552 mClicked = false;
1553
1554 RestoreFocus();
1555}
static const Position UnspecifiedPosition
Definition: ToolDock.h:105
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:647
ToolDock * GetDock()
Definition: ToolBar.cpp:639
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 1107 of file ToolManager.cpp.

1108{
1109 ToolBar *t = mBars[ type ].get();
1110
1111 // Handle docked and floaters differently
1112 if( t->IsDocked() )
1113 {
1114 t->GetDock()->Expose( type, show );
1115 }
1116 else
1117 {
1118 t->Expose( show );
1119 }
1120}
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:101
bool IsDocked() const
Definition: ToolBar.cpp:432
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:453
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 688 of file ToolManager.cpp.

689{
690 // Snoop the global event stream for changes of focused window. Remember
691 // the last one of our own that is not a grabber.
692
693 if (event.GetEventType() == wxEVT_KILL_FOCUS) {
694 auto &focusEvent = static_cast<wxFocusEvent&>(event);
695 auto window = focusEvent.GetWindow();
696 auto top = wxGetTopLevelParent(window);
697 if(auto toolFrame = dynamic_cast<ToolFrame*>(top))
698 top = toolFrame->GetParent();
699 // window is that which will GET the focus
700 if ( window &&
701 !dynamic_cast<Grabber*>( window ) &&
702 !dynamic_cast<ToolFrame*>( window ) &&
703 top == FindProjectFrame( mParent ) )
704 // Note this is a dangle-proof wxWindowRef:
705 mLastFocus = window;
706 }
707
708 return Event_Skip;
709}
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

◆ 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 1044 of file ToolManager.cpp.

1045{
1046 return mBotDock;
1047}

References mBotDock.

◆ GetBotDock() [2/2]

const ToolDock * ToolManager::GetBotDock ( ) const

Definition at line 1049 of file ToolManager.cpp.

1050{
1051 return mBotDock;
1052}

References mBotDock.

◆ GetToolBar()

ToolBar * ToolManager::GetToolBar ( int  type) const

Definition at line 1023 of file ToolManager.cpp.

1024{
1025 return mBars[ type ].get();
1026}

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 1031 of file ToolManager.cpp.

1032{
1033 return mTopDock;
1034}

References mTopDock.

◆ GetTopDock() [2/2]

const ToolDock * ToolManager::GetTopDock ( ) const

Definition at line 1036 of file ToolManager.cpp.

1037{
1038 return mTopDock;
1039}

References mTopDock.

◆ HandleEscapeKey()

void ToolManager::HandleEscapeKey ( )
private

Definition at line 1495 of file ToolManager.cpp.

1496{
1497 if (mDragBar) {
1498 if(mPrevDock) {
1499 // Sheriff John Stone,
1500 // Why don't you leave me alone?
1501 // Well, I feel so break up
1502 // I want to go home.
1504 mPrevDock->Dock( mDragBar, true, mPrevSlot );
1505 Updated();
1506
1507 // Done with the floater
1509 mDragWindow->Destroy();
1510 mDragWindow = nullptr;
1511 mDragBar->Refresh(false);
1512 }
1513 else {
1514 // Floater remains, and returns to where it begain
1515 auto parent = mDragBar->GetParent();
1516 parent->SetPosition(mPrevPosition);
1517 mDragBar->SetDocked(NULL, false);
1518 }
1519
1520 DoneDragging();
1521 }
1522}
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 1068 of file ToolManager.cpp.

1069{
1070 return mBars[ type ]->IsDocked();
1071}

References mBars.

◆ IsVisible()

bool ToolManager::IsVisible ( int  type)

Definition at line 1076 of file ToolManager.cpp.

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

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 1125 of file ToolManager.cpp.

1126{
1127 // Update the layout
1128 if (mTopDock)
1129 {
1131 }
1132
1133 if (mBotDock)
1134 {
1136 }
1137}
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 1329 of file ToolManager.cpp.

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

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 1447 of file ToolManager.cpp.

1448{
1449 // No need to propagate any further
1450 event.Skip( false );
1451
1452 if(event.IsEscaping())
1453 return HandleEscapeKey();
1454
1455 // Remember which bar we're dragging
1456 mDragBar = mBars[ event.GetId() ].get();
1457
1458 // Remember state, in case of ESCape key later
1459 if (mDragBar->IsDocked()) {
1460 mPrevDock = dynamic_cast<ToolDock*>(mDragBar->GetParent());
1461 wxASSERT(mPrevDock);
1464 }
1465 else
1466 mPrevPosition = mDragBar->GetParent()->GetPosition();
1467
1468 // Calculate the drag offset
1469 wxPoint mp = event.GetPosition();
1470 mDragOffset = mp -
1471 mDragBar->GetParent()->ClientToScreen( mDragBar->GetPosition() ) +
1472 wxPoint( 1, 1 );
1473
1474 mClicked = true;
1475 if( mPrevDock )
1476 {
1477 mDragWindow = nullptr;
1478 }
1479 else
1480 {
1481 mDragWindow = (ToolFrame *) mDragBar->GetParent();
1482 }
1483
1484 // We want all mouse events from this point on
1485 auto &window = GetProjectFrame( *mParent );
1486 if( !window.HasCapture() )
1487 window.CaptureMouse();
1488
1489 // Start monitoring shift key changes
1490 mLastState = wxGetKeyState( WXK_SHIFT );
1491 mTimer.Start( 100 );
1492}
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 1406 of file ToolManager.cpp.

1407{
1408#if defined(__WXGTK__)
1409 mIndicator->SetShape( *mCurrent );
1410#endif
1411 event.Skip();
1412}
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 1389 of file ToolManager.cpp.

1390{
1391 // TODO: Better to use a bitmap than a triangular region.
1392 wxWindow *w = (wxWindow *)event.GetEventObject();
1393 wxPaintDC dc( w );
1394 // TODO: Better (faster) to use the existing spare brush.
1395 wxBrush brush( theTheme.Colour( clrTrackPanelText ) );
1396 dc.SetBackground( brush );
1397 dc.Clear();
1398}
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 1142 of file ToolManager.cpp.

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

554{
555 auto &project = context.project;
556 auto &toolManager = ToolManager::Get( project );
557
558 toolManager.Reset();
559 MenuManager::Get(project).ModifyToolbarMenus(project);
560}
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 1349 of file ToolManager.cpp.

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

References mDragWindow, mIndicator, mLastState, and mTransition.

◆ operator=()

ToolManager & ToolManager::operator= ( const ToolManager )

◆ ReadConfig()

void ToolManager::ReadConfig ( )
private

Definition at line 714 of file ToolManager.cpp.

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

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 680 of file ToolManager.cpp.

681{
682 for (const auto &bar : mBars) {
683 if (bar)
684 bar->RegenerateTooltips();
685 }
686}

References mBars.

Referenced by ProjectManager::New().

Here is the caller graph for this function:

◆ Reset()

void ToolManager::Reset ( )

Definition at line 563 of file ToolManager.cpp.

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

1558{
1559 if (mLastFocus) {
1560 auto temp1 = AButton::TemporarilyAllowFocus();
1561 auto temp2 = ASlider::TemporarilyAllowFocus();
1563 mLastFocus->SetFocus();
1564 return true;
1565 }
1566 return false;
1567}
static TempAllowFocus TemporarilyAllowFocus()
Definition: AButton.cpp:661
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1898
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 1098 of file ToolManager.cpp.

1099{
1100 Expose( type, !mBars[ type ]->IsVisible() );
1101 Updated();
1102}
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 1414 of file ToolManager.cpp.

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

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 1058 of file ToolManager.cpp.

1059{
1060 // Queue an update event
1061 wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1062 GetProjectFrame( *mParent ).GetEventHandler()->AddPendingEvent( e );
1063}

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 961 of file ToolManager.cpp.

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

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, ToolBarConfiguration::Write(), and wxT().

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: