Audacity  2.2.2
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:

Public Member Functions

 ToolManager (AudacityProject *parent, wxWindow *topDockParent)
 Methods for ToolManager. More...
 
 ~ToolManager ()
 
void LayoutToolBars ()
 
void UpdatePrefs ()
 
bool IsDocked (int type)
 
bool IsVisible (int type)
 
void ShowHide (int type)
 
void Expose (int type, bool show)
 
ToolBarGetToolBar (int type) const
 
ToolDockGetTopDock ()
 
ToolDockGetBotDock ()
 
void Reset ()
 
void RegenerateTooltips ()
 
int FilterEvent (wxEvent &event) override
 
bool RestoreFocus ()
 

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
 
wxWindow * 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 45 of file ToolManager.h.

Member Typedef Documentation

using ToolManager::FramePtr = Destroy_ptr<wxFrame>
private

Definition at line 107 of file ToolManager.h.

Constructor & Destructor Documentation

ToolManager::ToolManager ( AudacityProject parent,
wxWindow *  topDockParent 
)

Methods for ToolManager.

Definition at line 330 of file ToolManager.cpp.

References BotDockID, DeviceBarID, EditBarID, MeterBarID, MixerBarID, OnCaptureLost(), OnIndicatorCreate(), OnIndicatorPaint(), OnMouse(), PlayMeterBarID, RecordMeterBarID, safenew, ScrubbingBarID, SelectionBarID, SpectralSelectionBarID, ToolsBarID, TopDockID, TranscriptionBarID, and TransportBarID.

331 : wxEvtHandler()
332 {
333  wxPoint pt[ 3 ];
334 
335 #if defined(__WXMAC__)
336  // Save original transition
337  mTransition = wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION );
338 #endif
339 
340  // Initialize everything
341  mParent = parent;
342  mLastPos.x = mBarPos.x = -1;
343  mLastPos.y = mBarPos.y = -1;
344  mDragWindow = NULL;
345  mDragDock = NULL;
346  mDragBar = NULL;
347 
348  // Create the down arrow
349  pt[ 0 ].x = 0;
350  pt[ 0 ].y = 0;
351  pt[ 1 ].x = 9;
352  pt[ 1 ].y = 9;
353  pt[ 2 ].x = 18;
354  pt[ 2 ].y = 0;
355 
356  // Create the shaped region
357  mDown = std::make_unique<wxRegion>( 3, &pt[0] );
358 
359  // Create the down arrow
360  pt[ 0 ].x = 9;
361  pt[ 0 ].y = 0;
362  pt[ 1 ].x = 0;
363  pt[ 1 ].y = 9;
364  pt[ 2 ].x = 9;
365  pt[ 2 ].y = 18;
366 
367  // Create the shaped region
368  mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
369 
370  // Create the indicator frame
371  // parent is null but FramePtr ensures destruction
372  mIndicator = FramePtr{ safenew wxFrame( NULL,
373  wxID_ANY,
374  wxEmptyString,
375  wxDefaultPosition,
376  wxSize( 32, 32 ),
377  wxFRAME_TOOL_WINDOW |
378  wxFRAME_SHAPED |
379  wxNO_BORDER |
380  wxFRAME_NO_TASKBAR |
381  wxSTAY_ON_TOP )
382  };
383 
384  // Hook the creation event...only needed on GTK, but doesn't hurt for all
385  mIndicator->Bind( wxEVT_CREATE,
387  this );
388 
389  // Hook the paint event...needed for all
390  mIndicator->Bind( wxEVT_PAINT,
392  this );
393 
394  // It's a little shy
395  mIndicator->Hide();
396 
397  // Hook the parents mouse events...using the parent helps greatly
398  // under GTK
399  mParent->Bind( wxEVT_LEFT_UP,
401  this );
402  mParent->Bind( wxEVT_MOTION,
404  this );
405  mParent->Bind( wxEVT_MOUSE_CAPTURE_LOST,
407  this );
408 
409  // Create the top and bottom docks
410  mTopDock = safenew ToolDock( this, topDockParent, TopDockID );
412 
413  // Create all of the toolbars
414  // All have the project as parent window
415  wxASSERT(parent);
426 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
428 #endif
430 
431  // We own the timer
432  mTimer.SetOwner( this );
433 
434  // Process the toolbar config settings
435  ReadConfig();
436 
437  wxEvtHandler::AddFilter(this);
438 }
void OnIndicatorPaint(wxPaintEvent &event)
ToolBar * mDragBar
Definition: ToolManager.h:100
A ToolBar that has the main Transport buttons.
A ToolBar that holds the VU Meter.
Definition: MeterToolBar.h:32
std::unique_ptr< wxRegion > mLeft
Definition: ToolManager.h:109
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
ToolFrame * mDragWindow
Definition: ToolManager.h:98
(not quite a Toolbar) at foot of screen for setting and viewing the selection range.
Definition: SelectionBar.h:42
void OnCaptureLost(wxMouseCaptureLostEvent &event)
A ToolBar that has the edit buttons on it.
Definition: EditToolBar.h:73
wxRect mBarPos
Definition: ToolManager.h:105
#define safenew
Definition: Audacity.h:230
AudacityProject * mParent
Definition: ToolManager.h:95
FramePtr mIndicator
Definition: ToolManager.h:108
void ReadConfig()
(not quite a Toolbar) at foot of screen for setting and viewing the frequency selection range...
A toobar to allow easier changing of input and output devices .
Definition: DeviceToolBar.h:25
Destroy_ptr< ToolBar > Holder
Definition: ToolBar.h:92
ToolDock * mBotDock
Definition: ToolManager.h:120
wxTimer mTimer
Definition: ToolManager.h:112
ToolDock * mTopDock
Definition: ToolManager.h:119
Destroy_ptr< wxFrame > FramePtr
Definition: ToolManager.h:107
std::unique_ptr< wxRegion > mDown
Definition: ToolManager.h:109
A kind of ToolBar with Tools on it.
Definition: ToolsToolBar.h:49
wxPoint mLastPos
Definition: ToolManager.h:104
void OnMouse(wxMouseEvent &event)
ToolDock * mDragDock
Definition: ToolManager.h:99
A kind of ToolBar used to help with analysing voice recordings.
A ToolBar that provides the record and playback volume settings.
Definition: MixerToolBar.h:25
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
void OnIndicatorCreate(wxWindowCreateEvent &event)
ToolManager::~ToolManager ( )

Definition at line 443 of file ToolManager.cpp.

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

