1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 17:14:07 +01:00

TrackPanel still draws Velocity, but no longer handles clicks on it...

... also implemented ESC key for that drag
This commit is contained in:
Paul Licameli
2017-05-14 17:26:17 -04:00
parent a569476e79
commit 7cab380192
7 changed files with 161 additions and 73 deletions

View File

@@ -14,6 +14,7 @@ Paul Licameli split from TrackPanel.cpp
#include "NoteTrackControls.h"
#include "../../ui/PlayableTrackButtonHandles.h"
#include "NoteTrackSliderHandles.h"
#include "../../../../HitTestResult.h"
#include "../../../../Track.h"
@@ -52,6 +53,11 @@ HitTestResult NoteTrackControls::HitTest
(result = SoloButtonHandle::HitTest
(event, rect, pProject, track)).handle)
return result;
#ifdef EXPERIMENTAL_MIDI_OUT
if (NULL != (result =
VelocitySliderHandle::HitTest(event, rect, pProject, mpTrack)).handle)
return result;
#endif
}
}

View File

@@ -0,0 +1,94 @@
/**********************************************************************
Audacity: A Digital Audio Editor
NoteTrackSliderHandles.cpp
Paul Licameli split from TrackPanel.cpp
**********************************************************************/
#include "../../../../Audacity.h"
#include "NoteTrackSliderHandles.h"
#ifdef EXPERIMENTAL_MIDI_OUT
#include "../../../../HitTestResult.h"
#include "../../../../MixerBoard.h"
#include "../../../../Project.h"
#include "../../../../RefreshCode.h"
#include "../../../../TrackPanel.h" // for TrackInfo
#include "../../../../UndoManager.h"
#include "../../../../NoteTrack.h"
VelocitySliderHandle::VelocitySliderHandle()
: SliderHandle()
{
}
VelocitySliderHandle::~VelocitySliderHandle()
{
}
VelocitySliderHandle &VelocitySliderHandle::Instance()
{
static VelocitySliderHandle instance;
return instance;
}
NoteTrack *VelocitySliderHandle::GetTrack()
{
return static_cast<NoteTrack*>(mpTrack);
}
float VelocitySliderHandle::GetValue()
{
return GetTrack()->GetVelocity();
}
UIHandle::Result VelocitySliderHandle::SetValue
(AudacityProject *pProject, float newValue)
{
GetTrack()->SetVelocity(newValue);
MixerBoard *const pMixerBoard = pProject->GetMixerBoard();
if (pMixerBoard)
pMixerBoard->UpdateVelocity(GetTrack());
return RefreshCode::RefreshCell;
}
UIHandle::Result VelocitySliderHandle::CommitChanges
(const wxMouseEvent &, AudacityProject *pProject)
{
pProject->PushState(_("Moved velocity slider"), _("Velocity"), UndoPush::CONSOLIDATE);
return RefreshCode::RefreshCell;
}
HitTestResult VelocitySliderHandle::HitTest
(const wxMouseEvent &event, const wxRect &rect,
const AudacityProject *pProject, Track *pTrack)
{
if (!event.Button(wxMOUSE_BTN_LEFT))
return {};
wxRect sliderRect;
TrackInfo::GetVelocityRect(rect.GetTopLeft(), sliderRect);
if ( TrackInfo::HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
return {};
if (sliderRect.Contains(event.m_x, event.m_y)) {
NoteTrack *const notetrack = static_cast<NoteTrack*>(pTrack);
auto slider = TrackInfo::VelocitySlider
(sliderRect, notetrack, true,
const_cast<TrackPanel*>(pProject->GetTrackPanel()));
Instance().mpSlider = slider;
Instance().mpTrack = notetrack;
return { HitPreview(), &Instance() };
}
else
return {};
}
#endif

View File

@@ -0,0 +1,52 @@
/**********************************************************************
Audacity: A Digital Audio Editor
NoteTrackSliderHandles.h
Paul Licameli split from TrackPanel.cpp
**********************************************************************/
#ifndef __AUDACITY_NOTE_TRACK_SLIDER_HANDLES__
#define __AUDACITY_NOTE_TRACK_SLIDER_HANDLES__
#include "../../../../Experimental.h"
#ifdef EXPERIMENTAL_MIDI_OUT
#include "../../../ui/SliderHandle.h"
class NoteTrack;
struct HitTestResult;
class VelocitySliderHandle final : public SliderHandle
{
VelocitySliderHandle(const VelocitySliderHandle&) = delete;
VelocitySliderHandle &operator=(const VelocitySliderHandle&) = delete;
VelocitySliderHandle();
virtual ~VelocitySliderHandle();
static VelocitySliderHandle& Instance();
NoteTrack *GetTrack();
protected:
float GetValue() override;
Result SetValue
(AudacityProject *pProject, float newValue) override;
Result CommitChanges
(const wxMouseEvent &event, AudacityProject *pProject) override;
bool StopsOnKeystroke () override { return true; }
public:
static HitTestResult HitTest
(const wxMouseEvent &event, const wxRect &rect,
const AudacityProject *pProject, Track *pTrack);
};
#endif
#endif