30#include "../commands/CommandContext.h"
36#include <wx/dcclient.h>
41#include <wx/settings.h>
48#include <wx/minifram.h>
49#include <wx/popupwin.h>
81#if !defined(__WXMAC__)
84 wxFRAME_FLOAT_ON_PARENT )
87 int width = bar->GetSize().x;
108 auto s = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
111 s->Add(bar, 1, wxEXPAND | wxALL, border);
124 SetSizer(s.release());
136 mMinSize = bar->GetMinSize() + ( GetSize() - bar->GetSize() );
158 wxSize sz =
mBar->GetSize();
160 int yDesiredMin = 26;
161 int y = sz.GetHeight();
162 if (y > yDesiredMin) {
163 sz.SetWidth((sz.GetWidth() * yDesiredMin) / y);
164 sz.SetHeight( yDesiredMin );
174 mBar->GetParent()->SetClientSize(
mBar->GetSize() );
182 wxPaintDC dc(
this );
183 wxSize sz = GetSize();
189 dc.SetBrush( *wxTRANSPARENT_BRUSH );
190 dc.DrawRectangle( 0, 0, sz.GetWidth(), sz.GetHeight() );
199 AColor::Line(dc, r.GetLeft(), r.GetBottom(), r.GetRight(), r.GetTop() );
200 AColor::Line(dc, r.GetLeft() + 3, r.GetBottom(), r.GetRight(), r.GetTop() + 3 );
201 AColor::Line(dc, r.GetLeft() + 6, r.GetBottom(), r.GetRight(), r.GetTop() + 6 );
202 AColor::Line(dc, r.GetLeft() + 9, r.GetBottom(), r.GetRight(), r.GetTop() + 9 );
216 wxPoint pos = ClientToScreen( event.GetPosition() );
217 if( HasCapture() && event.Dragging() )
219 wxRect rect = GetRect();
221 rect.SetBottomRight( pos );
224 wxSize maxsz =
mBar->GetMaxSize();
225 if (maxsz != wxDefaultSize)
227 if (maxsz.x != wxDefaultCoord && rect.width > maxsz.x)
229 rect.width = maxsz.x;
231 if (maxsz.y != wxDefaultCoord && rect.height > maxsz.y)
233 rect.height = maxsz.y;
249 else if( HasCapture() && event.LeftUp() )
253 else if( !HasCapture() )
255 wxRect rect = GetRect();
258 r.x = rect.GetRight() -
sizerW - 2,
259 r.y = rect.GetBottom() -
sizerW - 2;
264 if( r.Contains( pos ) && !event.Leaving() )
268 SetCursor( wxCURSOR_SIZENWSE );
269 if( event.LeftDown() )
276 SetCursor( wxCURSOR_ARROW );
297 if( HasCapture() && event.GetKeyCode() == WXK_ESCAPE ) {
336 return std::make_shared< ToolManager >( &parent ); }
357#if defined(__WXMAC__)
359 mTransition = wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION );
379 mDown = std::make_unique<wxRegion>( 3, &pt[0] );
390 mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
399 wxFRAME_TOOL_WINDOW |
427 window.Bind( wxEVT_LEFT_UP,
430 window.Bind( wxEVT_MOTION,
433 window.Bind( wxEVT_MOUSE_CAPTURE_LOST,
438 wxASSERT(topDockParent);
452 auto &slot =
mBars[bar->GetSection()];
459 slot = std::move(bar);
475 wxEvtHandler::AddFilter(
this);
488 wxEvtHandler::RemoveFilter(
this);
502 for (
auto &pair :
mBars)
530 {
wxT(
"Control"), {}, {} },
531 {
wxT(
"Tools"),
wxT(
"Control"), {} },
532 {
wxT(
"Edit"),
wxT(
"Tools"), {} },
533 {
wxT(
"CutCopyPaste"),
wxT(
"Edit"), {} },
534 {
wxT(
"Audio Setup"),
wxT(
"CutCopyPaste"), {} },
535#ifdef HAS_AUDIOCOM_UPLOAD
536 {
wxT(
"Share Audio"),
wxT(
"Audio Setup"), {} },
537 {
wxT(
"RecordMeter"),
wxT(
"Share Audio"), {} },
539 {
wxT(
"RecordMeter"),
wxT(
"Audio Setup"), {} },
541 {
wxT(
"PlayMeter"),
wxT(
"RecordMeter"), {} },
544 {
wxT(
"Scrub"), {},
wxT(
"Control") },
545 {
wxT(
"Device"),
wxT(
"Scrub"),
wxT(
"Control") },
548 {
wxT(
"CombinedMeter"), {}, {} },
551 {
wxT(
"TimeSignature"), {}, {}, },
552 {
wxT(
"Snapping"),
wxT(
"TimeSignature"), {}, },
553 {
wxT(
"Time"),
wxT(
"Snapping"), {} },
554 {
wxT(
"Selection"),
wxT(
"Time"), {} },
557#ifdef EXPERIMENTAL_DA
558 {
wxT(
"Transcription"), {}, {} },
560 {
wxT(
"Transcription"),
wxT(
"Selection"), {} },
564 {
wxT(
"SpectralSelection"), {}, {} },
570 auto &project = context.
project;
583 const auto &ndx =
entry.barID;
593 bar->SetSize( 20,20 );
607 floater = bar->GetParent();
616 bar->Reparent( dock );
629 bar->SetSize(bar->GetBestFittingSize());
641 dock->
Dock( bar,
false, position );
652 if( floater == NULL ) {
655 bar->Reparent( floater );
663 floater->CentreOnParent( );
666 floater->GetPosition() + wxSize{ index * 10 - 200, index * 10 });
673 if (bar && bar->HideAfterReset())
674 Expose(bar->GetSection(),
false);
688 bar->RegenerateTooltips();
697 if (event.GetEventType() == wxEVT_KILL_FOCUS) {
698 auto &focusEvent =
static_cast<wxFocusEvent&
>(event);
699 auto window = focusEvent.GetWindow();
700 auto top = wxGetTopLevelParent(window);
701 if(
auto toolFrame =
dynamic_cast<ToolFrame*
>(top))
702 top = toolFrame->GetParent();
705 !
dynamic_cast<Grabber*
>( window ) &&
721 std::vector<Identifier> unordered[
DockCount ];
722 std::vector<ToolBar*> dockedAndHidden;
723 std::map<Identifier, bool> show;
724 std::map<Identifier, int> width;
725 std::map<Identifier, int> height;
728 bool someFound {
false };
730#if defined(__WXMAC__)
732 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
740 int vMajor, vMinor, vMicro;
742 bool useLegacyDock =
false;
748 (vMajor == 2 && (vMinor <= 1 || (vMinor == 2 && vMicro <= 1))))
749 useLegacyDock =
true;
773 const bool found = (dock != -1);
785 default: d =
nullptr; pLegacy =
nullptr;
break;
791 bar, show[ ndx ], bShownByDefault)
796 gPrefs->Read(
wxT(
"W"), &width[ ndx ], -1 );
797 gPrefs->Read(
wxT(
"H"), &height[ ndx ], -1 );
805 if( dock < NoDockID || dock >
DockCount ) {
820 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
822 wxSize sz( width[ ndx ], height[ ndx ] );
828 if( width[ ndx ] >= bar->GetSize().x )
830 wxSize sz( width[ ndx ], bar->GetSize().y );
837 dockedAndHidden.push_back(bar);
842 unordered[ dock - 1 ].push_back( ndx );
855 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
857 wxSize sz( width[ ndx ], height[ ndx ] );
858 f->SetSizeHints( sz );
861 if( (x!=-1) && (y!=-1) )
866 wxSize msz(width[ndx],height[ndx]-1);
867 bar->GetParent()->SetMinSize(msz);
887 for( dock = 0; dock <
DockCount; dock++ )
894 for(
int ord = 0; ord < (int) unordered[ dock ].
size(); ord++ )
907 for (
auto bar : dockedAndHidden) {
916#if defined(__WXMAC__)
918 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
926 const auto &ndx =
entry.barID;
971 (dock ? &dock->GetConfiguration() :
nullptr, bar);
973 wxPoint pos( -1, -1 );
974 wxSize sz = bar->GetSize();
977 pos = bar->GetParent()->GetPosition();
978 sz = bar->GetParent()->GetSize();
1000 return (iter ==
end) ? nullptr : iter->second.get();
1036 wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1046 return pBar->IsDocked();
1056 return pBar->IsVisible();
1061 if( !t->IsDocked() )
1064 return t->GetParent()->IsShown();
1068 return t->IsShown();
1132#if defined(__WXMAC__)
1134 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1139 ( (wxWindow *)event.GetEventObject() )->ClientToScreen( event.GetPosition() ) -
mDragOffset;
1142 if( !event.LeftIsDown() )
1152 else if(
mDragDock && !event.ShiftDown() )
1172 else if( event.Dragging() && pos !=
mLastPos )
1177 wxPoint mp =
event.GetPosition();
1197 tr.SetBottom( tr.GetBottom() + 10 );
1198 tr.SetPosition(
mTopDock->GetParent()->ClientToScreen( tr.GetPosition() ) );
1202 br.SetTop( br.GetTop() - 10 );
1203 br.SetBottom( br.GetBottom() + 20 );
1204 br.SetPosition(
mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
1211 pos += wxPoint( 5, 20 );
1218 if( tr.Intersects( barRect ) )
1220 else if( br.Intersects( barRect ) )
1235 wxRect dr = dock->GetRect();
1241 if( r.GetTop() >= dr.GetHeight() )
1243 const auto &box =
mDown->GetBox();
1244 p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
1245 - (box.GetWidth() / 2);
1246 p.y = dr.GetBottom() - box.GetHeight();
1257 int h = wxMin(r.GetHeight(), 2*tbs-1);
1258 p.x = dr.GetLeft() + r.GetLeft();
1259 p.y = dr.GetTop() + r.GetTop() +
1260 ( ( h -
mLeft->GetBox().GetHeight() ) / 2 );
1266 if( !event.ShiftDown() )
1275 mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
1297#if defined(__WXMAC__)
1299 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1318 wxMouseEvent e(wxEVT_LEFT_UP);
1344 bool state = wxGetKeyState( WXK_SHIFT );
1349#if defined(__WXMAC__)
1351 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1356#if defined(__WXMAC__)
1358 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1374 wxWindow *w = (wxWindow *)event.GetEventObject();
1378 dc.SetBackground( brush );
1390#if defined(__WXGTK__)
1398#if defined(__WXMAC__)
1400 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1413 mDragWindow->SetLayoutDirection(wxLayout_LeftToRight);
1420#if defined(__WXMAC__)
1422 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1432 event.Skip(
false );
1451 wxPoint mp =
event.GetPosition();
1468 if( !window.HasCapture() )
1469 window.CaptureMouse();
1497 auto parent =
mDragBar->GetParent();
1516 if( window.HasCapture() )
1518 window.ReleaseMouse();
1554 auto &project = *pProject;
1559#include "../commands/CommandManager.h"
1567 toolManager.ForEach([](
auto bar){
1569 bar->EnableDisableButtons();
1583 std::vector< Identifier > excludeIDs
1586 Registry::Placement{
wxT(
"View/Other/Toolbars/Toolbars/Other"), hint },
1589 {
return *
this; } ),
1595 return toolManager.IsVisible(
id ); } ) ) ) }
1596 , mExcludeIds{ std::move( excludeIDs ) }
1601 auto &project = context.
project;
1604 if( !toolManager.IsVisible(
mId ) )
1607 toolManager.Expose( excludedID,
false );
1610 toolManager.ShowHide(
mId);
constexpr CommandFlag AlwaysEnabledFlag
wxEvtHandler CommandHandlerObject
const TranslatableString name
#define EVT_GRABBER(id, fn)
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
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
BoolSetting SyncLockTracks
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
static TempAllowFocus TemporarilyAllowFocus()
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
void UpdateCheckmarks(AudacityProject &project)
static CommandManager & Get(AudacityProject &project)
void GetVersionKeysInit(int &major, int &minor, int µ) const
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
virtual const wxString & GetPath() const wxOVERRIDE
virtual void SetPath(const wxString &strPath) wxOVERRIDE
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
The widget to the left of a ToolBar that allows it to be dragged around to NEW positions.
An explicitly nonlocalized string, not meant for the user to see.
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
static TempAllowFocus TemporarilyAllowFocus()
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
void SetSyncLock(bool flag)
static SyncLockState & Get(AudacityProject &project)
wxColour & Colour(int iIndex)
Holds a msgid for the translation catalog; may also bind format arguments.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
static RegisteredToolbarFactory factory
Options && CheckTest(const CheckFn &fn) &&