444 {
445  wxEvtHandler::RemoveFilter(this);
446 
447  // Save the toolbar states
448  WriteConfig();
449 
450  // This function causes the toolbars to be destroyed, so
451  // clear the configuration of the ToolDocks which refer to
452  // these toolbars. This change was needed to stop Audacity
453  // crashing when running with Jaws on Windows 10 1703.
456 }
void WriteConfig()
ToolDock * mBotDock
Definition: ToolManager.h:120
ToolDock * mTopDock
Definition: ToolManager.h:119
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:310

Member Function Documentation

void ToolManager::DoneDragging ( )
private

Definition at line 1484 of file ToolManager.cpp.

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

Referenced by HandleEscapeKey(), and OnMouse().

1485 {
1486  // Done dragging
1487  // Release capture
1488  if( mParent->HasCapture() )
1489  {
1490  mParent->ReleaseMouse();
1491  }
1492 
1493  // Hide the indicator
1494  mIndicator->Hide();
1495 
1496  mDragWindow = NULL;
1497  mDragDock = NULL;
1498  mDragBar = NULL;
1499  mPrevDock = NULL;
1502  mLastPos.x = mBarPos.x = -1;
1503  mLastPos.y = mBarPos.y = -1;
1504  mTimer.Stop();
1505  mDidDrag = false;
1506  mClicked = false;
1507 
1508  RestoreFocus();
1509 }
ToolBar * mDragBar
Definition: ToolManager.h:100
ToolFrame * mDragWindow
Definition: ToolManager.h:98
bool RestoreFocus()
wxRect mBarPos
Definition: ToolManager.h:105
ToolBarConfiguration::Position mPrevSlot
Definition: ToolManager.h:127
ToolDock * mPrevDock
Definition: ToolManager.h:125
AudacityProject * mParent
Definition: ToolManager.h:95
FramePtr mIndicator
Definition: ToolManager.h:108
static const Position UnspecifiedPosition
Definition: ToolDock.h:106
wxTimer mTimer
Definition: ToolManager.h:112
ToolBarConfiguration mPrevConfiguration
Definition: ToolManager.h:128
wxPoint mLastPos
Definition: ToolManager.h:104
ToolDock * mDragDock
Definition: ToolManager.h:99
void ToolManager::Expose ( int  type,
bool  show 
)

Definition at line 1071 of file ToolManager.cpp.

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

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

1072 {
1073  ToolBar *t = mBars[ type ].get();
1074 
1075  // Handle docked and floaters differently
1076  if( t->IsDocked() )
1077  {
1078  t->GetDock()->Expose( type, show );
1079  }
1080  else
1081  {
1082  t->Expose( show );
1083  }
1084 }
bool IsDocked() const
Definition: ToolBar.cpp:390
ToolDock * GetDock()
Definition: ToolBar.cpp:560
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:411
void Expose(int type, bool show)
Definition: ToolDock.cpp:831
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
int ToolManager::FilterEvent ( wxEvent &  event)
override

Definition at line 621 of file ToolManager.cpp.

References mLastFocus, and mParent.

622 {
623  // Snoop the global event stream for changes of focused window. Remember
624  // the last one of our own that is not a grabber.
625 
626  if (event.GetEventType() == wxEVT_KILL_FOCUS) {
627  auto &focusEvent = static_cast<wxFocusEvent&>(event);
628  auto window = focusEvent.GetWindow();
629  auto top = wxGetTopLevelParent(window);
630  if(auto toolFrame = dynamic_cast<ToolFrame*>(top))
631  top = toolFrame->GetParent();
632  // window is that which will GET the focus
633  if ( window &&
634  !dynamic_cast<Grabber*>( window ) &&
635  !dynamic_cast<ToolFrame*>( window ) &&
636  top == mParent )
637  mLastFocus = window;
638  }
639  else if (event.GetEventType() == wxEVT_DESTROY) {
640  auto &closeEvent = static_cast<wxWindowDestroyEvent&>(event);
641  auto window = closeEvent.GetEventObject();
642  if (window == mLastFocus)
643  // Avoid a dangling pointer!
644  mLastFocus = nullptr;
645  }
646 
647  return Event_Skip;
648 }
AudacityProject * mParent
Definition: ToolManager.h:95
wxWindow * mLastFocus
Definition: ToolManager.h:96
ToolBar* ToolManager::Float ( ToolBar t,
wxPoint &  pos 
)
private
ToolDock * ToolManager::GetBotDock ( )

Definition at line 1014 of file ToolManager.cpp.

References mBotDock.

1015 {
1016  return mBotDock;
1017 }
ToolDock * mBotDock
Definition: ToolManager.h:120
ToolBar * ToolManager::GetToolBar ( int  type) const

Definition at line 998 of file ToolManager.cpp.

References mBars.

Referenced by Theme::ApplyUpdatedImages(), ScreenshotCommand::CaptureToolbar(), Scrubber::OnToggleScrubRuler(), and ControlToolBar::StopPlaying().

999 {
1000  return mBars[ type ].get();
1001 }
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
ToolDock * ToolManager::GetTopDock ( )

Definition at line 1006 of file ToolManager.cpp.

References mTopDock.

Referenced by ScreenshotCommand::Apply().

1007 {
1008  return mTopDock;
1009 }
ToolDock * mTopDock
Definition: ToolManager.h:119
void ToolManager::HandleEscapeKey ( )
private

Definition at line 1456 of file ToolManager.cpp.

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

Referenced by OnGrabber().

1457 {
1458  if (mDragBar) {
1459  if(mPrevDock) {
1460  // Sheriff John Stone,
1461  // Why don't you leave me alone?
1462  // Well, I feel so break up
1463  // I want to go home.
1465  mPrevDock->Dock( mDragBar, true, mPrevSlot );
1466 
1467  // Done with the floater
1468  mDragWindow->ClearBar();
1469  mDragWindow->Destroy();
1470  mDragWindow = nullptr;
1471  mDragBar->Refresh(false);
1472  }
1473  else {
1474  // Floater remains, and returns to where it begain
1475  auto parent = mDragBar->GetParent();
1476  parent->SetPosition(mPrevPosition);
1477  mDragBar->SetDocked(NULL, false);
1478  }
1479 
1480  DoneDragging();
1481  }
1482 }
ToolBar * mDragBar
Definition: ToolManager.h:100
void ClearBar()
Definition: ToolManager.h:152
ToolFrame * mDragWindow
Definition: ToolManager.h:98
ToolBarConfiguration::Position mPrevSlot
Definition: ToolManager.h:127
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:412
ToolDock * mPrevDock
Definition: ToolManager.h:125
void DoneDragging()
ToolBarConfiguration mPrevConfiguration
Definition: ToolManager.h:128
wxPoint mPrevPosition
Definition: ToolManager.h:124
void RestoreConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:821
void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:568
bool ToolManager::IsDocked ( int  type)

