mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-06 14:52:34 +02:00
Move drawing code for zoom guidelines
This commit is contained in:
parent
488cb466c3
commit
f84d92f0a8
@ -69,6 +69,7 @@ public:
|
||||
PassMargins,
|
||||
PassBorders,
|
||||
PassControls,
|
||||
PassZooming,
|
||||
|
||||
NPasses
|
||||
};
|
||||
|
@ -972,8 +972,6 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
|
||||
}
|
||||
|
||||
auto target = Target();
|
||||
if (target)
|
||||
target->DrawExtras(UIHandle::Cells, dc, region, clip);
|
||||
|
||||
// Paint over the part below the tracks
|
||||
trackRect.y += trackRect.height;
|
||||
|
@ -43,7 +43,6 @@ public:
|
||||
|
||||
// Argument for the drawing function
|
||||
enum DrawingPass {
|
||||
Cells,
|
||||
Panel,
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../../Project.h"
|
||||
#include "../../../../ProjectHistory.h"
|
||||
#include "../../../../RefreshCode.h"
|
||||
#include "../../../../TrackArtist.h"
|
||||
#include "../../../../TrackPanelMouseEvent.h"
|
||||
#include "../../../../widgets/PopupMenuTable.h"
|
||||
#include "../../../../../images/Cursors.h"
|
||||
@ -356,16 +357,27 @@ UIHandle::Result NoteTrackVZoomHandle::Cancel(AudacityProject *WXUNUSED(pProject
|
||||
return RefreshCode::RefreshAll;
|
||||
}
|
||||
|
||||
void NoteTrackVZoomHandle::DrawExtras
|
||||
(DrawingPass pass, wxDC * dc, const wxRegion &, const wxRect &panelRect)
|
||||
void NoteTrackVZoomHandle::Draw(
|
||||
TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, unsigned iPass )
|
||||
{
|
||||
if (!mpTrack.lock()) //? TrackList::Lock()
|
||||
return;
|
||||
if ( iPass == TrackArtist::PassZooming ) {
|
||||
if (!mpTrack.lock()) //? TrackList::Lock()
|
||||
return;
|
||||
|
||||
if ( IsDragZooming( mZoomStart, mZoomEnd ) )
|
||||
TrackVRulerControls::DrawZooming
|
||||
( context, rect, mZoomStart, mZoomEnd );
|
||||
}
|
||||
}
|
||||
|
||||
if ( pass == UIHandle::Cells &&
|
||||
IsDragZooming( mZoomStart, mZoomEnd ) )
|
||||
TrackVRulerControls::DrawZooming
|
||||
( dc, mRect, panelRect, mZoomStart, mZoomEnd );
|
||||
wxRect NoteTrackVZoomHandle::DrawingArea(
|
||||
const wxRect &rect, const wxRect &panelRect, unsigned iPass )
|
||||
{
|
||||
if ( iPass == TrackArtist::PassZooming )
|
||||
return TrackVRulerControls::ZoomingArea( rect, panelRect );
|
||||
else
|
||||
return rect;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -54,12 +54,15 @@ public:
|
||||
|
||||
Result Cancel(AudacityProject *pProject) override;
|
||||
|
||||
void DrawExtras
|
||||
(DrawingPass pass,
|
||||
wxDC * dc, const wxRegion &updateRegion, const wxRect &panelRect)
|
||||
override;
|
||||
|
||||
private:
|
||||
// TrackPanelDrawable implementation
|
||||
void Draw(
|
||||
TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, unsigned iPass ) override;
|
||||
|
||||
wxRect DrawingArea(
|
||||
const wxRect &rect, const wxRect &panelRect, unsigned iPass ) override;
|
||||
|
||||
std::weak_ptr<NoteTrack> mpTrack;
|
||||
|
||||
int mZoomStart, mZoomEnd;
|
||||
|
@ -22,6 +22,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../../Project.h"
|
||||
#include "../../../../ProjectHistory.h"
|
||||
#include "../../../../RefreshCode.h"
|
||||
#include "../../../../TrackArtist.h"
|
||||
#include "../../../../TrackPanelMouseEvent.h"
|
||||
#include "../../../../WaveTrack.h"
|
||||
#include "../../../../widgets/PopupMenuTable.h"
|
||||
@ -706,15 +707,25 @@ UIHandle::Result WaveTrackVZoomHandle::Cancel(AudacityProject*)
|
||||
return RefreshCode::RefreshAll;
|
||||
}
|
||||
|
||||
void WaveTrackVZoomHandle::DrawExtras
|
||||
(DrawingPass pass, wxDC * dc, const wxRegion &, const wxRect &panelRect)
|
||||
void WaveTrackVZoomHandle::Draw(
|
||||
TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, unsigned iPass )
|
||||
{
|
||||
if (!mpTrack.lock()) // TrackList::Lock()?
|
||||
return;
|
||||
|
||||
if ( pass == UIHandle::Cells &&
|
||||
IsDragZooming( mZoomStart, mZoomEnd ) )
|
||||
TrackVRulerControls::DrawZooming
|
||||
( dc, mRect, panelRect, mZoomStart, mZoomEnd );
|
||||
if ( iPass == TrackArtist::PassZooming ) {
|
||||
if (!mpTrack.lock()) //? TrackList::Lock()
|
||||
return;
|
||||
|
||||
if ( IsDragZooming( mZoomStart, mZoomEnd ) )
|
||||
TrackVRulerControls::DrawZooming
|
||||
( context, rect, mZoomStart, mZoomEnd );
|
||||
}
|
||||
}
|
||||
|
||||
wxRect WaveTrackVZoomHandle::DrawingArea(
|
||||
const wxRect &rect, const wxRect &panelRect, unsigned iPass )
|
||||
{
|
||||
if ( iPass == TrackArtist::PassZooming )
|
||||
return TrackVRulerControls::ZoomingArea( rect, panelRect );
|
||||
else
|
||||
return rect;
|
||||
}
|
||||
|
@ -57,12 +57,16 @@ public:
|
||||
|
||||
Result Cancel(AudacityProject *pProject) override;
|
||||
|
||||
void DrawExtras
|
||||
(DrawingPass pass,
|
||||
wxDC * dc, const wxRegion &updateRegion, const wxRect &panelRect)
|
||||
override;
|
||||
|
||||
private:
|
||||
|
||||
// TrackPanelDrawable implementation
|
||||
void Draw(
|
||||
TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, unsigned iPass ) override;
|
||||
|
||||
wxRect DrawingArea(
|
||||
const wxRect &rect, const wxRect &panelRect, unsigned iPass ) override;
|
||||
|
||||
std::weak_ptr<WaveTrack> mpTrack;
|
||||
|
||||
int mZoomStart{}, mZoomEnd{};
|
||||
|
@ -68,25 +68,40 @@ std::vector<UIHandlePtr> TrackVRulerControls::HitTest
|
||||
}
|
||||
|
||||
void TrackVRulerControls::DrawZooming
|
||||
( wxDC *dc, const wxRect &cellRect, const wxRect &panelRect,
|
||||
( TrackPanelDrawingContext &context, const wxRect &rect_,
|
||||
int zoomStart, int zoomEnd )
|
||||
{
|
||||
// Draw a dashed rectangle, its right side disappearing in the black right
|
||||
// border of the track area, which is not part of this cell but right of it.
|
||||
wxRect rect;
|
||||
auto &dc = context.dc;
|
||||
|
||||
dc->SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc->SetPen(*wxBLACK_DASHED_PEN);
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.SetPen(*wxBLACK_DASHED_PEN);
|
||||
|
||||
rect.y = std::min( zoomStart, zoomEnd);
|
||||
rect.height = 1 + abs( zoomEnd - zoomStart);
|
||||
wxRect rect {
|
||||
rect_.x,
|
||||
std::min( zoomStart, zoomEnd),
|
||||
rect_.width,
|
||||
1 + abs( zoomEnd - zoomStart)
|
||||
};
|
||||
|
||||
rect.x = cellRect.x;
|
||||
dc.DrawRectangle(rect);
|
||||
}
|
||||
|
||||
wxRect TrackVRulerControls::ZoomingArea(
|
||||
const wxRect &rect, const wxRect &panelRect )
|
||||
{
|
||||
// TODO: Don't use the constant kRightMargin, but somehow discover the
|
||||
// neighboring track rectangle
|
||||
rect.SetRight(panelRect.GetWidth() - kRightMargin);
|
||||
|
||||
dc->DrawRectangle(rect);
|
||||
return {
|
||||
// Left edge of the rectangle disappears in the vertical line at
|
||||
// left edge of the ruler
|
||||
rect.x,
|
||||
rect.y,
|
||||
// Extend the dashed rectangle right up to the track border
|
||||
(panelRect.width - kRightMargin + kBorderThickness) - rect.x,
|
||||
rect.height
|
||||
};
|
||||
}
|
||||
|
||||
void TrackVRulerControls::Draw(
|
||||
|
@ -39,9 +39,11 @@ public:
|
||||
(const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject) override;
|
||||
|
||||
// Helpers for handle classes' TrackPanelDrawable implementations
|
||||
static void DrawZooming
|
||||
( wxDC *dc, const wxRect &cellRect, const wxRect &panelRect,
|
||||
( TrackPanelDrawingContext &context, const wxRect &rect,
|
||||
int zoomStart, int zoomEnd);
|
||||
static wxRect ZoomingArea( const wxRect &rect, const wxRect &panelRect );
|
||||
|
||||
// Modify the ruler rectangle, and related display parameters,
|
||||
// cached in the associated track
|
||||
|
@ -19,6 +19,8 @@ Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
#include "../../HitTestResult.h"
|
||||
#include "../../RefreshCode.h"
|
||||
#include "../../TrackArtist.h"
|
||||
#include "../../TrackPanelDrawingContext.h"
|
||||
#include "../../TrackPanelMouseEvent.h"
|
||||
#include "../../ViewInfo.h"
|
||||
#include "../../../images/Cursors.h"
|
||||
@ -183,29 +185,37 @@ UIHandle::Result ZoomHandle::Cancel(AudacityProject*)
|
||||
return RefreshCode::RefreshAll;
|
||||
}
|
||||
|
||||
void ZoomHandle::DrawExtras
|
||||
(DrawingPass pass, wxDC * dc, const wxRegion &, const wxRect &panelRect)
|
||||
void ZoomHandle::Draw(
|
||||
TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, unsigned iPass )
|
||||
{
|
||||
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);
|
||||
if ( iPass == TrackArtist::PassZooming &&
|
||||
// PRL: Draw dashed lines only if we would zoom in
|
||||
// for button up.
|
||||
IsDragZooming() ) {
|
||||
auto &dc = context.dc;
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.SetPen(*wxBLACK_DASHED_PEN);
|
||||
// Make the top and bottom of the dashed rectangle disappear out of
|
||||
// bounds, so that you only see vertical dashed lines.
|
||||
dc.DrawRectangle( {
|
||||
std::min(mZoomStart, mZoomEnd),
|
||||
rect.y - 1,
|
||||
1 + abs(mZoomEnd - mZoomStart),
|
||||
rect.height + 2
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
wxRect ZoomHandle::DrawingArea(
|
||||
const wxRect &rect, const wxRect &panelRect, unsigned iPass )
|
||||
{
|
||||
if ( iPass == TrackArtist::PassZooming )
|
||||
return MaximizeHeight( rect, panelRect );
|
||||
else
|
||||
return rect;
|
||||
}
|
||||
|
||||
bool ZoomHandle::IsDragZooming() const
|
||||
{
|
||||
const int DragThreshold = 3;// Anything over 3 pixels is a drag, else a click.
|
||||
|
@ -50,12 +50,16 @@ public:
|
||||
|
||||
Result Cancel(AudacityProject *pProject) override;
|
||||
|
||||
void DrawExtras
|
||||
(DrawingPass pass,
|
||||
wxDC * dc, const wxRegion &updateRegion, const wxRect &panelRect)
|
||||
override;
|
||||
|
||||
private:
|
||||
|
||||
// TrackPanelDrawable implementation
|
||||
void Draw(
|
||||
TrackPanelDrawingContext &context,
|
||||
const wxRect &rect, unsigned iPass ) override;
|
||||
|
||||
wxRect DrawingArea(
|
||||
const wxRect &rect, const wxRect &panelRect, unsigned iPass ) override;
|
||||
|
||||
bool IsDragZooming() const;
|
||||
|
||||
int mZoomStart{}, mZoomEnd{};
|
||||
|
Loading…
x
Reference in New Issue
Block a user