Audacity  3.0.3
Public Types | 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]

Public Types

using GetTopPanelHook = std::function< wxWindow *(wxWindow &) >
 

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 GetTopPanelHook SetGetTopPanelHook (const GetTopPanelHook &)
 
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
 
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 50 of file ToolManager.h.

Member Typedef Documentation

◆ FramePtr

using ToolManager::FramePtr = Destroy_ptr<wxFrame>
private

Definition at line 129 of file ToolManager.h.

◆ GetTopPanelHook

using ToolManager::GetTopPanelHook = std::function< wxWindow*( wxWindow& ) >

Definition at line 58 of file ToolManager.h.

Constructor & Destructor Documentation

◆ ToolManager() [1/2]

ToolManager::ToolManager ( AudacityProject parent)

Definition at line 369 of file ToolManager.cpp.

370 : wxEvtHandler()
371 {
372  wxPoint pt[ 3 ];
373 
374 #if defined(__WXMAC__)
375  // Save original transition
376  mTransition = wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION );
377 #endif
378 
379  // Initialize everything
380  mParent = parent;
381  mLastPos.x = mBarPos.x = -1;
382  mLastPos.y = mBarPos.y = -1;
383  mDragWindow = NULL;
384  mDragDock = NULL;
385  mDragBar = NULL;
386 
387  // Create the down arrow
388  pt[ 0 ].x = 0;
389  pt[ 0 ].y = 0;
390  pt[ 1 ].x = 9;
391  pt[ 1 ].y = 9;
392  pt[ 2 ].x = 18;
393  pt[ 2 ].y = 0;
394 
395  // Create the shaped region
396  mDown = std::make_unique<wxRegion>( 3, &pt[0] );
397 
398  // Create the down arrow
399  pt[ 0 ].x = 9;
400  pt[ 0 ].y = 0;
401  pt[ 1 ].x = 0;
402  pt[ 1 ].y = 9;
403  pt[ 2 ].x = 9;
404  pt[ 2 ].y = 18;
405 
406  // Create the shaped region
407  mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
408 
409  // Create the indicator frame
410  // parent is null but FramePtr ensures destruction
411  mIndicator = FramePtr{ safenew wxFrame( NULL,
412  wxID_ANY,
413  wxEmptyString,
414  wxDefaultPosition,
415  wxSize( 32, 32 ),
416  wxFRAME_TOOL_WINDOW |
417  wxFRAME_SHAPED |
418  wxNO_BORDER |
419  wxFRAME_NO_TASKBAR |
420  wxSTAY_ON_TOP )
421  };
422 
423  // Hook the creation event...only needed on GTK, but doesn't hurt for all
424  mIndicator->Bind( wxEVT_CREATE,
426  this );
427 
428  // Hook the paint event...needed for all
429  mIndicator->Bind( wxEVT_PAINT,
431  this );
432 
433  // It's a little shy
434  mIndicator->Hide();
435 }

References mBarPos, mDown, mDragBar, mDragDock, mDragWindow, mIndicator, mLastPos, mLeft, mParent, 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 511 of file ToolManager.cpp.

512 {
513  Destroy();
514 }

References Destroy().

Here is the call graph for this function:

Member Function Documentation

◆ CreateWindows()

void ToolManager::CreateWindows ( )

Definition at line 437 of file ToolManager.cpp.

