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"), {} },
538 {
wxT(
"PlayMeter"),
wxT(
"Share Audio"),
wxT(
"RecordMeter"),
541 {
wxT(
"RecordMeter"),
wxT(
"Audio Setup"), {} },
542 {
wxT(
"PlayMeter"),
wxT(
"Audio Setup"),
wxT(
"RecordMeter"),
547 {
wxT(
"Device"), {},
wxT(
"Control") },
550 {
wxT(
"CombinedMeter"), {}, {} },
553 {
wxT(
"TimeSignature"), {}, {}, },
554 {
wxT(
"Snapping"),
wxT(
"TimeSignature"), {}, },
555 {
wxT(
"Time"),
wxT(
"Snapping"), {} },
556 {
wxT(
"Selection"),
wxT(
"Time"), {} },
558 {
wxT(
"Transcription"),
wxT(
"Selection"), {} },
562 {
wxT(
"SpectralSelection"), {}, {} },
581 const auto &ndx =
entry.barID;
591 bar->SetSize( 20,20 );
605 floater = bar->GetParent();
614 bar->Reparent( dock );
627 bar->SetSize(bar->GetBestFittingSize());
639 dock->
Dock( bar,
false, position );
650 if( floater == NULL ) {
653 bar->Reparent( floater );
661 floater->CentreOnParent( );
664 floater->GetPosition() + wxSize{ index * 10 - 200, index * 10 });
671 if (bar && bar->HideAfterReset())
672 Expose(bar->GetSection(),
false);
686 bar->RegenerateTooltips();
695 if (event.GetEventType() == wxEVT_KILL_FOCUS) {
696 auto &focusEvent =
static_cast<wxFocusEvent&
>(event);
697 auto window = focusEvent.GetWindow();
698 auto top = wxGetTopLevelParent(window);
699 if(
auto toolFrame =
dynamic_cast<ToolFrame*
>(top))
700 top = toolFrame->GetParent();
703 !
dynamic_cast<Grabber*
>( window ) &&
718 std::vector<Identifier> unordered[
DockCount ];
719 std::vector<ToolBar*> dockedAndHidden;
720 std::map<Identifier, bool> show;
721 std::map<Identifier, int> width;
722 std::map<Identifier, int> height;
725 bool someFound {
false };
727#if defined(__WXMAC__)
729 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
737 int vMajor, vMinor, vMicro;
739 bool useLegacyDock =
false;
745 (vMajor == 2 && (vMinor <= 1 || (vMinor == 2 && vMicro <= 1))))
746 useLegacyDock =
true;
770 const bool found = (dock != -1);
782 default: d =
nullptr; pLegacy =
nullptr;
break;
788 bar, show[ ndx ], bShownByDefault)
802 if( dock < NoDockID || dock >
DockCount ) {
817 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
819 wxSize sz( width[ ndx ], height[ ndx ] );
825 if( width[ ndx ] >= bar->GetSize().x )
827 wxSize sz( width[ ndx ], bar->GetSize().y );
834 dockedAndHidden.push_back(bar);
839 unordered[ dock - 1 ].push_back( ndx );
852 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
854 wxSize sz( width[ ndx ], height[ ndx ] );
855 f->SetSizeHints( sz );
858 if( (x!=-1) && (y!=-1) )
863 wxSize msz(width[ndx],height[ndx]-1);
864 bar->GetParent()->SetMinSize(msz);
878 for( dock = 0; dock <
DockCount; dock++ )
885 for(
int ord = 0; ord < (int) unordered[ dock ].
size(); ord++ )
898 for (
auto bar : dockedAndHidden) {
904 toolbarsGroup.Reset();
906#if defined(__WXMAC__)
908 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
916 const auto &ndx =
entry.barID;
958 (dock ? &dock->GetConfiguration() :
nullptr, bar);
960 wxPoint pos( -1, -1 );
961 wxSize sz = bar->GetSize();
964 pos = bar->GetParent()->GetPosition();
965 sz = bar->GetParent()->GetSize();
981 return (iter ==
end) ? nullptr : iter->second.get();
1017 wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1027 return pBar->IsDocked();
1037 return pBar->IsVisible();
1042 if( !t->IsDocked() )
1045 return t->GetParent()->IsShown();
1049 return t->IsShown();
1113#if defined(__WXMAC__)
1115 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1120 ( (wxWindow *)event.GetEventObject() )->ClientToScreen( event.GetPosition() ) -
mDragOffset;
1123 if( !event.LeftIsDown() )
1133 else if(
mDragDock && !event.ShiftDown() )
1153 else if( event.Dragging() && pos !=
mLastPos )
1158 wxPoint mp =
event.GetPosition();
1178 tr.SetBottom( tr.GetBottom() + 10 );
1179 tr.SetPosition(
mTopDock->GetParent()->ClientToScreen( tr.GetPosition() ) );
1183 br.SetTop( br.GetTop() - 10 );
1184 br.SetBottom( br.GetBottom() + 20 );
1185 br.SetPosition(
mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
1192 pos += wxPoint( 5, 20 );
1199 if( tr.Intersects( barRect ) )
1201 else if( br.Intersects( barRect ) )
1216 wxRect dr = dock->GetRect();
1222 if( r.GetTop() >= dr.GetHeight() )
1224 const auto &box =
mDown->GetBox();
1225 p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
1226 - (box.GetWidth() / 2);
1227 p.y = dr.GetBottom() - box.GetHeight();
1238 int h = wxMin(r.GetHeight(), 2*tbs-1);
1239 p.x = dr.GetLeft() + r.GetLeft();
1240 p.y = dr.GetTop() + r.GetTop() +
1241 ( ( h -
mLeft->GetBox().GetHeight() ) / 2 );
1247 if( !event.ShiftDown() )
1256 mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
1278#if defined(__WXMAC__)
1280 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1299 wxMouseEvent e(wxEVT_LEFT_UP);
1325 bool state = wxGetKeyState( WXK_SHIFT );
1330#if defined(__WXMAC__)
1332 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1337#if defined(__WXMAC__)
1339 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1355 wxWindow *w = (wxWindow *)event.GetEventObject();
1359 dc.SetBackground( brush );
1371#if defined(__WXGTK__)
1379#if defined(__WXMAC__)
1381 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1394 mDragWindow->SetLayoutDirection(wxLayout_LeftToRight);
1401#if defined(__WXMAC__)
1403 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1413 event.Skip(
false );
1432 wxPoint mp =
event.GetPosition();
1449 if( !window.HasCapture() )
1450 window.CaptureMouse();
1478 auto parent =
mDragBar->GetParent();
1497 if( window.HasCapture() )
1499 window.ReleaseMouse();
1548 toolManager.ForEach([](
auto bar){
1550 bar->EnableDisableButtons();
1566 std::vector< Identifier > excludeIDs
1571 {
return *
this; } ),
1577 return toolManager.IsVisible(
id ); } ) ) ),
1580 , mExcludeIds{ std::move( excludeIDs ) }
1588 if( !toolManager.IsVisible(
mId ) )
1591 toolManager.Expose( excludedID,
false );
1594 toolManager.ShowHide(
mId);
constexpr CommandFlag AlwaysEnabledFlag
wxEvtHandler CommandHandlerObject
#define EVT_GRABBER(id, fn)
static ProjectFileIORegistry::AttributeWriterEntry entry
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
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
const char * end(const char *str) noexcept