Definition at line 1033 of file ToolManager.cpp.

References mBars.

1034 {
1035  return mBars[ type ]->IsDocked();
1036 }
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
bool ToolManager::IsVisible ( int  type)

Definition at line 1041 of file ToolManager.cpp.

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

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

1042 {
1043  ToolBar *t = mBars[ type ].get();
1044 
1045  return t->IsVisible();
1046 
1047 #if 0
1048  // If toolbar is floating
1049  if( !t->IsDocked() )
1050  {
1051  // Must return state of floater window
1052  return t->GetParent()->IsShown();
1053  }
1054 
1055  // Return state of docked toolbar
1056  return t->IsShown();
1057 #endif
1058 }
bool IsDocked() const
Definition: ToolBar.cpp:390
bool IsVisible() const
Definition: ToolBar.cpp:398
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
void ToolManager::LayoutToolBars ( )

Definition at line 1089 of file ToolManager.cpp.

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

Referenced by Reset().

1090 {
1091  // Update the layout
1094 }
ToolDock * mBotDock
Definition: ToolManager.h:120
ToolDock * mTopDock
Definition: ToolManager.h:119
void LayoutToolBars()
Definition: ToolDock.cpp:664
void ToolManager::OnCaptureLost ( wxMouseCaptureLostEvent &  event)
private

Definition at line 1291 of file ToolManager.cpp.

References mDragWindow, mParent, and OnMouse().

Referenced by ToolManager().

1292 {
1293  // Can't do anything if we're not dragging. This also prevents
1294  // us from intercepting events that don't belong to us from the
1295  // parent since we're Connect()ed to a couple.
1296  if( !mDragWindow )
1297  {
1298  event.Skip();
1299  return;
1300  }
1301 
1302  // Simulate button up
1303  wxMouseEvent e(wxEVT_LEFT_UP);
1304  e.SetEventObject(mParent);
1305  OnMouse(e);
1306 }
ToolFrame * mDragWindow
Definition: ToolManager.h:98
AudacityProject * mParent
Definition: ToolManager.h:95
void OnMouse(wxMouseEvent &event)
void ToolManager::OnGrabber ( GrabberEvent event)
private

Definition at line 1409 of file ToolManager.cpp.

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

1410 {
1411  // No need to propagate any further
1412  event.Skip( false );
1413 
1414  if(event.IsEscaping())
1415  return HandleEscapeKey();
1416 
1417  // Remember which bar we're dragging
1418  mDragBar = mBars[ event.GetId() ].get();
1419 
1420  // Remember state, in case of ESCape key later
1421  if (mDragBar->IsDocked()) {
1422  mPrevDock = dynamic_cast<ToolDock*>(mDragBar->GetParent());
1423  wxASSERT(mPrevDock);
1426  }
1427  else
1428  mPrevPosition = mDragBar->GetParent()->GetPosition();
1429 
1430  // Calculate the drag offset
1431  wxPoint mp = event.GetPosition();
1432  mDragOffset = mp -
1433  mDragBar->GetParent()->ClientToScreen( mDragBar->GetPosition() ) +
1434  wxPoint( 1, 1 );
1435 
1436  mClicked = true;
1437  if( mPrevDock )
1438  {
1439  mDragWindow = nullptr;
1440  }
1441  else
1442  {
1443  mDragWindow = (ToolFrame *) mDragBar->GetParent();
1444  }
1445 
1446  // We want all mouse events from this point on
1447  if( !mParent->HasCapture() )
1448  mParent->CaptureMouse();
1449 
1450  // Start monitoring shift key changes
1451  mLastState = wxGetKeyState( WXK_SHIFT );
1452  mTimer.Start( 100 );
1453 }
ToolBar * mDragBar
Definition: ToolManager.h:100
Position Find(const ToolBar *bar) const
Definition: ToolDock.cpp:92
bool IsDocked() const
Definition: ToolBar.cpp:390
void WrapConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:814
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
ToolFrame * mDragWindow
Definition: ToolManager.h:98
bool IsEscaping() const
Definition: Grabber.h:70
ToolBarConfiguration::Position mPrevSlot
Definition: ToolManager.h:127
ToolDock * mPrevDock
Definition: ToolManager.h:125
class ToolFrame
Definition: ToolManager.h:143
AudacityProject * mParent
Definition: ToolManager.h:95
bool mLastState
Definition: ToolManager.h:113
wxPoint mDragOffset
Definition: ToolManager.h:101
wxTimer mTimer
Definition: ToolManager.h:112
ToolBarConfiguration mPrevConfiguration
Definition: ToolManager.h:128
wxPoint mPrevPosition
Definition: ToolManager.h:124
void HandleEscapeKey()
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:310
void ToolManager::OnIndicatorCreate ( wxWindowCreateEvent &  event)
private

Definition at line 1368 of file ToolManager.cpp.

References mCurrent, and mIndicator.

Referenced by ToolManager().

1369 {
1370 #if defined(__WXGTK__)
1371  mIndicator->SetShape( *mCurrent );
1372 #endif
1373  event.Skip();
1374 }
FramePtr mIndicator
Definition: ToolManager.h:108
wxRegion * mCurrent
Definition: ToolManager.h:110
void ToolManager::OnIndicatorPaint ( wxPaintEvent &  event)
private

Definition at line 1351 of file ToolManager.cpp.

References ThemeBase::Colour(), and theTheme.

Referenced by ToolManager().