438 {
439  auto parent = mParent;
440  auto &window = GetProjectFrame( *parent );
441 
442  // Hook the parents mouse events...using the parent helps greatly
443  // under GTK
444  window.Bind( wxEVT_LEFT_UP,
446  this );
447  window.Bind( wxEVT_MOTION,
449  this );
450  window.Bind( wxEVT_MOUSE_CAPTURE_LOST,
452  this );
453 
454  wxWindow *topDockParent = getTopPanelHook()( window );
455 
456  // Create the top and bottom docks
457  mTopDock = safenew ToolDock( this, topDockParent, TopDockID );
458  mBotDock = safenew ToolDock( this, &window, BotDockID );
459 
460  // Create all of the toolbars
461  // All have the project as parent window
462  wxASSERT(parent);
463 
464  size_t ii = 0;
465  for (const auto &factory : RegisteredToolbarFactory::GetFactories()) {
466  if (factory) {
467  mBars[ii] = factory( *parent );
468  }
469  else
470  wxASSERT( false );
471  ++ii;
472  }
473 
474  // We own the timer
475  mTimer.SetOwner( this );
476 
477  // Process the toolbar config settings
478  ReadConfig();
479 
480  wxEvtHandler::AddFilter(this);
481 }

References BotDockID, factory, RegisteredToolbarFactory::GetFactories(), GetProjectFrame(), getTopPanelHook(), 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 487 of file ToolManager.cpp.

488 {
489  if ( mTopDock || mBotDock ) { // destroy at most once
490  wxEvtHandler::RemoveFilter(this);
491 
492  // Save the toolbar states
493  WriteConfig();
494 
495  // This function causes the toolbars to be destroyed, so
496  // clear the configuration of the ToolDocks which refer to
497  // these toolbars. This change was needed to stop Audacity
498  // crashing when running with Jaws on Windows 10 1703.
501 
502  mTopDock = mBotDock = nullptr; // indicate that it has been destroyed
503 
504  for ( size_t ii = 0; ii < ToolBarCount; ++ii )
505  mBars[ii].reset();
506 
507  mIndicator.reset();
508  }
509 }

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

1531 {
1532  // Done dragging - ensure grabber button isn't pushed
1533  if( mDragBar )
1534  {
1535  mDragBar->SetDocked( mDragBar->GetDock(), false );
1536  }
1537 
1538  // Release capture
1539  auto &window = GetProjectFrame( *mParent );
1540  if( window.HasCapture() )
1541  {
1542  window.ReleaseMouse();
1543  }
1544 
1545  // Hide the indicator
1546  mIndicator->Hide();
1547 
1548  mDragWindow = NULL;
1549  mDragDock = NULL;
1550  mDragBar = NULL;
1551  mPrevDock = NULL;
1554  mLastPos.x = mBarPos.x = -1;
1555  mLastPos.y = mBarPos.y = -1;
1556  mTimer.Stop();
1557  mDidDrag = false;
1558  mClicked = false;
1559 
1560  RestoreFocus();
1561 }

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

1114 {
1115  ToolBar *t = mBars[ type ].get();
1116 
1117  // Handle docked and floaters differently
1118  if( t->IsDocked() )
1119  {
1120  t->GetDock()->Expose( type, show );
1121  }
1122  else
1123  {
1124  t->Expose( show );
1125  }
1126 }

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

697 {
698  // Snoop the global event stream for changes of focused window. Remember
699  // the last one of our own that is not a grabber.
700 
701  if (event.GetEventType() == wxEVT_KILL_FOCUS) {
702  auto &focusEvent = static_cast<wxFocusEvent&>(event);
703  auto window = focusEvent.GetWindow();
704  auto top = wxGetTopLevelParent(window);
705  if(auto toolFrame = dynamic_cast<ToolFrame*>(top))
706  top = toolFrame->GetParent();
707  // window is that which will GET the focus
708  if ( window &&
709  !dynamic_cast<Grabber*>( window ) &&
710  !dynamic_cast<ToolFrame*>( window ) &&
711  top == FindProjectFrame( mParent ) )
712  // Note this is a dangle-proof wxWindowRef:
713  mLastFocus = window;
714  }
715 
716  return Event_Skip;
717 }

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

362 {
363  return Get( const_cast< AudacityProject & >( project ) );
364 }

References Get().

Here is the call graph for this function:

◆ GetBotDock() [1/2]

ToolDock * ToolManager::GetBotDock ( )

