mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-14 17:14:07 +01:00
TrackPanel still draws Miminize and Close, but no longer handles...
clicks on them... ... also implemented ESC key for those drags
This commit is contained in:
committed by
Paul Licameli
parent
7cab380192
commit
c3f5fea5fc
@@ -8,7 +8,11 @@ Paul Licameli
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "../../Audacity.h"
|
||||
#include "ButtonHandle.h"
|
||||
|
||||
#include "../../MemoryX.h"
|
||||
|
||||
#include "../../HitTestResult.h"
|
||||
#include "../../Project.h"
|
||||
#include "../../RefreshCode.h"
|
||||
@@ -27,8 +31,8 @@ ButtonHandle::~ButtonHandle()
|
||||
|
||||
HitTestPreview ButtonHandle::HitPreview()
|
||||
{
|
||||
// No special message or cursor
|
||||
return {};
|
||||
static wxCursor arrowCursor{ wxCURSOR_ARROW };
|
||||
return { {}, &arrowCursor };
|
||||
}
|
||||
|
||||
UIHandle::Result ButtonHandle::Click
|
||||
|
||||
126
src/tracks/ui/TrackButtonHandles.cpp
Normal file
126
src/tracks/ui/TrackButtonHandles.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
TrackButtonHandles.cpp
|
||||
|
||||
Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "TrackButtonHandles.h"
|
||||
|
||||
#include "../../HitTestResult.h"
|
||||
#include "../../Project.h"
|
||||
#include "../../RefreshCode.h"
|
||||
#include "../../Track.h"
|
||||
#include "../../TrackPanel.h"
|
||||
|
||||
MinimizeButtonHandle::MinimizeButtonHandle()
|
||||
: ButtonHandle{ TrackPanel::IsMinimizing }
|
||||
{
|
||||
}
|
||||
|
||||
MinimizeButtonHandle::~MinimizeButtonHandle()
|
||||
{
|
||||
}
|
||||
|
||||
MinimizeButtonHandle &MinimizeButtonHandle::Instance()
|
||||
{
|
||||
static MinimizeButtonHandle instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
UIHandle::Result MinimizeButtonHandle::CommitChanges
|
||||
(const wxMouseEvent &, AudacityProject *pProject, wxWindow*)
|
||||
{
|
||||
using namespace RefreshCode;
|
||||
|
||||
if (mpTrack)
|
||||
{
|
||||
mpTrack->SetMinimized(!mpTrack->GetMinimized());
|
||||
if (mpTrack->GetLink())
|
||||
mpTrack->GetLink()->SetMinimized(mpTrack->GetMinimized());
|
||||
pProject->ModifyState(true);
|
||||
|
||||
// Redraw all tracks when any one of them expands or contracts
|
||||
// (Could we invent a return code that draws only those at or below
|
||||
// the affected track?)
|
||||
return RefreshAll | FixScrollbars;
|
||||
}
|
||||
|
||||
return RefreshNone;
|
||||
}
|
||||
|
||||
HitTestResult MinimizeButtonHandle::HitTest
|
||||
(const wxMouseEvent &event, const wxRect &rect)
|
||||
{
|
||||
wxRect buttonRect;
|
||||
TrackInfo::GetMinimizeRect(rect, buttonRect);
|
||||
|
||||
if (buttonRect.Contains(event.m_x, event.m_y)) {
|
||||
Instance().mRect = buttonRect;
|
||||
return {
|
||||
HitPreview(),
|
||||
&Instance()
|
||||
};
|
||||
}
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CloseButtonHandle::CloseButtonHandle()
|
||||
: ButtonHandle{ TrackPanel::IsClosing }
|
||||
{
|
||||
}
|
||||
|
||||
CloseButtonHandle::~CloseButtonHandle()
|
||||
{
|
||||
}
|
||||
|
||||
CloseButtonHandle &CloseButtonHandle::Instance()
|
||||
{
|
||||
static CloseButtonHandle instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
UIHandle::Result CloseButtonHandle::CommitChanges
|
||||
(const wxMouseEvent &, AudacityProject *pProject, wxWindow*)
|
||||
{
|
||||
using namespace RefreshCode;
|
||||
Result result = RefreshNone;
|
||||
|
||||
if (mpTrack)
|
||||
{
|
||||
pProject->StopIfPaused();
|
||||
if (!pProject->IsAudioActive()) {
|
||||
// This pushes an undo item:
|
||||
pProject->RemoveTrack(mpTrack);
|
||||
// Redraw all tracks when any one of them closes
|
||||
// (Could we invent a return code that draws only those at or below
|
||||
// the affected track?)
|
||||
result |= Resize | RefreshAll | FixScrollbars | DestroyedCell;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
HitTestResult CloseButtonHandle::HitTest
|
||||
(const wxMouseEvent &event, const wxRect &rect)
|
||||
{
|
||||
wxRect buttonRect;
|
||||
TrackInfo::GetCloseBoxRect(rect, buttonRect);
|
||||
|
||||
if (buttonRect.Contains(event.m_x, event.m_y)) {
|
||||
Instance().mRect = buttonRect;
|
||||
return {
|
||||
HitPreview(),
|
||||
&Instance()
|
||||
};
|
||||
}
|
||||
else
|
||||
return {};
|
||||
}
|
||||
58
src/tracks/ui/TrackButtonHandles.h
Normal file
58
src/tracks/ui/TrackButtonHandles.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
WavelTrackButtonHandles.h
|
||||
|
||||
Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_TRACK_BUTTON_HANDLES__
|
||||
#define __AUDACITY_TRACK_BUTTON_HANDLES__
|
||||
|
||||
#include "../ui/ButtonHandle.h"
|
||||
|
||||
struct HitTestResult;
|
||||
|
||||
class MinimizeButtonHandle final : public ButtonHandle
|
||||
{
|
||||
MinimizeButtonHandle(const MinimizeButtonHandle&) = delete;
|
||||
MinimizeButtonHandle &operator=(const MinimizeButtonHandle&) = delete;
|
||||
|
||||
MinimizeButtonHandle();
|
||||
virtual ~MinimizeButtonHandle();
|
||||
static MinimizeButtonHandle& Instance();
|
||||
|
||||
protected:
|
||||
Result CommitChanges
|
||||
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
|
||||
override;
|
||||
|
||||
public:
|
||||
static HitTestResult HitTest(const wxMouseEvent &event, const wxRect &rect);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CloseButtonHandle final : public ButtonHandle
|
||||
{
|
||||
CloseButtonHandle(const CloseButtonHandle&) = delete;
|
||||
CloseButtonHandle &operator=(const CloseButtonHandle&) = delete;
|
||||
|
||||
CloseButtonHandle();
|
||||
virtual ~CloseButtonHandle();
|
||||
static CloseButtonHandle& Instance();
|
||||
|
||||
protected:
|
||||
Result CommitChanges
|
||||
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
|
||||
override;
|
||||
|
||||
bool StopsOnKeystroke () override { return true; }
|
||||
|
||||
public:
|
||||
static HitTestResult HitTest(const wxMouseEvent &event, const wxRect &rect);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -10,7 +10,10 @@ Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
#include "../../Audacity.h"
|
||||
#include "TrackControls.h"
|
||||
#include "TrackButtonHandles.h"
|
||||
#include "../../HitTestResult.h"
|
||||
#include "../../TrackPanel.h"
|
||||
#include "../../TrackPanelMouseEvent.h"
|
||||
|
||||
int TrackControls::gCaptureState;
|
||||
|
||||
@@ -19,10 +22,20 @@ TrackControls::~TrackControls()
|
||||
}
|
||||
|
||||
HitTestResult TrackControls::HitTest
|
||||
(const TrackPanelMouseEvent &,
|
||||
(const TrackPanelMouseEvent &evt,
|
||||
const AudacityProject *)
|
||||
{
|
||||
return {};
|
||||
const wxMouseEvent &event = evt.event;
|
||||
const wxRect &rect = evt.rect;
|
||||
HitTestResult result;
|
||||
|
||||
if (NULL != (result = CloseButtonHandle::HitTest(event, rect)).handle)
|
||||
return result;
|
||||
|
||||
if (NULL != (result = MinimizeButtonHandle::HitTest(event, rect)).handle)
|
||||
return result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Track *TrackControls::FindTrack()
|
||||
|
||||
Reference in New Issue
Block a user