mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 00:49:33 +02:00
Define drawing function of CellularPanel, which visits nodes
This commit is contained in:
parent
040decf9e3
commit
cb2ea25afc
@ -252,6 +252,7 @@ src/TrackPanel.h
|
||||
src/TrackPanelAx.cpp
|
||||
src/TrackPanelAx.h
|
||||
src/TrackPanelCell.h
|
||||
src/TrackPanelDrawable.h
|
||||
src/TrackPanelDrawingContext.h
|
||||
src/TrackPanelListener.h
|
||||
src/TrackPanelMouseEvent.h
|
||||
|
@ -3238,6 +3238,7 @@
|
||||
5E19D64C217D51190024D0B1 /* PluginMenus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PluginMenus.cpp; path = menus/PluginMenus.cpp; sourceTree = "<group>"; };
|
||||
5E19F59722A9665500E3F88E /* AutoRecoveryDialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutoRecoveryDialog.cpp; sourceTree = "<group>"; };
|
||||
5E19F59822A9665500E3F88E /* AutoRecoveryDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoRecoveryDialog.h; sourceTree = "<group>"; };
|
||||
5E1C3F4D218F7604002CD087 /* TrackPanelDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrackPanelDrawable.h; sourceTree = "<group>"; };
|
||||
5E2A19921EED688500217B58 /* SelectionState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionState.cpp; sourceTree = "<group>"; };
|
||||
5E2A19931EED688500217B58 /* SelectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionState.h; sourceTree = "<group>"; };
|
||||
5E2B3E6022BF9621005042E1 /* RealtimeEffectManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeEffectManager.cpp; sourceTree = "<group>"; };
|
||||
@ -4607,6 +4608,7 @@
|
||||
1790B0ED09883BFD008A330A /* TrackPanel.h */,
|
||||
1790B0EF09883BFD008A330A /* TrackPanelAx.h */,
|
||||
5E74D2D91CC4427B00D88B0B /* TrackPanelCell.h */,
|
||||
5E1C3F4D218F7604002CD087 /* TrackPanelDrawable.h */,
|
||||
5E52335F1EFDD57D001E4BB8 /* TrackPanelDrawingContext.h */,
|
||||
2803C8B619F35AA000278526 /* TrackPanelListener.h */,
|
||||
5E15123A1DB000C000702E29 /* TrackPanelMouseEvent.h */,
|
||||
|
@ -1122,3 +1122,32 @@ std::shared_ptr<TrackPanelCell> CellularPanel::LastCell() const
|
||||
auto &state = *mState;
|
||||
return state.mLastCell.lock();
|
||||
}
|
||||
|
||||
void CellularPanel::Draw( TrackPanelDrawingContext &context, unsigned nPasses )
|
||||
{
|
||||
const auto panelRect = GetClientRect();
|
||||
auto lastCell = LastCell();
|
||||
for ( unsigned iPass = 0; iPass < nPasses; ++iPass ) {
|
||||
|
||||
VisitPostorder( [&]( const wxRect &rect, TrackPanelNode &node ) {
|
||||
|
||||
// Draw the node
|
||||
const auto newRect = node.DrawingArea( rect, panelRect, iPass );
|
||||
if ( newRect.Intersects( panelRect ) )
|
||||
node.Draw( context, newRect, iPass );
|
||||
|
||||
// Draw the current handle if it is associated with the node
|
||||
if ( &node == lastCell.get() ) {
|
||||
auto target = Target();
|
||||
if ( target ) {
|
||||
const auto targetRect =
|
||||
target->DrawingArea( rect, panelRect, iPass );
|
||||
if ( targetRect.Intersects( panelRect ) )
|
||||
target->Draw( context, targetRect, iPass );
|
||||
}
|
||||
}
|
||||
|
||||
} ); // nodes
|
||||
|
||||
} // passes
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ class ViewInfo;
|
||||
class AudacityProject;
|
||||
|
||||
class TrackPanelCell;
|
||||
struct TrackPanelDrawingContext;
|
||||
class TrackPanelGroup;
|
||||
class TrackPanelNode;
|
||||
struct TrackPanelMouseEvent;
|
||||
@ -107,6 +108,12 @@ public:
|
||||
wxCoord MostRecentXCoord() const;
|
||||
|
||||
void HandleCursorForPresentMouseState(bool doHit = true);
|
||||
|
||||
// Visit the Draw functions of all cells that intersect the panel area,
|
||||
// and of handles associated with such cells,
|
||||
// and of all groups of cells,
|
||||
// repeatedly with a pass count from 0 to nPasses - 1
|
||||
void Draw( TrackPanelDrawingContext &context, unsigned nPasses );
|
||||
|
||||
protected:
|
||||
bool HasEscape();
|
||||
|
@ -298,6 +298,7 @@ audacity_SOURCES = \
|
||||
TrackPanelAx.cpp \
|
||||
TrackPanelAx.h \
|
||||
TrackPanelCell.h \
|
||||
TrackPanelDrawable.h \
|
||||
TrackPanelDrawingContext.h \
|
||||
TrackPanelListener.h \
|
||||
TrackPanelMouseEvent.h \
|
||||
|
@ -345,26 +345,26 @@ am__audacity_SOURCES_DIST = BlockFile.cpp BlockFile.h DirManager.cpp \
|
||||
TimeTrack.h Track.cpp Track.h TrackArtist.cpp TrackArtist.h \
|
||||
TrackInfo.cpp TrackInfo.h TrackPanel.cpp TrackPanel.h \
|
||||
TrackPanelAx.cpp TrackPanelAx.h TrackPanelCell.h \
|
||||
TrackPanelDrawingContext.h TrackPanelListener.h \
|
||||
TrackPanelMouseEvent.h TrackPanelResizeHandle.cpp \
|
||||
TrackPanelResizeHandle.h TrackPanelResizerCell.cpp \
|
||||
TrackPanelResizerCell.h TrackUtilities.cpp TrackUtilities.h \
|
||||
TranslatableStringArray.h UIHandle.h UIHandle.cpp \
|
||||
UndoManager.cpp UndoManager.h UserException.cpp \
|
||||
UserException.h ViewInfo.cpp ViewInfo.h VoiceKey.cpp \
|
||||
VoiceKey.h WaveClip.cpp WaveClip.h WaveTrack.cpp WaveTrack.h \
|
||||
WaveTrackLocation.h WrappedType.cpp WrappedType.h ZoomInfo.cpp \
|
||||
ZoomInfo.h wxFileNameWrapper.h commands/AppCommandEvent.cpp \
|
||||
commands/AppCommandEvent.h commands/AudacityCommand.cpp \
|
||||
commands/AudacityCommand.h commands/BatchEvalCommand.cpp \
|
||||
commands/BatchEvalCommand.h commands/Command.cpp \
|
||||
commands/Command.h commands/CommandBuilder.cpp \
|
||||
commands/CommandBuilder.h commands/CommandContext.cpp \
|
||||
commands/CommandContext.h commands/CommandDirectory.cpp \
|
||||
commands/CommandDirectory.h commands/CommandFlag.h \
|
||||
commands/CommandFunctors.h commands/CommandHandler.cpp \
|
||||
commands/CommandHandler.h commands/CommandManager.cpp \
|
||||
commands/CommandManager.h \
|
||||
TrackPanelDrawable.h TrackPanelDrawingContext.h \
|
||||
TrackPanelListener.h TrackPanelMouseEvent.h \
|
||||
TrackPanelResizeHandle.cpp TrackPanelResizeHandle.h \
|
||||
TrackPanelResizerCell.cpp TrackPanelResizerCell.h \
|
||||
TrackUtilities.cpp TrackUtilities.h TranslatableStringArray.h \
|
||||
UIHandle.h UIHandle.cpp UndoManager.cpp UndoManager.h \
|
||||
UserException.cpp UserException.h ViewInfo.cpp ViewInfo.h \
|
||||
VoiceKey.cpp VoiceKey.h WaveClip.cpp WaveClip.h WaveTrack.cpp \
|
||||
WaveTrack.h WaveTrackLocation.h WrappedType.cpp WrappedType.h \
|
||||
ZoomInfo.cpp ZoomInfo.h wxFileNameWrapper.h \
|
||||
commands/AppCommandEvent.cpp commands/AppCommandEvent.h \
|
||||
commands/AudacityCommand.cpp commands/AudacityCommand.h \
|
||||
commands/BatchEvalCommand.cpp commands/BatchEvalCommand.h \
|
||||
commands/Command.cpp commands/Command.h \
|
||||
commands/CommandBuilder.cpp commands/CommandBuilder.h \
|
||||
commands/CommandContext.cpp commands/CommandContext.h \
|
||||
commands/CommandDirectory.cpp commands/CommandDirectory.h \
|
||||
commands/CommandFlag.h commands/CommandFunctors.h \
|
||||
commands/CommandHandler.cpp commands/CommandHandler.h \
|
||||
commands/CommandManager.cpp commands/CommandManager.h \
|
||||
commands/CommandManagerWindowClasses.h commands/CommandMisc.h \
|
||||
commands/CommandSignature.cpp commands/CommandSignature.h \
|
||||
commands/CommandTargets.h commands/CommandType.cpp \
|
||||
@ -1449,26 +1449,26 @@ audacity_SOURCES = $(libaudacity_la_SOURCES) AboutDialog.cpp \
|
||||
TimeTrack.h Track.cpp Track.h TrackArtist.cpp TrackArtist.h \
|
||||
TrackInfo.cpp TrackInfo.h TrackPanel.cpp TrackPanel.h \
|
||||
TrackPanelAx.cpp TrackPanelAx.h TrackPanelCell.h \
|
||||
TrackPanelDrawingContext.h TrackPanelListener.h \
|
||||
TrackPanelMouseEvent.h TrackPanelResizeHandle.cpp \
|
||||
TrackPanelResizeHandle.h TrackPanelResizerCell.cpp \
|
||||
TrackPanelResizerCell.h TrackUtilities.cpp TrackUtilities.h \
|
||||
TranslatableStringArray.h UIHandle.h UIHandle.cpp \
|
||||
UndoManager.cpp UndoManager.h UserException.cpp \
|
||||
UserException.h ViewInfo.cpp ViewInfo.h VoiceKey.cpp \
|
||||
VoiceKey.h WaveClip.cpp WaveClip.h WaveTrack.cpp WaveTrack.h \
|
||||
WaveTrackLocation.h WrappedType.cpp WrappedType.h ZoomInfo.cpp \
|
||||
ZoomInfo.h wxFileNameWrapper.h commands/AppCommandEvent.cpp \
|
||||
commands/AppCommandEvent.h commands/AudacityCommand.cpp \
|
||||
commands/AudacityCommand.h commands/BatchEvalCommand.cpp \
|
||||
commands/BatchEvalCommand.h commands/Command.cpp \
|
||||
commands/Command.h commands/CommandBuilder.cpp \
|
||||
commands/CommandBuilder.h commands/CommandContext.cpp \
|
||||
commands/CommandContext.h commands/CommandDirectory.cpp \
|
||||
commands/CommandDirectory.h commands/CommandFlag.h \
|
||||
commands/CommandFunctors.h commands/CommandHandler.cpp \
|
||||
commands/CommandHandler.h commands/CommandManager.cpp \
|
||||
commands/CommandManager.h \
|
||||
TrackPanelDrawable.h TrackPanelDrawingContext.h \
|
||||
TrackPanelListener.h TrackPanelMouseEvent.h \
|
||||
TrackPanelResizeHandle.cpp TrackPanelResizeHandle.h \
|
||||
TrackPanelResizerCell.cpp TrackPanelResizerCell.h \
|
||||
TrackUtilities.cpp TrackUtilities.h TranslatableStringArray.h \
|
||||
UIHandle.h UIHandle.cpp UndoManager.cpp UndoManager.h \
|
||||
UserException.cpp UserException.h ViewInfo.cpp ViewInfo.h \
|
||||
VoiceKey.cpp VoiceKey.h WaveClip.cpp WaveClip.h WaveTrack.cpp \
|
||||
WaveTrack.h WaveTrackLocation.h WrappedType.cpp WrappedType.h \
|
||||
ZoomInfo.cpp ZoomInfo.h wxFileNameWrapper.h \
|
||||
commands/AppCommandEvent.cpp commands/AppCommandEvent.h \
|
||||
commands/AudacityCommand.cpp commands/AudacityCommand.h \
|
||||
commands/BatchEvalCommand.cpp commands/BatchEvalCommand.h \
|
||||
commands/Command.cpp commands/Command.h \
|
||||
commands/CommandBuilder.cpp commands/CommandBuilder.h \
|
||||
commands/CommandContext.cpp commands/CommandContext.h \
|
||||
commands/CommandDirectory.cpp commands/CommandDirectory.h \
|
||||
commands/CommandFlag.h commands/CommandFunctors.h \
|
||||
commands/CommandHandler.cpp commands/CommandHandler.h \
|
||||
commands/CommandManager.cpp commands/CommandManager.h \
|
||||
commands/CommandManagerWindowClasses.h commands/CommandMisc.h \
|
||||
commands/CommandSignature.cpp commands/CommandSignature.h \
|
||||
commands/CommandTargets.h commands/CommandType.cpp \
|
||||
|
@ -1666,6 +1666,21 @@ void TrackPanel::OnTrackFocusChange( wxCommandEvent &event )
|
||||
}
|
||||
}
|
||||
|
||||
TrackPanelDrawable::~TrackPanelDrawable()
|
||||
{
|
||||
}
|
||||
|
||||
void TrackPanelDrawable::Draw(
|
||||
TrackPanelDrawingContext &, const wxRect &, unsigned )
|
||||
{
|
||||
}
|
||||
|
||||
wxRect TrackPanelDrawable::DrawingArea(
|
||||
const wxRect &rect, const wxRect &, unsigned )
|
||||
{
|
||||
return rect;
|
||||
}
|
||||
|
||||
TrackPanelNode::TrackPanelNode()
|
||||
{
|
||||
}
|
||||
|
@ -14,9 +14,11 @@ Paul Licameli
|
||||
#include "Audacity.h"
|
||||
|
||||
#include "MemoryX.h"
|
||||
#include "TrackPanelDrawable.h" // to inherit
|
||||
|
||||
class AudacityProject;
|
||||
struct HitTestPreview;
|
||||
struct TrackPanelDrawingContext;
|
||||
struct TrackPanelMouseEvent;
|
||||
struct TrackPanelMouseState;
|
||||
class ViewInfo;
|
||||
@ -31,9 +33,9 @@ using UIHandlePtr = std::shared_ptr<UIHandle>;
|
||||
#include <vector>
|
||||
|
||||
/// \brief The TrackPanel is built up of nodes, subtrees of the CellularPanel's area
|
||||
/// This class itself has almost nothing in it. Other classes derived from it
|
||||
/// build up the capabilities.
|
||||
/// Common base class for TrackPanelCell (leaf) and TrackPanelGroup (nonleaf)
|
||||
class AUDACITY_DLL_API /* not final */ TrackPanelNode
|
||||
: public TrackPanelDrawable
|
||||
{
|
||||
public:
|
||||
TrackPanelNode();
|
||||
|
51
src/TrackPanelDrawable.h
Normal file
51
src/TrackPanelDrawable.h
Normal file
@ -0,0 +1,51 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
TrackPanelDrawable.h
|
||||
|
||||
Paul Licameli
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_TRACK_PANEL_DRAWABLE__
|
||||
#define __AUDACITY_TRACK_PANEL_DRAWABLE__
|
||||
|
||||
struct TrackPanelDrawingContext;
|
||||
struct wxRect;
|
||||
|
||||
/// \brief Drawing interface common to cells, groups of cells, and temporary handles in CellularPanel
|
||||
class TrackPanelDrawable {
|
||||
public:
|
||||
virtual ~TrackPanelDrawable() = 0;
|
||||
|
||||
// Drawing functions of the subdivision are visited repeatedly in one
|
||||
// painting if their areas (as computed by DrawingArea) intersect the
|
||||
// panel area, and depending on iPass may overpaint results of previous
|
||||
// passes.
|
||||
// Drawing function is given the rectangle computed by DrawingArea.
|
||||
// iPass counts zero-based up to some limit given to CellularPanel::Draw.
|
||||
// Default implementation does nothing.
|
||||
virtual void Draw(
|
||||
TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass );
|
||||
|
||||
// For drawing purposes, a cell might require a bigger rectangle than for
|
||||
// hit-test purposes, spilling over into other parts of the partition of the
|
||||
// panel area.
|
||||
// Default implementation returns rect unchanged.
|
||||
virtual wxRect DrawingArea(
|
||||
const wxRect &rect, const wxRect &panelRect, unsigned iPass );
|
||||
|
||||
// Utilities for implementing DrawingArea:
|
||||
static inline wxRect MaximizeWidth(
|
||||
const wxRect &rect, const wxRect &panelRect ) {
|
||||
return { panelRect.x, rect.y, panelRect.width, rect.height };
|
||||
}
|
||||
|
||||
static inline wxRect MaximizeHeight(
|
||||
const wxRect &rect, const wxRect &panelRect ) {
|
||||
return { rect.x, panelRect.y, rect.width, panelRect.height };
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
@ -13,6 +13,7 @@ Paul Licameli
|
||||
|
||||
#include <utility>
|
||||
#include "MemoryX.h"
|
||||
#include "TrackPanelDrawable.h" // to inherit
|
||||
|
||||
class wxDC;
|
||||
class wxRect;
|
||||
@ -27,10 +28,11 @@ struct TrackPanelMouseState;
|
||||
|
||||
#include "MemoryX.h"
|
||||
|
||||
/// \brief Short-lived drawing and event-handling object associated with a TrackPanelCell
|
||||
// A TrackPanelCell reports a handle object of some subclass, in response to a
|
||||
// hit test at a mouse position; then this handle processes certain events,
|
||||
// and maintains necessary state through click-drag-release event sequences.
|
||||
class UIHandle /* not final */
|
||||
class UIHandle /* not final */ : public TrackPanelDrawable
|
||||
{
|
||||
public:
|
||||
// See RefreshCode.h for bit flags:
|
||||
|
@ -582,6 +582,7 @@
|
||||
<ClInclude Include="..\..\..\src\toolbars\SpectralSelectionBar.h" />
|
||||
<ClInclude Include="..\..\..\src\toolbars\SpectralSelectionBarListener.h" />
|
||||
<ClInclude Include="..\..\..\src\TrackPanelCell.h" />
|
||||
<ClInclude Include="..\..\..\src\TrackPanelDrawable.h" />
|
||||
<ClInclude Include="..\..\..\src\TrackPanelDrawingContext.h" />
|
||||
<ClInclude Include="..\..\..\src\TrackPanelListener.h" />
|
||||
<ClInclude Include="..\..\..\src\TrackPanelMouseEvent.h" />
|
||||
|
@ -2404,6 +2404,9 @@
|
||||
<ClInclude Include="..\..\..\src\tracks\ui\TrackView.h">
|
||||
<Filter>src\tracks\ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\TrackPanelDrawable.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\audacity.ico">
|
||||
|
Loading…
x
Reference in New Issue
Block a user