Definition at line 1050 of file ToolManager.cpp.

1051 {
1052  return mBotDock;
1053 }

References mBotDock.

◆ GetBotDock() [2/2]

const ToolDock * ToolManager::GetBotDock ( ) const

Definition at line 1055 of file ToolManager.cpp.

1056 {
1057  return mBotDock;
1058 }

References mBotDock.

◆ GetToolBar()

ToolBar * ToolManager::GetToolBar ( int  type) const

Definition at line 1029 of file ToolManager.cpp.

1030 {
1031  return mBars[ type ].get();
1032 }

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

1038 {
1039  return mTopDock;
1040 }

References mTopDock.

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetTopDock() [2/2]

const ToolDock * ToolManager::GetTopDock ( ) const

Definition at line 1042 of file ToolManager.cpp.

1043 {
1044  return mTopDock;
1045 }

References mTopDock.

◆ HandleEscapeKey()

void ToolManager::HandleEscapeKey ( )
private

Definition at line 1501 of file ToolManager.cpp.

1502 {
1503  if (mDragBar) {
1504  if(mPrevDock) {
1505  // Sheriff John Stone,
1506  // Why don't you leave me alone?
1507  // Well, I feel so break up
1508  // I want to go home.
1510  mPrevDock->Dock( mDragBar, true, mPrevSlot );
1511  Updated();
1512 
1513  // Done with the floater
1514  mDragWindow->ClearBar();
1515  mDragWindow->Destroy();
1516  mDragWindow = nullptr;
1517  mDragBar->Refresh(false);
1518  }
1519  else {
1520  // Floater remains, and returns to where it begain
1521  auto parent = mDragBar->GetParent();
1522  parent->SetPosition(mPrevPosition);
1523  mDragBar->SetDocked(NULL, false);
1524  }
1525 
1526  DoneDragging();
1527  }
1528 }

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

1075 {
1076  return mBars[ type ]->IsDocked();
1077 }

References mBars.

◆ IsVisible()

bool ToolManager::IsVisible ( int  type)

Definition at line 1082 of file ToolManager.cpp.

1083 {
1084  ToolBar *t = mBars[ type ].get();
1085 
1086  return t && t->IsVisible();
1087 
1088 #if 0
1089  // If toolbar is floating
1090  if( !t->IsDocked() )
1091  {
1092  // Must return state of floater window
1093  return t->GetParent()->IsShown();
1094  }
1095 
1096  // Return state of docked toolbar
1097  return t->IsShown();
1098 #endif
1099 }

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

1132 {
1133  // Update the layout
1134  if (mTopDock)
1135  {
1137  }
1138 
1139  if (mBotDock)
1140  {
1142  }
1143 }

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

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

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

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

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

1413 {
1414 #if defined(__WXGTK__)
1415  mIndicator->SetShape( *mCurrent );
1416 #endif
1417  event.Skip();
1418 }

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

1396 {
1397  // TODO: Better to use a bitmap than a triangular region.
1398  wxWindow *w = (wxWindow *)event.GetEventObject();
1399  wxPaintDC dc( w );
1400  // TODO: Better (faster) to use the existing spare brush.
1401  wxBrush brush( theTheme.Colour( clrTrackPanelText ) );
1402  dc.SetBackground( brush );
1403  dc.Clear();
1404 }

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

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

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

563 {
564  auto &project = context.project;
565  auto &toolManager = ToolManager::Get( project );
566 
567  toolManager.Reset();
568  MenuManager::Get(project).ModifyToolbarMenus(project);
569 }

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

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

References mDragWindow, mIndicator, and mLastState.

◆ operator=()

ToolManager& ToolManager::operator= ( const ToolManager )

◆ ReadConfig()

void ToolManager::ReadConfig ( )
private

Definition at line 722 of file ToolManager.cpp.

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

