mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 16:40:07 +02:00
Note track affordances
This commit is contained in:
parent
5672a179da
commit
75e6f4b8bc
@ -794,6 +794,8 @@ list( APPEND SOURCES
|
|||||||
tracks/labeltrack/ui/LabelTrackVRulerControls.h
|
tracks/labeltrack/ui/LabelTrackVRulerControls.h
|
||||||
tracks/labeltrack/ui/LabelTrackView.cpp
|
tracks/labeltrack/ui/LabelTrackView.cpp
|
||||||
tracks/labeltrack/ui/LabelTrackView.h
|
tracks/labeltrack/ui/LabelTrackView.h
|
||||||
|
tracks/playabletrack/notetrack/ui/NoteTrackAffordanceControls.h
|
||||||
|
tracks/playabletrack/notetrack/ui/NoteTrackAffordanceControls.cpp
|
||||||
tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.cpp
|
tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.cpp
|
||||||
tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.h
|
tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.h
|
||||||
tracks/playabletrack/notetrack/ui/NoteTrackControls.cpp
|
tracks/playabletrack/notetrack/ui/NoteTrackControls.cpp
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
/*!********************************************************************
|
||||||
|
*
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
NoteTrackAffordanceControls.cpp
|
||||||
|
|
||||||
|
Vitaly Sverchinsky
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "NoteTrackAffordanceControls.h"
|
||||||
|
|
||||||
|
#include <wx/dc.h>
|
||||||
|
|
||||||
|
#include "../../../ui/AffordanceHandle.h"
|
||||||
|
#include "../../../../AllThemeResources.h"
|
||||||
|
#include "../../../../AColor.h"
|
||||||
|
#include "../../../../NoteTrack.h"
|
||||||
|
#include "../../../../ViewInfo.h"
|
||||||
|
#include "../../../../TrackArtist.h"
|
||||||
|
#include "../../../../TrackPanelMouseEvent.h"
|
||||||
|
#include "../../../../TrackPanelDrawingContext.h"
|
||||||
|
|
||||||
|
#include "../lib-src/header-substitutes/allegro.h"
|
||||||
|
|
||||||
|
|
||||||
|
NoteTrackAffordanceControls::NoteTrackAffordanceControls(const std::shared_ptr<Track>& pTrack)
|
||||||
|
: CommonTrackCell(pTrack)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<UIHandlePtr> NoteTrackAffordanceControls::HitTest(const TrackPanelMouseState& state, const AudacityProject* pProject)
|
||||||
|
{
|
||||||
|
std::vector<UIHandlePtr> results;
|
||||||
|
|
||||||
|
auto track = FindTrack();
|
||||||
|
const auto nt = std::static_pointer_cast<const NoteTrack>(track->SubstitutePendingChangedTrack());
|
||||||
|
|
||||||
|
const auto rect = state.rect;
|
||||||
|
|
||||||
|
auto& zoomInfo = ViewInfo::Get(*pProject);
|
||||||
|
auto left = zoomInfo.TimeToPosition(nt->GetOffset(), rect.x);
|
||||||
|
auto right = zoomInfo.TimeToPosition(nt->GetOffset() + nt->GetSeq().get_real_dur(), rect.x);
|
||||||
|
auto headerRect = wxRect(left, rect.y, right - left, rect.height);
|
||||||
|
|
||||||
|
auto px = state.state.m_x;
|
||||||
|
auto py = state.state.m_y;
|
||||||
|
|
||||||
|
if (px >= headerRect.GetLeft() && px <= headerRect.GetRight() &&
|
||||||
|
py >= headerRect.GetTop() && py <= headerRect.GetBottom())
|
||||||
|
{
|
||||||
|
results.push_back(AffordanceHandle::HitAnywhere(mAffordanceHandle, track));
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteTrackAffordanceControls::Draw(TrackPanelDrawingContext& context, const wxRect& rect, unsigned iPass)
|
||||||
|
{
|
||||||
|
if (iPass == TrackArtist::PassBackground) {
|
||||||
|
const auto nt = std::static_pointer_cast<const NoteTrack>(FindTrack()->SubstitutePendingChangedTrack());
|
||||||
|
const auto artist = TrackArtist::Get(context);
|
||||||
|
|
||||||
|
TrackArt::DrawBackgroundWithSelection(context, rect, nt.get(), AColor::labelSelectedBrush, AColor::labelUnselectedBrush);
|
||||||
|
|
||||||
|
const auto& zoomInfo = *artist->pZoomInfo;
|
||||||
|
auto left = zoomInfo.TimeToPosition(nt->GetOffset(), rect.x);
|
||||||
|
auto right = zoomInfo.TimeToPosition(nt->GetOffset() + nt->GetSeq().get_real_dur(), rect.x);
|
||||||
|
auto clipRect = wxRect(left, rect.y, right - left + 1, rect.height);
|
||||||
|
|
||||||
|
auto px = context.lastState.m_x;
|
||||||
|
auto py = context.lastState.m_y;
|
||||||
|
|
||||||
|
auto selected = IsSelected();
|
||||||
|
auto highlight = selected ||
|
||||||
|
(px >= clipRect.GetLeft() && px <= clipRect.GetRight() &&
|
||||||
|
py >= clipRect.GetTop() && py <= clipRect.GetBottom());
|
||||||
|
|
||||||
|
context.dc.SetClippingRegion(rect);
|
||||||
|
TrackArt::DrawClipAffordance(context.dc, clipRect, highlight, selected);
|
||||||
|
context.dc.DestroyClippingRegion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NoteTrackAffordanceControls::IsSelected() const
|
||||||
|
{
|
||||||
|
if (auto handle = mAffordanceHandle.lock())
|
||||||
|
{
|
||||||
|
return handle->Clicked();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/*!********************************************************************
|
||||||
|
*
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
NoteTrackAffordanceControls.h
|
||||||
|
|
||||||
|
Vitaly Sverchinsky
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../../../ui/CommonTrackPanelCell.h"
|
||||||
|
|
||||||
|
class AffordanceHandle;
|
||||||
|
|
||||||
|
class AUDACITY_DLL_API NoteTrackAffordanceControls : public CommonTrackCell
|
||||||
|
{
|
||||||
|
std::weak_ptr<AffordanceHandle> mAffordanceHandle;
|
||||||
|
public:
|
||||||
|
NoteTrackAffordanceControls(const std::shared_ptr<Track>& pTrack);
|
||||||
|
|
||||||
|
std::vector<UIHandlePtr> HitTest(const TrackPanelMouseState& state, const AudacityProject* pProject) override;
|
||||||
|
|
||||||
|
void Draw(TrackPanelDrawingContext& context, const wxRect& rect, unsigned iPass) override;
|
||||||
|
|
||||||
|
bool IsSelected() const;
|
||||||
|
};
|
@ -27,6 +27,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../../../ViewInfo.h"
|
#include "../../../../ViewInfo.h"
|
||||||
#include "../../../ui/SelectHandle.h"
|
#include "../../../ui/SelectHandle.h"
|
||||||
#include "StretchHandle.h"
|
#include "StretchHandle.h"
|
||||||
|
#include "NoteTrackAffordanceControls.h"
|
||||||
|
|
||||||
#include <wx/dc.h>
|
#include <wx/dc.h>
|
||||||
|
|
||||||
@ -75,6 +76,11 @@ std::shared_ptr<TrackVRulerControls> NoteTrackView::DoGetVRulerControls()
|
|||||||
#define TIME_TO_X(t) (zoomInfo.TimeToPosition((t), rect.x))
|
#define TIME_TO_X(t) (zoomInfo.TimeToPosition((t), rect.x))
|
||||||
#define X_TO_TIME(xx) (zoomInfo.PositionToTime((xx), rect.x))
|
#define X_TO_TIME(xx) (zoomInfo.PositionToTime((xx), rect.x))
|
||||||
|
|
||||||
|
std::shared_ptr<CommonTrackCell> NoteTrackView::DoGetAffordanceControls()
|
||||||
|
{
|
||||||
|
return std::make_shared<NoteTrackAffordanceControls>(DoFindTrack());
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -352,7 +358,8 @@ window and draw out-of-bounds notes here instead.
|
|||||||
void DrawNoteTrack(TrackPanelDrawingContext &context,
|
void DrawNoteTrack(TrackPanelDrawingContext &context,
|
||||||
const NoteTrack *track,
|
const NoteTrack *track,
|
||||||
const wxRect & rect,
|
const wxRect & rect,
|
||||||
bool muted)
|
bool muted,
|
||||||
|
bool selected)
|
||||||
{
|
{
|
||||||
auto &dc = context.dc;
|
auto &dc = context.dc;
|
||||||
const auto artist = TrackArtist::Get( context );
|
const auto artist = TrackArtist::Get( context );
|
||||||
@ -378,11 +385,6 @@ void DrawNoteTrack(TrackPanelDrawingContext &context,
|
|||||||
int numPitches = (rect.height) / data.GetPitchHeight(1);
|
int numPitches = (rect.height) / data.GetPitchHeight(1);
|
||||||
if (numPitches < 0) numPitches = 0; // cannot be negative
|
if (numPitches < 0) numPitches = 0; // cannot be negative
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_NOTETRACK_OVERLAY
|
|
||||||
TrackArt::DrawBackgroundWithSelection(context, rect, track,
|
|
||||||
AColor::labelSelectedBrush, AColor::labelUnselectedBrush);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Background comes in 4 colors, that are now themed.
|
// Background comes in 4 colors, that are now themed.
|
||||||
// 214, 214,214 -- unselected white keys
|
// 214, 214,214 -- unselected white keys
|
||||||
// 192,192,192 -- black keys
|
// 192,192,192 -- black keys
|
||||||
@ -704,6 +706,14 @@ void DrawNoteTrack(TrackPanelDrawingContext &context,
|
|||||||
TrackArt::DrawNegativeOffsetTrackArrows( context, rect );
|
TrackArt::DrawNegativeOffsetTrackArrows( context, rect );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//draw clip edges
|
||||||
|
{
|
||||||
|
int left = TIME_TO_X(track->GetOffset());
|
||||||
|
int right = TIME_TO_X(track->GetOffset() + track->GetSeq().get_real_dur());
|
||||||
|
|
||||||
|
TrackArt::DrawClipEdges(dc, wxRect(left, rect.GetTop(), right - left + 1, rect.GetHeight()), selected);
|
||||||
|
}
|
||||||
|
|
||||||
dc.DestroyClippingRegion();
|
dc.DestroyClippingRegion();
|
||||||
SonifyEndNoteForeground();
|
SonifyEndNoteForeground();
|
||||||
}
|
}
|
||||||
@ -723,7 +733,17 @@ void NoteTrackView::Draw(
|
|||||||
const auto hasSolo = artist->hasSolo;
|
const auto hasSolo = artist->hasSolo;
|
||||||
muted = (hasSolo || nt->GetMute()) && !nt->GetSolo();
|
muted = (hasSolo || nt->GetMute()) && !nt->GetSolo();
|
||||||
#endif
|
#endif
|
||||||
DrawNoteTrack( context, nt.get(), rect, muted );
|
|
||||||
|
#ifdef EXPERIMENTAL_NOTETRACK_OVERLAY
|
||||||
|
TrackArt::DrawBackgroundWithSelection(context, rect, nt.get(), AColor::labelSelectedBrush, AColor::labelUnselectedBrush);
|
||||||
|
#endif
|
||||||
|
bool selected{ false };
|
||||||
|
if (auto affordance = std::dynamic_pointer_cast<NoteTrackAffordanceControls>(GetAffordanceControls()))
|
||||||
|
{
|
||||||
|
selected = affordance->IsSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawNoteTrack(context, nt.get(), rect, muted, selected);
|
||||||
}
|
}
|
||||||
CommonTrackView::Draw( context, rect, iPass );
|
CommonTrackView::Draw( context, rect, iPass );
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,10 @@ public:
|
|||||||
NoteTrackView( const std::shared_ptr<Track> &pTrack );
|
NoteTrackView( const std::shared_ptr<Track> &pTrack );
|
||||||
~NoteTrackView() override;
|
~NoteTrackView() override;
|
||||||
|
|
||||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||||
|
std::shared_ptr<CommonTrackCell> DoGetAffordanceControls() override;
|
||||||
|
|
||||||
std::vector<UIHandlePtr> DetailedHitTest
|
std::vector<UIHandlePtr> DetailedHitTest
|
||||||
(const TrackPanelMouseState &state,
|
(const TrackPanelMouseState &state,
|
||||||
const AudacityProject *pProject, int currentTool, bool bMultiTool)
|
const AudacityProject *pProject, int currentTool, bool bMultiTool)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user