mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
AdornedRulerPanel inherits from OverlayPanel, doesn't need to manage the backing
This commit is contained in:
parent
7c2a531486
commit
468026f9b4
@ -1765,7 +1765,7 @@ enum {
|
|||||||
OnShowHideScrubbingID,
|
OnShowHideScrubbingID,
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(AdornedRulerPanel, wxPanel)
|
BEGIN_EVENT_TABLE(AdornedRulerPanel, OverlayPanel)
|
||||||
EVT_PAINT(AdornedRulerPanel::OnPaint)
|
EVT_PAINT(AdornedRulerPanel::OnPaint)
|
||||||
EVT_SIZE(AdornedRulerPanel::OnSize)
|
EVT_SIZE(AdornedRulerPanel::OnSize)
|
||||||
EVT_MOUSE_EVENTS(AdornedRulerPanel::OnMouseEvents)
|
EVT_MOUSE_EVENTS(AdornedRulerPanel::OnMouseEvents)
|
||||||
@ -1799,7 +1799,7 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* parent,
|
|||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
ViewInfo *viewinfo)
|
ViewInfo *viewinfo)
|
||||||
: wxPanel(parent, id, pos, size)
|
: OverlayPanel(parent, id, pos, size)
|
||||||
, mProject(parent)
|
, mProject(parent)
|
||||||
, mViewInfo(viewinfo)
|
, mViewInfo(viewinfo)
|
||||||
{
|
{
|
||||||
@ -1807,9 +1807,6 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* parent,
|
|||||||
SetName(GetLabel());
|
SetName(GetLabel());
|
||||||
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
|
|
||||||
mBack = new wxBitmap(1, 1);
|
|
||||||
mBackDC.SelectObject(*mBack);
|
|
||||||
|
|
||||||
mCursorDefault = wxCursor(wxCURSOR_DEFAULT);
|
mCursorDefault = wxCursor(wxCURSOR_DEFAULT);
|
||||||
mCursorHand = wxCursor(wxCURSOR_HAND);
|
mCursorHand = wxCursor(wxCURSOR_HAND);
|
||||||
mCursorSizeWE = wxCursor(wxCURSOR_SIZEWE);
|
mCursorSizeWE = wxCursor(wxCURSOR_SIZEWE);
|
||||||
@ -1873,12 +1870,6 @@ AdornedRulerPanel::~AdornedRulerPanel()
|
|||||||
wxCommandEventHandler(AdornedRulerPanel::OnCapture),
|
wxCommandEventHandler(AdornedRulerPanel::OnCapture),
|
||||||
NULL,
|
NULL,
|
||||||
this);
|
this);
|
||||||
|
|
||||||
if (mBack)
|
|
||||||
{
|
|
||||||
mBackDC.SelectObject(wxNullBitmap);
|
|
||||||
delete mBack;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -2129,52 +2120,44 @@ void AdornedRulerPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
|||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
if (mBack)
|
auto &backDC = GetBackingDCForRepaint();
|
||||||
{
|
|
||||||
mBackDC.SelectObject(wxNullBitmap);
|
|
||||||
delete mBack;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize sz = GetClientSize();
|
DoDrawBackground(&backDC);
|
||||||
mBack = new wxBitmap();
|
|
||||||
mBack->Create(sz.x, sz.y, dc);
|
|
||||||
mBackDC.SelectObject(*mBack);
|
|
||||||
|
|
||||||
DoDrawBackground(&mBackDC);
|
|
||||||
|
|
||||||
if (!mViewInfo->selectedRegion.isPoint())
|
if (!mViewInfo->selectedRegion.isPoint())
|
||||||
{
|
{
|
||||||
DoDrawSelection(&mBackDC);
|
DoDrawSelection(&backDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
DoDrawMarks(&mBackDC, true);
|
DoDrawMarks(&backDC, true);
|
||||||
|
|
||||||
if (mIndType >= 0)
|
if (mIndType >= 0)
|
||||||
{
|
{
|
||||||
const bool scrub = mProject->GetScrubber().HasStartedScrubbing();
|
const bool scrub = mProject->GetScrubber().HasStartedScrubbing();
|
||||||
DoDrawIndicator(&mBackDC, mIndTime, mIndType != 0, IndicatorMediumWidth, false);
|
DoDrawIndicator(&backDC, mIndTime, mIndType != 0, IndicatorMediumWidth, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mViewInfo->selectedRegion.isPoint())
|
if (mViewInfo->selectedRegion.isPoint())
|
||||||
{
|
{
|
||||||
DoDrawCursor(&mBackDC);
|
DoDrawCursor(&backDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
DoDrawPlayRegion(&mBackDC);
|
DoDrawPlayRegion(&backDC);
|
||||||
|
|
||||||
DoDrawPushbuttons(&mBackDC);
|
DoDrawPushbuttons(&backDC);
|
||||||
|
|
||||||
DoDrawEdge(&mBackDC);
|
DoDrawEdge(&backDC);
|
||||||
|
|
||||||
dc.Blit(0, 0, mBack->GetWidth(), mBack->GetHeight(), &mBackDC, 0, 0);
|
DisplayBitmap(dc);
|
||||||
|
|
||||||
|
// Stroke the quick play direct to the client area
|
||||||
if (mQuickPlayInd)
|
if (mQuickPlayInd)
|
||||||
{
|
{
|
||||||
DrawQuickPlayIndicator(&dc, true);
|
DrawQuickPlayIndicator(&dc, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::OnSize(wxSizeEvent & WXUNUSED(evt))
|
void AdornedRulerPanel::OnSize(wxSizeEvent &evt)
|
||||||
{
|
{
|
||||||
mOuter = GetClientRect();
|
mOuter = GetClientRect();
|
||||||
if (mOuter.GetWidth() == 0 || mOuter.GetHeight() == 0)
|
if (mOuter.GetWidth() == 0 || mOuter.GetHeight() == 0)
|
||||||
@ -2184,7 +2167,7 @@ void AdornedRulerPanel::OnSize(wxSizeEvent & WXUNUSED(evt))
|
|||||||
|
|
||||||
UpdateRects();
|
UpdateRects();
|
||||||
|
|
||||||
Refresh();
|
OverlayPanel::OnSize(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::UpdateRects()
|
void AdornedRulerPanel::UpdateRects()
|
||||||
@ -3576,7 +3559,7 @@ void AdornedRulerPanel::DoEraseIndicator(wxDC *dc, int x)
|
|||||||
dc->Blit(xx, yy,
|
dc->Blit(xx, yy,
|
||||||
indsize * 2 + 1 + 2,
|
indsize * 2 + 1 + 2,
|
||||||
GetSize().GetHeight(),
|
GetSize().GetHeight(),
|
||||||
&mBackDC,
|
&GetBackingDC(),
|
||||||
xx, yy);
|
xx, yy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
#ifndef __AUDACITY_RULER__
|
#ifndef __AUDACITY_RULER__
|
||||||
#define __AUDACITY_RULER__
|
#define __AUDACITY_RULER__
|
||||||
|
|
||||||
|
#include "OverlayPanel.h"
|
||||||
|
|
||||||
#include "../MemoryX.h"
|
#include "../MemoryX.h"
|
||||||
#include <wx/bitmap.h>
|
#include <wx/bitmap.h>
|
||||||
#include <wx/dc.h>
|
#include <wx/dc.h>
|
||||||
#include <wx/dcmemory.h>
|
#include <wx/dcmemory.h>
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
#include <wx/font.h>
|
#include <wx/font.h>
|
||||||
#include <wx/panel.h>
|
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
#include "../Experimental.h"
|
#include "../Experimental.h"
|
||||||
|
|
||||||
@ -280,7 +281,7 @@ class QuickPlayIndicatorOverlay;
|
|||||||
// Once TrackPanel uses wxSizers, we will derive it from some
|
// Once TrackPanel uses wxSizers, we will derive it from some
|
||||||
// wxWindow and the GetSize and SetSize functions
|
// wxWindow and the GetSize and SetSize functions
|
||||||
// will then be wxWidgets functions instead.
|
// will then be wxWidgets functions instead.
|
||||||
class AUDACITY_DLL_API AdornedRulerPanel final : public wxPanel
|
class AUDACITY_DLL_API AdornedRulerPanel final : public OverlayPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AdornedRulerPanel(AudacityProject* parent,
|
AdornedRulerPanel(AudacityProject* parent,
|
||||||
@ -432,9 +433,6 @@ private:
|
|||||||
AudacityProject *const mProject;
|
AudacityProject *const mProject;
|
||||||
TrackList *mTracks;
|
TrackList *mTracks;
|
||||||
|
|
||||||
wxBitmap *mBack;
|
|
||||||
wxMemoryDC mBackDC;
|
|
||||||
|
|
||||||
wxRect mOuter;
|
wxRect mOuter;
|
||||||
wxRect mScrubZone;
|
wxRect mScrubZone;
|
||||||
wxRect mInner;
|
wxRect mInner;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user