References BotDockID, ToolBar::Create(), ToolDock::Dock(), DockCount, Expose(), ToolDock::GetConfiguration(), FileConfig::GetPath(), ToolBar::GetSection(), FileConfig::GetVersionKeysInit(), gPrefs, ToolDock::LoadConfig(), mBars, mBotDock, MeterBarID, mParent, mTopDock, 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 688 of file ToolManager.cpp.

689 {
690  for (const auto &bar : mBars) {
691  if (bar)
692  bar->RegenerateTooltips();
693  }
694 }

References mBars.

Referenced by ProjectManager::New().

Here is the caller graph for this function:

◆ Reset()

void ToolManager::Reset ( )

Definition at line 572 of file ToolManager.cpp.

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

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

1564 {
1565  if (mLastFocus) {
1566  auto temp1 = AButton::TemporarilyAllowFocus();
1567  auto temp2 = ASlider::TemporarilyAllowFocus();
1569  mLastFocus->SetFocus();
1570  return true;
1571  }
1572  return false;
1573 }

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:

◆ SetGetTopPanelHook()

auto ToolManager::SetGetTopPanelHook ( const GetTopPanelHook hook)
static

Definition at line 342 of file ToolManager.cpp.

344 {
345  auto &theHook = getTopPanelHook();
346  auto result = theHook;
347  theHook = hook;
348  return result;
349 }

References getTopPanelHook().

Referenced by InstallTopPanelHook::InstallTopPanelHook().

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

1105 {
1106  Expose( type, !mBars[ type ]->IsVisible() );
1107  Updated();
1108 }

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

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

References mDragBar, mDragOffset, mDragWindow, mParent, 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 1064 of file ToolManager.cpp.

1065 {
1066  // Queue an update event
1067  wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1068  GetProjectFrame( *mParent ).GetEventHandler()->AddPendingEvent( e );
1069 }

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

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

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 127 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 152 of file ToolManager.h.

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

◆ mCurrent

wxRegion* ToolManager::mCurrent
private

Definition at line 132 of file ToolManager.h.

Referenced by OnIndicatorCreate(), and OnMouse().

◆ mDidDrag

bool ToolManager::mDidDrag {}
private

Definition at line 151 of file ToolManager.h.

Referenced by DoneDragging(), and OnMouse().

◆ mDown

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

Definition at line 131 of file ToolManager.h.

Referenced by OnMouse(), and ToolManager().

◆ mDragBar

ToolBar* ToolManager::mDragBar {}
private

Definition at line 122 of file ToolManager.h.

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

◆ mDragBefore

ToolBarConfiguration::Position ToolManager::mDragBefore {}
private

Definition at line 124 of file ToolManager.h.

Referenced by OnMouse().

◆ mDragDock

ToolDock* ToolManager::mDragDock
private

Definition at line 121 of file ToolManager.h.

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

◆ mDragOffset

wxPoint ToolManager::mDragOffset
private

Definition at line 123 of file ToolManager.h.

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

◆ mDragWindow

ToolFrame* ToolManager::mDragWindow
private

◆ mIndicator

FramePtr ToolManager::mIndicator
private

Definition at line 130 of file ToolManager.h.

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

◆ mLastFocus

wxWindowRef ToolManager::mLastFocus {}
private

Definition at line 118 of file ToolManager.h.

Referenced by FilterEvent(), and RestoreFocus().

◆ mLastPos

wxPoint ToolManager::mLastPos
private

Definition at line 126 of file ToolManager.h.

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

◆ mLastState

bool ToolManager::mLastState
private

Definition at line 135 of file ToolManager.h.

Referenced by OnGrabber(), and OnTimer().

◆ mLeft

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

Definition at line 131 of file ToolManager.h.

Referenced by OnMouse(), and ToolManager().

◆ mParent

AudacityProject* ToolManager::mParent
private

◆ mPrevConfiguration

ToolBarConfiguration ToolManager::mPrevConfiguration
private

