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>
80#if !defined(__WXMAC__)
83 wxFRAME_FLOAT_ON_PARENT )
86 int width = bar->GetSize().x;
107 auto s = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
110 s->Add(bar, 1, wxEXPAND | wxALL, border);
123 SetSizer(s.release());
135 mMinSize = bar->GetMinSize() + ( GetSize() - bar->GetSize() );
157 wxSize sz =
mBar->GetSize();
159 int yDesiredMin = 26;
160 int y = sz.GetHeight();
161 if (y > yDesiredMin) {
162 sz.SetWidth((sz.GetWidth() * yDesiredMin) / y);
163 sz.SetHeight( yDesiredMin );
173 mBar->GetParent()->SetClientSize(
mBar->GetSize() );
181 wxPaintDC dc(
this );
182 wxSize sz = GetSize();
188 dc.SetBrush( *wxTRANSPARENT_BRUSH );
189 dc.DrawRectangle( 0, 0, sz.GetWidth(), sz.GetHeight() );
198 AColor::Line(dc, r.GetLeft(), r.GetBottom(), r.GetRight(), r.GetTop() );
199 AColor::Line(dc, r.GetLeft() + 3, r.GetBottom(), r.GetRight(), r.GetTop() + 3 );
200 AColor::Line(dc, r.GetLeft() + 6, r.GetBottom(), r.GetRight(), r.GetTop() + 6 );
201 AColor::Line(dc, r.GetLeft() + 9, r.GetBottom(), r.GetRight(), r.GetTop() + 9 );
215 wxPoint pos = ClientToScreen( event.GetPosition() );
216 if( HasCapture() && event.Dragging() )
218 wxRect rect = GetRect();
220 rect.SetBottomRight( pos );
223 wxSize maxsz =
mBar->GetMaxSize();
224 if (maxsz != wxDefaultSize)
226 if (maxsz.x != wxDefaultCoord && rect.width > maxsz.x)
228 rect.width = maxsz.x;
230 if (maxsz.y != wxDefaultCoord && rect.height > maxsz.y)
232 rect.height = maxsz.y;
248 else if( HasCapture() && event.LeftUp() )
252 else if( !HasCapture() )
254 wxRect rect = GetRect();
257 r.x = rect.GetRight() -
sizerW - 2,
258 r.y = rect.GetBottom() -
sizerW - 2;
263 if( r.Contains( pos ) && !event.Leaving() )
267 SetCursor( wxCURSOR_SIZENWSE );
268 if( event.LeftDown() )
275 SetCursor( wxCURSOR_ARROW );
296 if( HasCapture() && event.GetKeyCode() == WXK_ESCAPE ) {
335 return std::make_shared< ToolManager >( &parent ); }
356#if defined(__WXMAC__)
358 mTransition = wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION );
378 mDown = std::make_unique<wxRegion>( 3, &pt[0] );
389 mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
398 wxFRAME_TOOL_WINDOW |
426 window.Bind( wxEVT_LEFT_UP,
429 window.Bind( wxEVT_MOTION,
432 window.Bind( wxEVT_MOUSE_CAPTURE_LOST,
437 wxASSERT(topDockParent);
451 auto &slot =
mBars[bar->GetSection()];
458 slot = std::move(bar);
474 wxEvtHandler::AddFilter(
this);
487 wxEvtHandler::RemoveFilter(
this);
501 for (
auto &pair :
mBars)
529 {
wxT(
"Control"), {}, {} },
530 {
wxT(
"Tools"),
wxT(
"Control"), {} },
531 {
wxT(
"Edit"),
wxT(
"Tools"), {} },
532 {
wxT(
"CutCopyPaste"),
wxT(
"Edit"), {} },
533 {
wxT(
"Audio Setup"),
wxT(
"CutCopyPaste"), {} },
534#ifdef HAS_AUDIOCOM_UPLOAD
535 {
wxT(
"Share Audio"),
wxT(
"Audio Setup"), {} },
536 {
wxT(
"RecordMeter"),
wxT(
"Share Audio"), {} },
538 {
wxT(
"RecordMeter"),
wxT(
"Audio Setup"), {} },
540 {
wxT(
"PlayMeter"),
wxT(
"RecordMeter"), {} },
543 {
wxT(
"Scrub"), {},
wxT(
"Control") },
544 {
wxT(
"Device"),
wxT(
"Scrub"),
wxT(
"Control") },
547 {
wxT(
"CombinedMeter"), {}, {} },
550 {
wxT(
"Selection"), {}, {} },
551 {
wxT(
"Time"),
wxT(
"Selection"), {} },
554#ifdef EXPERIMENTAL_DA
555 {
wxT(
"Transcription"), {}, {} },
557 {
wxT(
"Transcription"),
wxT(
"Time"), {} },
561 {
wxT(
"SpectralSelection"), {}, {} },
567 auto &project = context.
project;
580 const auto &ndx =
entry.barID;
590 bar->SetSize( 20,20 );
604 floater = bar->GetParent();
613 bar->Reparent( dock );
626 bar->SetSize(bar->GetBestFittingSize());
638 dock->
Dock( bar,
false, position );
649 if( floater == NULL ) {
652 bar->Reparent( floater );
660 floater->CentreOnParent( );
663 floater->GetPosition() + wxSize{ index * 10 - 200, index * 10 });
670 if (bar && bar->HideAfterReset())
671 Expose(bar->GetSection(),
false);
685 bar->RegenerateTooltips();
694 if (event.GetEventType() == wxEVT_KILL_FOCUS) {
695 auto &focusEvent =
static_cast<wxFocusEvent&
>(event);
696 auto window = focusEvent.GetWindow();
697 auto top = wxGetTopLevelParent(window);
698 if(
auto toolFrame =
dynamic_cast<ToolFrame*
>(top))
699 top = toolFrame->GetParent();
702 !
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)
793 gPrefs->Read(
wxT(
"W"), &width[ ndx ], -1 );
794 gPrefs->Read(
wxT(
"H"), &height[ ndx ], -1 );
802 if( dock < NoDockID || dock >
DockCount ) {
817 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
819 wxSize sz( width[ ndx ], height[ ndx ] );
824#ifdef EXPERIMENTAL_SYNC_LOCK
826 if( width[ ndx ] >= bar->GetSize().x )
828 wxSize sz( width[ ndx ], bar->GetSize().y );
839 if( thisBar !=
wxT(
"Edit"))
842 if( width[ ndx ] >= bar->GetSize().x )
844 wxSize sz( width[ ndx ], bar->GetSize().y );
852 dockedAndHidden.push_back(bar);
857 unordered[ dock - 1 ].push_back( ndx );
870 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
872 wxSize sz( width[ ndx ], height[ ndx ] );
873 f->SetSizeHints( sz );
876 if( (x!=-1) && (y!=-1) )
881 wxSize msz(width[ndx],height[ndx]-1);
882 bar->GetParent()->SetMinSize(msz);
902 for( dock = 0; dock <
DockCount; dock++ )
909 for(
int ord = 0; ord < (int) unordered[ dock ].
size(); ord++ )
922 for (
auto bar : dockedAndHidden) {
931#if defined(__WXMAC__)
933 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
941 const auto &ndx =
entry.barID;
986 (dock ? &dock->GetConfiguration() :
nullptr, bar);
988 wxPoint pos( -1, -1 );
989 wxSize sz = bar->GetSize();
992 pos = bar->GetParent()->GetPosition();
993 sz = bar->GetParent()->GetSize();
1015 return (iter ==
end) ? nullptr : iter->second.get();
1051 wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1061 return pBar->IsDocked();
1071 return pBar->IsVisible();
1076 if( !t->IsDocked() )
1079 return t->GetParent()->IsShown();
1083 return t->IsShown();
1147#if defined(__WXMAC__)
1149 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1154 ( (wxWindow *)event.GetEventObject() )->ClientToScreen( event.GetPosition() ) -
mDragOffset;
1157 if( !event.LeftIsDown() )
1167 else if(
mDragDock && !event.ShiftDown() )
1187 else if( event.Dragging() && pos !=
mLastPos )
1192 wxPoint mp =
event.GetPosition();
1212 tr.SetBottom( tr.GetBottom() + 10 );
1213 tr.SetPosition(
mTopDock->GetParent()->ClientToScreen( tr.GetPosition() ) );
1217 br.SetTop( br.GetTop() - 10 );
1218 br.SetBottom( br.GetBottom() + 20 );
1219 br.SetPosition(
mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
1226 pos += wxPoint( 5, 20 );
1233 if( tr.Intersects( barRect ) )
1235 else if( br.Intersects( barRect ) )
1250 wxRect dr = dock->GetRect();
1256 if( r.GetTop() >= dr.GetHeight() )
1258 const auto &box =
mDown->GetBox();
1259 p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
1260 - (box.GetWidth() / 2);
1261 p.y = dr.GetBottom() - box.GetHeight();
1272 int h = wxMin(r.GetHeight(), 2*tbs-1);
1273 p.x = dr.GetLeft() + r.GetLeft();
1274 p.y = dr.GetTop() + r.GetTop() +
1275 ( ( h -
mLeft->GetBox().GetHeight() ) / 2 );
1281 if( !event.ShiftDown() )
1290 mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
1312#if defined(__WXMAC__)
1314 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1333 wxMouseEvent e(wxEVT_LEFT_UP);
1359 bool state = wxGetKeyState( WXK_SHIFT );
1364#if defined(__WXMAC__)
1366 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1371#if defined(__WXMAC__)
1373 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1389 wxWindow *w = (wxWindow *)event.GetEventObject();
1393 dc.SetBackground( brush );
1405#if defined(__WXGTK__)
1413#if defined(__WXMAC__)
1415 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1428 mDragWindow->SetLayoutDirection(wxLayout_LeftToRight);
1435#if defined(__WXMAC__)
1437 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1447 event.Skip(
false );
1466 wxPoint mp =
event.GetPosition();
1483 if( !window.HasCapture() )
1484 window.CaptureMouse();
1512 auto parent =
mDragBar->GetParent();
1531 if( window.HasCapture() )
1533 window.ReleaseMouse();
1569 auto &project = *pProject;
1574#include "../commands/CommandManager.h"
1575#include "../ProjectSettings.h"
1585 toolManager.ForEach([](
auto bar){
1587 bar->EnableDisableButtons();
1594 gPrefs->Read(
wxT(
"/GUI/SyncLockTracks"), &active,
false);
1603 std::vector< Identifier > excludeIDs
1606 Registry::Placement{
wxT(
"View/Other/Toolbars/Toolbars/Other"), hint },
1609 {
return *
this; } ),
1615 return toolManager.IsVisible(
id ); } ) ) ) }
1616 , mExcludeIds{ std::move( excludeIDs ) }
1621 auto &project = context.
project;
1624 if( !toolManager.IsVisible(
mId ) )
1627 toolManager.Expose( excludedID,
false );
1630 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
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
static Settings & settings()
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.
static ProjectSettings & 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) &&