mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 00:20:06 +02:00
TrackPanel no longer implements the zoom tool...
... Also changed the behavior of drawing of dashed lines: make them disappear when they approach close enough that right-up will zoom out, not in.
This commit is contained in:
parent
cba51e1bf8
commit
85c03bb3b3
@ -1239,6 +1239,7 @@
|
||||
5EF17C231D1F0A690090A642 /* ScrubbingToolBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF17C211D1F0A690090A642 /* ScrubbingToolBar.cpp */; };
|
||||
5EF958851DEB121800191280 /* InconsistencyException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF958831DEB121800191280 /* InconsistencyException.cpp */; };
|
||||
5E73963B1DAFD82D00BA0A4D /* PopupMenuTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E7396391DAFD82D00BA0A4D /* PopupMenuTable.cpp */; };
|
||||
5E73963E1DAFD86000BA0A4D /* ZoomHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E73963C1DAFD86000BA0A4D /* ZoomHandle.cpp */; };
|
||||
8406A93812D0F2510011EA01 /* EQDefaultCurves.xml in Resources */ = {isa = PBXBuildFile; fileRef = 8406A93712D0F2510011EA01 /* EQDefaultCurves.xml */; };
|
||||
8484F31413086237002DF7F0 /* DeviceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8484F31213086237002DF7F0 /* DeviceManager.cpp */; };
|
||||
AA0084191EA8C6E70070CCE3 /* TracksBehaviorsPrefs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA0084181EA8C6E70070CCE3 /* TracksBehaviorsPrefs.cpp */; };
|
||||
@ -3075,6 +3076,8 @@
|
||||
5EF958841DEB121800191280 /* InconsistencyException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InconsistencyException.h; sourceTree = "<group>"; };
|
||||
5E7396391DAFD82D00BA0A4D /* PopupMenuTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PopupMenuTable.cpp; sourceTree = "<group>"; };
|
||||
5E73963A1DAFD82D00BA0A4D /* PopupMenuTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupMenuTable.h; sourceTree = "<group>"; };
|
||||
5E73963C1DAFD86000BA0A4D /* ZoomHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZoomHandle.cpp; sourceTree = "<group>"; };
|
||||
5E73963D1DAFD86000BA0A4D /* ZoomHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZoomHandle.h; sourceTree = "<group>"; };
|
||||
82FF184D13CF01A600C1B664 /* dBTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dBTable.cpp; path = sbsms/src/dBTable.cpp; sourceTree = "<group>"; };
|
||||
82FF184E13CF01A600C1B664 /* dBTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dBTable.h; path = sbsms/src/dBTable.h; sourceTree = "<group>"; };
|
||||
82FF184F13CF01A600C1B664 /* slide.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = slide.cpp; path = sbsms/src/slide.cpp; sourceTree = "<group>"; };
|
||||
@ -5729,12 +5732,14 @@
|
||||
5E1512681DB0010C00702E29 /* TrackControls.cpp */,
|
||||
5E15126A1DB0010C00702E29 /* TrackUI.cpp */,
|
||||
5E15126B1DB0010C00702E29 /* TrackVRulerControls.cpp */,
|
||||
5E73963C1DAFD86000BA0A4D /* ZoomHandle.cpp */,
|
||||
5E1512671DB0010C00702E29 /* CommonTrackPanelCell.h */,
|
||||
5E74D2DE1CC4429700D88B0B /* EditCursorOverlay.h */,
|
||||
5E74D2E01CC4429700D88B0B /* PlayIndicatorOverlay.h */,
|
||||
5E74D2E21CC4429700D88B0B /* Scrubbing.h */,
|
||||
5E1512691DB0010C00702E29 /* TrackControls.h */,
|
||||
5E15126C1DB0010C00702E29 /* TrackVRulerControls.h */,
|
||||
5E73963D1DAFD86000BA0A4D /* ZoomHandle.h */,
|
||||
);
|
||||
path = ui;
|
||||
sourceTree = "<group>";
|
||||
@ -7748,6 +7753,7 @@
|
||||
28D540060FD1912A00FA7C75 /* CommandBuilder.cpp in Sources */,
|
||||
28D540070FD1912A00FA7C75 /* CommandHandler.cpp in Sources */,
|
||||
28D540080FD1912A00FA7C75 /* ScriptCommandRelay.cpp in Sources */,
|
||||
5E73963E1DAFD86000BA0A4D /* ZoomHandle.cpp in Sources */,
|
||||
28DB34790FDC2C5D0011F589 /* ResponseQueue.cpp in Sources */,
|
||||
28DABFBE0FF19DB100AC7848 /* RealFFTf.cpp in Sources */,
|
||||
2800FE370FF32566005CA9E5 /* MidiIOPrefs.cpp in Sources */,
|
||||
|
@ -582,6 +582,8 @@ audacity_SOURCES = \
|
||||
tracks/ui/TrackUI.cpp \
|
||||
tracks/ui/TrackVRulerControls.cpp \
|
||||
tracks/ui/TrackVRulerControls.h \
|
||||
tracks/ui/ZoomHandle.cpp \
|
||||
tracks/ui/ZoomHandle.h \
|
||||
widgets/AButton.cpp \
|
||||
widgets/AButton.h \
|
||||
widgets/ASlider.cpp \
|
||||
|
@ -1146,7 +1146,6 @@ void TrackPanel::HandleInterruptedDrag()
|
||||
case IsSoloing:
|
||||
case IsMinimizing:
|
||||
case IsPopping:
|
||||
case IsZooming:
|
||||
sendEvent = false;
|
||||
|
||||
default:
|
||||
@ -1298,7 +1297,6 @@ bool TrackPanel::HandleEscapeKey(bool down)
|
||||
pMixerBoard->Refresh();
|
||||
}
|
||||
break;
|
||||
case IsZooming:
|
||||
case IsVZooming:
|
||||
//case IsAdjustingSample:
|
||||
break;
|
||||
@ -1779,9 +1777,6 @@ void TrackPanel::SetCursorAndTipByTool( int tool,
|
||||
case slideTool:
|
||||
SetCursor(unsafe ? *mDisabledCursor : *mSlideCursor);
|
||||
break;
|
||||
case zoomTool:
|
||||
SetCursor(event.ShiftDown()? *mZoomOutCursor : *mZoomInCursor);
|
||||
break;
|
||||
case drawTool:
|
||||
if (unsafe)
|
||||
SetCursor(*mDisabledCursor);
|
||||
@ -4057,88 +4052,6 @@ double TrackPanel::OnClipMove
|
||||
}
|
||||
|
||||
|
||||
/// This method takes care of our different zoom
|
||||
/// possibilities. It is possible for a user to just
|
||||
/// "zoom in" or "zoom out," but it is also possible
|
||||
/// for a user to drag and select an area that he
|
||||
/// or she wants to be zoomed in on. We use mZoomStart
|
||||
/// and mZoomEnd to track the beggining and end of such
|
||||
/// a zoom area. Note that the ViewInfo member
|
||||
/// mViewInfo actually keeps track of our zoom constant,
|
||||
/// so we achieve zooming by altering the zoom constant
|
||||
/// and forcing a refresh.
|
||||
void TrackPanel::HandleZoom(wxMouseEvent & event)
|
||||
{
|
||||
if (event.ButtonDown() || event.LeftDClick()) {
|
||||
HandleZoomClick(event);
|
||||
}
|
||||
else if (mMouseCapture == IsZooming) {
|
||||
if (event.Dragging()) {
|
||||
HandleZoomDrag(event);
|
||||
}
|
||||
else if (event.ButtonUp()) {
|
||||
HandleZoomButtonUp(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Zoom button down, record the position.
|
||||
void TrackPanel::HandleZoomClick(wxMouseEvent & event)
|
||||
{
|
||||
if (mCapturedTrack)
|
||||
return;
|
||||
|
||||
const auto foundCell = FindCell(event.m_x, event.m_y);
|
||||
mCapturedTrack = foundCell.pTrack;
|
||||
mCapturedRect = foundCell.rect;
|
||||
if (foundCell.type != CellType::Track || !(mCapturedTrack = foundCell.pTrack))
|
||||
return;
|
||||
|
||||
SetCapturedTrack(mCapturedTrack, IsZooming);
|
||||
|
||||
mZoomStart = event.m_x;
|
||||
mZoomEnd = event.m_x;
|
||||
}
|
||||
|
||||
/// Zoom drag
|
||||
void TrackPanel::HandleZoomDrag(wxMouseEvent & event)
|
||||
{
|
||||
const int left = GetLeftOffset();
|
||||
const int right = GetSize().x - kRightMargin - 1;
|
||||
|
||||
mZoomEnd = event.m_x;
|
||||
|
||||
if (event.m_x < left) {
|
||||
mZoomEnd = left;
|
||||
}
|
||||
else if (event.m_x > right) {
|
||||
mZoomEnd = right;
|
||||
}
|
||||
|
||||
if (IsDragZooming()) {
|
||||
Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// Zoom button up
|
||||
void TrackPanel::HandleZoomButtonUp(wxMouseEvent & event)
|
||||
{
|
||||
if (mZoomEnd < mZoomStart)
|
||||
std::swap(mZoomStart, mZoomEnd);
|
||||
|
||||
if (IsDragZooming())
|
||||
DragZoom(event, GetLeftOffset());
|
||||
else
|
||||
DoZoomInOut(event, GetLeftOffset());
|
||||
|
||||
mZoomEnd = mZoomStart = 0;
|
||||
|
||||
SetCapturedTrack(NULL);
|
||||
|
||||
MakeParentRedrawScrollbars();
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
/// Determines if drag zooming is active
|
||||
bool TrackPanel::IsDragZooming(int zoomStart, int zoomEnd)
|
||||
{
|
||||
@ -4153,41 +4066,6 @@ bool TrackPanel::IsMouseCaptured()
|
||||
}
|
||||
|
||||
|
||||
/// This actually sets the Zoom value when you're done doing
|
||||
/// a drag zoom.
|
||||
void TrackPanel::DragZoom(wxMouseEvent & event, int trackLeftEdge)
|
||||
{
|
||||
double left = mViewInfo->PositionToTime(mZoomStart, trackLeftEdge);
|
||||
double right = mViewInfo->PositionToTime(mZoomEnd, trackLeftEdge);
|
||||
double multiplier = (GetScreenEndTime() - mViewInfo->h) / (right - left);
|
||||
if (event.ShiftDown())
|
||||
multiplier = 1.0 / multiplier;
|
||||
|
||||
mViewInfo->ZoomBy(multiplier);
|
||||
|
||||
mViewInfo->h = left;
|
||||
}
|
||||
|
||||
/// This handles normal Zoom In/Out, if you just clicked;
|
||||
/// IOW, if you were NOT dragging to zoom an area.
|
||||
/// \todo MAGIC NUMBER: We've got several in this method.
|
||||
void TrackPanel::DoZoomInOut(wxMouseEvent & event, int trackLeftEdge)
|
||||
{
|
||||
double center_h = mViewInfo->PositionToTime(event.m_x, trackLeftEdge);
|
||||
|
||||
const double multiplier =
|
||||
(event.RightUp() || event.RightDClick() || event.ShiftDown())
|
||||
? 0.5 : 2.0;
|
||||
mViewInfo->ZoomBy(multiplier);
|
||||
|
||||
if (event.MiddleUp() || event.MiddleDClick())
|
||||
mViewInfo->SetZoom(ZoomInfo::GetDefaultZoom()); // AS: Reset zoom.
|
||||
|
||||
double new_center_h = mViewInfo->PositionToTime(event.m_x, trackLeftEdge);
|
||||
|
||||
mViewInfo->h += (center_h - new_center_h);
|
||||
}
|
||||
|
||||
/// Vertical zooming (triggered by clicking in the
|
||||
/// vertical ruler)
|
||||
void TrackPanel::HandleVZoom(wxMouseEvent & event)
|
||||
@ -6536,9 +6414,6 @@ try
|
||||
case IsMinimizing:
|
||||
HandleMinimizing(event);
|
||||
break;
|
||||
case IsZooming:
|
||||
HandleZoom(event);
|
||||
break;
|
||||
case IsAdjustingLabel:
|
||||
// Reach this case only when the captured track was label
|
||||
HandleGlyphDragRelease(static_cast<LabelTrack *>(mCapturedTrack), event);
|
||||
@ -7010,9 +6885,6 @@ void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event)
|
||||
if (!unsafe)
|
||||
HandleSlide(event);
|
||||
break;
|
||||
case zoomTool:
|
||||
HandleZoom(event);
|
||||
break;
|
||||
case drawTool:
|
||||
if (!unsafe)
|
||||
HandleSampleEditing(event);
|
||||
@ -7067,10 +6939,7 @@ int TrackPanel::DetermineToolToUse( ToolsToolBar * pTtb, const wxMouseEvent & ev
|
||||
int trackKind = pTrack->GetKind();
|
||||
currentTool = selectTool; // the default.
|
||||
|
||||
if (event.ButtonIsDown(wxMOUSE_BTN_RIGHT) || event.RightUp()){
|
||||
currentTool = zoomTool;
|
||||
}
|
||||
else if (trackKind == Track::Time){
|
||||
if (trackKind == Track::Time){
|
||||
currentTool = envelopeTool;
|
||||
} else if( trackKind == Track::Label ){
|
||||
currentTool = selectTool;
|
||||
@ -7473,8 +7342,7 @@ void TrackPanel::DrawEverythingElse(wxDC * dc,
|
||||
if (mUIHandle)
|
||||
mUIHandle->DrawExtras(UIHandle::Cells, dc, region, clip);
|
||||
|
||||
if ((mMouseCapture == IsZooming || mMouseCapture == IsVZooming) &&
|
||||
IsDragZooming()
|
||||
if (mMouseCapture == IsVZooming && IsDragZooming()
|
||||
// note track zooming now works like audio track
|
||||
//#ifdef USE_MIDI
|
||||
// && mCapturedTrack && mCapturedTrack->GetKind() != Track::Note
|
||||
|
@ -515,16 +515,8 @@ protected:
|
||||
static void AddClipsToCaptured
|
||||
( ClipMoveState &state, Track *t, double t0, double t1 );
|
||||
|
||||
// AS: Handle zooming into tracks
|
||||
virtual void HandleZoom(wxMouseEvent & event);
|
||||
virtual void HandleZoomClick(wxMouseEvent & event);
|
||||
virtual void HandleZoomDrag(wxMouseEvent & event);
|
||||
virtual void HandleZoomButtonUp(wxMouseEvent & event);
|
||||
|
||||
static bool IsDragZooming(int zoomStart, int zoomEnd);
|
||||
virtual bool IsDragZooming() { return IsDragZooming(mZoomStart, mZoomEnd); }
|
||||
virtual void DragZoom(wxMouseEvent &event, int x);
|
||||
virtual void DoZoomInOut(wxMouseEvent &event, int x);
|
||||
|
||||
virtual void HandleVZoom(wxMouseEvent & event);
|
||||
virtual void HandleVZoomClick(wxMouseEvent & event);
|
||||
@ -902,7 +894,6 @@ public:
|
||||
IsMinimizing,
|
||||
WasOverCutLine,
|
||||
IsPopping,
|
||||
IsZooming,
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
IsVelocitySliding,
|
||||
#endif
|
||||
|
@ -89,6 +89,8 @@ ToolsToolBar::ToolsToolBar()
|
||||
|
||||
mMessageOfTool[envelopeTool] = _("Click and drag to edit the amplitude envelope");
|
||||
mMessageOfTool[drawTool] = _("Click and drag to edit the samples");
|
||||
|
||||
// TODO: Why not mention middle click to zoom normal on Windows too?
|
||||
#if defined( __WXMAC__ )
|
||||
mMessageOfTool[zoomTool] = _("Click to Zoom In, Shift-Click to Zoom Out");
|
||||
#elif defined( __WXMSW__ )
|
||||
@ -96,6 +98,7 @@ ToolsToolBar::ToolsToolBar()
|
||||
#elif defined( __WXGTK__ )
|
||||
mMessageOfTool[zoomTool] = _("Left=Zoom In, Right=Zoom Out, Middle=Normal");
|
||||
#endif
|
||||
|
||||
mMessageOfTool[slideTool] = _("Click and drag to move a track in time");
|
||||
mMessageOfTool[multiTool] = wxT(""); // multi-mode tool
|
||||
|
||||
|
@ -9,6 +9,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
**********************************************************************/
|
||||
|
||||
#include "../../Track.h"
|
||||
#include "../../TrackPanelMouseEvent.h"
|
||||
#include "TrackControls.h"
|
||||
#include "TrackVRulerControls.h"
|
||||
|
||||
@ -16,8 +17,10 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../Project.h"
|
||||
#include "../../toolbars/ToolsToolBar.h"
|
||||
|
||||
#include "ZoomHandle.h"
|
||||
|
||||
HitTestResult Track::HitTest
|
||||
(const TrackPanelMouseEvent &,
|
||||
(const TrackPanelMouseEvent &event,
|
||||
const AudacityProject *pProject)
|
||||
{
|
||||
const ToolsToolBar * pTtb = pProject->GetToolsToolBar();
|
||||
@ -25,10 +28,12 @@ HitTestResult Track::HitTest
|
||||
const bool isMultiTool = pTtb->IsDown(multiTool);
|
||||
if (!isMultiTool) {
|
||||
switch (pTtb->GetCurrentTool()) {
|
||||
case zoomTool:
|
||||
return ZoomHandle::HitAnywhere(event.event, pProject);
|
||||
|
||||
case selectTool:
|
||||
case envelopeTool:
|
||||
case drawTool:
|
||||
case zoomTool:
|
||||
case slideTool:
|
||||
default:
|
||||
// cases not yet implemented
|
||||
@ -40,9 +45,8 @@ HitTestResult Track::HitTest
|
||||
// Replicate some of the logic of TrackPanel::DetermineToolToUse
|
||||
HitTestResult result;
|
||||
|
||||
if (isMultiTool) {
|
||||
// To do: special hit tests
|
||||
}
|
||||
if (isMultiTool)
|
||||
result = ZoomHandle::HitTest(event.event, pProject);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
212
src/tracks/ui/ZoomHandle.cpp
Normal file
212
src/tracks/ui/ZoomHandle.cpp
Normal file
@ -0,0 +1,212 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ZoomHandle.cpp
|
||||
|
||||
Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "../../Audacity.h"
|
||||
#include "ZoomHandle.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "../../MemoryX.h"
|
||||
|
||||
#include <wx/dc.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/gdicmn.h>
|
||||
|
||||
#include "../../HitTestResult.h"
|
||||
#include "../../Project.h"
|
||||
#include "../../RefreshCode.h"
|
||||
#include "../../TrackPanelMouseEvent.h"
|
||||
#include "../../toolbars/ToolsToolBar.h"
|
||||
#include "../../ViewInfo.h"
|
||||
#include "../../../images/Cursors.h"
|
||||
|
||||
/// This class takes care of our different zoom
|
||||
/// possibilities. It is possible for a user to just
|
||||
/// "zoom in" or "zoom out," but it is also possible
|
||||
/// for a user to drag and select an area that he
|
||||
/// or she wants to be zoomed in on. We use mZoomStart
|
||||
/// and mZoomEnd to track the beginning and end of such
|
||||
/// a zoom area. Note that the ViewInfo
|
||||
/// actually keeps track of our zoom constant,
|
||||
/// so we achieve zooming by altering the zoom constant
|
||||
/// and forcing a refresh.
|
||||
|
||||
ZoomHandle::ZoomHandle()
|
||||
{
|
||||
}
|
||||
|
||||
ZoomHandle &ZoomHandle::Instance()
|
||||
{
|
||||
static ZoomHandle instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
HitTestPreview ZoomHandle::HitPreview
|
||||
(const wxMouseEvent &event, const AudacityProject *pProject)
|
||||
{
|
||||
static auto zoomInCursor =
|
||||
::MakeCursor(wxCURSOR_MAGNIFIER, ZoomInCursorXpm, 19, 15);
|
||||
static auto zoomOutCursor =
|
||||
::MakeCursor(wxCURSOR_MAGNIFIER, ZoomOutCursorXpm, 19, 15);
|
||||
const ToolsToolBar *const ttb = pProject->GetToolsToolBar();
|
||||
return {
|
||||
ttb->GetMessageForTool(zoomTool),
|
||||
(event.ShiftDown() ? &*zoomOutCursor : &*zoomInCursor)
|
||||
};
|
||||
}
|
||||
|
||||
HitTestResult ZoomHandle::HitAnywhere
|
||||
(const wxMouseEvent &event, const AudacityProject *pProject)
|
||||
{
|
||||
return { HitPreview(event, pProject), &Instance() };
|
||||
}
|
||||
|
||||
HitTestResult ZoomHandle::HitTest
|
||||
(const wxMouseEvent &event, const AudacityProject *pProject)
|
||||
{
|
||||
if (event.ButtonIsDown(wxMOUSE_BTN_RIGHT) || event.RightUp())
|
||||
return HitAnywhere(event, pProject);
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
ZoomHandle::~ZoomHandle()
|
||||
{
|
||||
}
|
||||
|
||||
UIHandle::Result ZoomHandle::Click
|
||||
(const TrackPanelMouseEvent &evt, AudacityProject *)
|
||||
{
|
||||
const wxMouseEvent &event = evt.event;
|
||||
if (event.ButtonDown() || event.LeftDClick()) {
|
||||
/// Zoom button down, record the position.
|
||||
mZoomStart = event.m_x;
|
||||
mZoomEnd = event.m_x;
|
||||
mRect = evt.rect;
|
||||
}
|
||||
return RefreshCode::RefreshNone;
|
||||
}
|
||||
|
||||
UIHandle::Result ZoomHandle::Drag
|
||||
(const TrackPanelMouseEvent &evt, AudacityProject *)
|
||||
{
|
||||
const wxMouseEvent &event = evt.event;
|
||||
const int left = mRect.GetLeft();
|
||||
const int right = mRect.GetRight();
|
||||
|
||||
mZoomEnd = event.m_x;
|
||||
|
||||
if (event.m_x < left) {
|
||||
mZoomEnd = left;
|
||||
}
|
||||
else if (event.m_x > right) {
|
||||
mZoomEnd = right;
|
||||
}
|
||||
|
||||
// Refresh tracks ALWAYS. Even if IsDragZooming() becomes false, make the
|
||||
// dashed lines disappear. -- PRL
|
||||
return RefreshCode::RefreshAll; // (IsDragZooming() ? RefreshAllTracks : RefreshNone),
|
||||
}
|
||||
|
||||
HitTestPreview ZoomHandle::Preview
|
||||
(const TrackPanelMouseEvent &evt, const AudacityProject *pProject)
|
||||
{
|
||||
return HitPreview(evt.event, pProject);
|
||||
}
|
||||
|
||||
UIHandle::Result ZoomHandle::Release
|
||||
(const TrackPanelMouseEvent &evt, AudacityProject *pProject,
|
||||
wxWindow *)
|
||||
{
|
||||
const wxMouseEvent &event = evt.event;
|
||||
ViewInfo &viewInfo = pProject->GetViewInfo();
|
||||
if (mZoomEnd < mZoomStart)
|
||||
std::swap(mZoomStart, mZoomEnd);
|
||||
|
||||
const int trackLeftEdge = mRect.x;
|
||||
if (IsDragZooming())
|
||||
{
|
||||
/// This actually sets the Zoom value when you're done doing
|
||||
/// a drag zoom.
|
||||
double left = viewInfo.PositionToTime(mZoomStart, trackLeftEdge);
|
||||
double right = viewInfo.PositionToTime(mZoomEnd, trackLeftEdge);
|
||||
|
||||
double multiplier =
|
||||
(viewInfo.PositionToTime(mRect.width) - viewInfo.PositionToTime(0)) /
|
||||
(right - left);
|
||||
if (event.ShiftDown())
|
||||
multiplier = 1.0 / multiplier;
|
||||
|
||||
viewInfo.ZoomBy(multiplier);
|
||||
|
||||
viewInfo.h = left;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// This handles normal Zoom In/Out, if you just clicked;
|
||||
/// IOW, if you were NOT dragging to zoom an area.
|
||||
/// \todo MAGIC NUMBER: We've got several in this method.
|
||||
const double center_h =
|
||||
viewInfo.PositionToTime(event.m_x, trackLeftEdge);
|
||||
|
||||
const double multiplier =
|
||||
(event.RightUp() || event.RightDClick() || event.ShiftDown())
|
||||
? 0.5 : 2.0;
|
||||
viewInfo.ZoomBy(multiplier);
|
||||
|
||||
if (event.MiddleUp() || event.MiddleDClick())
|
||||
viewInfo.SetZoom(ZoomInfo::GetDefaultZoom()); // AS: Reset zoom.
|
||||
|
||||
const double new_center_h =
|
||||
viewInfo.PositionToTime(event.m_x, trackLeftEdge);
|
||||
|
||||
viewInfo.h += (center_h - new_center_h);
|
||||
}
|
||||
|
||||
mZoomEnd = mZoomStart = 0;
|
||||
|
||||
using namespace RefreshCode;
|
||||
return RefreshAll | FixScrollbars;
|
||||
}
|
||||
|
||||
UIHandle::Result ZoomHandle::Cancel(AudacityProject*)
|
||||
{
|
||||
// Cancel is implemented! And there is no initial state to restore,
|
||||
// so just return a code.
|
||||
return RefreshCode::RefreshAll;
|
||||
}
|
||||
|
||||
void ZoomHandle::DrawExtras
|
||||
(DrawingPass pass, wxDC * dc, const wxRegion &, const wxRect &panelRect)
|
||||
{
|
||||
if (pass == Cells) {
|
||||
// PRL: Draw dashed lines only if we would zoom in
|
||||
// for button up.
|
||||
if (!IsDragZooming())
|
||||
return;
|
||||
|
||||
wxRect rect;
|
||||
|
||||
dc->SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc->SetPen(*wxBLACK_DASHED_PEN);
|
||||
|
||||
rect.x = std::min(mZoomStart, mZoomEnd);
|
||||
rect.width = 1 + abs(mZoomEnd - mZoomStart);
|
||||
rect.y = -1;
|
||||
rect.height = panelRect.height + 2;
|
||||
|
||||
dc->DrawRectangle(rect);
|
||||
}
|
||||
}
|
||||
|
||||
bool ZoomHandle::IsDragZooming() const
|
||||
{
|
||||
const int DragThreshold = 3;// Anything over 3 pixels is a drag, else a click.
|
||||
return (abs(mZoomEnd - mZoomStart) > DragThreshold);
|
||||
}
|
66
src/tracks/ui/ZoomHandle.h
Normal file
66
src/tracks/ui/ZoomHandle.h
Normal file
@ -0,0 +1,66 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ZoomHandle.h
|
||||
|
||||
Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_ZOOM_HANDLE__
|
||||
#define __AUDACITY_ZOOM_HANDLE__
|
||||
|
||||
#include "../../UIHandle.h"
|
||||
|
||||
class wxMouseEvent;
|
||||
#include <wx/gdicmn.h>
|
||||
|
||||
struct HitTestResult;
|
||||
|
||||
class ZoomHandle final : public UIHandle
|
||||
{
|
||||
ZoomHandle();
|
||||
ZoomHandle(const ZoomHandle&) = delete;
|
||||
ZoomHandle &operator=(const ZoomHandle&) = delete;
|
||||
static ZoomHandle& Instance();
|
||||
static HitTestPreview HitPreview
|
||||
(const wxMouseEvent &event, const AudacityProject *pProject);
|
||||
|
||||
public:
|
||||
static HitTestResult HitAnywhere
|
||||
(const wxMouseEvent &event, const AudacityProject *pProject);
|
||||
static HitTestResult HitTest
|
||||
(const wxMouseEvent &event, const AudacityProject *pProject);
|
||||
|
||||
virtual ~ZoomHandle();
|
||||
|
||||
Result Click
|
||||
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
|
||||
|
||||
Result Drag
|
||||
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
|
||||
|
||||
HitTestPreview Preview
|
||||
(const TrackPanelMouseEvent &event, const AudacityProject *pProject)
|
||||
override;
|
||||
|
||||
Result Release
|
||||
(const TrackPanelMouseEvent &event, AudacityProject *pProject,
|
||||
wxWindow *pParent) override;
|
||||
|
||||
Result Cancel(AudacityProject *pProject) override;
|
||||
|
||||
void DrawExtras
|
||||
(DrawingPass pass,
|
||||
wxDC * dc, const wxRegion &updateRegion, const wxRect &panelRect)
|
||||
override;
|
||||
|
||||
private:
|
||||
bool IsDragZooming() const;
|
||||
|
||||
int mZoomStart{}, mZoomEnd{};
|
||||
wxRect mRect{};
|
||||
};
|
||||
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
@ -243,6 +243,7 @@
|
||||
<ClCompile Include="..\..\..\src\tracks\ui\TrackControls.cpp" />
|
||||
<ClCompile Include="..\..\..\src\tracks\ui\TrackUI.cpp" />
|
||||
<ClCompile Include="..\..\..\src\tracks\ui\TrackVRulerControls.cpp" />
|
||||
<ClCompile Include="..\..\..\src\tracks\ui\ZoomHandle.cpp" />
|
||||
<ClCompile Include="..\..\..\src\UIHandle.cpp" />
|
||||
<ClCompile Include="..\..\..\src\UndoManager.cpp" />
|
||||
<ClCompile Include="..\..\..\src\UserException.cpp" />
|
||||
@ -501,6 +502,7 @@
|
||||
<ClInclude Include="..\..\..\src\TranslatableStringArray.h" />
|
||||
<ClInclude Include="..\..\..\src\UserException.h" />
|
||||
<ClInclude Include="..\..\..\src\tracks\ui\TrackControls.h" />
|
||||
<ClInclude Include="..\..\..\src\tracks\ui\ZoomHandle.h" />
|
||||
<ClInclude Include="..\..\..\src\tracks\timetrack\ui\TimeTrackVRulerControls.h" />
|
||||
<ClInclude Include="..\..\..\src\tracks\ui\TrackVRulerControls.h" />
|
||||
<ClInclude Include="..\..\..\src\UIHandle.h" />
|
||||
|
@ -950,6 +950,9 @@
|
||||
<ClCompile Include="..\..\..\src\tracks\ui\TrackControls.cpp">
|
||||
<Filter>src\tracks\ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\tracks\ui\ZoomHandle.cpp">
|
||||
<Filter>src\tracks\ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\tracks\timetrack\ui\TimeTrackControls.cpp">
|
||||
<Filter>src\tracks\timetrack\ui</Filter>
|
||||
</ClCompile>
|
||||
@ -1894,6 +1897,9 @@
|
||||
<ClInclude Include="..\..\..\src\tracks\ui\TrackControls.h">
|
||||
<Filter>src\tracks\ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\tracks\ui\ZoomHandle.h">
|
||||
<Filter>src\tracks\ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\tracks\timetrack\ui\TimeTrackControls.h">
|
||||
<Filter>src\tracks\timetrack\ui</Filter>
|
||||
</ClInclude>
|
||||
|
Loading…
x
Reference in New Issue
Block a user