Definition at line 150 of file ToolManager.h.

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

◆ mPrevDock

ToolDock* ToolManager::mPrevDock {}
private

Definition at line 147 of file ToolManager.h.

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

◆ mPrevPosition

wxPoint ToolManager::mPrevPosition {}
private

Definition at line 146 of file ToolManager.h.

Referenced by HandleEscapeKey(), and OnGrabber().

◆ mPrevSlot

Definition at line 148 of file ToolManager.h.

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

◆ mTimer

wxTimer ToolManager::mTimer
private

Definition at line 134 of file ToolManager.h.

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

◆ mTopDock

ToolDock* ToolManager::mTopDock {}
private

The documentation for this class was generated from the following files:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
ToolManager::mPrevSlot
ToolBarConfiguration::Position mPrevSlot
Definition: ToolManager.h:149
toolbarGap
#define toolbarGap
Definition: ToolBar.h:64
FileConfig::SetPath
virtual void SetPath(const wxString &strPath) wxOVERRIDE
Definition: FileConfig.cpp:93
TimeBarID
@ TimeBarID
Definition: ToolBar.h:86
ToolDock::RestoreConfiguration
void RestoreConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:824
ToolManager::OnIndicatorCreate
void OnIndicatorCreate(wxWindowCreateEvent &event)
Definition: ToolManager.cpp:1412
ToolDock
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
BotDockID
@ BotDockID
Definition: ToolDock.h:43
ToolBarCount
@ ToolBarCount
Definition: ToolBar.h:87
ToolBarConfiguration::Position
Definition: ToolDock.h:70
AButton::TemporarilyAllowFocus
static TempAllowFocus TemporarilyAllowFocus()
Definition: AButton.cpp:636
ToolManager::mCurrent
wxRegion * mCurrent
Definition: ToolManager.h:132
ToolBar::ResizingDone
virtual void ResizingDone()
Definition: ToolBar.h:186
ToolFrame
class ToolFrame
Definition: ToolManager.h:166
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
ToolFrame::ClearBar
void ClearBar()
Definition: ToolManager.h:174
ToolManager::mTopDock
ToolDock * mTopDock
Definition: ToolManager.h:141
ToolDock::Undock
void Undock(ToolBar *bar)
Definition: ToolDock.cpp:403
DefaultConfigTable
static struct DefaultConfigEntry DefaultConfigTable[]
ToolBarConfiguration::Contains
bool Contains(const ToolBar *bar) const
Definition: ToolDock.h:233
ToolManager::Get
static ToolManager & Get(AudacityProject &project)
Definition: ToolManager.cpp:356
NoDockID
@ NoDockID
Definition: ToolDock.h:41
DeviceBarID
@ DeviceBarID
Definition: ToolBar.h:81
entry
static ProjectFileIORegistry::WriterEntry entry
Definition: ProjectSettings.cpp:197
ToolManager::mDragDock
ToolDock * mDragDock
Definition: ToolManager.h:121
ToolManager::Updated
void Updated()
Definition: ToolManager.cpp:1064
ToolManager::mPrevDock
ToolDock * mPrevDock
Definition: ToolManager.h:147
ToolBar::EnableDisableButtons
virtual void EnableDisableButtons()=0
ToolDock::GetConfiguration
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:309
ToolManager::mLastFocus
wxWindowRef mLastFocus
Definition: ToolManager.h:118
ToolDock::LayoutToolBars
void LayoutToolBars()
Definition: ToolDock.cpp:663
ToolManager::Expose
void Expose(int type, bool show)
Definition: ToolManager.cpp:1113
ToolBar::ReCreateButtons
virtual void ReCreateButtons()
Definition: ToolBar.cpp:516
Grabber
The widget to the left of a ToolBar that allows it to be dragged around to NEW positions.
Definition: Grabber.h:103
ToolManager::mParent
AudacityProject * mParent
Definition: ToolManager.h:117
ToolManager::IsVisible
bool IsVisible(int type)
Definition: ToolManager.cpp:1082
ToolManager::mIndicator
FramePtr mIndicator
Definition: ToolManager.h:130
ToolDock::Expose
void Expose(int type, bool show)
Definition: ToolDock.cpp:834
ToolManager::ReadConfig
void ReadConfig()
Definition: ToolManager.cpp:722
ToolManager::DoneDragging
void DoneDragging()
Definition: ToolManager.cpp:1530
ToolManager::mLastState
bool mLastState
Definition: ToolManager.h:135
ToolManager::mLeft
std::unique_ptr< wxRegion > mLeft
Definition: ToolManager.h:131
ToolManager::OnMouse
void OnMouse(wxMouseEvent &event)
Definition: ToolManager.cpp:1148
GrabberEvent::IsEscaping
bool IsEscaping() const
Definition: Grabber.h:74
ToolBarConfiguration::Clear
void Clear()
Definition: ToolDock.h:61
ToolManager::FramePtr
Destroy_ptr< wxFrame > FramePtr
Definition: ToolManager.h:129
ToolBar::IsPositioned
bool IsPositioned()
Definition: ToolBar.h:137
ToolManager::mDragOffset
wxPoint mDragOffset
Definition: ToolManager.h:123
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:817
ToolManager::OnCaptureLost
void OnCaptureLost(wxMouseCaptureLostEvent &event)
Definition: ToolManager.cpp:1335
MeterPanelBase::TemporarilyAllowFocus
static TempAllowFocus TemporarilyAllowFocus()
Definition: MeterPanelBase.cpp:17
RegisteredToolbarFactory::GetFactories
static const Functions & GetFactories()
Definition: ToolBar.cpp:977
ToolManager::mDown
std::unique_ptr< wxRegion > mDown
Definition: ToolManager.h:131
ScrubbingBarID
@ ScrubbingBarID
Definition: ToolBar.h:80
ToolBar::SetPositioned
void SetPositioned()
Definition: ToolBar.h:139
ToolManager::mBotDock
ToolDock * mBotDock
Definition: ToolManager.h:142
ToolBarConfiguration::UnspecifiedPosition
static const Position UnspecifiedPosition
Definition: ToolDock.h:105
ToolManager::mLastPos
wxPoint mLastPos
Definition: ToolManager.h:126
ToolManager::mPrevConfiguration
ToolBarConfiguration mPrevConfiguration
Definition: ToolManager.h:150
ToolManager::Reset
void Reset()
Definition: ToolManager.cpp:572
ToolManager::mTimer
wxTimer mTimer
Definition: ToolManager.h:134
ToolManager::OnIndicatorPaint
void OnIndicatorPaint(wxPaintEvent &event)
Definition: ToolManager.cpp:1395
ToolBarConfiguration::Read
static bool Read(ToolBarConfiguration *pConfiguration, Legacy *pLegacy, ToolBar *bar, bool &visible, bool defaultVisible)
Definition: ToolDock.cpp:255
ToolBar::GetDock
ToolDock * GetDock()
Definition: ToolBar.cpp:630
ToolDock::PositionBar
ToolBarConfiguration::Position PositionBar(ToolBar *t, const wxPoint &pos, wxRect &rect)
Definition: ToolDock.cpp:720
ToolManager::mBarPos
wxRect mBarPos
Definition: ToolManager.h:127
ToolBar::IsResizable
bool IsResizable() const
Definition: ToolBar.cpp:415
ToolManager::LayoutToolBars
void LayoutToolBars()
Definition: ToolManager.cpp:1131
ToolBar::Create
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:475
FileConfig::GetVersionKeysInit
void GetVersionKeysInit(int &major, int &minor, int &micro) const
Definition: FileConfig.h:56
ToolBar::IsDocked
bool IsDocked() const
Definition: ToolBar.cpp:423
ToolManager::WriteConfig
void WriteConfig()
Definition: ToolManager.cpp:967
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
ToolManager::mBars
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:144
ToolManager::Destroy
void Destroy()
Definition: ToolManager.cpp:487
SelectionBarID
@ SelectionBarID
Definition: ToolBar.h:82
TranscriptionBarID
@ TranscriptionBarID
Definition: ToolBar.h:79
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
ToolDock::LoadConfig
void LoadConfig()
Definition: ToolDock.cpp:443
TopDockID
@ TopDockID
Definition: ToolDock.h:42
ToolManager::mDragBar
ToolBar * mDragBar
Definition: ToolManager.h:122
ToolBar::Expose
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:444
ToolManager::UndockBar
void UndockBar(wxPoint mp)
Definition: ToolManager.cpp:1420
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
ToolBar::SetToDefaultSize
virtual void SetToDefaultSize()
Definition: ToolBar.cpp:496
ToolBarConfiguration::Write
static void Write(const ToolBarConfiguration *pConfiguration, const ToolBar *bar)
Definition: ToolDock.cpp:331
ToolManager::RestoreFocus
bool RestoreFocus()
Definition: ToolManager.cpp:1563
GetProjectFrame
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 ...
Definition: ProjectWindows.cpp:72
ToolManager::mPrevPosition
wxPoint mPrevPosition
Definition: ToolManager.h:146
MenuManager::Get
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:70
ToolManager::HandleEscapeKey
void HandleEscapeKey()
Definition: ToolManager.cpp:1501
ToolBarConfiguration::PostRead
void PostRead(Legacy &legacy)
Definition: ToolDock.cpp:310
ToolBar
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:98
ToolDock::WrapConfiguration
void WrapConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:817
ToolManager::mDragBefore
ToolBarConfiguration::Position mDragBefore
Definition: ToolManager.h:124
ASlider::TemporarilyAllowFocus
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1791
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1189
MeterBarID
@ MeterBarID
Definition: ToolBar.h:74
FindProjectFrame
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
Definition: ProjectWindows.cpp:88
DockCount
@ DockCount
Definition: ToolDock.h:44
ToolBarConfiguration::Legacy
Definition: ToolDock.h:253
ToolBarConfiguration::Find
Position Find(const ToolBar *bar) const
Definition: ToolDock.cpp:89
ToolBar::SetDocked
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:638
ToolBar::SetVisible
void SetVisible(bool bVisible)
Definition: ToolBar.cpp:436
ToolManager::mDidDrag
bool mDidDrag
Definition: ToolManager.h:151
safenew
#define safenew
Definition: MemoryX.h:10
ToolManager::mClicked
bool mClicked
Definition: ToolManager.h:152
toolbarSingle
#define toolbarSingle
Definition: ToolBar.h:59
ToolBar::IsVisible
bool IsVisible() const
Definition: ToolBar.cpp:431
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:64
MenuManager::ModifyToolbarMenus
static void ModifyToolbarMenus(AudacityProject &project)
Definition: Menus.cpp:592
ToolBar::GetSection
wxString GetSection()
Definition: ToolBar.cpp:382
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: ToolManager.cpp:351
ToolManager::mDragWindow
ToolFrame * mDragWindow
Definition: ToolManager.h:120
getTopPanelHook
static ToolManager::GetTopPanelHook & getTopPanelHook()
Methods for ToolManager.
Definition: ToolManager.cpp:336
ToolDock::Dock
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:415
ToolManager
class ToolManager
Definition: ToolManager.h:54
NoBarID
@ NoBarID
Definition: ToolBar.h:71
ToolBarConfiguration::Remove
void Remove(const ToolBar *bar)
Definition: ToolDock.cpp:212
FileConfig::GetPath
virtual const wxString & GetPath() const wxOVERRIDE
Definition: FileConfig.cpp:98