mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-25 16:48:44 +02:00
Merge branch 'master' into scrubbing
This commit is contained in:
commit
e0c80a8d20
@ -528,6 +528,7 @@ def url_open(url):
|
|||||||
L = urlparse.urlparse(url)
|
L = urlparse.urlparse(url)
|
||||||
if L[1] != domain:
|
if L[1] != domain:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
if L[1] == '': return(['',''])
|
||||||
print "connection to", domain, "closed."
|
print "connection to", domain, "closed."
|
||||||
conn = httplib.HTTPConnection(L[1])
|
conn = httplib.HTTPConnection(L[1])
|
||||||
domain = L[1]
|
domain = L[1]
|
||||||
|
@ -285,7 +285,8 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSupportedFormat(const wxDataFormat & format, Direction WXUNUSED(dir = Get)) const override
|
bool IsSupportedFormat(const wxDataFormat & format, Direction WXUNUSED(dir = Get)) const
|
||||||
|
// PRL: This function does NOT override any inherited virtual! What does it do?
|
||||||
{
|
{
|
||||||
if (format.GetType() == wxDF_FILENAME) {
|
if (format.GetType() == wxDF_FILENAME) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -29,62 +29,62 @@ using CommandFunctorPointer = std::shared_ptr <CommandFunctor>;
|
|||||||
// Define functor subclasses that dispatch to the correct call sequence on
|
// Define functor subclasses that dispatch to the correct call sequence on
|
||||||
// member functions of AudacityProject (or other class!)
|
// member functions of AudacityProject (or other class!)
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
using audCommandFunction = void (THIS::*)();
|
using audCommandFunction = void (OBJ::*)();
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
class VoidFunctor final : public CommandFunctor
|
class VoidFunctor final : public CommandFunctor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit VoidFunctor(THIS *This, audCommandFunction<THIS> pfn)
|
explicit VoidFunctor(OBJ *This, audCommandFunction<OBJ> pfn)
|
||||||
: mThis{ This }, mCommandFunction{ pfn } {}
|
: mThis{ This }, mCommandFunction{ pfn } {}
|
||||||
void operator () (int, const wxEvent *) override
|
void operator () (int, const wxEvent *) override
|
||||||
{ (mThis->*mCommandFunction) (); }
|
{ (mThis->*mCommandFunction) (); }
|
||||||
private:
|
private:
|
||||||
THIS *const mThis;
|
OBJ *const mThis;
|
||||||
const audCommandFunction<THIS> mCommandFunction;
|
const audCommandFunction<OBJ> mCommandFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
using audCommandKeyFunction = void (THIS::*)(const wxEvent *);
|
using audCommandKeyFunction = void (OBJ::*)(const wxEvent *);
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
class KeyFunctor final : public CommandFunctor
|
class KeyFunctor final : public CommandFunctor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit KeyFunctor(THIS *This, audCommandKeyFunction<THIS> pfn)
|
explicit KeyFunctor(OBJ *This, audCommandKeyFunction<OBJ> pfn)
|
||||||
: mThis{ This }, mCommandKeyFunction{ pfn } {}
|
: mThis{ This }, mCommandKeyFunction{ pfn } {}
|
||||||
void operator () (int, const wxEvent *evt) override
|
void operator () (int, const wxEvent *evt) override
|
||||||
{ (mThis->*mCommandKeyFunction) (evt); }
|
{ (mThis->*mCommandKeyFunction) (evt); }
|
||||||
private:
|
private:
|
||||||
THIS *const mThis;
|
OBJ *const mThis;
|
||||||
const audCommandKeyFunction<THIS> mCommandKeyFunction;
|
const audCommandKeyFunction<OBJ> mCommandKeyFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
using audCommandListFunction = void (THIS::*)(int);
|
using audCommandListFunction = void (OBJ::*)(int);
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
class ListFunctor final : public CommandFunctor
|
class ListFunctor final : public CommandFunctor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ListFunctor(THIS *This, audCommandListFunction<THIS> pfn)
|
explicit ListFunctor(OBJ *This, audCommandListFunction<OBJ> pfn)
|
||||||
: mThis{ This }, mCommandListFunction{ pfn } {}
|
: mThis{ This }, mCommandListFunction{ pfn } {}
|
||||||
void operator () (int index, const wxEvent *) override
|
void operator () (int index, const wxEvent *) override
|
||||||
{ (mThis->*mCommandListFunction)(index); }
|
{ (mThis->*mCommandListFunction)(index); }
|
||||||
private:
|
private:
|
||||||
THIS *const mThis;
|
OBJ *const mThis;
|
||||||
const audCommandListFunction<THIS> mCommandListFunction;
|
const audCommandListFunction<OBJ> mCommandListFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
using audCommandPluginFunction = bool (THIS::*)(const PluginID &, int);
|
using audCommandPluginFunction = bool (OBJ::*)(const PluginID &, int);
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
class PluginFunctor final : public CommandFunctor
|
class PluginFunctor final : public CommandFunctor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PluginFunctor(THIS *This, const PluginID &id, audCommandPluginFunction<THIS> pfn)
|
explicit PluginFunctor(OBJ *This, const PluginID &id, audCommandPluginFunction<OBJ> pfn)
|
||||||
: mPluginID{ id }, mThis{ This }, mCommandPluginFunction{ pfn } {}
|
: mPluginID{ id }, mThis{ This }, mCommandPluginFunction{ pfn } {}
|
||||||
void operator () (int, const wxEvent *) override
|
void operator () (int, const wxEvent *) override
|
||||||
{ (mThis->*mCommandPluginFunction)
|
{ (mThis->*mCommandPluginFunction)
|
||||||
@ -93,34 +93,34 @@ public:
|
|||||||
); }
|
); }
|
||||||
private:
|
private:
|
||||||
const PluginID mPluginID;
|
const PluginID mPluginID;
|
||||||
THIS *const mThis;
|
OBJ *const mThis;
|
||||||
const audCommandPluginFunction<THIS> mCommandPluginFunction;
|
const audCommandPluginFunction<OBJ> mCommandPluginFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now define an overloaded factory function
|
// Now define an overloaded factory function
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
inline CommandFunctorPointer MakeFunctor(THIS *This,
|
inline CommandFunctorPointer MakeFunctor(OBJ *This,
|
||||||
audCommandFunction<THIS> pfn)
|
audCommandFunction<OBJ> pfn)
|
||||||
{ return CommandFunctorPointer{ safenew VoidFunctor<THIS>{ This, pfn } }; }
|
{ return CommandFunctorPointer{ safenew VoidFunctor<OBJ>{ This, pfn } }; }
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
inline CommandFunctorPointer MakeFunctor(THIS *This,
|
inline CommandFunctorPointer MakeFunctor(OBJ *This,
|
||||||
audCommandKeyFunction<THIS> pfn)
|
audCommandKeyFunction<OBJ> pfn)
|
||||||
{ return CommandFunctorPointer{ safenew KeyFunctor<THIS>{ This, pfn } }; }
|
{ return CommandFunctorPointer{ safenew KeyFunctor<OBJ>{ This, pfn } }; }
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
inline CommandFunctorPointer MakeFunctor(THIS *This,
|
inline CommandFunctorPointer MakeFunctor(OBJ *This,
|
||||||
audCommandListFunction<THIS> pfn)
|
audCommandListFunction<OBJ> pfn)
|
||||||
{ return CommandFunctorPointer{ safenew ListFunctor<THIS>{ This, pfn } }; }
|
{ return CommandFunctorPointer{ safenew ListFunctor<OBJ>{ This, pfn } }; }
|
||||||
|
|
||||||
template<typename THIS>
|
template<typename OBJ>
|
||||||
inline CommandFunctorPointer MakeFunctor(THIS *This, const PluginID &id,
|
inline CommandFunctorPointer MakeFunctor(OBJ *This, const PluginID &id,
|
||||||
audCommandPluginFunction<THIS> pfn)
|
audCommandPluginFunction<OBJ> pfn)
|
||||||
{ return CommandFunctorPointer{ safenew PluginFunctor<THIS>{ This, id, pfn } }; }
|
{ return CommandFunctorPointer{ safenew PluginFunctor<OBJ>{ This, id, pfn } }; }
|
||||||
|
|
||||||
// Now define the macro abbreviations that call the factory
|
// Now define the macro abbreviations that call the factory
|
||||||
#define FNT(THIS, This, X) (MakeFunctor<THIS>(This, X ))
|
#define FNT(OBJ, This, X) (MakeFunctor<OBJ>(This, X ))
|
||||||
#define FNTS(THIS, This, X, S) (MakeFunctor<THIS>(This, (S), X ))
|
#define FNTS(OBJ, This, X, S) (MakeFunctor<OBJ>(This, (S), X ))
|
||||||
|
|
||||||
#define FN(X) FNT(AudacityProject, this, & AudacityProject :: X)
|
#define FN(X) FNT(AudacityProject, this, & AudacityProject :: X)
|
||||||
#define FNS(X, S) FNTS(AudacityProject, this, & AudacityProject :: X, S)
|
#define FNS(X, S) FNTS(AudacityProject, this, & AudacityProject :: X, S)
|
||||||
|
@ -3245,6 +3245,8 @@ void EffectUIHost::OnApply(wxCommandEvent & evt)
|
|||||||
|
|
||||||
if (IsModal())
|
if (IsModal())
|
||||||
{
|
{
|
||||||
|
mDismissed = true;
|
||||||
|
|
||||||
EndModal(true);
|
EndModal(true);
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
@ -3265,7 +3267,7 @@ void EffectUIHost::OnApply(wxCommandEvent & evt)
|
|||||||
|
|
||||||
void EffectUIHost::DoCancel()
|
void EffectUIHost::DoCancel()
|
||||||
{
|
{
|
||||||
if (!mCancelled) {
|
if (!mDismissed) {
|
||||||
mEffect->mUIResultID = wxID_CANCEL;
|
mEffect->mUIResultID = wxID_CANCEL;
|
||||||
|
|
||||||
if (IsModal())
|
if (IsModal())
|
||||||
@ -3273,7 +3275,7 @@ void EffectUIHost::DoCancel()
|
|||||||
else
|
else
|
||||||
Hide();
|
Hide();
|
||||||
|
|
||||||
mCancelled = true;
|
mDismissed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ private:
|
|||||||
SelectedRegion mRegion;
|
SelectedRegion mRegion;
|
||||||
double mPlayPos;
|
double mPlayPos;
|
||||||
|
|
||||||
bool mCancelled{};
|
bool mDismissed{};
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,8 @@ public:
|
|||||||
virtual ~ToolBarResizer();
|
virtual ~ToolBarResizer();
|
||||||
|
|
||||||
// We don't need or want to accept focus.
|
// We don't need or want to accept focus.
|
||||||
bool AcceptsFocus() const;
|
// PRL: except for ESC key now.
|
||||||
|
// bool AcceptsFocus() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnErase(wxEraseEvent & event);
|
void OnErase(wxEraseEvent & event);
|
||||||
@ -77,11 +78,14 @@ private:
|
|||||||
void OnEnter(wxMouseEvent & event);
|
void OnEnter(wxMouseEvent & event);
|
||||||
void OnLeave(wxMouseEvent & event);
|
void OnLeave(wxMouseEvent & event);
|
||||||
void OnMotion(wxMouseEvent & event);
|
void OnMotion(wxMouseEvent & event);
|
||||||
|
void ResizeBar(const wxSize &size);
|
||||||
void OnCaptureLost(wxMouseCaptureLostEvent & event);
|
void OnCaptureLost(wxMouseCaptureLostEvent & event);
|
||||||
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ToolBar *mBar;
|
ToolBar *mBar;
|
||||||
wxPoint mResizeStart;
|
wxPoint mResizeStart;
|
||||||
|
wxSize mOrigSize;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
@ -96,6 +100,7 @@ BEGIN_EVENT_TABLE( ToolBarResizer, wxWindow )
|
|||||||
EVT_LEFT_UP( ToolBarResizer::OnLeftUp )
|
EVT_LEFT_UP( ToolBarResizer::OnLeftUp )
|
||||||
EVT_MOTION( ToolBarResizer::OnMotion )
|
EVT_MOTION( ToolBarResizer::OnMotion )
|
||||||
EVT_MOUSE_CAPTURE_LOST( ToolBarResizer::OnCaptureLost )
|
EVT_MOUSE_CAPTURE_LOST( ToolBarResizer::OnCaptureLost )
|
||||||
|
EVT_KEY_DOWN( ToolBarResizer::OnKeyDown )
|
||||||
END_EVENT_TABLE();
|
END_EVENT_TABLE();
|
||||||
|
|
||||||
ToolBarResizer::ToolBarResizer(ToolBar *bar)
|
ToolBarResizer::ToolBarResizer(ToolBar *bar)
|
||||||
@ -109,10 +114,12 @@ ToolBarResizer::~ToolBarResizer()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
bool ToolBarResizer::AcceptsFocus() const
|
bool ToolBarResizer::AcceptsFocus() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle background erasure
|
// Handle background erasure
|
||||||
@ -157,6 +164,8 @@ void ToolBarResizer::OnLeftDown( wxMouseEvent & event )
|
|||||||
// Retrieve the mouse position
|
// Retrieve the mouse position
|
||||||
mResizeStart = ClientToScreen( event.GetPosition() );
|
mResizeStart = ClientToScreen( event.GetPosition() );
|
||||||
|
|
||||||
|
mOrigSize = mBar->GetSize();
|
||||||
|
|
||||||
// We want all of the mouse events
|
// We want all of the mouse events
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
}
|
}
|
||||||
@ -181,7 +190,7 @@ void ToolBarResizer::OnMotion( wxMouseEvent & event )
|
|||||||
wxPoint raw_pos = event.GetPosition();
|
wxPoint raw_pos = event.GetPosition();
|
||||||
wxPoint pos = ClientToScreen( raw_pos );
|
wxPoint pos = ClientToScreen( raw_pos );
|
||||||
|
|
||||||
if( event.Dragging() )
|
if( HasCapture() && event.Dragging() )
|
||||||
{
|
{
|
||||||
wxRect r = mBar->GetRect();
|
wxRect r = mBar->GetRect();
|
||||||
wxSize msz = mBar->GetMinSize();
|
wxSize msz = mBar->GetMinSize();
|
||||||
@ -212,8 +221,13 @@ void ToolBarResizer::OnMotion( wxMouseEvent & event )
|
|||||||
mResizeStart = pos;
|
mResizeStart = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize the bar
|
ResizeBar( r.GetSize() );
|
||||||
mBar->SetSize( r.GetSize() );
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBarResizer::ResizeBar(const wxSize &size)
|
||||||
|
{
|
||||||
|
mBar->SetSize( size );
|
||||||
|
|
||||||
// Tell everyone we've changed sizes
|
// Tell everyone we've changed sizes
|
||||||
mBar->Updated();
|
mBar->Updated();
|
||||||
@ -222,7 +236,6 @@ void ToolBarResizer::OnMotion( wxMouseEvent & event )
|
|||||||
mBar->GetParent()->Refresh();
|
mBar->GetParent()->Refresh();
|
||||||
mBar->GetParent()->Update();
|
mBar->GetParent()->Update();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ToolBarResizer::OnCaptureLost( wxMouseCaptureLostEvent & WXUNUSED(event) )
|
void ToolBarResizer::OnCaptureLost( wxMouseCaptureLostEvent & WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
@ -232,6 +245,15 @@ void ToolBarResizer::OnCaptureLost( wxMouseCaptureLostEvent & WXUNUSED(event) )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolBarResizer::OnKeyDown(wxKeyEvent &event)
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
if (HasCapture() && WXK_ESCAPE == event.GetKeyCode()) {
|
||||||
|
ResizeBar( mOrigSize );
|
||||||
|
ReleaseMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Methods for ToolBar
|
/// Methods for ToolBar
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -452,6 +452,11 @@ void ToolDock::Expose( int type, bool show )
|
|||||||
Updated();
|
Updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ToolDock::Find(ToolBar *bar) const
|
||||||
|
{
|
||||||
|
return mDockedBars.Index(bar);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Queues an EVT_TOOLBAR_UPDATED command event to notify any
|
// Queues an EVT_TOOLBAR_UPDATED command event to notify any
|
||||||
// interested parties of an updated toolbar or dock layout
|
// interested parties of an updated toolbar or dock layout
|
||||||
@ -468,6 +473,8 @@ void ToolDock::Updated()
|
|||||||
//
|
//
|
||||||
void ToolDock::OnGrabber( GrabberEvent & event )
|
void ToolDock::OnGrabber( GrabberEvent & event )
|
||||||
{
|
{
|
||||||
|
auto pos = event.GetPosition();
|
||||||
|
if (!event.IsEscaping()) {
|
||||||
ToolBar *t = mBars[ event.GetId() ];
|
ToolBar *t = mBars[ event.GetId() ];
|
||||||
|
|
||||||
// Pass it on to the manager since it isn't in the handling hierarchy
|
// Pass it on to the manager since it isn't in the handling hierarchy
|
||||||
@ -476,6 +483,7 @@ void ToolDock::OnGrabber( GrabberEvent & event )
|
|||||||
// We no longer have control
|
// We no longer have control
|
||||||
mDockedBars.Remove( t );
|
mDockedBars.Remove( t );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle sizing
|
// Handle sizing
|
||||||
|
@ -57,6 +57,7 @@ class ToolDock final : public wxPanel
|
|||||||
|
|
||||||
void LayoutToolBars();
|
void LayoutToolBars();
|
||||||
void Expose( int type, bool show );
|
void Expose( int type, bool show );
|
||||||
|
int Find(ToolBar *bar) const;
|
||||||
int GetOrder( ToolBar *bar );
|
int GetOrder( ToolBar *bar );
|
||||||
int GetBarCount();
|
int GetBarCount();
|
||||||
void Dock( ToolBar *bar, int ndx = -1 );
|
void Dock( ToolBar *bar, int ndx = -1 );
|
||||||
|
@ -234,10 +234,7 @@ class ToolFrame final : public wxFrame
|
|||||||
rect.height = mMinSize.y;
|
rect.height = mMinSize.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMinSize( rect.GetSize() );
|
Resize( rect.GetSize() );
|
||||||
SetSize( rect.GetSize() );
|
|
||||||
Layout();
|
|
||||||
Refresh( false );
|
|
||||||
}
|
}
|
||||||
else if( HasCapture() && event.LeftUp() )
|
else if( HasCapture() && event.LeftUp() )
|
||||||
{
|
{
|
||||||
@ -256,6 +253,8 @@ class ToolFrame final : public wxFrame
|
|||||||
// Is left click within resize grabber?
|
// Is left click within resize grabber?
|
||||||
if( r.Contains( pos ) && !event.Leaving() )
|
if( r.Contains( pos ) && !event.Leaving() )
|
||||||
{
|
{
|
||||||
|
mOrigSize = GetSize();
|
||||||
|
|
||||||
SetCursor( wxCURSOR_SIZENWSE );
|
SetCursor( wxCURSOR_SIZENWSE );
|
||||||
if( event.LeftDown() )
|
if( event.LeftDown() )
|
||||||
{
|
{
|
||||||
@ -286,12 +285,30 @@ class ToolFrame final : public wxFrame
|
|||||||
event.Veto();
|
event.Veto();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnKeyDown( wxKeyEvent &event )
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
if( HasCapture() && event.GetKeyCode() == WXK_ESCAPE ) {
|
||||||
|
Resize( mOrigSize );
|
||||||
|
ReleaseMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Resize( const wxSize &size )
|
||||||
|
{
|
||||||
|
SetMinSize( size );
|
||||||
|
SetSize( size );
|
||||||
|
Layout();
|
||||||
|
Refresh( false );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
wxWindow *mParent;
|
wxWindow *mParent;
|
||||||
ToolManager *mManager;
|
ToolManager *mManager;
|
||||||
ToolBar *mBar;
|
ToolBar *mBar;
|
||||||
wxSize mMinSize;
|
wxSize mMinSize;
|
||||||
|
wxSize mOrigSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -308,6 +325,7 @@ BEGIN_EVENT_TABLE( ToolFrame, wxFrame )
|
|||||||
EVT_MOUSE_CAPTURE_LOST( ToolFrame::OnCaptureLost )
|
EVT_MOUSE_CAPTURE_LOST( ToolFrame::OnCaptureLost )
|
||||||
EVT_CLOSE( ToolFrame::OnClose )
|
EVT_CLOSE( ToolFrame::OnClose )
|
||||||
EVT_COMMAND( wxID_ANY, EVT_TOOLBAR_UPDATED, ToolFrame::OnToolBarUpdate )
|
EVT_COMMAND( wxID_ANY, EVT_TOOLBAR_UPDATED, ToolFrame::OnToolBarUpdate )
|
||||||
|
EVT_KEY_DOWN( ToolFrame::OnKeyDown )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
IMPLEMENT_CLASS( ToolManager, wxEvtHandler );
|
IMPLEMENT_CLASS( ToolManager, wxEvtHandler );
|
||||||
@ -988,15 +1006,6 @@ void ToolManager::OnMouse( wxMouseEvent & event )
|
|||||||
// Button was released...finish the drag
|
// Button was released...finish the drag
|
||||||
if( !event.LeftIsDown() )
|
if( !event.LeftIsDown() )
|
||||||
{
|
{
|
||||||
// Release capture
|
|
||||||
if( mParent->HasCapture() )
|
|
||||||
{
|
|
||||||
mParent->ReleaseMouse();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide the indicator
|
|
||||||
mIndicator->Hide();
|
|
||||||
|
|
||||||
// Transition the bar to a dock
|
// Transition the bar to a dock
|
||||||
if( mDragDock && !event.ShiftDown() )
|
if( mDragDock && !event.ShiftDown() )
|
||||||
{
|
{
|
||||||
@ -1013,13 +1022,7 @@ void ToolManager::OnMouse( wxMouseEvent & event )
|
|||||||
mDragBar->SetDocked( NULL, false );
|
mDragBar->SetDocked( NULL, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done dragging
|
DoneDragging();
|
||||||
mDragWindow = NULL;
|
|
||||||
mDragDock = NULL;
|
|
||||||
mDragBar = NULL;
|
|
||||||
mLastPos.x = mBarPos.x = -1;
|
|
||||||
mLastPos.y = mBarPos.y = -1;
|
|
||||||
mTimer.Stop();
|
|
||||||
}
|
}
|
||||||
else if( event.Dragging() && pos != mLastPos )
|
else if( event.Dragging() && pos != mLastPos )
|
||||||
{
|
{
|
||||||
@ -1221,9 +1224,21 @@ void ToolManager::OnGrabber( GrabberEvent & event )
|
|||||||
// No need to propagate any further
|
// No need to propagate any further
|
||||||
event.Skip( false );
|
event.Skip( false );
|
||||||
|
|
||||||
|
if(event.IsEscaping())
|
||||||
|
return HandleEscapeKey();
|
||||||
|
|
||||||
// Remember which bar we're dragging
|
// Remember which bar we're dragging
|
||||||
mDragBar = mBars[ event.GetId() ];
|
mDragBar = mBars[ event.GetId() ];
|
||||||
|
|
||||||
|
// Remember state, in case of ESCape key later
|
||||||
|
if (mDragBar->IsDocked()) {
|
||||||
|
mPrevDock = dynamic_cast<ToolDock*>(mDragBar->GetParent());
|
||||||
|
wxASSERT(mPrevDock);
|
||||||
|
mPrevSlot = mPrevDock->Find(mDragBar);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mPrevPosition = mDragBar->GetParent()->GetPosition();
|
||||||
|
|
||||||
// Calculate the drag offset
|
// Calculate the drag offset
|
||||||
wxPoint mp = event.GetPosition();
|
wxPoint mp = event.GetPosition();
|
||||||
mDragOffset = mp -
|
mDragOffset = mp -
|
||||||
@ -1231,7 +1246,7 @@ void ToolManager::OnGrabber( GrabberEvent & event )
|
|||||||
wxPoint( 1, 1 );
|
wxPoint( 1, 1 );
|
||||||
|
|
||||||
// Must set the bar afloat if it's currently docked
|
// Must set the bar afloat if it's currently docked
|
||||||
if( mDragBar->IsDocked() )
|
if( mPrevDock )
|
||||||
{
|
{
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
// Disable window animation
|
// Disable window animation
|
||||||
@ -1271,3 +1286,51 @@ void ToolManager::OnGrabber( GrabberEvent & event )
|
|||||||
mLastState = wxGetKeyState( WXK_SHIFT );
|
mLastState = wxGetKeyState( WXK_SHIFT );
|
||||||
mTimer.Start( 100 );
|
mTimer.Start( 100 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToolManager::HandleEscapeKey()
|
||||||
|
{
|
||||||
|
if (mDragBar) {
|
||||||
|
if(mPrevDock) {
|
||||||
|
// Sheriff John Stone,
|
||||||
|
// Why don't you leave me alone?
|
||||||
|
// Well, I feel so break up
|
||||||
|
// I want to go home.
|
||||||
|
mPrevDock->Dock( mDragBar, mPrevSlot );
|
||||||
|
|
||||||
|
// Done with the floater
|
||||||
|
mDragWindow->Destroy();
|
||||||
|
mDragBar->Refresh(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Floater remains, and returns to where it begain
|
||||||
|
auto parent = mDragBar->GetParent();
|
||||||
|
parent->SetPosition(mPrevPosition);
|
||||||
|
mDragBar->SetDocked(NULL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
DoneDragging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolManager::DoneDragging()
|
||||||
|
{
|
||||||
|
// Done dragging
|
||||||
|
// Release capture
|
||||||
|
if( mParent->HasCapture() )
|
||||||
|
{
|
||||||
|
mParent->ReleaseMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide the indicator
|
||||||
|
mIndicator->Hide();
|
||||||
|
|
||||||
|
mDragWindow = NULL;
|
||||||
|
mDragDock = NULL;
|
||||||
|
mDragBar = NULL;
|
||||||
|
mPrevDock = NULL;
|
||||||
|
mPrevSlot = -1;
|
||||||
|
mLastPos.x = mBarPos.x = -1;
|
||||||
|
mLastPos.y = mBarPos.y = -1;
|
||||||
|
mTimer.Stop();
|
||||||
|
}
|
||||||
|
@ -75,6 +75,8 @@ class ToolManager final : public wxEvtHandler
|
|||||||
void OnMouse( wxMouseEvent & event );
|
void OnMouse( wxMouseEvent & event );
|
||||||
void OnCaptureLost( wxMouseCaptureLostEvent & event );
|
void OnCaptureLost( wxMouseCaptureLostEvent & event );
|
||||||
void OnGrabber( GrabberEvent & event );
|
void OnGrabber( GrabberEvent & event );
|
||||||
|
void HandleEscapeKey();
|
||||||
|
void DoneDragging();
|
||||||
|
|
||||||
void OnIndicatorCreate( wxWindowCreateEvent & event );
|
void OnIndicatorCreate( wxWindowCreateEvent & event );
|
||||||
void OnIndicatorPaint( wxPaintEvent & event );
|
void OnIndicatorPaint( wxPaintEvent & event );
|
||||||
@ -87,7 +89,7 @@ class ToolManager final : public wxEvtHandler
|
|||||||
|
|
||||||
ToolFrame *mDragWindow;
|
ToolFrame *mDragWindow;
|
||||||
ToolDock *mDragDock;
|
ToolDock *mDragDock;
|
||||||
ToolBar *mDragBar;
|
ToolBar *mDragBar {};
|
||||||
wxPoint mDragOffset;
|
wxPoint mDragOffset;
|
||||||
int mDragBefore;
|
int mDragBefore;
|
||||||
|
|
||||||
@ -112,6 +114,10 @@ class ToolManager final : public wxEvtHandler
|
|||||||
|
|
||||||
ToolBar *mBars[ ToolBarCount ];
|
ToolBar *mBars[ ToolBarCount ];
|
||||||
|
|
||||||
|
wxPoint mPrevPosition {};
|
||||||
|
ToolDock *mPrevDock {};
|
||||||
|
int mPrevSlot {-1};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DECLARE_CLASS( ToolManager );
|
DECLARE_CLASS( ToolManager );
|
||||||
|
@ -44,6 +44,7 @@ BEGIN_EVENT_TABLE(Grabber, wxWindow)
|
|||||||
EVT_LEAVE_WINDOW(Grabber::OnLeave)
|
EVT_LEAVE_WINDOW(Grabber::OnLeave)
|
||||||
EVT_LEFT_DOWN(Grabber::OnLeftDown)
|
EVT_LEFT_DOWN(Grabber::OnLeftDown)
|
||||||
EVT_PAINT(Grabber::OnPaint)
|
EVT_PAINT(Grabber::OnPaint)
|
||||||
|
EVT_KEY_DOWN(Grabber::OnKeyDown)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -78,12 +79,12 @@ Grabber::~Grabber()
|
|||||||
//
|
//
|
||||||
// Queue a drag event
|
// Queue a drag event
|
||||||
//
|
//
|
||||||
void Grabber::SendEvent(wxEventType type, const wxPoint & pos)
|
void Grabber::SendEvent(wxEventType type, const wxPoint & pos, bool escaping)
|
||||||
{
|
{
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
|
|
||||||
// Initialize event and convert mouse coordinates to screen space
|
// Initialize event and convert mouse coordinates to screen space
|
||||||
GrabberEvent e(type, GetId(), parent->ClientToScreen(pos));
|
GrabberEvent e(type, GetId(), parent->ClientToScreen(pos), escaping);
|
||||||
|
|
||||||
// Set the object of our desire
|
// Set the object of our desire
|
||||||
e.SetEventObject(parent);
|
e.SetEventObject(parent);
|
||||||
@ -190,7 +191,7 @@ void Grabber::OnLeftDown(wxMouseEvent & event)
|
|||||||
PushButton(true);
|
PushButton(true);
|
||||||
|
|
||||||
// Notify parent
|
// Notify parent
|
||||||
SendEvent(EVT_GRABBER_CLICKED, event.GetPosition());
|
SendEvent(EVT_GRABBER_CLICKED, event.GetPosition(), false);
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
@ -227,3 +228,15 @@ void Grabber::OnPaint(wxPaintEvent & WXUNUSED(event))
|
|||||||
// Redraw the grabber
|
// Redraw the grabber
|
||||||
DrawGrabber(dc);
|
DrawGrabber(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Grabber::OnKeyDown(wxKeyEvent &event)
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
|
||||||
|
if(event.GetKeyCode() == WXK_ESCAPE) {
|
||||||
|
// We must not only skip this key event, but propagate it up the window
|
||||||
|
// hierarchy, so that ToolFrame detects it too.
|
||||||
|
event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
|
||||||
|
SendEvent(EVT_GRABBER_CLICKED, wxPoint{ -1, -1 }, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -45,17 +45,15 @@ class GrabberEvent final : public wxCommandEvent
|
|||||||
|
|
||||||
GrabberEvent(wxEventType type = wxEVT_NULL,
|
GrabberEvent(wxEventType type = wxEVT_NULL,
|
||||||
wxWindowID winid = 0,
|
wxWindowID winid = 0,
|
||||||
const wxPoint& pt = wxDefaultPosition)
|
const wxPoint& pt = wxDefaultPosition,
|
||||||
|
bool escaping = false)
|
||||||
: wxCommandEvent(type, winid)
|
: wxCommandEvent(type, winid)
|
||||||
{
|
{
|
||||||
mPos = pt;
|
mPos = pt;
|
||||||
|
mEscaping = escaping;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrabberEvent(const GrabberEvent & event)
|
GrabberEvent(const GrabberEvent & event) = default;
|
||||||
: wxCommandEvent(event)
|
|
||||||
{
|
|
||||||
mPos = event.mPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Position of event (in screen coordinates)
|
// Position of event (in screen coordinates)
|
||||||
const wxPoint & GetPosition() const
|
const wxPoint & GetPosition() const
|
||||||
@ -68,6 +66,8 @@ class GrabberEvent final : public wxCommandEvent
|
|||||||
mPos = pos;
|
mPos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsEscaping() const { return mEscaping; }
|
||||||
|
|
||||||
// Clone is required by wxwidgets; implemented via copy constructor
|
// Clone is required by wxwidgets; implemented via copy constructor
|
||||||
wxEvent *Clone() const override
|
wxEvent *Clone() const override
|
||||||
{
|
{
|
||||||
@ -77,6 +77,7 @@ class GrabberEvent final : public wxCommandEvent
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
wxPoint mPos;
|
wxPoint mPos;
|
||||||
|
bool mEscaping {};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (wxEvtHandler::*GrabberEventFunction)(GrabberEvent &);
|
typedef void (wxEvtHandler::*GrabberEventFunction)(GrabberEvent &);
|
||||||
@ -105,7 +106,8 @@ class Grabber final : public wxWindow
|
|||||||
// not a need to dock/float a toolbar from the keyboard. If this
|
// not a need to dock/float a toolbar from the keyboard. If this
|
||||||
// changes, remove this and add the necessary keyboard movement
|
// changes, remove this and add the necessary keyboard movement
|
||||||
// handling.
|
// handling.
|
||||||
bool AcceptsFocus() const {return false;}
|
// PRL: Commented out so the ESC key can stop dragging.
|
||||||
|
// bool AcceptsFocus() const {return false;}
|
||||||
|
|
||||||
void PushButton(bool state);
|
void PushButton(bool state);
|
||||||
|
|
||||||
@ -115,11 +117,12 @@ class Grabber final : public wxWindow
|
|||||||
void OnEnter(wxMouseEvent & event);
|
void OnEnter(wxMouseEvent & event);
|
||||||
void OnLeave(wxMouseEvent & event);
|
void OnLeave(wxMouseEvent & event);
|
||||||
void OnPaint(wxPaintEvent & event);
|
void OnPaint(wxPaintEvent & event);
|
||||||
|
void OnKeyDown(wxKeyEvent & event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void DrawGrabber(wxDC & dc);
|
void DrawGrabber(wxDC & dc);
|
||||||
void SendEvent(wxEventType type, const wxPoint & pos);
|
void SendEvent(wxEventType type, const wxPoint & pos, bool escaping);
|
||||||
|
|
||||||
bool mOver;
|
bool mOver;
|
||||||
bool mPressed;
|
bool mPressed;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user