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"), {}, {} },
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 ) &&
720 std::vector<Identifier> unordered[
DockCount ];
721 std::vector<ToolBar*> dockedAndHidden;
722 std::map<Identifier, bool> show;
723 std::map<Identifier, int> width;
724 std::map<Identifier, int> height;
727 bool someFound {
false };
729#if defined(__WXMAC__)
731 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
739 int vMajor, vMinor, vMicro;
741 bool useLegacyDock =
false;
747 (vMajor == 2 && (vMinor <= 1 || (vMinor == 2 && vMicro <= 1))))
748 useLegacyDock =
true;
772 const bool found = (dock != -1);
784 default: d =
nullptr; pLegacy =
nullptr;
break;
790 bar, show[ ndx ], bShownByDefault)
804 if( dock < NoDockID || dock >
DockCount ) {
819 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
821 wxSize sz( width[ ndx ], height[ ndx ] );
827 if( width[ ndx ] >= bar->GetSize().x )
829 wxSize sz( width[ ndx ], bar->GetSize().y );
836 dockedAndHidden.push_back(bar);
841 unordered[ dock - 1 ].push_back( ndx );
854 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
856 wxSize sz( width[ ndx ], height[ ndx ] );
857 f->SetSizeHints( sz );
860 if( (x!=-1) && (y!=-1) )
865 wxSize msz(width[ndx],height[ndx]-1);
866 bar->GetParent()->SetMinSize(msz);
880 for( dock = 0; dock <
DockCount; dock++ )
887 for(
int ord = 0; ord < (int) unordered[ dock ].
size(); ord++ )
900 for (
auto bar : dockedAndHidden) {
906 toolbarsGroup.Reset();
908#if defined(__WXMAC__)
910 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
918 const auto &ndx =
entry.barID;
959 (dock ? &dock->GetConfiguration() :
nullptr, bar);
961 wxPoint pos( -1, -1 );
962 wxSize sz = bar->GetSize();
965 pos = bar->GetParent()->GetPosition();
966 sz = bar->GetParent()->GetSize();
982 return (iter ==
end) ? nullptr : iter->second.get();
1018 wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1028 return pBar->IsDocked();
1038 return pBar->IsVisible();
1043 if( !t->IsDocked() )
1046 return t->GetParent()->IsShown();
1050 return t->IsShown();
1114#if defined(__WXMAC__)
1116 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1121 ( (wxWindow *)event.GetEventObject() )->ClientToScreen( event.GetPosition() ) -
mDragOffset;
1124 if( !event.LeftIsDown() )
1134 else if(
mDragDock && !event.ShiftDown() )
1154 else if( event.Dragging() && pos !=
mLastPos )
1159 wxPoint mp =
event.GetPosition();
1179 tr.SetBottom( tr.GetBottom() + 10 );
1180 tr.SetPosition(
mTopDock->GetParent()->ClientToScreen( tr.GetPosition() ) );
1184 br.SetTop( br.GetTop() - 10 );
1185 br.SetBottom( br.GetBottom() + 20 );
1186 br.SetPosition(
mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
1193 pos += wxPoint( 5, 20 );
1200 if( tr.Intersects( barRect ) )
1202 else if( br.Intersects( barRect ) )
1217 wxRect dr = dock->GetRect();
1223 if( r.GetTop() >= dr.GetHeight() )
1225 const auto &box =
mDown->GetBox();
1226 p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
1227 - (box.GetWidth() / 2);
1228 p.y = dr.GetBottom() - box.GetHeight();
1239 int h = wxMin(r.GetHeight(), 2*tbs-1);
1240 p.x = dr.GetLeft() + r.GetLeft();
1241 p.y = dr.GetTop() + r.GetTop() +
1242 ( ( h -
mLeft->GetBox().GetHeight() ) / 2 );
1248 if( !event.ShiftDown() )
1257 mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
1279#if defined(__WXMAC__)
1281 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1300 wxMouseEvent e(wxEVT_LEFT_UP);
1326 bool state = wxGetKeyState( WXK_SHIFT );
1331#if defined(__WXMAC__)
1333 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1338#if defined(__WXMAC__)
1340 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1356 wxWindow *w = (wxWindow *)event.GetEventObject();
1360 dc.SetBackground( brush );
1372#if defined(__WXGTK__)
1380#if defined(__WXMAC__)
1382 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1395 mDragWindow->SetLayoutDirection(wxLayout_LeftToRight);
1402#if defined(__WXMAC__)
1404 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1414 event.Skip(
false );
1433 wxPoint mp =
event.GetPosition();
1450 if( !window.HasCapture() )
1451 window.CaptureMouse();
1479 auto parent =
mDragBar->GetParent();
1498 if( window.HasCapture() )
1500 window.ReleaseMouse();
1541#include "../commands/CommandManager.h"
1549 toolManager.ForEach([](
auto bar){
1551 bar->EnableDisableButtons();
1565 std::vector< Identifier > excludeIDs
1568 Registry::Placement{
wxT(
"View/Other/Toolbars/Toolbars/Other"), hint },
1571 {
return *
this; } ),
1577 return toolManager.IsVisible(
id ); } ) ) ) }
1578 , mExcludeIds{ std::move( excludeIDs ) }
1586 if( !toolManager.IsVisible(
mId ) )
1589 toolManager.Expose( excludedID,
false );
1592 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
audacity::BasicSettings * gPrefs
void GetPreferencesVersion(int &vMajor, int &vMinor, int &vMicro)
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)
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.
virtual bool Flush() noexcept=0
GroupScope BeginGroup(const wxString &prefix)
Appends a prefix to the current group or sets a new absolute path. Group that was set as current befo...
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
static RegisteredToolbarFactory factory
Options && CheckTest(const CheckFn &fn) &&