| 1 |
/*!******************************************************************** |
| 2 |
* |
| 3 |
Audacity: A Digital Audio Editor |
| 4 |
|
| 5 |
WaveClipAdjustBorderHandle.cpp |
| 6 |
|
| 7 |
Vitaly Sverchinsky |
| 8 |
|
| 9 |
**********************************************************************/ |
| 10 |
|
| 11 |
#include "WaveClipAdjustBorderHandle.h" |
| 12 |
#include "ProjectAudioIO.h" |
| 13 |
#include "RefreshCode.h" |
| 14 |
|
| 15 |
#include <wx/event.h> |
| 16 |
|
| 17 |
#include "ClipParameters.h" |
| 18 |
#include "../../../../TrackArt.h" |
| 19 |
#include "../../../../TrackArtist.h" |
| 20 |
#include "Snap.h" |
| 21 |
#include "../../../../TrackPanelDrawingContext.h" |
| 22 |
#include "../../../../../images/Cursors.h" |
| 23 |
#include "WaveClip.h" |
| 24 |
#include "WaveTrack.h" |
| 25 |
#include "WaveChannelView.h" |
| 26 |
#include "HitTestResult.h" |
| 27 |
#include "TrackPanelMouseEvent.h" |
| 28 |
#include "ViewInfo.h" |
| 29 |
#include "ProjectHistory.h" |
| 30 |
#include "UndoManager.h" |
| 31 |
#include "WaveClipUIUtilities.h" |
| 32 |
|
| 33 |
namespace { |
| 34 |
|
| 35 |
void TrimLeftTo(WaveTrack::Interval& interval, double t) |
| 36 |
{ |
| 37 |
interval.TrimLeftTo(t); |
| 38 |
} |
| 39 |
|
| 40 |
void TrimRightTo(WaveTrack::Interval& interval, double t) |
| 41 |
{ |
| 42 |
interval.TrimRightTo(t); |
| 43 |
} |
| 44 |
|
| 45 |
void StretchLeftTo(WaveTrack::Interval& interval, double t) |
| 46 |
{ |
| 47 |
interval.StretchLeftTo(t); |
| 48 |
} |
| 49 |
|
| 50 |
void StretchRightTo(WaveTrack::Interval& interval, double t) |
| 51 |
{ |
| 52 |
interval.StretchRightTo(t); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
//Different policies implement different adjustment scenarios |
| 57 |
class WaveClipAdjustBorderHandle::AdjustPolicy |
| 58 |
{ |
| 59 |
public: |
| 60 |
virtual ~AdjustPolicy(); |
| 61 |
|
| 62 |
virtual bool Init(const TrackPanelMouseEvent& event) = 0; |
| 63 |
virtual UIHandle::Result Drag(const TrackPanelMouseEvent& event, AudacityProject& project) = 0; |
| 64 |
virtual void Finish(AudacityProject& project) = 0; |
| 65 |
virtual void Cancel() = 0; |
| 66 |
|
| 67 |
virtual void Draw( |
| 68 |
TrackPanelDrawingContext &context, |
| 69 |
const wxRect &rect, |
| 70 |
unsigned iPass); |
| 71 |
|
| 72 |
virtual wxRect DrawingArea( |
| 73 |
TrackPanelDrawingContext&, |
| 74 |
const wxRect &rect, |
| 75 |
const wxRect &panelRect, |
| 76 |
unsigned iPass); |
| 77 |
}; |
| 78 |
|
| 79 |
WaveClipAdjustBorderHandle::AdjustPolicy::~AdjustPolicy() = default; |
| 80 |
|
| 81 |
namespace { |
| 82 |
double GetLeftAdjustLimit(const WaveTrack::Interval& interval, |
| 83 |
const WaveTrack& track, |
| 84 |
bool adjustingLeftBorder, |
| 85 |
bool isStretchMode) |
| 86 |
{ |
| 87 |
if (!adjustingLeftBorder) |
| 88 |
return std::min( |
| 89 |
interval.GetSequenceEndTime(), |
| 90 |
interval.Start() + 1.0 / track.GetRate() |
| 91 |
); |
| 92 |
|
| 93 |
const auto prevInterval = track.GetNextInterval(interval, PlaybackDirection::backward); |
| 94 |
if(isStretchMode) |
| 95 |
return prevInterval ? prevInterval->End() : |
| 96 |
std::numeric_limits<double>::lowest(); |
| 97 |
if(prevInterval) |
| 98 |
return std::max(interval.GetSequenceStartTime(), |
| 99 |
prevInterval->End()); |
| 100 |
return interval.GetSequenceStartTime(); |
| 101 |
} |
| 102 |
|
| 103 |
double GetRightAdjustLimit( |
| 104 |
const WaveTrack::Interval& interval, const WaveTrack& track, bool adjustingLeftBorder, |
| 105 |
bool isStretchMode) |
| 106 |
{ |
| 107 |
if (adjustingLeftBorder) |
| 108 |
return std::max( |
| 109 |
interval.GetSequenceStartTime(), |
| 110 |
interval.End() - 1.0 / track.GetRate() |
| 111 |
); |
| 112 |
|
| 113 |
const auto nextInterval = track.GetNextInterval(interval, PlaybackDirection::forward); |
| 114 |
if (isStretchMode) |
| 115 |
return nextInterval ? nextInterval->Start() : |
| 116 |
std::numeric_limits<double>::max(); |
| 117 |
|
| 118 |
if(nextInterval) |
| 119 |
return std::min(interval.GetSequenceEndTime(), |
| 120 |
nextInterval->Start()); |
| 121 |
return interval.GetSequenceEndTime(); |
| 122 |
} |
| 123 |
} // namespace |
| 124 |
|
| 125 |
class AdjustClipBorder final : public WaveClipAdjustBorderHandle::AdjustPolicy |
| 126 |
{ |
| 127 |
public: |
| 128 |
using AdjustHandler = std::function<void(WaveTrack::Interval&, double)>; |
| 129 |
|
| 130 |
private: |
| 131 |
std::shared_ptr<WaveTrack> mTrack; |
| 132 |
std::shared_ptr<WaveTrack::Interval> mInterval; |
| 133 |
int mDragStartX{ }; |
| 134 |
const bool mAdjustingLeftBorder; |
| 135 |
const bool mIsStretchMode; |
| 136 |
const double mInitialBorderPosition; |
| 137 |
double mBorderPosition; |
| 138 |
const std::pair<double, double> mRange; |
| 139 |
AdjustHandler mAdjustHandler; |
| 140 |
|
| 141 |
std::unique_ptr<SnapManager> mSnapManager; |
| 142 |
SnapResults mSnap; |
| 143 |
|
| 144 |
void TrimTo(double t) |
| 145 |
{ |
| 146 |
mBorderPosition = std::clamp(t, mRange.first, mRange.second); |
| 147 |
mAdjustHandler(*mInterval, mBorderPosition); |
| 148 |
} |
| 149 |
|
| 150 |
//Search for a good snap points among all tracks except |
| 151 |
//one to which moving interval belongs to |
| 152 |
static SnapPointArray FindSnapPoints( |
| 153 |
const WaveTrack* currentTrack, |
| 154 |
const std::pair<double, double> range) |
| 155 |
{ |
| 156 |
SnapPointArray result; |
| 157 |
|
| 158 |
auto addSnapPoint = [&](double t, const Track* track) |
| 159 |
{ |
| 160 |
if(t > range.second || t < range.first) |
| 161 |
return; |
| 162 |
|
| 163 |
for(const auto& snapPoint : result) |
| 164 |
if(snapPoint.t == t) |
| 165 |
return; |
| 166 |
result.emplace_back(t, track); |
| 167 |
}; |
| 168 |
|
| 169 |
if(const auto trackList = currentTrack->GetOwner()) |
| 170 |
{ |
| 171 |
for(const auto track : as_const(*trackList)) |
| 172 |
{ |
| 173 |
if(track == currentTrack) |
| 174 |
{ |
| 175 |
//skip track that interval belongs to |
| 176 |
continue; |
| 177 |
} |
| 178 |
|
| 179 |
for (const auto &interval : track->Intervals()) { |
| 180 |
addSnapPoint(interval->Start(), track); |
| 181 |
if(interval->Start() != interval->End()) |
| 182 |
addSnapPoint(interval->End(), track); |
| 183 |
} |
| 184 |
} |
| 185 |
} |
| 186 |
return result; |
| 187 |
} |
| 188 |
|
| 189 |
public: |
| 190 |
AdjustClipBorder(AdjustHandler adjustHandler, |
| 191 |
std::shared_ptr<WaveTrack> track, |
| 192 |
std::shared_ptr<WaveTrack::Interval> interval, |
| 193 |
bool adjustLeftBorder, |
| 194 |
bool isStretchMode, |
| 195 |
const ZoomInfo& zoomInfo) |
| 196 |
: mTrack { std::move(track) } |
| 197 |
, mInterval { std::move(interval) } |
| 198 |
, mAdjustingLeftBorder { adjustLeftBorder } |
| 199 |
, mIsStretchMode { isStretchMode } |
| 200 |
, mInitialBorderPosition { adjustLeftBorder ? mInterval->Start() : |
| 201 |
mInterval->End() } |
| 202 |
, mBorderPosition { mInitialBorderPosition } |
| 203 |
, mRange { GetLeftAdjustLimit( *mInterval, *mTrack, adjustLeftBorder, isStretchMode), |
| 204 |
GetRightAdjustLimit(*mInterval, *mTrack, adjustLeftBorder, isStretchMode) } |
| 205 |
, mAdjustHandler { std::move(adjustHandler) } |
| 206 |
{ |
| 207 |
assert(mRange.first <= mRange.second); |
| 208 |
if(const auto trackList = mTrack->GetOwner()) |
| 209 |
{ |
| 210 |
mSnapManager = std::make_unique<SnapManager>( |
| 211 |
*trackList->GetOwner(), |
| 212 |
FindSnapPoints(mTrack.get(), mRange), |
| 213 |
zoomInfo); |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
bool Init(const TrackPanelMouseEvent& event) override |
| 218 |
{ |
| 219 |
if (event.event.LeftDown()) |
| 220 |
{ |
| 221 |
mDragStartX = event.event.GetX(); |
| 222 |
return true; |
| 223 |
} |
| 224 |
return false; |
| 225 |
} |
| 226 |
|
| 227 |
UIHandle::Result Drag(const TrackPanelMouseEvent& event, AudacityProject& project) override |
| 228 |
{ |
| 229 |
const auto eventX = event.event.GetX(); |
| 230 |
const auto dx = eventX - mDragStartX; |
| 231 |
|
| 232 |
const auto& viewInfo = ViewInfo::Get(project); |
| 233 |
|
| 234 |
const auto eventT = viewInfo.PositionToTime( |
| 235 |
viewInfo.TimeToPosition(mInitialBorderPosition, event.rect.x) + dx, |
| 236 |
event.rect.x |
| 237 |
); |
| 238 |
|
| 239 |
const auto offset = sampleCount(floor((eventT - mInitialBorderPosition) * mTrack->GetRate())).as_double() |
| 240 |
/ mTrack->GetRate(); |
| 241 |
const auto t = std::clamp(mInitialBorderPosition + offset, mRange.first, mRange.second); |
| 242 |
const auto wasSnapped = mSnap.Snapped(); |
| 243 |
if(mSnapManager) |
| 244 |
mSnap = mSnapManager->Snap(mTrack.get(), t, !mAdjustingLeftBorder); |
| 245 |
if(mSnap.Snapped()) |
| 246 |
{ |
| 247 |
if (mSnap.outTime >= mRange.first && mSnap.outTime <= mRange.second) |
| 248 |
{ |
| 249 |
//Make sure that outTime belongs to the adjustment range after snapping |
| 250 |
TrimTo(mSnap.outTime); |
| 251 |
return RefreshCode::RefreshAll; |
| 252 |
} |
| 253 |
mSnap = {}; |
| 254 |
} |
| 255 |
TrimTo(t); |
| 256 |
//If there was a snap line, make sure it is removed |
| 257 |
//from the screen by redrawing whole TrackPanel |
| 258 |
return wasSnapped ? RefreshCode::RefreshAll : RefreshCode::RefreshCell; |
| 259 |
} |
| 260 |
|
| 261 |
void Finish(AudacityProject& project) override |
| 262 |
{ |
| 263 |
const auto dt = std::abs(mInitialBorderPosition - mBorderPosition); |
| 264 |
if (dt != 0) |
| 265 |
{ |
| 266 |
if (mIsStretchMode) |
| 267 |
{ |
| 268 |
WaveClipUIUtilities::PushClipSpeedChangedUndoState( |
| 269 |
project, 100.0 / mInterval->GetStretchRatio()); |
| 270 |
} |
| 271 |
else if (mAdjustingLeftBorder) |
| 272 |
{ |
| 273 |
/*i18n-hint: This is about trimming a clip, a length in seconds like "2.4 seconds" is shown*/ |
| 274 |
ProjectHistory::Get(project).PushState(XO("Adjust left trim by %.02f seconds").Format(dt), |
| 275 |
/*i18n-hint: This is about trimming a clip, a length in seconds like "2.4s" is shown*/ |
| 276 |
XO("Trim by %.02fs").Format(dt)); |
| 277 |
} |
| 278 |
else |
| 279 |
{ |
| 280 |
/*i18n-hint: This is about trimming a clip, a length in seconds like "2.4 seconds" is shown*/ |
| 281 |
ProjectHistory::Get(project).PushState(XO("Adjust right trim by %.02f seconds").Format(dt), |
| 282 |
/*i18n-hint: This is about trimming a clip, a length in seconds like "2.4s" is shown*/ |
| 283 |
XO("Trim by %.02fs").Format(dt)); |
| 284 |
} |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
void Cancel() override |
| 289 |
{ |
| 290 |
TrimTo(mInitialBorderPosition); |
| 291 |
} |
| 292 |
|
| 293 |
void Draw(TrackPanelDrawingContext& context, const wxRect& rect, unsigned iPass) override |
| 294 |
{ |
| 295 |
if(iPass == TrackArtist::PassSnapping && mSnap.Snapped()) |
| 296 |
{ |
| 297 |
auto &dc = context.dc; |
| 298 |
TrackArt::DrawSnapLines(&dc, rect.x + mSnap.outCoord, -1); |
| 299 |
} |
| 300 |
} |
| 301 |
|
| 302 |
wxRect DrawingArea(TrackPanelDrawingContext&, const wxRect& rect, const wxRect& panelRect, unsigned iPass) override |
| 303 |
{ |
| 304 |
if(iPass == TrackArtist::PassSnapping) |
| 305 |
return TrackPanelDrawable::MaximizeHeight(rect, panelRect); |
| 306 |
return rect; |
| 307 |
} |
| 308 |
}; |
| 309 |
|
| 310 |
HitTestPreview WaveClipAdjustBorderHandle::HitPreviewTrim(const AudacityProject*, bool unsafe, bool isLeftBorder) |
| 311 |
{ |
| 312 |
static auto disabledCursor = |
| 313 |
MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16); |
| 314 |
static auto trimCursorLeft = |
| 315 |
MakeCursor(wxCURSOR_SIZEWE, ClipTrimLeftXpm , 16, 16); |
| 316 |
static auto trimCursorRight = |
| 317 |
MakeCursor(wxCURSOR_SIZEWE, ClipTrimRightXpm, 16, 16); |
| 318 |
auto message = XO("Click and drag to move clip boundary in time"); |
| 319 |
|
| 320 |
return { |
| 321 |
message, |
| 322 |
(unsafe |
| 323 |
? &*disabledCursor |
| 324 |
: &*(isLeftBorder ? trimCursorLeft : trimCursorRight)) |
| 325 |
}; |
| 326 |
} |
| 327 |
|
| 328 |
HitTestPreview WaveClipAdjustBorderHandle::HitPreviewStretch(const AudacityProject*, bool unsafe, bool isLeftBorder) |
| 329 |
{ |
| 330 |
static auto disabledCursor = |
| 331 |
MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16); |
| 332 |
static auto stretchCursorLeft = |
| 333 |
MakeCursor(wxCURSOR_SIZEWE, ClipStretchLeftXpm, 16, 16); |
| 334 |
static auto stretchCursorRight = |
| 335 |
MakeCursor(wxCURSOR_SIZEWE, ClipStretchRightXpm, 16, 16); |
| 336 |
auto message = XO("Click and drag to stretch clip"); |
| 337 |
|
| 338 |
return { |
| 339 |
message, |
| 340 |
(unsafe |
| 341 |
? &*disabledCursor |
| 342 |
: &*(isLeftBorder ? stretchCursorLeft : stretchCursorRight)) |
| 343 |
}; |
| 344 |
} |
| 345 |
|
| 346 |
WaveClipAdjustBorderHandle::WaveClipAdjustBorderHandle( |
| 347 |
std::unique_ptr<AdjustPolicy>& adjustPolicy, |
| 348 |
std::shared_ptr<const WaveTrack> pTrack, |
| 349 |
bool stretchMode, |
| 350 |
bool leftBorder) |
| 351 |
: mAdjustPolicy{ std::move(adjustPolicy) } |
| 352 |
, mpTrack{ move(pTrack) } |
| 353 |
, mIsStretchMode{stretchMode} |
| 354 |
, mIsLeftBorder{leftBorder} |
| 355 |
{ |
| 356 |
|
| 357 |
} |
| 358 |
|
| 359 |
WaveClipAdjustBorderHandle::~WaveClipAdjustBorderHandle() = default; |
| 360 |
|
| 361 |
std::shared_ptr<const Track> WaveClipAdjustBorderHandle::FindTrack() const |
| 362 |
{ |
| 363 |
return mpTrack; |
| 364 |
} |
| 365 |
|
| 366 |
WaveClipAdjustBorderHandle::WaveClipAdjustBorderHandle(WaveClipAdjustBorderHandle&&) noexcept = default; |
| 367 |
|
| 368 |
WaveClipAdjustBorderHandle& WaveClipAdjustBorderHandle::operator=(WaveClipAdjustBorderHandle&&) noexcept = default; |
| 369 |
|
| 370 |
void WaveClipAdjustBorderHandle::AdjustPolicy::Draw(TrackPanelDrawingContext&, const wxRect&, unsigned) { } |
| 371 |
|
| 372 |
wxRect WaveClipAdjustBorderHandle::AdjustPolicy::DrawingArea(TrackPanelDrawingContext&, const wxRect& rect, const wxRect&, unsigned) |
| 373 |
{ |
| 374 |
return rect; |
| 375 |
} |
| 376 |
|
| 377 |
UIHandlePtr WaveClipAdjustBorderHandle::HitAnywhere( |
| 378 |
std::weak_ptr<WaveClipAdjustBorderHandle>& holder, |
| 379 |
const std::shared_ptr<WaveTrack>& waveTrack, |
| 380 |
const AudacityProject* pProject, |
| 381 |
const TrackPanelMouseState& state) |
| 382 |
{ |
| 383 |
const auto rect = state.rect; |
| 384 |
|
| 385 |
const auto px = state.state.m_x; |
| 386 |
|
| 387 |
auto& zoomInfo = ViewInfo::Get(*pProject); |
| 388 |
|
| 389 |
std::shared_ptr<WaveTrack::Interval> leftInterval; |
| 390 |
std::shared_ptr<WaveTrack::Interval> rightInterval; |
| 391 |
|
| 392 |
//Test left and right boundaries of each clip |
| 393 |
//to determine which kind of adjustment is |
| 394 |
//more appropriate |
| 395 |
for (const auto &interval : waveTrack->Intervals()) { |
| 396 |
const auto& clip = *interval; |
| 397 |
if(!WaveChannelView::ClipDetailsVisible(clip, zoomInfo, rect)) |
| 398 |
continue; |
| 399 |
|
| 400 |
auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, rect); |
| 401 |
if(std::abs(px - clipRect.GetLeft()) <= BoundaryThreshold * 2) |
| 402 |
rightInterval = interval; |
| 403 |
else if (std::abs(px - clipRect.GetRight()) <= BoundaryThreshold * 2) |
| 404 |
leftInterval = interval; |
| 405 |
} |
| 406 |
|
| 407 |
std::shared_ptr<WaveTrack::Interval> adjustedInterval; |
| 408 |
bool adjustLeftBorder {false}; |
| 409 |
if (leftInterval && rightInterval) |
| 410 |
{ |
| 411 |
//between adjacent clips |
| 412 |
if(ClipParameters::GetClipRect(*leftInterval, zoomInfo, rect).GetRight() > px) |
| 413 |
{ |
| 414 |
adjustedInterval = leftInterval; |
| 415 |
adjustLeftBorder = false; |
| 416 |
} |
| 417 |
else |
| 418 |
{ |
| 419 |
adjustedInterval = rightInterval; |
| 420 |
adjustLeftBorder = true; |
| 421 |
} |
| 422 |
} |
| 423 |
else |
| 424 |
{ |
| 425 |
adjustedInterval = leftInterval ? leftInterval : rightInterval; |
| 426 |
if (adjustedInterval) |
| 427 |
{ |
| 428 |
//single clip case, determine the border, |
| 429 |
//hit testing area differs from one |
| 430 |
//used for general case |
| 431 |
const auto clipRect = ClipParameters::GetClipRect(*adjustedInterval, zoomInfo, rect); |
| 432 |
if (std::abs(px - clipRect.GetLeft()) <= BoundaryThreshold) |
| 433 |
adjustLeftBorder = true; |
| 434 |
else if (std::abs(px - clipRect.GetRight()) <= BoundaryThreshold) |
| 435 |
adjustLeftBorder = false; |
| 436 |
else |
| 437 |
adjustedInterval.reset(); |
| 438 |
} |
| 439 |
} |
| 440 |
|
| 441 |
if(adjustedInterval) |
| 442 |
{ |
| 443 |
const auto isStretchMode = state.state.AltDown(); |
| 444 |
AdjustClipBorder::AdjustHandler adjustHandler = isStretchMode |
| 445 |
? (adjustLeftBorder ? StretchLeftTo : StretchRightTo) |
| 446 |
: (adjustLeftBorder ? TrimLeftTo : TrimRightTo); |
| 447 |
|
| 448 |
std::unique_ptr<AdjustPolicy> policy = |
| 449 |
std::make_unique<AdjustClipBorder>( |
| 450 |
adjustHandler, waveTrack, adjustedInterval, adjustLeftBorder, |
| 451 |
isStretchMode, zoomInfo); |
| 452 |
|
| 453 |
return AssignUIHandlePtr( |
| 454 |
holder, |
| 455 |
std::make_shared<WaveClipAdjustBorderHandle>(policy, waveTrack, |
| 456 |
isStretchMode, |
| 457 |
adjustLeftBorder)); |
| 458 |
} |
| 459 |
return { }; |
| 460 |
} |
| 461 |
|
| 462 |
UIHandlePtr WaveClipAdjustBorderHandle::HitTest(std::weak_ptr<WaveClipAdjustBorderHandle>& holder, |
| 463 |
WaveChannelView& view, const AudacityProject* pProject, |
| 464 |
const TrackPanelMouseState& state) |
| 465 |
{ |
| 466 |
auto waveChannel = view.FindWaveChannel(); |
| 467 |
// For multichannel tracks, show adjustment handle only for the topmost |
| 468 |
// channel |
| 469 |
if (waveChannel->GetChannelIndex() != 0) |
| 470 |
return {}; |
| 471 |
|
| 472 |
std::vector<UIHandlePtr> results; |
| 473 |
|
| 474 |
const auto rect = state.rect; |
| 475 |
|
| 476 |
auto py = state.state.m_y; |
| 477 |
|
| 478 |
if (py >= rect.GetTop() && |
| 479 |
py <= (rect.GetTop() + static_cast<int>(rect.GetHeight() * 0.3))) |
| 480 |
{ |
| 481 |
return HitAnywhere(holder, |
| 482 |
waveChannel->GetTrack().SharedPointer<WaveTrack>(), |
| 483 |
pProject, state); |
| 484 |
} |
| 485 |
return {}; |
| 486 |
} |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
HitTestPreview WaveClipAdjustBorderHandle::Preview(const TrackPanelMouseState& mouseState, AudacityProject* pProject) |
| 491 |
{ |
| 492 |
const bool unsafe = ProjectAudioIO::Get(*pProject).IsAudioActive(); |
| 493 |
return mIsStretchMode |
| 494 |
? HitPreviewStretch(pProject, unsafe, mIsLeftBorder) |
| 495 |
: HitPreviewTrim(pProject, unsafe, mIsLeftBorder); |
| 496 |
} |
| 497 |
|
| 498 |
UIHandle::Result WaveClipAdjustBorderHandle::Click |
| 499 |
(const TrackPanelMouseEvent& event, AudacityProject* pProject) |
| 500 |
{ |
| 501 |
if (!ProjectAudioIO::Get(*pProject).IsAudioActive()) |
| 502 |
{ |
| 503 |
if (mAdjustPolicy->Init(event)) |
| 504 |
return RefreshCode::RefreshNone; |
| 505 |
} |
| 506 |
return RefreshCode::Cancelled; |
| 507 |
} |
| 508 |
|
| 509 |
UIHandle::Result WaveClipAdjustBorderHandle::Drag |
| 510 |
(const TrackPanelMouseEvent& event, AudacityProject* project) |
| 511 |
{ |
| 512 |
return mAdjustPolicy->Drag(event, *project); |
| 513 |
} |
| 514 |
|
| 515 |
UIHandle::Result WaveClipAdjustBorderHandle::Release |
| 516 |
(const TrackPanelMouseEvent& event, AudacityProject* project, |
| 517 |
wxWindow* pParent) |
| 518 |
{ |
| 519 |
mAdjustPolicy->Finish(*project); |
| 520 |
return RefreshCode::RefreshAll; |
| 521 |
} |
| 522 |
|
| 523 |
UIHandle::Result WaveClipAdjustBorderHandle::Cancel(AudacityProject* pProject) |
| 524 |
{ |
| 525 |
mAdjustPolicy->Cancel(); |
| 526 |
return RefreshCode::RefreshAll; |
| 527 |
} |
| 528 |
|
| 529 |
void WaveClipAdjustBorderHandle::Draw(TrackPanelDrawingContext& context, const wxRect& rect, unsigned iPass) |
| 530 |
{ |
| 531 |
mAdjustPolicy->Draw(context, rect, iPass); |
| 532 |
} |
| 533 |
|
| 534 |
wxRect WaveClipAdjustBorderHandle::DrawingArea(TrackPanelDrawingContext& context, const wxRect& rect, |
| 535 |
const wxRect& panelRect, unsigned iPass) |
| 536 |
{ |
| 537 |
return mAdjustPolicy->DrawingArea(context, rect, panelRect, iPass); |
| 538 |
} |