Audacity 3.2.0
ToolManager.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ToolManager.cpp
6
7 Dominic Mazzoni
8 Shane T. Mueller
9 Leland Lucius
10
11 See ToolManager.h for details.
12
13*******************************************************************//*******************************************************************//**********************************************************************/
26
27
28#include "ToolManager.h"
29
30#include "../commands/CommandContext.h"
31
32// For compilers that support precompilation, includes "wx/wx.h".
33#include <wx/wxprec.h>
34
35#ifndef WX_PRECOMP
36#include <wx/app.h>
37#include <wx/dcclient.h>
38#include <wx/defs.h>
39#include <wx/event.h>
40#include <wx/frame.h>
41#include <wx/gdicmn.h>
42#include <wx/intl.h>
43#include <wx/region.h>
44#include <wx/settings.h>
45#include <wx/sizer.h>
46#include <wx/sysopt.h>
47#include <wx/timer.h>
48#include <wx/utils.h>
49#include <wx/window.h>
50#endif /* */
51
52#include <wx/minifram.h>
53#include <wx/popupwin.h>
54
55#include "AColor.h"
56#include "AllThemeResources.h"
57#include "ImageManipulation.h"
58#include "Prefs.h"
59#include "Project.h"
60#include "ProjectWindows.h"
61#include "widgets/AButton.h"
62#include "widgets/ASlider.h"
64#include "widgets/Grabber.h"
65
69#define sizerW 11
70
71//
72// Constructor
73//
75 ( AudacityProject *parent, ToolManager *manager, ToolBar *bar, wxPoint pos )
76 : wxFrame( FindProjectFrame( parent ),
77 bar->GetId(),
78 wxEmptyString,
79 pos,
80 wxDefaultSize,
81 wxNO_BORDER |
82 wxFRAME_NO_TASKBAR |
83#if !defined(__WXMAC__) // bug1358
84 wxFRAME_TOOL_WINDOW |
85#endif
86 wxFRAME_FLOAT_ON_PARENT )
87 , mParent{ parent }
88{
89 int width = bar->GetSize().x;
90 int border = 1;
91
92 // Save parameters
94 mBar = bar;
95
96 // Transfer the bar to the ferry
97 bar->Reparent(this);
98
99 // Bug 2120 (comment 6 residual): No need to set a minimum size
100 // if the toolbar is not resizable. On GTK, setting a minimum
101 // size will prevent the frame from shrinking if the toolbar gets
102 // reconfigured and needs to resize smaller.
103 if (bar->IsResizable())
104 {
105 SetMinSize(bar->GetDockedSize());
106 }
107
108 {
109 // We use a sizer to maintain proper spacing
110 auto s = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
111
112 // Add the bar to the sizer
113 s->Add(bar, 1, wxEXPAND | wxALL, border);
114
115 // Add space for the resize grabber
116 if (bar->IsResizable())
117 {
118 s->Add(sizerW, 1);
119 width += sizerW;
120 }
121
122 SetSize(width + 2 * ToolBarFloatMargin,
123 bar->GetDockedSize().y + 2 * ToolBarFloatMargin);
124
125 // Attach the sizer and resize the window to fit
126 SetSizer(s.release());
127 }
128
129 Layout();
130
131 // Inform toolbar of change
132 bar->SetDocked( NULL, true );
133
134 // Make sure resizable floaters don't get any smaller than initial size
135 if( bar->IsResizable() )
136 {
137 // Calc the minimum size of the frame
138 mMinSize = bar->GetMinSize() + ( GetSize() - bar->GetSize() );
139 }
140}
141
143{
144 if(HasCapture())
145 ReleaseMouse();
146}
147
149{
150 // Pass it on to the manager since it isn't in the handling hierarchy
151 mManager->ProcessEvent( event );
152}
153
154// The current size determines the min size for resizing...
155// the 'lock in' is at that aspect ratio.
157{
158 mBar = pBar;
159
160 wxSize sz = mBar->GetSize();
161 SetClientSize( sz );
162 int yDesiredMin = 26;
163 int y = sz.GetHeight();
164 if (y > yDesiredMin) {
165 sz.SetWidth((sz.GetWidth() * yDesiredMin) / y);
166 sz.SetHeight( yDesiredMin );
167 }
168 mMinSize = sz -wxSize( 10, 0);
169}
170
171void ToolFrame::OnToolBarUpdate( wxCommandEvent & event )
172{
173 // Resize floater window to exactly contain toolbar
174 // use actual size rather than minimum size.
175 if (mBar)
176 mBar->GetParent()->SetClientSize( mBar->GetSize() );// ->GetMinSize() );
177
178 // Allow it to propagate to our parent
179 event.Skip();
180}
181
182void ToolFrame::OnPaint( wxPaintEvent & WXUNUSED(event) )
183{
184 wxPaintDC dc( this );
185 wxSize sz = GetSize();
186 wxRect r;
187
188 dc.SetPen( theTheme.Colour( clrTrackPanelText ) );
189 dc.SetBackground( wxBrush( theTheme.Colour( clrMedium ) ) );
190 dc.Clear();
191 dc.SetBrush( *wxTRANSPARENT_BRUSH );
192 dc.DrawRectangle( 0, 0, sz.GetWidth(), sz.GetHeight() );
193
194 if( mBar && mBar->IsResizable() )
195 {
196 r.x = sz.x - sizerW - 2,
197 r.y = sz.y - sizerW - 2;
198 r.width = sizerW + 2;
199 r.height = sizerW + 2;
200
201 AColor::Line(dc, r.GetLeft(), r.GetBottom(), r.GetRight(), r.GetTop() );
202 AColor::Line(dc, r.GetLeft() + 3, r.GetBottom(), r.GetRight(), r.GetTop() + 3 );
203 AColor::Line(dc, r.GetLeft() + 6, r.GetBottom(), r.GetRight(), r.GetTop() + 6 );
204 AColor::Line(dc, r.GetLeft() + 9, r.GetBottom(), r.GetRight(), r.GetTop() + 9 );
205 }
206
207}
208
209void ToolFrame::OnMotion( wxMouseEvent & event )
210{
211 // Don't do anything if we're docked or not resizeable
212 if( !mBar || mBar->IsDocked() || !mBar->IsResizable() )
213 {
214 return;
215 }
216
217 // Retrieve the mouse position
218 wxPoint pos = ClientToScreen( event.GetPosition() );
219 if( HasCapture() && event.Dragging() )
220 {
221 wxRect rect = GetRect();
222
223 rect.SetBottomRight( pos );
224
225 // Keep it within max size, if specified
226 wxSize maxsz = mBar->GetMaxSize();
227 if (maxsz != wxDefaultSize)
228 {
229 if (maxsz.x != wxDefaultCoord && rect.width > maxsz.x)
230 {
231 rect.width = maxsz.x;
232 }
233 if (maxsz.y != wxDefaultCoord && rect.height > maxsz.y)
234 {
235 rect.height = maxsz.y;
236 }
237 }
238
239 if( rect.width < mMinSize.x )
240 {
241 rect.width = mMinSize.x;
242 }
243
244 if( rect.height < mMinSize.y )
245 {
246 rect.height = mMinSize.y;
247 }
248
249 Resize( rect.GetSize() );
250 }
251 else if( HasCapture() && event.LeftUp() )
252 {
253 ReleaseMouse();
254 }
255 else if( !HasCapture() )
256 {
257 wxRect rect = GetRect();
258 wxRect r;
259
260 r.x = rect.GetRight() - sizerW - 2,
261 r.y = rect.GetBottom() - sizerW - 2;
262 r.width = sizerW + 2;
263 r.height = sizerW + 2;
264
265 // Is left click within resize grabber?
266 if( r.Contains( pos ) && !event.Leaving() )
267 {
268 mOrigSize = GetSize();
269
270 SetCursor( wxCURSOR_SIZENWSE );
271 if( event.LeftDown() )
272 {
273 CaptureMouse();
274 }
275 }
276 else
277 {
278 SetCursor( wxCURSOR_ARROW );
279 }
280 }
281}
282
283void ToolFrame::OnCaptureLost( wxMouseCaptureLostEvent & WXUNUSED(event) )
284{
285 if( HasCapture() )
286 {
287 ReleaseMouse();
288 }
289}
290
291void ToolFrame::OnClose( wxCloseEvent & event )
292{
293 event.Veto();
294}
295
296void ToolFrame::OnKeyDown( wxKeyEvent &event )
297{
298 event.Skip();
299 if( HasCapture() && event.GetKeyCode() == WXK_ESCAPE ) {
300 Resize( mOrigSize );
301 ReleaseMouse();
302 }
303}
304
305void ToolFrame::Resize( const wxSize &size )
306{
307 SetMinSize( size );
308 SetSize( size );
309 Layout();
310 Refresh( false );
311}
312
314
315BEGIN_EVENT_TABLE( ToolFrame, wxFrame )
317 EVT_PAINT( ToolFrame::OnPaint )
318 EVT_MOUSE_EVENTS( ToolFrame::OnMotion )
319 EVT_MOUSE_CAPTURE_LOST( ToolFrame::OnCaptureLost )
320 EVT_CLOSE( ToolFrame::OnClose )
321 EVT_COMMAND( wxID_ANY, EVT_TOOLBAR_UPDATED, ToolFrame::OnToolBarUpdate )
322 EVT_KEY_DOWN( ToolFrame::OnKeyDown )
324
326
330
331BEGIN_EVENT_TABLE( ToolManager, wxEvtHandler )
332 EVT_GRABBER( wxID_ANY, ToolManager::OnGrabber )
333 EVT_TIMER( wxID_ANY, ToolManager::OnTimer )
335
336static const AudacityProject::AttachedObjects::RegisteredFactory key{
337 []( AudacityProject &parent ){
338 return std::make_shared< ToolManager >( &parent ); }
339};
340
342{
343 return project.AttachedObjects::Get< ToolManager >( key );
344}
345
347{
348 return Get( const_cast< AudacityProject & >( project ) );
349}
350
351//
352// Constructor
353//
355: wxEvtHandler()
356{
357 wxPoint pt[ 3 ];
358
359#if defined(__WXMAC__)
360 // Save original transition
361 mTransition = wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION );
362#endif
363
364 // Initialize everything
365 mParent = parent;
366 mLastPos.x = mBarPos.x = -1;
367 mLastPos.y = mBarPos.y = -1;
368 mDragWindow = NULL;
369 mDragDock = NULL;
370 mDragBar = NULL;
371
372 // Create the down arrow
373 pt[ 0 ].x = 0;
374 pt[ 0 ].y = 0;
375 pt[ 1 ].x = 9;
376 pt[ 1 ].y = 9;
377 pt[ 2 ].x = 18;
378 pt[ 2 ].y = 0;
379
380 // Create the shaped region
381 mDown = std::make_unique<wxRegion>( 3, &pt[0] );
382
383 // Create the down arrow
384 pt[ 0 ].x = 9;
385 pt[ 0 ].y = 0;
386 pt[ 1 ].x = 0;
387 pt[ 1 ].y = 9;
388 pt[ 2 ].x = 9;
389 pt[ 2 ].y = 18;
390
391 // Create the shaped region
392 mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
393
394 // Create the indicator frame
395 // parent is null but FramePtr ensures destruction
396 mIndicator = FramePtr{ safenew wxFrame( NULL,
397 wxID_ANY,
398 wxEmptyString,
399 wxDefaultPosition,
400 wxSize( 32, 32 ),
401 wxFRAME_TOOL_WINDOW |
402 wxFRAME_SHAPED |
403 wxNO_BORDER |
404 wxFRAME_NO_TASKBAR |
405 wxSTAY_ON_TOP )
406 };
407
408 // Hook the creation event...only needed on GTK, but doesn't hurt for all
409 mIndicator->Bind( wxEVT_CREATE,
411 this );
412
413 // Hook the paint event...needed for all
414 mIndicator->Bind( wxEVT_PAINT,
416 this );
417
418 // It's a little shy
419 mIndicator->Hide();
420}
421
423{
424 auto parent = mParent;
425 auto &window = GetProjectFrame( *parent );
426
427 // Hook the parents mouse events...using the parent helps greatly
428 // under GTK
429 window.Bind( wxEVT_LEFT_UP,
431 this );
432 window.Bind( wxEVT_MOTION,
434 this );
435 window.Bind( wxEVT_MOUSE_CAPTURE_LOST,
437 this );
438
439 wxWindow *topDockParent = TopPanelHook::Call( window );
440 wxASSERT(topDockParent);
441
442 // Create the top and bottom docks
443 mTopDock = safenew ToolDock( this, topDockParent, TopDockID );
444 mBotDock = safenew ToolDock( this, &window, BotDockID );
445
446 // Create all of the toolbars
447 // All have the project as parent window
448 wxASSERT(parent);
449
450 size_t ii = 0;
451 for (const auto &factory : RegisteredToolbarFactory::GetFactories()) {
452 if (factory) {
453 mBars[ii] = factory( *parent );
454 }
455 else
456 wxASSERT( false );
457 ++ii;
458 }
459
460 // We own the timer
461 mTimer.SetOwner( this );
462
463 // Process the toolbar config settings
464 ReadConfig();
465
466 wxEvtHandler::AddFilter(this);
467}
468
469//
470// Destructor
471//
472
474{
475 if ( mTopDock || mBotDock ) { // destroy at most once
476 wxEvtHandler::RemoveFilter(this);
477
478 // Save the toolbar states
479 WriteConfig();
480
481 // This function causes the toolbars to be destroyed, so
482 // clear the configuration of the ToolDocks which refer to
483 // these toolbars. This change was needed to stop Audacity
484 // crashing when running with Jaws on Windows 10 1703.
487
488 mTopDock = mBotDock = nullptr; // indicate that it has been destroyed
489
490 for ( size_t ii = 0; ii < ToolBarCount; ++ii )
491 mBars[ii].reset();
492
493 mIndicator.reset();
494 }
495}
496
498{
499 Destroy();
500}
501
502// This table describes the default configuration of the toolbars as
503// a "tree" and must be kept in pre-order traversal.
504
505// In fact this tree is more of a broom -- nothing properly branches except
506// at the root.
507
508// "Root" corresponds to left edge of the main window, and successive siblings
509// go from top to bottom. But in practice layout may wrap this abstract
510// configuration if the window size is narrow.
511
512static struct DefaultConfigEntry {
513 int barID;
514 int rightOf; // parent
515 int below; // preceding sibling
516} DefaultConfigTable [] = {
517 // Top dock row, may wrap
524
525 // start another top dock row
528
529 // Hidden by default in top dock
531
532 // Bottom dock
535
536// DA: Transcription Toolbar not docked, by default.
537#ifdef EXPERIMENTAL_DA
539#else
541#endif
542
543 // Hidden by default in bottom dock
544 { SpectralSelectionBarID, NoBarID, NoBarID },
546
547// Static member function.
549{
550 auto &project = context.project;
551 auto &toolManager = ToolManager::Get( project );
552
553 toolManager.Reset();
554 MenuManager::Get(project).ModifyToolbarMenus(project);
555}
556
557
559{
560 // Disconnect all docked bars
561 for ( const auto &entry : DefaultConfigTable )
562 {
563 int ndx = entry.barID;
564 ToolBar *bar = mBars[ ndx ].get();
565
567 (entry.rightOf == NoBarID) ? nullptr : mBars[ entry.rightOf ].get(),
568 (entry.below == NoBarID) ? nullptr : mBars[ entry.below ].get()
569 };
570 bar->SetSize( 20,20 );
571
572 wxWindow *floater;
573 ToolDock *dock;
574 bool expose = true;
575
576 // Disconnect the bar
577 if( bar->IsDocked() )
578 {
579 bar->GetDock()->Undock( bar );
580 floater = NULL;
581 }
582 else
583 {
584 floater = bar->GetParent();
585 }
586
587 // Decide which dock.
588 if (ndx == SelectionBarID
589#ifdef EXPERIMENTAL_SPECTRAL_EDITING
590 || ndx == SpectralSelectionBarID
591#endif
592 || ndx == TimeBarID
593 || ndx == TranscriptionBarID
594 )
595 dock = mBotDock;
596 else
597 dock = mTopDock;
598
599 // PRL: Destroy the tool frame before recreating buttons.
600 // This fixes some subtle sizing problems on macOs.
601 bar->Reparent( dock );
602 //OK (and good) to DELETE floater, as bar is no longer in it.
603 if( floater )
604 floater->Destroy();
605
606 // Recreate bar buttons (and resize it)
607 bar->SetToDefaultSize();
608 bar->ReCreateButtons();
610
611#if 0
612 if( bar->IsResizable() )
613 {
614 bar->SetSize(bar->GetBestFittingSize());
615 }
616#endif
617
618 // Hide some bars.
619 if( ndx == MeterBarID
620#ifdef EXPERIMENTAL_SPECTRAL_EDITING
621 || ndx == SpectralSelectionBarID
622#endif
623 || ndx == ScrubbingBarID
624 || ndx == DeviceBarID
625// DA: Hides two more toolbars.
626#ifdef EXPERIMENTAL_DA
627 || ndx == TranscriptionBarID
628 || ndx == SelectionBarID
629#endif
630 )
631 expose = false;
632
633 // Next condition will always (?) be true, as the reset configuration is
634 // with no floating toolbars.
635 if( dock != NULL )
636 {
637 // when we dock, we reparent, so bar is no longer a child of floater.
638 dock->Dock( bar, false, position );
639 Expose( ndx, expose );
640 }
641 else
642 {
643 // The (tool)bar has a dragger window round it, the floater.
644 // in turn floater will have mParent (the entire App) as its
645 // parent.
646
647 // Maybe construct a NEW floater
648 // this happens if we have just been bounced out of a dock.
649 if( floater == NULL ) {
650 wxASSERT(mParent);
651 floater = safenew ToolFrame( mParent, this, bar, wxPoint(-1,-1) );
652 bar->Reparent( floater );
653 }
654
655 // This bar is undocked and invisible.
656 // We are doing a reset toolbars, so even the invisible undocked bars should
657 // be moved somewhere sensible. Put bar near center of window.
658 // If there were multiple hidden toobars the ndx * 10 adjustment means
659 // they won't overlap too much.
660 floater->CentreOnParent( );
661 floater->Move( floater->GetPosition() + wxSize( ndx * 10 - 200, ndx * 10 ));
662 bar->SetDocked( NULL, false );
663 Expose( ndx, false );
664 }
665
666 }
667 // TODO:??
668 // If audio was playing, we stopped the VU meters,
669 // It would be nice to show them again, but hardly essential as
670 // they will show up again on the next play.
671 // SetVUMeters(AudacityProject *p);
672 Updated();
673}
674
676{
677 for (const auto &bar : mBars) {
678 if (bar)
679 bar->RegenerateTooltips();
680 }
681}
682
683int ToolManager::FilterEvent(wxEvent &event)
684{
685 // Snoop the global event stream for changes of focused window. Remember
686 // the last one of our own that is not a grabber.
687
688 if (event.GetEventType() == wxEVT_KILL_FOCUS) {
689 auto &focusEvent = static_cast<wxFocusEvent&>(event);
690 auto window = focusEvent.GetWindow();
691 auto top = wxGetTopLevelParent(window);
692 if(auto toolFrame = dynamic_cast<ToolFrame*>(top))
693 top = toolFrame->GetParent();
694 // window is that which will GET the focus
695 if ( window &&
696 !dynamic_cast<Grabber*>( window ) &&
697 !dynamic_cast<ToolFrame*>( window ) &&
698 top == FindProjectFrame( mParent ) )
699 // Note this is a dangle-proof wxWindowRef:
700 mLastFocus = window;
701 }
702
703 return Event_Skip;
704}
705
706//
707// Read the toolbar states
708//
710{
711 wxString oldpath = gPrefs->GetPath();
712 std::vector<int> unordered[ DockCount ];
713 std::vector<ToolBar*> dockedAndHidden;
714 bool show[ ToolBarCount ];
715 int width[ ToolBarCount ];
716 int height[ ToolBarCount ];
717 int x, y;
718 int dock, ndx;
719 bool someFound { false };
720
721#if defined(__WXMAC__)
722 // Disable window animation
723 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
724#endif
725
726 // Change to the bar root
727 gPrefs->SetPath( wxT("/GUI/ToolBars") );
728
729 ToolBarConfiguration::Legacy topLegacy, botLegacy;
730
731 int vMajor, vMinor, vMicro;
732 gPrefs->GetVersionKeysInit(vMajor, vMinor, vMicro);
733 bool useLegacyDock = false;
734 // note that vMajor, vMinor, and vMicro will all be zero if either it's a new audacity.cfg file
735 // or the version is less than 1.3.13 (when there were no version keys according to the comments in
736 // InitPreferences()). So for new audacity.cfg
737 // file useLegacyDock will be true, but this doesn't matter as there are no Dock or DockV2 keys in the file yet.
738 if (vMajor <= 1 ||
739 (vMajor == 2 && (vMinor <= 1 || (vMinor == 2 && vMicro <= 1)))) // version <= 2.2.1
740 useLegacyDock = true;
741
742
743 // Load and apply settings for each bar
744 for( ndx = 0; ndx < ToolBarCount; ndx++ )
745 {
746 ToolBar *bar = mBars[ ndx ].get();
747 //wxPoint Center = mParent->GetPosition() + (mParent->GetSize() * 0.33);
748 //wxPoint Center(
749 // wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) /2 ,
750 // wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) /2 );
751
752 // Change to the bar subkey
753 gPrefs->SetPath( bar->GetSection() );
754
755 bool bShownByDefault = true;
756 int defaultDock = TopDockID;
757
758 if( ndx == SelectionBarID )
759 defaultDock = BotDockID;
760 if( ndx == MeterBarID )
761 bShownByDefault = false;
762 if( ndx == ScrubbingBarID )
763 bShownByDefault = false;
764 if( ndx == DeviceBarID )
765 bShownByDefault = false;
766 if( ndx == TimeBarID )
767 defaultDock = BotDockID;
768
769#ifdef EXPERIMENTAL_SPECTRAL_EDITING
770 if( ndx == SpectralSelectionBarID ){
771 defaultDock = BotDockID;
772 bShownByDefault = false; // Only show if asked for.
773 }
774#endif
775
776 // Read in all the settings
777
778 if (useLegacyDock)
779 gPrefs->Read( wxT("Dock"), &dock, -1); // legacy version of DockV2
780 else
781 gPrefs->Read( wxT("DockV2"), &dock, -1);
782
783 const bool found = (dock != -1);
784 if (found)
785 someFound = true;
786 if (!found)
787 dock = defaultDock;
788
789 ToolDock *d;
791 switch(dock)
792 {
793 case TopDockID: d = mTopDock; pLegacy = &topLegacy; break;
794 case BotDockID: d = mBotDock; pLegacy = &botLegacy; break;
795 default: d = nullptr; pLegacy = nullptr; break;
796 }
797
798 bool ordered = ToolBarConfiguration::Read(
799 d ? &d->GetConfiguration() : nullptr,
800 pLegacy,
801 bar, show[ ndx ], bShownByDefault)
802 && found;
803
804 gPrefs->Read( wxT("X"), &x, -1 );
805 gPrefs->Read( wxT("Y"), &y, -1 );
806 gPrefs->Read( wxT("W"), &width[ ndx ], -1 );
807 gPrefs->Read( wxT("H"), &height[ ndx ], -1 );
808
809 bar->SetVisible( show[ ndx ] );
810
811 // Docked or floating?
812 if( dock )
813 {
814 // Default to top dock if the ID isn't valid
815 if( dock < NoDockID || dock > DockCount ) {
816 dock = TopDockID;
817 }
818
819 // Create the bar with the correct parent
820 if( dock == TopDockID )
821 {
822 bar->Create( mTopDock );
823 }
824 else
825 {
826 bar->Create( mBotDock );
827 }
828
829 // Set the width and height
830 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
831 {
832 wxSize sz( width[ ndx ], height[ ndx ] );
833 bar->SetSize( sz );
834 bar->ResizingDone();
835 }
836
837#ifdef EXPERIMENTAL_SYNC_LOCK
838 // Set the width
839 if( width[ ndx ] >= bar->GetSize().x )
840 {
841 wxSize sz( width[ ndx ], bar->GetSize().y );
842 bar->SetSize( sz );
843 bar->Layout();
844 }
845#else
846 // note that this section is here because if you had been using sync-lock and now you aren't,
847 // the space for the extra button is stored in audacity.cfg, and so you get an extra space
848 // in the EditToolbar.
849 // It is needed so that the meterToolbar size gets preserved.
850 // Longer-term we should find a better fix for this.
851 wxString thisBar = bar->GetSection();
852 if( thisBar != wxT("Edit"))
853 {
854 // Set the width
855 if( width[ ndx ] >= bar->GetSize().x )
856 {
857 wxSize sz( width[ ndx ], bar->GetSize().y );
858 bar->SetSize( sz );
859 bar->Layout();
860 }
861 }
862#endif
863 // make a note of docked and hidden toolbars
864 if (!show[ndx])
865 dockedAndHidden.push_back(bar);
866
867 if (!ordered)
868 {
869 // These must go at the end
870 unordered[ dock - 1 ].push_back( ndx );
871 }
872 }
873 else
874 {
875 // Create the bar (with the top dock being temporary parent)
876 bar->Create( mTopDock );
877
878 // Construct a NEW floater
879 wxASSERT(mParent);
880 ToolFrame *f = safenew ToolFrame( mParent, this, bar, wxPoint( x, y ) );
881
882 // Set the width and height
883 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
884 {
885 wxSize sz( width[ ndx ], height[ ndx ] );
886 f->SetSizeHints( sz );
887 f->SetSize( sz );
888 f->Layout();
889 if( (x!=-1) && (y!=-1) )
890 bar->SetPositioned();
891 }
892
893 // Required on Linux Xfce
894 wxSize msz(width[ndx],height[ndx]-1);
895 bar->GetParent()->SetMinSize(msz);
896
897 // Inform toolbar of change
898 bar->SetDocked( NULL, false );
899
900 // Show or hide it
901 Expose( ndx, show[ ndx ] );
902 }
903
904 // Change back to the bar root
905 //gPrefs->SetPath( wxT("..") ); <-- Causes a warning...
906 // May or may not have gone into a subdirectory,
907 // so use an absolute path.
908 gPrefs->SetPath( wxT("/GUI/ToolBars") );
909 }
910
911 mTopDock->GetConfiguration().PostRead(topLegacy);
912 mBotDock->GetConfiguration().PostRead(botLegacy);
913
914 // Add all toolbars to their target dock
915 for( dock = 0; dock < DockCount; dock++ )
916 {
917 ToolDock *d = ( dock + 1 == TopDockID ? mTopDock : mBotDock );
918
919 d->LoadConfig();
920
921 // Add all unordered toolbars
922 for( int ord = 0; ord < (int) unordered[ dock ].size(); ord++ )
923 {
924 ToolBar *t = mBars[ unordered[ dock ][ ord ] ].get();
925
926 // Dock it
927 d->Dock( t, false );
928
929 // Show or hide the bar
930 Expose( t->GetId(), show[ t->GetId() ] );
931 }
932 }
933
934 // hidden docked toolbars
935 for (auto bar : dockedAndHidden) {
936 bar->SetVisible(false );
937 bar->GetDock()->Dock(bar, false);
938 bar->Expose(false);
939 }
940
941 // Restore original config path
942 gPrefs->SetPath( oldpath );
943
944#if defined(__WXMAC__)
945 // Reinstate original transition
946 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
947#endif
948
949 if (!someFound)
950 Reset();
951}
952
953//
954// Save the toolbar states
955//
957{
958 if( !gPrefs )
959 {
960 return;
961 }
962
963 wxString oldpath = gPrefs->GetPath();
964 int ndx;
965
966 // Change to the bar root
967 gPrefs->SetPath( wxT("/GUI/ToolBars") );
968
969 // Save state of each bar
970 for( ndx = 0; ndx < ToolBarCount; ndx++ )
971 {
972 ToolBar *bar = mBars[ ndx ].get();
973
974 // Change to the bar subkey
975 gPrefs->SetPath( bar->GetSection() );
976
977 // Search both docks for toolbar order
978 bool to = mTopDock->GetConfiguration().Contains( bar );
979 bool bo = mBotDock->GetConfiguration().Contains( bar );
980
981 // Save
982 // Note that DockV2 was introduced in 2.2.2 to fix bug #1554. Dock is retained so that
983 // the toolbar layout is not changed when opening a version before 2.2.2, and in particular
984 // its value is compatible with versions 2.1.3 to 2.2.1 which have this bug.
985 ToolDock* dock = bar->GetDock(); // dock for both shown and hidden toolbars
986 gPrefs->Write( wxT("DockV2"), static_cast<int>(dock == mTopDock ? TopDockID : dock == mBotDock ? BotDockID : NoDockID ));
987
988 gPrefs->Write( wxT("Dock"), static_cast<int>( to ? TopDockID : bo ? BotDockID : NoDockID));
989
990 dock = to ? mTopDock : bo ? mBotDock : nullptr; // dock for shown toolbars
992 (dock ? &dock->GetConfiguration() : nullptr, bar);
993
994 wxPoint pos( -1, -1 );
995 wxSize sz = bar->GetSize();
996 if( !bar->IsDocked() && bar->IsPositioned() )
997 {
998 pos = bar->GetParent()->GetPosition();
999 sz = bar->GetParent()->GetSize();
1000 }
1001 gPrefs->Write( wxT("X"), pos.x );
1002 gPrefs->Write( wxT("Y"), pos.y );
1003 gPrefs->Write( wxT("W"), sz.x );
1004 gPrefs->Write( wxT("H"), sz.y );
1005
1006 // Change back to the bar root
1007 gPrefs->SetPath( wxT("..") );
1008 }
1009
1010 // Restore original config path
1011 gPrefs->SetPath( oldpath );
1012 gPrefs->Flush();
1013}
1014
1015//
1016// Return a pointer to the specified toolbar
1017//
1019{
1020 return mBars[ type ].get();
1021}
1022
1023//
1024// Return a pointer to the top dock
1025//
1027{
1028 return mTopDock;
1029}
1030
1032{
1033 return mTopDock;
1034}
1035
1036//
1037// Return a pointer to the bottom dock
1038//
1040{
1041 return mBotDock;
1042}
1043
1045{
1046 return mBotDock;
1047}
1048
1049//
1050// Queues an EVT_TOOLBAR_UPDATED command event to notify any
1051// interest parties of an updated toolbar or dock layout
1052//
1054{
1055 // Queue an update event
1056 wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1057 GetProjectFrame( *mParent ).GetEventHandler()->AddPendingEvent( e );
1058}
1059
1060//
1061// Return docked state of specified toolbar
1062//
1064{
1065 return mBars[ type ]->IsDocked();
1066}
1067
1068//
1069// Returns the visibility of the specified toolbar
1070//
1072{
1073 ToolBar *t = mBars[ type ].get();
1074
1075 return t && t->IsVisible();
1076
1077#if 0
1078 // If toolbar is floating
1079 if( !t->IsDocked() )
1080 {
1081 // Must return state of floater window
1082 return t->GetParent()->IsShown();
1083 }
1084
1085 // Return state of docked toolbar
1086 return t->IsShown();
1087#endif
1088}
1089
1090//
1091// Toggles the visible/hidden state of a toolbar
1092//
1094{
1095 Expose( type, !mBars[ type ]->IsVisible() );
1096 Updated();
1097}
1098
1099//
1100// Set the visible/hidden state of a toolbar
1101//
1102void ToolManager::Expose( int type, bool show )
1103{
1104 ToolBar *t = mBars[ type ].get();
1105
1106 // Handle docked and floaters differently
1107 if( t->IsDocked() )
1108 {
1109 t->GetDock()->Expose( type, show );
1110 }
1111 else
1112 {
1113 t->Expose( show );
1114 }
1115}
1116
1117//
1118// Ask both docks to (re)layout their bars
1119//
1121{
1122 // Update the layout
1123 if (mTopDock)
1124 {
1126 }
1127
1128 if (mBotDock)
1129 {
1131 }
1132}
1133
1134//
1135// Handle toolbar dragging
1136//
1137void ToolManager::OnMouse( wxMouseEvent & event )
1138{
1139 // Go ahead and set the event to propagate
1140 event.Skip();
1141
1142 // Can't do anything if we're not dragging. This also prevents
1143 // us from intercepting events that don't belong to us from the
1144 // parent since we're Connect()ed to a couple.
1145 if( !mClicked )
1146 {
1147 return;
1148 }
1149
1150#if defined(__WXMAC__)
1151 // Disable window animation
1152 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1153#endif
1154
1155 // Retrieve the event position
1156 wxPoint pos =
1157 ( (wxWindow *)event.GetEventObject() )->ClientToScreen( event.GetPosition() ) - mDragOffset;
1158
1159
1160 if( !event.LeftIsDown() )
1161 {
1162 // Button was released...finish the drag
1163 // Transition the bar to a dock
1164 if (!mDidDrag) {
1165 if (mPrevDock)
1167 DoneDragging();
1168 return;
1169 }
1170 else if( mDragDock && !event.ShiftDown() )
1171 {
1172 // Trip over...everyone ashore that's going ashore...
1174 Updated();
1176
1177 // Done with the floater
1178 mDragWindow->Destroy();
1179 mDragWindow = nullptr;
1180 mDragBar->Refresh(false);
1181 }
1182 else
1183 {
1184 // Calling SetDocked() to force the grabber button to popup
1185 mDragBar->SetDocked( NULL, false );
1186 }
1187
1188 DoneDragging();
1189 }
1190 else if( event.Dragging() && pos != mLastPos )
1191 {
1192 if (!mDidDrag) {
1193 // Must set the bar afloat if it's currently docked
1194 mDidDrag = true;
1195 wxPoint mp = event.GetPosition();
1196 mp = GetProjectFrame( *mParent ).ClientToScreen(mp);
1197 if (!mDragWindow) {
1198 // We no longer have control
1199 if (mPrevDock)
1201 UndockBar(mp);
1202 // Rearrange the remaining toolbars before trying to re-insert this one.
1204 }
1205 }
1206
1207 // Make toolbar follow the mouse
1208 mDragWindow->Move( pos );
1209
1210 // Remember to prevent excessive movement
1211 mLastPos = pos;
1212
1213 // Calc the top dock hittest rectangle
1214 wxRect tr = mTopDock->GetRect();
1215 tr.SetBottom( tr.GetBottom() + 10 );
1216 tr.SetPosition( mTopDock->GetParent()->ClientToScreen( tr.GetPosition() ) );
1217
1218 // Calc the bottom dock hittest rectangle
1219 wxRect br = mBotDock->GetRect();
1220 br.SetTop( br.GetTop() - 10 );
1221 br.SetBottom( br.GetBottom() + 20 );
1222 br.SetPosition( mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
1223
1224
1225 // Add half the bar height. We could use the actual bar height, but that would be confusing as a
1226 // bar removed at a place might not dock back there if just let go.
1227 // Also add 5 pixels in horizontal direction, so that a click without a move (or a very small move)
1228 // lands back where we started.
1229 pos += wxPoint( 5, 20 );
1230
1231
1232 // To find which dock, rather than test against pos, test against the whole dragger rect.
1233 // This means it is enough to overlap the dock to dock with it.
1234 wxRect barRect = mDragWindow->GetRect();
1235 ToolDock *dock = NULL;
1236 if( tr.Intersects( barRect ) )
1237 dock = mTopDock;
1238 else if( br.Intersects( barRect ) )
1239 dock = mBotDock;
1240
1241 // Looks like we have a winner...
1242 if( dock )
1243 {
1244 wxPoint p;
1245 wxRect r;
1246
1247 // Calculate where the bar would be placed
1248 mDragBefore = dock->PositionBar( mDragBar, pos, r );
1249
1250 // If different than the last time, the indicator must be moved
1251 if( r != mBarPos )
1252 {
1253 wxRect dr = dock->GetRect();
1254
1255 // Hide the indicator before changing the shape
1256 mIndicator->Hide();
1257
1258 // Decide which direction the arrow should point
1259 if( r.GetTop() >= dr.GetHeight() )
1260 {
1261 const auto &box = mDown->GetBox();
1262 p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
1263 - (box.GetWidth() / 2);
1264 p.y = dr.GetBottom() - box.GetHeight();
1265 mCurrent = mDown.get();
1266 }
1267 else
1268 {
1269 // r is the rectangle of the toolbar being dragged.
1270 // A tall undocked toolbar will become at most 2 tbs
1271 // high when docked, so the triangular drop indicator
1272 // needs to use that height, h, not the bar height
1273 // for calculating where to be drawn.
1274 const int tbs = toolbarSingle + toolbarGap;
1275 int h = wxMin(r.GetHeight(), 2*tbs-1);
1276 p.x = dr.GetLeft() + r.GetLeft();
1277 p.y = dr.GetTop() + r.GetTop() +
1278 ( ( h - mLeft->GetBox().GetHeight() ) / 2 );
1279 mCurrent = mLeft.get();
1280 }
1281
1282 // Change the shape while hidden and then show it if okay
1283 mIndicator->SetShape( *mCurrent );
1284 if( !event.ShiftDown() )
1285 {
1286 mIndicator->Show();
1287 mIndicator->Update();
1288 }
1289
1290 // Move it into position
1291 // LL: Do this after the Show() since KDE doesn't move the window
1292 // if it's not shown. (Do it outside if the previous IF as well)
1293 mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
1294
1295 // Remember for next go round
1296 mBarPos = r;
1297 }
1298 }
1299 else
1300 {
1301 // Hide the indicator if it's still shown
1302 if( mBarPos.x != -1 )
1303 {
1304 // Hide any
1305 mIndicator->Hide();
1306 mBarPos.x = -1;
1307 mBarPos.y = -1;
1308 }
1309 }
1310
1311 // Remember to which dock the drag bar belongs.
1312 mDragDock = dock;
1313 }
1314
1315#if defined(__WXMAC__)
1316 // Reinstate original transition
1317 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1318#endif
1319}
1320
1321//
1322// Deal with NEW capture lost event
1323//
1324void ToolManager::OnCaptureLost( wxMouseCaptureLostEvent & event )
1325{
1326 // Can't do anything if we're not dragging. This also prevents
1327 // us from intercepting events that don't belong to us from the
1328 // parent since we're Connect()ed to a couple.
1329 if( !mDragWindow )
1330 {
1331 event.Skip();
1332 return;
1333 }
1334
1335 // Simulate button up
1336 wxMouseEvent e(wxEVT_LEFT_UP);
1337 e.SetEventObject(mParent);
1338 OnMouse(e);
1339}
1340
1341//
1342// Watch for shift key changes
1343//
1344void ToolManager::OnTimer( wxTimerEvent & event )
1345{
1346 // Go ahead and set the event to propagate
1347 event.Skip();
1348
1349 // Can't do anything if we're not dragging. This also prevents
1350 // us from intercepting events that don't belong to us from the
1351 // parent since we're Connect()ed to a couple.
1352 if( !mDragWindow )
1353 {
1354 return;
1355 }
1356
1357 bool state = wxGetKeyState( WXK_SHIFT );
1358 if( mLastState != state )
1359 {
1360 mLastState = state;
1361
1362#if defined(__WXMAC__)
1363 // Disable window animation
1364 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1365#endif
1366
1367 mIndicator->Show( !state );
1368
1369#if defined(__WXMAC__)
1370 // Disable window animation
1371 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1372#endif
1373 }
1374
1375 return;
1376}
1377
1378//
1379// Handle Indicator paint events
1380//
1381// Really only needed for the Mac since SetBackgroundColour()
1382// doesn't seem to work with shaped frames.
1383//
1384void ToolManager::OnIndicatorPaint( wxPaintEvent & event )
1385{
1386 // TODO: Better to use a bitmap than a triangular region.
1387 wxWindow *w = (wxWindow *)event.GetEventObject();
1388 wxPaintDC dc( w );
1389 // TODO: Better (faster) to use the existing spare brush.
1390 wxBrush brush( theTheme.Colour( clrTrackPanelText ) );
1391 dc.SetBackground( brush );
1392 dc.Clear();
1393}
1394
1395//
1396// Handle Indicator creation event
1397//
1398// Without this, the initial Indicator window will be a solid blue square
1399// until the next time it changes.
1400//
1401void ToolManager::OnIndicatorCreate( wxWindowCreateEvent & event )
1402{
1403#if defined(__WXGTK__)
1404 mIndicator->SetShape( *mCurrent );
1405#endif
1406 event.Skip();
1407}
1408
1409void ToolManager::UndockBar( wxPoint mp )
1410{
1411#if defined(__WXMAC__)
1412 // Disable window animation
1413 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1414#endif
1415
1416 // Adjust the starting position
1417 mp -= mDragOffset;
1418
1419 // Inform toolbar of change
1420 mDragBar->SetDocked( NULL, true );
1422
1423 // Construct a NEW floater
1424 wxASSERT(mParent);
1426 mDragWindow->SetLayoutDirection(wxLayout_LeftToRight);
1427 // Make sure the ferry is visible
1428 mDragWindow->Show();
1429
1430 // Notify parent of change
1431 Updated();
1432
1433#if defined(__WXMAC__)
1434 // Reinstate original transition
1435 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
1436#endif
1437}
1438
1439//
1440// Transition a toolbar from float to dragging
1441//
1443{
1444 // No need to propagate any further
1445 event.Skip( false );
1446
1447 if(event.IsEscaping())
1448 return HandleEscapeKey();
1449
1450 // Remember which bar we're dragging
1451 mDragBar = mBars[ event.GetId() ].get();
1452
1453 // Remember state, in case of ESCape key later
1454 if (mDragBar->IsDocked()) {
1455 mPrevDock = dynamic_cast<ToolDock*>(mDragBar->GetParent());
1456 wxASSERT(mPrevDock);
1459 }
1460 else
1461 mPrevPosition = mDragBar->GetParent()->GetPosition();
1462
1463 // Calculate the drag offset
1464 wxPoint mp = event.GetPosition();
1465 mDragOffset = mp -
1466 mDragBar->GetParent()->ClientToScreen( mDragBar->GetPosition() ) +
1467 wxPoint( 1, 1 );
1468
1469 mClicked = true;
1470 if( mPrevDock )
1471 {
1472 mDragWindow = nullptr;
1473 }
1474 else
1475 {
1476 mDragWindow = (ToolFrame *) mDragBar->GetParent();
1477 }
1478
1479 // We want all mouse events from this point on
1480 auto &window = GetProjectFrame( *mParent );
1481 if( !window.HasCapture() )
1482 window.CaptureMouse();
1483
1484 // Start monitoring shift key changes
1485 mLastState = wxGetKeyState( WXK_SHIFT );
1486 mTimer.Start( 100 );
1487}
1488
1489
1491{
1492 if (mDragBar) {
1493 if(mPrevDock) {
1494 // Sheriff John Stone,
1495 // Why don't you leave me alone?
1496 // Well, I feel so break up
1497 // I want to go home.
1499 mPrevDock->Dock( mDragBar, true, mPrevSlot );
1500 Updated();
1501
1502 // Done with the floater
1504 mDragWindow->Destroy();
1505 mDragWindow = nullptr;
1506 mDragBar->Refresh(false);
1507 }
1508 else {
1509 // Floater remains, and returns to where it begain
1510 auto parent = mDragBar->GetParent();
1511 parent->SetPosition(mPrevPosition);
1512 mDragBar->SetDocked(NULL, false);
1513 }
1514
1515 DoneDragging();
1516 }
1517}
1518
1520{
1521 // Done dragging - ensure grabber button isn't pushed
1522 if( mDragBar )
1523 {
1524 mDragBar->SetDocked( mDragBar->GetDock(), false );
1525 }
1526
1527 // Release capture
1528 auto &window = GetProjectFrame( *mParent );
1529 if( window.HasCapture() )
1530 {
1531 window.ReleaseMouse();
1532 }
1533
1534 // Hide the indicator
1535 mIndicator->Hide();
1536
1537 mDragWindow = NULL;
1538 mDragDock = NULL;
1539 mDragBar = NULL;
1540 mPrevDock = NULL;
1543 mLastPos.x = mBarPos.x = -1;
1544 mLastPos.y = mBarPos.y = -1;
1545 mTimer.Stop();
1546 mDidDrag = false;
1547 mClicked = false;
1548
1549 RestoreFocus();
1550}
1551
1553{
1554 if (mLastFocus) {
1555 auto temp1 = AButton::TemporarilyAllowFocus();
1556 auto temp2 = ASlider::TemporarilyAllowFocus();
1558 mLastFocus->SetFocus();
1559 return true;
1560 }
1561 return false;
1562}
1563
1564#include "../commands/CommandContext.h"
1565#include "../Menus.h"
1566
1568 ToolBarID id, const CommandID &name, const TranslatableString &label_in,
1569 const Registry::OrderingHint &hint,
1570 std::vector< ToolBarID > excludeIDs )
1571 : mId{ id }
1572 , mAttachedItem{
1573 Registry::Placement{ wxT("View/Other/Toolbars/Toolbars/Other"), hint },
1574 ( MenuTable::FinderScope(
1576 { return *this; } ),
1577 MenuTable::Command( name, label_in,
1581 auto &toolManager = ToolManager::Get( project );
1582 return toolManager.IsVisible( id ); } ) ) ) }
1583 , mExcludeIds{ std::move( excludeIDs ) }
1584{}
1585
1587{
1588 auto &project = context.project;
1589 auto &toolManager = ToolManager::Get( project );
1590
1591 if( !toolManager.IsVisible( mId ) )
1592 {
1593 for ( const auto excludedID : mExcludeIds )
1594 toolManager.Expose( excludedID, false );
1595 }
1596
1597 toolManager.ShowHide(mId);
1598 MenuManager::Get(project).ModifyToolbarMenus(project);
1599}
END_EVENT_TABLE()
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:35
wxEvtHandler CommandHandlerObject
static RegisteredToolbarFactory factory
const TranslatableString name
Definition: Distortion.cpp:82
#define EVT_GRABBER(id, fn)
Definition: Grabber.h:93
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
Definition: LabelDialog.cpp:92
#define safenew
Definition: MemoryX.h:10
FileConfig * gPrefs
Definition: Prefs.cpp:71
static ProjectFileIORegistry::AttributeWriterEntry entry
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
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 ...
accessors for certain important windows associated with each project
static const AttachedProjectObjects::RegisteredFactory manager
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define toolbarSingle
Definition: ToolBar.h:59
@ ToolBarFloatMargin
Definition: ToolBar.h:91
#define toolbarGap
Definition: ToolBar.h:64
ToolBarID
Definition: ToolBar.h:70
@ NoBarID
Definition: ToolBar.h:71
@ ScrubbingBarID
Definition: ToolBar.h:80
@ RecordMeterBarID
Definition: ToolBar.h:75
@ PlayMeterBarID
Definition: ToolBar.h:76
@ DeviceBarID
Definition: ToolBar.h:81
@ SelectionBarID
Definition: ToolBar.h:82
@ TranscriptionBarID
Definition: ToolBar.h:79
@ TimeBarID
Definition: ToolBar.h:86
@ TransportBarID
Definition: ToolBar.h:72
@ MeterBarID
Definition: ToolBar.h:74
@ MixerBarID
Definition: ToolBar.h:77
@ ToolsBarID
Definition: ToolBar.h:73
@ ToolBarCount
Definition: ToolBar.h:87
@ EditBarID
Definition: ToolBar.h:78
@ BotDockID
Definition: ToolDock.h:43
@ DockCount
Definition: ToolDock.h:44
@ TopDockID
Definition: ToolDock.h:42
@ NoDockID
Definition: ToolDock.h:41
static const AudacityProject::AttachedObjects::RegisteredFactory key
Methods for ToolManager.
#define sizerW
Methods for ToolFrame.
Definition: ToolManager.cpp:69
IMPLEMENT_CLASS(ToolFrame, wxFrame)
static struct DefaultConfigEntry DefaultConfigTable[]
int id
static TempAllowFocus TemporarilyAllowFocus()
Definition: AButton.cpp:636
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1791
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
void GetVersionKeysInit(int &major, int &minor, int &micro) const
Definition: FileConfig.h:56
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
virtual const wxString & GetPath() const wxOVERRIDE
Definition: FileConfig.cpp:98
virtual void SetPath(const wxString &strPath) wxOVERRIDE
Definition: FileConfig.cpp:93
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
Grabber Class.
Definition: Grabber.h:48
bool IsEscaping() const
Definition: Grabber.h:74
The widget to the left of a ToolBar that allows it to be dragged around to NEW positions.
Definition: Grabber.h:103
static void ModifyToolbarMenus(AudacityProject &project)
Definition: Menus.cpp:600
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:71
static TempAllowFocus TemporarilyAllowFocus()
wxColour & Colour(int iIndex)
static bool Read(ToolBarConfiguration *pConfiguration, Legacy *pLegacy, ToolBar *bar, bool &visible, bool defaultVisible)
Definition: ToolDock.cpp:255
static const Position UnspecifiedPosition
Definition: ToolDock.h:105
bool Contains(const ToolBar *bar) const
Definition: ToolDock.h:233
static void Write(const ToolBarConfiguration *pConfiguration, const ToolBar *bar)
Definition: ToolDock.cpp:331
void PostRead(Legacy &legacy)
Definition: ToolDock.cpp:310
Position Find(const ToolBar *bar) const
Definition: ToolDock.cpp:89
void Remove(const ToolBar *bar)
Definition: ToolDock.cpp:212
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:98
virtual void EnableDisableButtons()=0
bool IsDocked() const
Definition: ToolBar.cpp:423
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:638
virtual void ReCreateButtons()
Definition: ToolBar.cpp:516
void SetVisible(bool bVisible)
Definition: ToolBar.cpp:436
bool IsResizable() const
Definition: ToolBar.cpp:415
wxString GetSection()
Definition: ToolBar.cpp:382
virtual void ResizingDone()
Definition: ToolBar.h:186
ToolDock * GetDock()
Definition: ToolBar.cpp:630
bool IsPositioned()
Definition: ToolBar.h:137
void SetPositioned()
Definition: ToolBar.h:139
bool IsVisible() const
Definition: ToolBar.cpp:431
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:444
virtual void SetToDefaultSize()
Definition: ToolBar.cpp:496
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:475
virtual wxSize GetDockedSize()
Definition: ToolBar.h:145
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
void Undock(ToolBar *bar)
Definition: ToolDock.cpp:403
void RestoreConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:824
void LoadConfig()
Definition: ToolDock.cpp:443
void WrapConfiguration(ToolBarConfiguration &backup)
Definition: ToolDock.cpp:817
void Expose(int type, bool show)
Definition: ToolDock.cpp:834
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:309
ToolBarConfiguration::Position PositionBar(ToolBar *t, const wxPoint &pos, wxRect &rect)
Definition: ToolDock.cpp:720
void LayoutToolBars()
Definition: ToolDock.cpp:663
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:415
class ToolFrame
Definition: ToolManager.h:168
ToolFrame(AudacityProject *parent, ToolManager *manager, ToolBar *bar, wxPoint pos)
Definition: ToolManager.cpp:75
wxSize mOrigSize
Definition: ToolManager.h:214
ToolBar * mBar
Definition: ToolManager.h:212
void OnMotion(wxMouseEvent &event)
wxSize mMinSize
Definition: ToolManager.h:213
ToolManager * mManager
Definition: ToolManager.h:211
void Resize(const wxSize &size)
void OnClose(wxCloseEvent &event)
void OnGrabber(GrabberEvent &event)
void OnPaint(wxPaintEvent &WXUNUSED(event))
void OnCaptureLost(wxMouseCaptureLostEvent &WXUNUSED(event))
void LockInMinSize(ToolBar *pBar)
void ClearBar()
Definition: ToolManager.h:176
void OnToolBarUpdate(wxCommandEvent &event)
void OnKeyDown(wxKeyEvent &event)
class ToolManager
Definition: ToolManager.h:55
static ToolManager & Get(AudacityProject &project)
void OnIndicatorCreate(wxWindowCreateEvent &event)
bool mLastState
Definition: ToolManager.h:137
ToolDock * GetBotDock()
ToolBar * mDragBar
Definition: ToolManager.h:124
static void OnResetToolBars(const CommandContext &context)
void OnGrabber(GrabberEvent &event)
void ReadConfig()
void OnCaptureLost(wxMouseCaptureLostEvent &event)
ToolDock * mTopDock
Definition: ToolManager.h:143
void OnTimer(wxTimerEvent &event)
bool mTransition
Definition: ToolManager.h:140
void CreateWindows()
wxPoint mPrevPosition
Definition: ToolManager.h:148
wxTimer mTimer
Definition: ToolManager.h:136
ToolDock * GetTopDock()
ToolFrame * mDragWindow
Definition: ToolManager.h:122
void WriteConfig()
int FilterEvent(wxEvent &event) override
std::unique_ptr< wxRegion > mLeft
Definition: ToolManager.h:133
void RegenerateTooltips()
void UndockBar(wxPoint mp)
void LayoutToolBars()
void ShowHide(int type)
void Expose(int type, bool show)
void Destroy()
bool IsDocked(int type)
AudacityProject * mParent
Definition: ToolManager.h:119
void OnIndicatorPaint(wxPaintEvent &event)
void HandleEscapeKey()
ToolBarConfiguration mPrevConfiguration
Definition: ToolManager.h:152
std::unique_ptr< wxRegion > mDown
Definition: ToolManager.h:133
ToolDock * mPrevDock
Definition: ToolManager.h:149
ToolBarConfiguration::Position mPrevSlot
Definition: ToolManager.h:151
ToolBar::Holder mBars[ToolBarCount]
Definition: ToolManager.h:146
void DoneDragging()
bool IsVisible(int type)
ToolDock * mDragDock
Definition: ToolManager.h:123
void OnMouse(wxMouseEvent &event)
ToolBarConfiguration::Position mDragBefore
Definition: ToolManager.h:126
bool RestoreFocus()
Destroy_ptr< wxFrame > FramePtr
Definition: ToolManager.h:131
ToolBar * GetToolBar(int type) const
wxRegion * mCurrent
Definition: ToolManager.h:134
wxRect mBarPos
Definition: ToolManager.h:129
ToolDock * mBotDock
Definition: ToolManager.h:144
wxWindowRef mLastFocus
Definition: ToolManager.h:120
ToolManager(AudacityProject *parent)
wxPoint mDragOffset
Definition: ToolManager.h:125
FramePtr mIndicator
Definition: ToolManager.h:132
wxPoint mLastPos
Definition: ToolManager.h:128
Holds a msgid for the translation catalog; may also bind format arguments.
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
Definition: Menus.h:36
const ToolBarID mId
Definition: ToolManager.h:235
void OnShowToolBar(const CommandContext &context)
AttachedToolBarMenuItem(ToolBarID id, const CommandID &name, const TranslatableString &label_in, const Registry::OrderingHint &hint={}, std::vector< ToolBarID > excludeIds={})
const std::vector< ToolBarID > mExcludeIds
Definition: ToolManager.h:237
Options && CheckTest(const CheckFn &fn) &&
int barID
int rightOf
int below
static const Functions & GetFactories()
Definition: ToolBar.cpp:977