30#include "../commands/CommandContext.h"
37#include <wx/dcclient.h>
44#include <wx/settings.h>
52#include <wx/minifram.h>
53#include <wx/popupwin.h>
83#if !defined(__WXMAC__)
86 wxFRAME_FLOAT_ON_PARENT )
89 int width = bar->GetSize().x;
110 auto s = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
113 s->Add(bar, 1, wxEXPAND | wxALL, border);
126 SetSizer(s.release());
138 mMinSize = bar->GetMinSize() + ( GetSize() - bar->GetSize() );
160 wxSize sz =
mBar->GetSize();
162 int yDesiredMin = 26;
163 int y = sz.GetHeight();
164 if (y > yDesiredMin) {
165 sz.SetWidth((sz.GetWidth() * yDesiredMin) / y);
166 sz.SetHeight( yDesiredMin );
176 mBar->GetParent()->SetClientSize(
mBar->GetSize() );
184 wxPaintDC dc(
this );
185 wxSize sz = GetSize();
191 dc.SetBrush( *wxTRANSPARENT_BRUSH );
192 dc.DrawRectangle( 0, 0, sz.GetWidth(), sz.GetHeight() );
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 );
218 wxPoint pos = ClientToScreen( event.GetPosition() );
219 if( HasCapture() && event.Dragging() )
221 wxRect rect = GetRect();
223 rect.SetBottomRight( pos );
226 wxSize maxsz =
mBar->GetMaxSize();
227 if (maxsz != wxDefaultSize)
229 if (maxsz.x != wxDefaultCoord && rect.width > maxsz.x)
231 rect.width = maxsz.x;
233 if (maxsz.y != wxDefaultCoord && rect.height > maxsz.y)
235 rect.height = maxsz.y;
251 else if( HasCapture() && event.LeftUp() )
255 else if( !HasCapture() )
257 wxRect rect = GetRect();
260 r.x = rect.GetRight() -
sizerW - 2,
261 r.y = rect.GetBottom() -
sizerW - 2;
266 if( r.Contains( pos ) && !event.Leaving() )
270 SetCursor( wxCURSOR_SIZENWSE );
271 if( event.LeftDown() )
278 SetCursor( wxCURSOR_ARROW );
299 if( HasCapture() && event.GetKeyCode() == WXK_ESCAPE ) {
338 return std::make_shared< ToolManager >( &parent ); }
359#if defined(__WXMAC__)
361 mTransition = wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION );
381 mDown = std::make_unique<wxRegion>( 3, &pt[0] );
392 mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
401 wxFRAME_TOOL_WINDOW |
429 window.Bind( wxEVT_LEFT_UP,
432 window.Bind( wxEVT_MOTION,
435 window.Bind( wxEVT_MOUSE_CAPTURE_LOST,
440 wxASSERT(topDockParent);
466 wxEvtHandler::AddFilter(
this);
476 wxEvtHandler::RemoveFilter(
this);
537#ifdef EXPERIMENTAL_DA
550 auto &project = context.
project;
563 int ndx =
entry.barID;
570 bar->SetSize( 20,20 );
584 floater = bar->GetParent();
589#ifdef EXPERIMENTAL_SPECTRAL_EDITING
590 || ndx == SpectralSelectionBarID
601 bar->Reparent( dock );
614 bar->SetSize(bar->GetBestFittingSize());
620#ifdef EXPERIMENTAL_SPECTRAL_EDITING
621 || ndx == SpectralSelectionBarID
626#ifdef EXPERIMENTAL_DA
638 dock->
Dock( bar,
false, position );
649 if( floater == NULL ) {
652 bar->Reparent( floater );
660 floater->CentreOnParent( );
661 floater->Move( floater->GetPosition() + wxSize( ndx * 10 - 200, ndx * 10 ));
677 for (
const auto &bar :
mBars) {
679 bar->RegenerateTooltips();
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();
696 !
dynamic_cast<Grabber*
>( window ) &&
713 std::vector<ToolBar*> dockedAndHidden;
719 bool someFound {
false };
721#if defined(__WXMAC__)
723 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
731 int vMajor, vMinor, vMicro;
733 bool useLegacyDock =
false;
739 (vMajor == 2 && (vMinor <= 1 || (vMinor == 2 && vMicro <= 1))))
740 useLegacyDock =
true;
755 bool bShownByDefault =
true;
761 bShownByDefault =
false;
763 bShownByDefault =
false;
765 bShownByDefault =
false;
769#ifdef EXPERIMENTAL_SPECTRAL_EDITING
770 if( ndx == SpectralSelectionBarID ){
772 bShownByDefault =
false;
779 gPrefs->Read( wxT(
"Dock"), &dock, -1);
781 gPrefs->Read( wxT(
"DockV2"), &dock, -1);
783 const bool found = (dock != -1);
795 default: d =
nullptr; pLegacy =
nullptr;
break;
801 bar, show[ ndx ], bShownByDefault)
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 );
815 if( dock < NoDockID || dock >
DockCount ) {
830 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
832 wxSize sz( width[ ndx ], height[ ndx ] );
837#ifdef EXPERIMENTAL_SYNC_LOCK
839 if( width[ ndx ] >= bar->GetSize().x )
841 wxSize sz( width[ ndx ], bar->GetSize().y );
852 if( thisBar != wxT(
"Edit"))
855 if( width[ ndx ] >= bar->GetSize().x )
857 wxSize sz( width[ ndx ], bar->GetSize().y );
865 dockedAndHidden.push_back(bar);
870 unordered[ dock - 1 ].push_back( ndx );
883 if( width[ ndx ] != -1 && height[ ndx ] != -1 )
885 wxSize sz( width[ ndx ], height[ ndx ] );
886 f->SetSizeHints( sz );
889 if( (x!=-1) && (y!=-1) )
894 wxSize msz(width[ndx],height[ndx]-1);
895 bar->GetParent()->SetMinSize(msz);
901 Expose( ndx, show[ ndx ] );
915 for( dock = 0; dock <
DockCount; dock++ )
922 for(
int ord = 0; ord < (int) unordered[ dock ].
size(); ord++ )
930 Expose( t->GetId(), show[ t->GetId() ] );
935 for (
auto bar : dockedAndHidden) {
936 bar->SetVisible(
false );
937 bar->GetDock()->Dock(bar,
false);
944#if defined(__WXMAC__)
946 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
994 wxPoint pos( -1, -1 );
995 wxSize sz = bar->GetSize();
998 pos = bar->GetParent()->GetPosition();
999 sz = bar->GetParent()->GetSize();
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 );
1020 return mBars[ type ].get();
1056 wxCommandEvent e( EVT_TOOLBAR_UPDATED );
1065 return mBars[ type ]->IsDocked();
1082 return t->GetParent()->IsShown();
1086 return t->IsShown();
1150#if defined(__WXMAC__)
1152 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1157 ( (wxWindow *)event.GetEventObject() )->ClientToScreen( event.GetPosition() ) -
mDragOffset;
1160 if( !event.LeftIsDown() )
1170 else if(
mDragDock && !event.ShiftDown() )
1190 else if( event.Dragging() && pos !=
mLastPos )
1195 wxPoint mp =
event.GetPosition();
1215 tr.SetBottom( tr.GetBottom() + 10 );
1216 tr.SetPosition(
mTopDock->GetParent()->ClientToScreen( tr.GetPosition() ) );
1220 br.SetTop( br.GetTop() - 10 );
1221 br.SetBottom( br.GetBottom() + 20 );
1222 br.SetPosition(
mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
1229 pos += wxPoint( 5, 20 );
1236 if( tr.Intersects( barRect ) )
1238 else if( br.Intersects( barRect ) )
1253 wxRect dr = dock->GetRect();
1259 if( r.GetTop() >= dr.GetHeight() )
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();
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 );
1284 if( !event.ShiftDown() )
1293 mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
1315#if defined(__WXMAC__)
1317 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1336 wxMouseEvent e(wxEVT_LEFT_UP);
1357 bool state = wxGetKeyState( WXK_SHIFT );
1362#if defined(__WXMAC__)
1364 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1369#if defined(__WXMAC__)
1371 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1387 wxWindow *w = (wxWindow *)event.GetEventObject();
1391 dc.SetBackground( brush );
1403#if defined(__WXGTK__)
1411#if defined(__WXMAC__)
1413 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
1426 mDragWindow->SetLayoutDirection(wxLayout_LeftToRight);
1433#if defined(__WXMAC__)
1435 wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION,
mTransition );
1445 event.Skip(
false );
1464 wxPoint mp =
event.GetPosition();
1481 if( !window.HasCapture() )
1482 window.CaptureMouse();
1510 auto parent =
mDragBar->GetParent();
1529 if( window.HasCapture() )
1531 window.ReleaseMouse();
1564#include "../commands/CommandContext.h"
1565#include "../Menus.h"
1570 std::vector< ToolBarID > excludeIDs )
1573 Registry::Placement{ wxT(
"View/Other/Toolbars/Toolbars/Other"), hint },
1576 {
return *
this; } ),
1582 return toolManager.IsVisible(
id ); } ) ) ) }
1583 , mExcludeIds{ std::move( excludeIDs ) }
1588 auto &project = context.
project;
1591 if( !toolManager.IsVisible(
mId ) )
1594 toolManager.Expose( excludedID,
false );
1597 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 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 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.
static TempAllowFocus TemporarilyAllowFocus()
wxColour & Colour(int iIndex)
Holds a msgid for the translation catalog; may also bind format arguments.
Options && CheckTest(const CheckFn &fn) &&