1352 {
1353  // TODO: Better to use a bitmap than a triangular region.
1354  wxWindow *w = (wxWindow *)event.GetEventObject();
1355  wxPaintDC dc( w );
1356  // TODO: Better (faster) to use the existing spare brush.
1357  wxBrush brush( theTheme.Colour( clrTrackPanelText ) );
1358  dc.SetBackground( brush );
1359  dc.Clear();
1360 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void ToolManager::OnMouse ( wxMouseEvent &  event)
private

Definition at line 1114 of file ToolManager.cpp.

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

Referenced by OnCaptureLost(), and ToolManager().

1115 {
1116  // Go ahead and set the event to propagate
1117  event.Skip();
1118 
1119  // Can't do anything if we're not dragging. This also prevents
1120  // us from intercepting events that don't belong to us from the
1121  // parent since we're Connect()ed to a couple.
1122  if( !mClicked )
1123  {
1124  return;
1125  }
1126 
1127 #if defined(__WXMAC__)
1128  // Disable window animation
1129  wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1130 #endif
1131 
1132  // Retrieve the event position
1133  wxPoint pos =
1134  ( (wxWindow *)event.GetEventObject() )->ClientToScreen( event.GetPosition() ) - mDragOffset;
1135 
1136 
1137  if( !event.LeftIsDown() )
1138  {
1139  // Button was released...finish the drag
1140  // Transition the bar to a dock
1141  if (!mDidDrag) {
1142  if (mPrevDock)
1144  DoneDragging();
1145  return;
1146  }
1147  else if( mDragDock && !event.ShiftDown() )
1148  {
1149  // Trip over...everyone ashore that's going ashore...
1150  mDragDock->Dock( mDragBar, true, mDragBefore );
1151  mDragWindow->ClearBar();
1152 
1153  // Done with the floater
1154  mDragWindow->Destroy();
1155  mDragWindow = nullptr;
1156  mDragBar->Refresh(false);
1157  }
1158  else
1159  {
1160  // Calling SetDocked() to force the grabber button to popup
1161  mDragBar->SetDocked( NULL, false );
1162  }
1163 
1164  DoneDragging();
1165  }
1166  else if( event.Dragging() && pos != mLastPos )
1167  {
1168  if (!mDidDrag) {
1169  // Must set the bar afloat if it's currently docked
1170  mDidDrag = true;
1171  wxPoint mp = event.GetPosition();
1172  mp = mParent->ClientToScreen(mp);
1173  if (!mDragWindow) {
1174  // We no longer have control
1175  if (mPrevDock)
1177  UndockBar(mp);
1178  }
1179  }
1180 
1181  // Make toolbar follow the mouse
1182  mDragWindow->Move( pos );
1183 
1184  // Remember to prevent excessive movement
1185  mLastPos = pos;
1186 
1187  // Calc the top dock hittest rectangle
1188  wxRect tr = mTopDock->GetRect();
1189  tr.SetBottom( tr.GetBottom() + 10 );
1190  tr.SetPosition( mTopDock->GetParent()->ClientToScreen( tr.GetPosition() ) );
1191 
1192  // Calc the bottom dock hittest rectangle
1193  wxRect br = mBotDock->GetRect();
1194  br.SetTop( br.GetTop() - 10 );
1195  br.SetBottom( br.GetBottom() + 20 );
1196  br.SetPosition( mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
1197 
1198 
1199  // Add half the bar height. We could use the actual bar height, but that would be confusing as a
1200  // bar removed at a place might not dock back there if just let go.
1201  // Also add 5 pixels in horizontal direction, so that a click without a move (or a very small move)
1202  // lands back where we started.
1203  pos += wxPoint( 5, 20 );
1204 
1205 
1206  // To find which dock, rather than test against pos, test against the whole dragger rect.
1207  // This means it is enough to overlap the dock to dock with it.
1208  wxRect barRect = mDragWindow->GetRect();
1209  ToolDock *dock = NULL;
1210  if( tr.Intersects( barRect ) )
1211  dock = mTopDock;
1212  else if( br.Intersects( barRect ) )
1213  dock = mBotDock;
1214 
1215  // Looks like we have a winner...
1216  if( dock )
1217  {
1218  wxPoint p;
1219  wxRect r;
1220 
1221  // Calculate where the bar would be placed
1222  mDragBefore = dock->PositionBar( mDragBar, pos, r );
1223 
1224  // If different than the last time, the indicator must be moved
1225  if( r != mBarPos )
1226  {
1227  wxRect dr = dock->GetRect();
1228 
1229  // Hide the indicator before changing the shape
1230  mIndicator->Hide();
1231 
1232  // Decide which direction the arrow should point
1233  if( r.GetTop() >= dr.GetHeight() )
1234  {
1235  const auto &box = mDown->GetBox();
1236  p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
1237  - (box.GetWidth() / 2);
1238  p.y = dr.GetBottom() - box.GetHeight();
1239  mCurrent = mDown.get();
1240  }
1241  else
1242  {
1243  p.x = dr.GetLeft() + r.GetLeft();
1244  p.y = dr.GetTop() + r.GetTop() +
1245  ( ( r.GetHeight() - mLeft->GetBox().GetHeight() ) / 2 );
1246  mCurrent = mLeft.get();
1247  }
1248 
1249  // Change the shape while hidden and then show it if okay
1250  mIndicator->SetShape( *mCurrent );
1251  if( !event.ShiftDown() )
1252  {
1253  mIndicator->Show();
1254  mIndicator->Update();
1255  }
1256 
1257  // Move it into position
1258  // LL: Do this after the Show() since KDE doesn't move the window
1259  // if it's not shown. (Do it outside if the previous IF as well)
1260  mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
1261 
1262  // Remember for next go round
1263  mBarPos = r;
1264  }
1265  }
1266  else
1267  {
1268  // Hide the indicator if it's still shown
1269  if( mBarPos.x != -1 )
1270  {
1271  // Hide any
1272  mIndicator->Hide();
1273  mBarPos.x = -1;
1274  mBarPos.y = -1;
1275  }
1276  }
1277 
1278  // Remember to which dock the drag bar belongs.
1279  mDragDock = dock;
1280  }
1281 
1282 #if defined(__WXMAC__)
1283  // Reinstate original transition
1284  wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1285 #endif
1286 }
ToolBar * mDragBar
Definition: ToolManager.h:100
std::unique_ptr< wxRegion > mLeft
Definition: ToolManager.h:109
void ClearBar()
Definition: ToolManager.h:152
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
ToolFrame * mDragWindow
Definition: ToolManager.h:98
ToolBarConfiguration::Position PositionBar(ToolBar *t, const wxPoint &pos, wxRect &rect)
Definition: ToolDock.cpp:717
wxRect mBarPos
Definition: ToolManager.h:105
ToolBarConfiguration::Position mDragBefore
Definition: ToolManager.h:102
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:412
ToolDock * mPrevDock
Definition: ToolManager.h:125
void DoneDragging()
AudacityProject * mParent
Definition: ToolManager.h:95
FramePtr mIndicator
Definition: ToolManager.h:108
void Remove(const ToolBar *bar)
Definition: ToolDock.cpp:210
ToolDock * mBotDock
Definition: ToolManager.h:120
wxPoint mDragOffset
Definition: ToolManager.h:101
wxRegion * mCurrent
Definition: ToolManager.h:110
ToolDock * mTopDock
Definition: ToolManager.h:119
ToolBarConfiguration mPrevConfiguration
Definition: ToolManager.h:128
void RestoreConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:821
std::unique_ptr< wxRegion > mDown
Definition: ToolManager.h:109
wxPoint mLastPos
Definition: ToolManager.h:104
void UndockBar(wxPoint mp)
ToolDock * mDragDock
Definition: ToolManager.h:99
void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:568
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:310
void ToolManager::OnTimer ( wxTimerEvent &  event)
private

Definition at line 1311 of file ToolManager.cpp.

References mDragWindow, mIndicator, and mLastState.

1312 {
1313  // Go ahead and set the event to propagate
1314  event.Skip();
1315 
1316  // Can't do anything if we're not dragging. This also prevents
1317  // us from intercepting events that don't belong to us from the
1318  // parent since we're Connect()ed to a couple.
1319  if( !mDragWindow )
1320  {
1321  return;
1322  }
1323 
1324  bool state = wxGetKeyState( WXK_SHIFT );
1325  if( mLastState != state )
1326  {
1327  mLastState = state;
1328 
1329 #if defined(__WXMAC__)
1330  // Disable window animation
1331  wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1332 #endif
1333 
1334  mIndicator->Show( !state );
1335 
1336 #if defined(__WXMAC__)
1337  // Disable window animation
1338  wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1339 #endif
1340  }
1341 
1342  return;
1343 }
ToolFrame * mDragWindow
Definition: ToolManager.h:98
FramePtr mIndicator
Definition: ToolManager.h:108
bool mLastState
Definition: ToolManager.h:113
void ToolManager::ReadConfig ( )
private

Definition at line 653 of file ToolManager.cpp.

References BotDockID, DeviceBarID, ToolDock::Dock(), DockCount, Expose(), ToolBar::Expose(), ToolDock::GetConfiguration(), ToolBar::GetDock(), ToolBar::GetSection(), ToolBar::GetType(), AudacityApp::GetVersionKeysInit(), gPrefs, ToolDock::LoadConfig(), mBars, mBotDock, MeterBarID, mParent, mTopDock, ToolBarConfiguration::PostRead(), ToolBarConfiguration::Read(), Reset(), safenew, ScrubbingBarID, SelectionBarID, ToolBar::SetVisible(), SpectralSelectionBarID, ToolBarCount, TopDockID, ToolDock::WrapConfiguration(), and wxGetApp().

654 {
655  wxString oldpath = gPrefs->GetPath();
656  std::vector<int> unordered[ DockCount ];
657  std::vector<ToolBar*> dockedAndHidden;
658  bool show[ ToolBarCount ];
659  int width[ ToolBarCount ];
660  int height[ ToolBarCount ];
661  int x, y;
662  int dock, ndx;
663  bool someFound { false };
664 
665 #if defined(__WXMAC__)
666  // Disable window animation
667  wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
668 #endif
669 
670  // Change to the bar root
671  gPrefs->SetPath( wxT("/GUI/ToolBars") );
672 
673  ToolBarConfiguration::Legacy topLegacy, botLegacy;
674 
675  int vMajor, vMinor, vMicro;
676  wxGetApp().GetVersionKeysInit(vMajor, vMinor, vMicro);
677  bool useLegacyDock = false;
678  // note that vMajor, vMinor, and vMicro will all be zero if either it's a new audacity.cfg file
679  // or the version is less than 1.3.13 (when there were no version keys according to the comments in
680  // InitPreferences()). So for new audacity.cfg
681  // file useLegacyDock will be true, but this doesn't matter as there are no Dock or DockV2 keys in the file yet.
682  if (vMajor <= 1 ||
683  (vMajor == 2 && (vMinor <= 1 || (vMinor == 2 && vMicro <= 1)))) // version <= 2.2.1
684  useLegacyDock = true;
685 
686 
687  // Load and apply settings for each bar
688  for( ndx = 0; ndx < ToolBarCount; ndx++ )
689  {
690  ToolBar *bar = mBars[ ndx ].get();
691  //wxPoint Center = mParent->GetPosition() + (mParent->GetSize() * 0.33);
692  //wxPoint Center(
693  // wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) /2 ,
694  // wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) /2 );
695 
696  // Change to the bar subkey
697  gPrefs->SetPath( bar->GetSection() );
698 
699  bool bShownByDefault = true;
700  int defaultDock = TopDockID;
701 
702  if( ndx == SelectionBarID )
703  defaultDock = BotDockID;
704  if( ndx == MeterBarID )
705  bShownByDefault = false;
706  if( ndx == ScrubbingBarID )
707  bShownByDefault = false;
708 
709 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
710  if( ndx == SpectralSelectionBarID ){
711  defaultDock = BotDockID;
712  bShownByDefault = false; // Only show if asked for.
713  }
714 #endif
715 
716  // Read in all the settings
717 
718  if (useLegacyDock)
719  gPrefs->Read( wxT("Dock"), &dock, -1); // legacy version of DockV2
720  else
721  gPrefs->Read( wxT("DockV2"), &dock, -1);
722 
723  const bool found = (dock != -1);
724  if (found)
725  someFound = true;
726  if (!found)
727  dock = defaultDock;
728 
729  ToolDock *d;
731  switch(dock)
732  {
733  case TopDockID: d = mTopDock; pLegacy = &topLegacy; break;
734  case BotDockID: d = mBotDock; pLegacy = &botLegacy; break;
735  default: d = nullptr; pLegacy = nullptr; break;
736  }
737 
738  bool ordered = ToolBarConfiguration::Read(
739  d ? &d->GetConfiguration() : nullptr,
740  pLegacy,
741  bar, show[ ndx ], bShownByDefault)
742  && found;
743 
744  gPrefs->Read( wxT("X"), &x, -1 );
745  gPrefs->Read( wxT("Y"), &y, -1 );
746  gPrefs->Read( wxT("W"), &width[ ndx ], -1 );
747  gPrefs->Read( wxT("H"), &height[ ndx ], -1 );
748 
749  bar->SetVisible( show[ ndx ] );
750 
751  // Docked or floating?
752  if( dock )
753  {
754  // Default to top dock if the ID isn't valid
755  if( dock < NoDockID || dock > DockCount ) {
756  dock = TopDockID;
757  }
758 
759  // Create the bar with the correct parent
760  if( dock == TopDockID )
761  {
762  bar->Create( mTopDock );
763  }
764  else
765  {
766  bar->Create( mBotDock );
767  }
768 
769  // Set the width and height
770  if( width[ ndx ] != -1 && height[ ndx ] != -1 )
771  {
772  wxSize sz( width[ ndx ], height[ ndx ] );
773  bar->SetSize( sz );
774  }
775 
776 #ifdef EXPERIMENTAL_SYNC_LOCK
777  // Set the width
778  if( width[ ndx ] >= bar->GetSize().x )
779  {
780  wxSize sz( width[ ndx ], bar->GetSize().y );
781  bar->SetSize( sz );
782  bar->Layout();
783  }
784 #else
785  // note that this section is here because if you had been using sync-lock and now you aren't,
786  // the space for the extra button is stored in audacity.cfg, and so you get an extra space
787  // in the EditToolbar.
788  // It is needed so that the meterToolbar size gets preserved.
789  // Longer-term we should find a better fix for this.
790  wxString thisBar = bar->GetSection();
791  if( thisBar != wxT("Edit"))
792  {
793  // Set the width
794  if( width[ ndx ] >= bar->GetSize().x )
795  {
796  wxSize sz( width[ ndx ], bar->GetSize().y );
797  bar->SetSize( sz );
798  bar->Layout();
799  }
800  }
801 #endif
802  // make a note of docked and hidden toolbars
803  if (!show[ndx])
804  dockedAndHidden.push_back(bar);
805 
806  if (!ordered)
807  {
808  // These must go at the end
809  unordered[ dock - 1 ].push_back( ndx );
810  }
811  }
812  else
813  {
814  // Create the bar (with the top dock being temporary parent)
815  bar->Create( mTopDock );
816 
817  // Construct a NEW floater
818  wxASSERT(mParent);
819  ToolFrame *f = safenew ToolFrame( mParent, this, bar, wxPoint( x, y ) );
820 
821  // Set the width and height
822  if( width[ ndx ] != -1 && height[ ndx ] != -1 )
823  {
824  wxSize sz( width[ ndx ], height[ ndx ] );
825  f->SetSizeHints( sz );
826  f->SetSize( sz );
827  f->Layout();
828  if( (x!=-1) && (y!=-1) )
829  bar->SetPositioned();
830  }
831 
832  // Required on Linux Xfce
833  wxSize msz(width[ndx],height[ndx]-1);
834  bar->GetParent()->SetMinSize(msz);
835 
836  // Inform toolbar of change
837  bar->SetDocked( NULL, false );
838 
839  // Show or hide it
840  Expose( ndx, show[ ndx ] );
841  }
842 
843  // Change back to the bar root
844  //gPrefs->SetPath( wxT("..") ); <-- Causes a warning...
845  // May or may not have gone into a subdirectory,
846  // so use an absolute path.
847  gPrefs->SetPath( wxT("/GUI/ToolBars") );
848  }
849 
850  mTopDock->GetConfiguration().PostRead(topLegacy);
851  mBotDock->GetConfiguration().PostRead(botLegacy);
852 
853  // Add all toolbars to their target dock
854  for( dock = 0; dock < DockCount; dock++ )
855  {
856  ToolDock *d = ( dock + 1 == TopDockID ? mTopDock : mBotDock );
857 
858  d->LoadConfig();
859 
860  // Add all unordered toolbars
861  bool deviceWasPositioned = false;
862  for( int ord = 0; ord < (int) unordered[ dock ].size(); ord++ )
863  {
864  ToolBar *t = mBars[ unordered[ dock ][ ord ] ].get();
865 
866  if (deviceWasPositioned &&
867  t->GetType() == DeviceBarID)
868  continue;
869 
870  if (someFound &&
871  t->GetType() == ScrubbingBarID) {
872  // Special case code to put the NEW scrubbing toolbar where we
873  // want it, when audacity.cfg is present from an older version
874  ToolBar *lastRoot {};
875 
876  // Change from the ideal configuration to the constrained one,
877  // just as when dragging and dropping
878  ToolBarConfiguration dummy;
879  mTopDock->WrapConfiguration(dummy);
880 
881  // Start a NEW row with just the scrubbing toolbar
882  auto &configuration = mTopDock->GetConfiguration();
883  for (const auto place : configuration)
884  if (place.position.rightOf == nullptr)
885  lastRoot = place.pTree->pBar;
887  nullptr, lastRoot, false
888  };
889  mTopDock->Dock(t, false, position);
890 
891  // Reposition the device toolbar, if it was docked above,
892  // right of scrubbing
893  const auto deviceToolBar = mBars[ DeviceBarID ].get();
894  if (deviceToolBar->GetDock() == mTopDock) {
895  deviceToolBar->GetDock()->Undock(deviceToolBar);
896  position = ToolBarConfiguration::Position{ t, nullptr };
897  mTopDock->Dock(deviceToolBar, false, position);
898 
899  // Remember not to place the device toolbar again
900  deviceWasPositioned = true;
901  }
902  Expose( t->GetId(), show[ t->GetId() ] );
903  continue;
904  }
905 
906  // Dock it
907  d->Dock( t, false );
908 
909  // Show or hide the bar
910  Expose( t->GetId(), show[ t->GetId() ] );
911  }
912  }
913 
914  // hidden docked toolbars
915  for (auto bar : dockedAndHidden) {
916  bar->SetVisible(false );
917  bar->GetDock()->Dock(bar, false);
918  bar->Expose(false);
919  }
920 
921  // Restore original config path
922  gPrefs->SetPath( oldpath );
923 
924 #if defined(__WXMAC__)
925  // Reinstate original transition
926  wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
927 #endif
928 
929  if (!someFound)
930  Reset();
931 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void WrapConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:814
void LoadConfig()
Definition: ToolDock.cpp:445
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
static bool Read(ToolBarConfiguration *pConfiguration, Legacy *pLegacy, ToolBar *bar, bool &visible, bool defaultVisible)
Definition: ToolDock.cpp:253
void PostRead(Legacy &legacy)
Definition: ToolDock.cpp:308
void GetVersionKeysInit(int &major, int &minor, int &micro) const
Definition: AudacityApp.h:174
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:412
#define safenew
Definition: Audacity.h:230
class ToolFrame
Definition: ToolManager.h:143
AudacityProject * mParent
Definition: ToolManager.h:95
ToolDock * mBotDock
Definition: ToolManager.h:120
wxString GetSection()
Definition: ToolBar.cpp:358
ToolDock * mTopDock
Definition: ToolManager.h:119
int GetType()
Definition: ToolBar.cpp:366
AudacityApp & wxGetApp()
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
void Expose(int type, bool show)
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:310
void ToolManager::RegenerateTooltips ( )

Definition at line 613 of file ToolManager.cpp.

References mBars, and ToolBar::RegenerateTooltips().

614 {
615  for (const auto &bar : mBars) {
616  if (bar)
617  bar->RegenerateTooltips();
618  }
619 }
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
void ToolManager::Reset ( )

Definition at line 502 of file ToolManager.cpp.

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

Referenced by ReadConfig().

503 {
504  // Disconnect all docked bars
505  for ( const auto &entry : DefaultConfigTable )
506  {
507  int ndx = entry.barID;
508  ToolBar *bar = mBars[ ndx ].get();
509 
511  (entry.rightOf == NoBarID) ? nullptr : mBars[ entry.rightOf ].get(),
512  (entry.below == NoBarID) ? nullptr : mBars[ entry.below ].get()
513  };
514  bar->SetSize( 20,20 );
515 
516  wxWindow *floater;
517  ToolDock *dock;
518  bool expose = true;
519 
520  // Disconnect the bar
521  if( bar->IsDocked() )
522  {
523  bar->GetDock()->Undock( bar );
524  floater = NULL;
525  }
526  else
527  {
528  floater = bar->GetParent();
529  }
530 
531  // Decide which dock.
532  if (ndx == SelectionBarID
534  || ndx == SpectralSelectionBarID
535 #endif
536  )
537  dock = mBotDock;
538  else
539  dock = mTopDock;
540 
541  // Recreate bar buttons (and resize it)
542  bar->ReCreateButtons();
543  bar->EnableDisableButtons();
544 
545 #if 0
546  if( bar->IsResizable() )
547  {
548  bar->SetSize(bar->GetBestFittingSize());
549  }
550 #endif
551 
552  // Hide some bars.
553  if( ndx == MeterBarID
555  || ndx == SpectralSelectionBarID
556 #endif
557  || ndx == ScrubbingBarID
558 // DA: Hides three more toolbars.
559 #ifdef EXPERIMENTAL_DA
560  || ndx == DeviceBarID
561  || ndx == TranscriptionBarID
562  || ndx == SelectionBarID
563 #endif
564  )
565  expose = false;
566 
567  // Next condition will alwys (?) be true, as the reset configuration is
568  // with no floating toolbars.
569  if( dock != NULL )
570  {
571  // when we dock, we reparent, so bar is no longer a child of floater.
572  dock->Dock( bar, false, position );
573  Expose( ndx, expose );
574  //OK (and good) to DELETE floater, as bar is no longer in it.
575  if( floater )
576  floater->Destroy();
577  }
578  else
579  {
580  // The (tool)bar has a dragger window round it, the floater.
581  // in turn floater will have mParent (the entire App) as its
582  // parent.
583 
584  // Maybe construct a NEW floater
585  // this happens if we have just been bounced out of a dock.
586  if( floater == NULL ) {
587  wxASSERT(mParent);
588  floater = safenew ToolFrame( mParent, this, bar, wxPoint(-1,-1) );
589  bar->Reparent( floater );
590  }
591 
592  // This bar is undocked and invisible.
593  // We are doing a reset toolbars, so even the invisible undocked bars should
594  // be moved somewhere sensible. Put bar near center of window.
595  // If there were multiple hidden toobars the ndx * 10 adjustment means
596  // they won't overlap too much.
597  floater->CentreOnParent( );
598  floater->Move( floater->GetPosition() + wxSize( ndx * 10 - 200, ndx * 10 ));
599  bar->SetDocked( NULL, false );
600  Expose( ndx, false );
601  }
602 
603  }
604  // TODO:??
605  // If audio was playing, we stopped the VU meters,
606  // It would be nice to show them again, but hardly essential as
607  // they will show up again on the next play.
608  // SetVUMeters(AudacityProject *p);
609  LayoutToolBars();
610  Updated();
611 }
#define EXPERIMENTAL_SPECTRAL_EDITING
Definition: Project.h:137
bool IsDocked() const
Definition: ToolBar.cpp:390
static struct DefaultConfigEntry DefaultConfigTable[]
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
virtual void ReCreateButtons()
Definition: ToolBar.cpp:459
ToolDock * GetDock()
Definition: ToolBar.cpp:560
void LayoutToolBars()
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:412
#define safenew
Definition: Audacity.h:230
class ToolFrame
Definition: ToolManager.h:143
AudacityProject * mParent
Definition: ToolManager.h:95
virtual void EnableDisableButtons()=0
ToolDock * mBotDock
Definition: ToolManager.h:120
ToolDock * mTopDock
Definition: ToolManager.h:119
void Undock(ToolBar *bar)
Definition: ToolDock.cpp:400
bool IsResizable() const
Definition: ToolBar.cpp:382
void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:568
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
void Expose(int type, bool show)
bool ToolManager::RestoreFocus ( )

Definition at line 1511 of file ToolManager.cpp.

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

Referenced by DoneDragging().

1512 {
1513  if (mLastFocus) {
1514  auto temp1 = AButton::TemporarilyAllowFocus();
1515  auto temp2 = ASlider::TemporarilyAllowFocus();
1516  auto temp3 = MeterPanel::TemporarilyAllowFocus();
1517  mLastFocus->SetFocus();
1518  return true;
1519  }
1520  return false;
1521 }
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1616
static TempAllowFocus TemporarilyAllowFocus()
Definition: Meter.cpp:2045
wxWindow * mLastFocus
Definition: ToolManager.h:96
static TempAllowFocus TemporarilyAllowFocus()
Definition: AButton.cpp:556
void ToolManager::ShowHide ( int  type)

Definition at line 1063 of file ToolManager.cpp.

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

Referenced by ScreenshotCommand::CaptureToolbar().

1064 {
1065  Expose( type, !mBars[ type ]->IsVisible() );
1066 }
bool IsVisible(int type)
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
void Expose(int type, bool show)
void ToolManager::UndockBar ( wxPoint  mp)
private

Definition at line 1376 of file ToolManager.cpp.

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

Referenced by OnMouse().

1377 {
1378 #if defined(__WXMAC__)
1379  // Disable window animation
1380  wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1381 #endif
1382 
1383  // Adjust the starting position
1384  mp -= mDragOffset;
1385 
1386  // Inform toolbar of change
1387  mDragBar->SetDocked( NULL, true );
1389 
1390  // Construct a NEW floater
1391  wxASSERT(mParent);
1392  mDragWindow = safenew ToolFrame( mParent, this, mDragBar, mp );
1393 
1394  // Make sure the ferry is visible
1395  mDragWindow->Show();
1396 
1397  // Notify parent of change
1398  Updated();
1399 
1400 #if defined(__WXMAC__)
1401  // Reinstate original transition
1402  wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1403 #endif
1404 }
ToolBar * mDragBar
Definition: ToolManager.h:100
ToolFrame * mDragWindow
Definition: ToolManager.h:98
#define safenew
Definition: Audacity.h:230
class ToolFrame
Definition: ToolManager.h:143
AudacityProject * mParent
Definition: ToolManager.h:95
wxPoint mDragOffset
Definition: ToolManager.h:101
void SetPositioned()
Definition: ToolBar.h:123
void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:568
void ToolManager::Updated ( )
private

Definition at line 1023 of file ToolManager.cpp.

References mParent.

Referenced by Reset(), and UndockBar().

1024 {
1025  // Queue an update event
1026  wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1027  mParent->GetEventHandler()->AddPendingEvent( e );
1028 }
AudacityProject * mParent
Definition: ToolManager.h:95
void ToolManager::UpdatePrefs ( )

Definition at line 1099 of file ToolManager.cpp.

References mBars, ToolBarCount, and ToolBar::UpdatePrefs().

1100 {
1101  for( int ndx = 0; ndx < ToolBarCount; ndx++ )
1102  {
1103  ToolBar *bar = mBars[ ndx ].get();
1104  if( bar )
1105  {
1106  bar->UpdatePrefs();
1107  }
1108  }
1109 }
virtual void UpdatePrefs()
Definition: ToolBar.cpp:535
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
void ToolManager::WriteConfig ( )
private

Definition at line 936 of file ToolManager.cpp.

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

Referenced by ~ToolManager().

937 {
938  if( !gPrefs )
939  {
940  return;
941  }
942 
943  wxString oldpath = gPrefs->GetPath();
944  int ndx;
945 
946  // Change to the bar root
947  gPrefs->SetPath( wxT("/GUI/ToolBars") );
948 
949  // Save state of each bar
950  for( ndx = 0; ndx < ToolBarCount; ndx++ )
951  {
952  ToolBar *bar = mBars[ ndx ].get();
953 
954  // Change to the bar subkey
955  gPrefs->SetPath( bar->GetSection() );
956 
957  // Search both docks for toolbar order
958  bool to = mTopDock->GetConfiguration().Contains( bar );
959  bool bo = mBotDock->GetConfiguration().Contains( bar );
960 
961  // Save
962  // Note that DockV2 was introduced in 2.2.2 to fix bug #1554. Dock is retained so that
963  // the toolbar layout is not changed when opening a version before 2.2.2, and in particular
964  // its value is compatible with versions 2.1.3 to 2.2.1 which have this bug.
965  ToolDock* dock = bar->GetDock(); // dock for both shown and hidden toolbars
966  gPrefs->Write( wxT("DockV2"), static_cast<int>(dock == mTopDock ? TopDockID : dock == mBotDock ? BotDockID : NoDockID ));
967 
968  gPrefs->Write( wxT("Dock"), static_cast<int>( to ? TopDockID : bo ? BotDockID : NoDockID));
969 
970  dock = to ? mTopDock : bo ? mBotDock : nullptr; // dock for shown toolbars
972  (dock ? &dock->GetConfiguration() : nullptr, bar);
973 
974  wxPoint pos( -1, -1 );
975  wxSize sz = bar->GetSize();
976  if( !bar->IsDocked() && bar->IsPositioned() )
977  {
978  pos = bar->GetParent()->GetPosition();
979  sz = bar->GetParent()->GetSize();
980  }
981  gPrefs->Write( wxT("X"), pos.x );
982  gPrefs->Write( wxT("Y"), pos.y );
983  gPrefs->Write( wxT("W"), sz.x );
984  gPrefs->Write( wxT("H"), sz.y );
985 
986  // Change back to the bar root
987  gPrefs->SetPath( wxT("..") );
988  }
989 
990  // Restore original config path
991  gPrefs->SetPath( oldpath );
992  gPrefs->Flush();
993 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
bool IsDocked() const
Definition: ToolBar.cpp:390
bool Contains(const ToolBar *bar) const
Definition: ToolDock.h:234
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
ToolDock * GetDock()
Definition: ToolBar.cpp:560
bool IsPositioned()
Definition: ToolBar.h:121
ToolDock * mBotDock
Definition: ToolManager.h:120
wxString GetSection()
Definition: ToolBar.cpp:358
ToolDock * mTopDock
Definition: ToolManager.h:119
static void Write(const ToolBarConfiguration *pConfiguration, const ToolBar *bar)
Definition: ToolDock.cpp:329
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:122
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:310

Member Data Documentation

wxRect ToolManager::mBarPos
private

Definition at line 105 of file ToolManager.h.

Referenced by DoneDragging(), and OnMouse().

ToolBar::Holder ToolManager::mBars[ToolBarCount]
private
ToolDock* ToolManager::mBotDock
private
bool ToolManager::mClicked {}
private

Definition at line 130 of file ToolManager.h.

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

wxRegion* ToolManager::mCurrent
private

Definition at line 110 of file ToolManager.h.

Referenced by OnIndicatorCreate(), and OnMouse().

bool ToolManager::mDidDrag {}
private

Definition at line 129 of file ToolManager.h.

Referenced by DoneDragging(), and OnMouse().

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

Definition at line 109 of file ToolManager.h.

Referenced by OnMouse().

ToolBar* ToolManager::mDragBar {}
private

Definition at line 100 of file ToolManager.h.

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

ToolBarConfiguration::Position ToolManager::mDragBefore {}
private

Definition at line 102 of file ToolManager.h.

Referenced by OnMouse().

ToolDock* ToolManager::mDragDock
private

Definition at line 99 of file ToolManager.h.

Referenced by DoneDragging(), and OnMouse().

wxPoint ToolManager::mDragOffset
private

Definition at line 101 of file ToolManager.h.

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

ToolFrame* ToolManager::mDragWindow
private
FramePtr ToolManager::mIndicator
private

Definition at line 108 of file ToolManager.h.

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

wxWindow* ToolManager::mLastFocus {}
private

Definition at line 96 of file ToolManager.h.

Referenced by FilterEvent(), and RestoreFocus().

wxPoint ToolManager::mLastPos
private

Definition at line 104 of file ToolManager.h.

Referenced by DoneDragging(), and OnMouse().

bool ToolManager::mLastState
private

Definition at line 113 of file ToolManager.h.

Referenced by OnGrabber(), and OnTimer().

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

Definition at line 109 of file ToolManager.h.

Referenced by OnMouse().

AudacityProject* ToolManager::mParent
private
ToolBarConfiguration ToolManager::mPrevConfiguration
private

Definition at line 128 of file ToolManager.h.

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

ToolDock* ToolManager::mPrevDock {}
private

Definition at line 125 of file ToolManager.h.

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

wxPoint ToolManager::mPrevPosition {}
private

Definition at line 124 of file ToolManager.h.

Referenced by HandleEscapeKey(), and OnGrabber().

Definition at line 127 of file ToolManager.h.

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

wxTimer ToolManager::mTimer
private

Definition at line 112 of file ToolManager.h.

Referenced by DoneDragging(), and OnGrabber().

ToolDock* ToolManager::mTopDock
private

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