mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-15 16:17:41 +02:00
Reimplement the cursor mark in the ruler as an overlay
This commit is contained in:
parent
3466e91ed1
commit
d8e42b0af4
@ -937,7 +937,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
|||||||
}
|
}
|
||||||
bs->Layout();
|
bs->Layout();
|
||||||
|
|
||||||
// The right hand side translates to NEW TrackPanel(... in normal
|
// The right hand side translates to NEW TrackPanel(...) in normal
|
||||||
// Audacity without additional DLLs.
|
// Audacity without additional DLLs.
|
||||||
mTrackPanel = TrackPanel::FactoryFunction(pPage,
|
mTrackPanel = TrackPanel::FactoryFunction(pPage,
|
||||||
TrackPanelID,
|
TrackPanelID,
|
||||||
|
@ -15,7 +15,6 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../AColor.h"
|
#include "../../AColor.h"
|
||||||
#include "../../widgets/Ruler.h"
|
#include "../../widgets/Ruler.h"
|
||||||
#include "../../Project.h"
|
#include "../../Project.h"
|
||||||
//#include "../../TrackPanel.h"
|
|
||||||
#include "../../TrackPanelCell.h"
|
#include "../../TrackPanelCell.h"
|
||||||
#include "../../TrackPanelCellIterator.h"
|
#include "../../TrackPanelCellIterator.h"
|
||||||
#include "../../TrackPanelAx.h"
|
#include "../../TrackPanelAx.h"
|
||||||
@ -31,8 +30,9 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EditCursorOverlay::EditCursorOverlay(AudacityProject *project)
|
EditCursorOverlay::EditCursorOverlay(AudacityProject *project, bool isMaster)
|
||||||
: mProject(project)
|
: mProject(project)
|
||||||
|
, mIsMaster(isMaster)
|
||||||
, mLastCursorX(-1)
|
, mLastCursorX(-1)
|
||||||
, mCursorTime(-1)
|
, mCursorTime(-1)
|
||||||
, mNewCursorX(-1)
|
, mNewCursorX(-1)
|
||||||
@ -41,6 +41,11 @@ EditCursorOverlay::EditCursorOverlay(AudacityProject *project)
|
|||||||
|
|
||||||
EditCursorOverlay::~EditCursorOverlay()
|
EditCursorOverlay::~EditCursorOverlay()
|
||||||
{
|
{
|
||||||
|
if (mIsMaster && mPartner) {
|
||||||
|
auto ruler = mProject->GetRulerPanel();
|
||||||
|
if (ruler)
|
||||||
|
ruler->RemoveOverlay(mPartner.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<wxRect, bool> EditCursorOverlay::DoGetRectangle(wxSize size)
|
std::pair<wxRect, bool> EditCursorOverlay::DoGetRectangle(wxSize size)
|
||||||
@ -56,6 +61,7 @@ std::pair<wxRect, bool> EditCursorOverlay::DoGetRectangle(wxSize size)
|
|||||||
(mCursorTime, mProject->GetTrackPanel()->GetLeftOffset());
|
(mCursorTime, mProject->GetTrackPanel()->GetLeftOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Excessive height in case of the ruler, but it matters little.
|
||||||
return std::make_pair(
|
return std::make_pair(
|
||||||
mLastCursorX == -1
|
mLastCursorX == -1
|
||||||
? wxRect()
|
? wxRect()
|
||||||
@ -67,9 +73,13 @@ std::pair<wxRect, bool> EditCursorOverlay::DoGetRectangle(wxSize size)
|
|||||||
|
|
||||||
void EditCursorOverlay::Draw(OverlayPanel &panel, wxDC &dc)
|
void EditCursorOverlay::Draw(OverlayPanel &panel, wxDC &dc)
|
||||||
{
|
{
|
||||||
TrackPanel &tp = static_cast<TrackPanel&>(panel);
|
if (mIsMaster && !mPartner) {
|
||||||
TrackPanelCellIterator begin(&tp, true);
|
auto ruler = mProject->GetRulerPanel();
|
||||||
TrackPanelCellIterator end(&tp, false);
|
if (ruler) {
|
||||||
|
mPartner = std::make_unique<EditCursorOverlay>(mProject, false);
|
||||||
|
ruler->AddOverlay(mPartner.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mLastCursorX = mNewCursorX;
|
mLastCursorX = mNewCursorX;
|
||||||
if (mLastCursorX == -1)
|
if (mLastCursorX == -1)
|
||||||
@ -78,44 +88,56 @@ void EditCursorOverlay::Draw(OverlayPanel &panel, wxDC &dc)
|
|||||||
const ZoomInfo &viewInfo = mProject->GetZoomInfo();
|
const ZoomInfo &viewInfo = mProject->GetZoomInfo();
|
||||||
|
|
||||||
const bool
|
const bool
|
||||||
onScreen = between_incexc(viewInfo.h,
|
onScreen = between_incexc(viewInfo.h,
|
||||||
mCursorTime,
|
mCursorTime,
|
||||||
mProject->GetScreenEndTime());
|
mProject->GetScreenEndTime());
|
||||||
|
|
||||||
if (!onScreen)
|
if (!onScreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AColor::CursorColor(&dc);
|
if (auto tp = dynamic_cast<TrackPanel*>(&panel)) {
|
||||||
|
wxASSERT(mIsMaster);
|
||||||
|
AColor::CursorColor(&dc);
|
||||||
|
TrackPanelCellIterator begin(tp, true);
|
||||||
|
TrackPanelCellIterator end(tp, false);
|
||||||
|
|
||||||
// Draw cursor in all selected tracks
|
// Draw cursor in all selected tracks
|
||||||
for (; begin != end; ++begin)
|
for (; begin != end; ++begin)
|
||||||
{
|
|
||||||
TrackPanelCellIterator::value_type data(*begin);
|
|
||||||
Track *const pTrack = data.first;
|
|
||||||
if (!pTrack)
|
|
||||||
continue;
|
|
||||||
if (pTrack->GetSelected() ||
|
|
||||||
mProject->GetTrackPanel()->GetAx().IsFocused(pTrack))
|
|
||||||
{
|
{
|
||||||
const wxRect &rect = data.second;
|
TrackPanelCellIterator::value_type data(*begin);
|
||||||
// AColor::Line includes both endpoints so use GetBottom()
|
Track *const pTrack = data.first;
|
||||||
AColor::Line(dc, mLastCursorX, rect.GetTop(), mLastCursorX, rect.GetBottom()); // <-- The whole point of this routine.
|
if (!pTrack)
|
||||||
|
continue;
|
||||||
|
if (pTrack->GetSelected() ||
|
||||||
|
mProject->GetTrackPanel()->GetAx().IsFocused(pTrack))
|
||||||
|
{
|
||||||
|
const wxRect &rect = data.second;
|
||||||
|
// AColor::Line includes both endpoints so use GetBottom()
|
||||||
|
AColor::Line(dc, mLastCursorX, rect.GetTop(), mLastCursorX, rect.GetBottom());
|
||||||
|
// ^^^ The whole point of this routine.
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
|
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
|
||||||
if (MONO_WAVE_PAN(t)){
|
if (MONO_WAVE_PAN(t)){
|
||||||
y = t->GetY(true) - mViewInfo->vpos + 1;
|
y = t->GetY(true) - mViewInfo->vpos + 1;
|
||||||
top = y + kTopInset;
|
top = y + kTopInset;
|
||||||
bottom = y + t->GetHeight(true) - kTopInset;
|
bottom = y + t->GetHeight(true) - kTopInset;
|
||||||
AColor::Line(dc, mLastCursorX, top, mLastCursorX, bottom);
|
AColor::Line(dc, mLastCursorX, top, mLastCursorX, bottom);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This updates related displays such as numbers on the status bar
|
||||||
|
mProject->TP_DisplaySelection();
|
||||||
}
|
}
|
||||||
|
else if (auto ruler = dynamic_cast<AdornedRulerPanel*>(&panel)) {
|
||||||
// AS: Ah, no, this is where we draw the blinky thing in the ruler.
|
wxASSERT(!mIsMaster);
|
||||||
mProject->GetRulerPanel()->Refresh();
|
dc.SetPen(*wxBLACK_PEN);
|
||||||
|
// AColor::Line includes both endpoints so use GetBottom()
|
||||||
// This updates related displays such as numbers on the status bar
|
auto rect = ruler->GetInnerRect();
|
||||||
mProject->TP_DisplaySelection();
|
AColor::Line(dc, mLastCursorX, rect.GetTop(), mLastCursorX, rect.GetBottom());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
wxASSERT(false);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#ifndef __AUDACITY_EDIT_CURSOR_OVERLAY__
|
#ifndef __AUDACITY_EDIT_CURSOR_OVERLAY__
|
||||||
#define __AUDACITY_EDIT_CURSOR_OVERLAY__
|
#define __AUDACITY_EDIT_CURSOR_OVERLAY__
|
||||||
|
|
||||||
|
#include "../../MemoryX.h"
|
||||||
#include "../../widgets/Overlay.h"
|
#include "../../widgets/Overlay.h"
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
@ -18,7 +19,7 @@ class AudacityProject;
|
|||||||
class EditCursorOverlay final : public Overlay
|
class EditCursorOverlay final : public Overlay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EditCursorOverlay(AudacityProject *project);
|
EditCursorOverlay(AudacityProject *project, bool isMaster = true);
|
||||||
virtual ~EditCursorOverlay();
|
virtual ~EditCursorOverlay();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -26,6 +27,8 @@ private:
|
|||||||
void Draw(OverlayPanel &panel, wxDC &dc) override;
|
void Draw(OverlayPanel &panel, wxDC &dc) override;
|
||||||
|
|
||||||
AudacityProject *mProject;
|
AudacityProject *mProject;
|
||||||
|
bool mIsMaster;
|
||||||
|
std::unique_ptr<EditCursorOverlay> mPartner;
|
||||||
|
|
||||||
int mLastCursorX;
|
int mLastCursorX;
|
||||||
double mCursorTime;
|
double mCursorTime;
|
||||||
|
@ -2137,11 +2137,6 @@ void AdornedRulerPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
|||||||
DoDrawIndicator(&backDC, mIndTime, mIndType != 0, IndicatorMediumWidth, false);
|
DoDrawIndicator(&backDC, mIndTime, mIndType != 0, IndicatorMediumWidth, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mViewInfo->selectedRegion.isPoint())
|
|
||||||
{
|
|
||||||
DoDrawCursor(&backDC);
|
|
||||||
}
|
|
||||||
|
|
||||||
DoDrawPlayRegion(&backDC);
|
DoDrawPlayRegion(&backDC);
|
||||||
|
|
||||||
DoDrawPushbuttons(&backDC);
|
DoDrawPushbuttons(&backDC);
|
||||||
@ -3471,14 +3466,6 @@ void AdornedRulerPanel::SetLeftOffset(int offset)
|
|||||||
mRuler.SetUseZoomInfo(offset, mViewInfo);
|
mRuler.SetUseZoomInfo(offset, mViewInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::DoDrawCursor(wxDC * dc)
|
|
||||||
{
|
|
||||||
const int x = Time2Pos(mViewInfo->selectedRegion.t0());
|
|
||||||
|
|
||||||
// Draw cursor in ruler
|
|
||||||
dc->DrawLine( x, mInner.y, x, mInner.y + mInner.height );
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//This draws the little triangular indicator on the
|
//This draws the little triangular indicator on the
|
||||||
//AdornedRulerPanel.
|
//AdornedRulerPanel.
|
||||||
|
@ -295,6 +295,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static int GetRulerHeight();
|
static int GetRulerHeight();
|
||||||
static int GetRulerHeight(bool showScrubBar);
|
static int GetRulerHeight(bool showScrubBar);
|
||||||
|
wxRect GetInnerRect() const { return mInner; }
|
||||||
|
|
||||||
void SetLeftOffset(int offset);
|
void SetLeftOffset(int offset);
|
||||||
|
|
||||||
@ -378,7 +379,6 @@ private:
|
|||||||
void DoDrawBackground(wxDC * dc);
|
void DoDrawBackground(wxDC * dc);
|
||||||
void DoDrawEdge(wxDC *dc);
|
void DoDrawEdge(wxDC *dc);
|
||||||
void DoDrawMarks(wxDC * dc, bool /*text */ );
|
void DoDrawMarks(wxDC * dc, bool /*text */ );
|
||||||
void DoDrawCursor(wxDC * dc);
|
|
||||||
void DoDrawSelection(wxDC * dc);
|
void DoDrawSelection(wxDC * dc);
|
||||||
void DoDrawIndicator(wxDC * dc, double time, bool playing, int width, bool scrub);
|
void DoDrawIndicator(wxDC * dc, double time, bool playing, int width, bool scrub);
|
||||||
void DoEraseIndicator(wxDC *dc, int x);
|
void DoEraseIndicator(wxDC *dc, int x);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user