Преглед изворни кода

Deleted clips and notes fade out as in FL Studio (issue #250)

FL draws a ghost of each clip or note removed by Delete, Cut or an erase stroke when Animations is at its default
"Make it pretty" (REA_rodada190oq §6, FUN_00e8fc60 / FUN_00e884b0 / FUN_00e88030). ui::DeleteFade draws the same: the
item's colour with its HSL lightness held in 0.55..0.80, on the item's rectangle growing to 4 px per side, rounded
(radius <= 8 px), outline (3a + 0.5) px at 224a/255, fill (224a - 96)/255, opacity 0.01^(t/T) (T 1000 ms Playlist,
500 ms Piano roll; gone under 0.025: ~801 / ~401 ms), above the remaining items. Gated by Settings > General >
Animations (on by default, FL's level) and Reduced effects. No ghost: no timer and no paint change.
Ka1-S пре 1 недеља
родитељ
комит
a92693936d

+ 2 - 0
CMakeLists.txt

@@ -699,6 +699,8 @@ if(LYNX_BUILD_APP)
         src/ui/ArticulatorTools.cpp
         src/ui/ArticulatorTools.cpp
         src/ui/SampleProperties.cpp
         src/ui/SampleProperties.cpp
         src/ui/ToolWindow.cpp
         src/ui/ToolWindow.cpp
+        src/ui/DeleteFade.cpp
+        src/ui/StartPage.cpp
         src/ui/SpeechDialog.cpp
         src/ui/SpeechDialog.cpp
         src/ui/TempoTapper.cpp
         src/ui/TempoTapper.cpp
         src/ui/TempoDetectionDialog.cpp
         src/ui/TempoDetectionDialog.cpp

+ 1 - 1
scripts/build-windows-zig.sh

@@ -247,7 +247,7 @@ APP_SOURCES+=(src/platform/CrashGuard.cpp)
 # workflow P2: core (note tools, mixer operations, history labels, browser search)
 # workflow P2: core (note tools, mixer operations, history labels, browser search)
 APP_SOURCES+=(src/core/NoteTools.cpp src/core/MidiTools.cpp src/core/MidiGenerate.cpp src/core/PianoRollTools.cpp src/core/EventEdit.cpp src/core/AudioEdit.cpp src/core/AudioEditTools.cpp src/core/FlAutoSlicer.cpp src/core/MixerOps.cpp src/core/History.cpp src/core/SearchQuery.cpp src/core/SearchIndex.cpp src/core/SearchService.cpp src/core/BrowserView.cpp src/core/EffectPresets.cpp src/core/PluginPresets.cpp src/core/GeneratorPresets.cpp src/core/ParamHelp.cpp)
 APP_SOURCES+=(src/core/NoteTools.cpp src/core/MidiTools.cpp src/core/MidiGenerate.cpp src/core/PianoRollTools.cpp src/core/EventEdit.cpp src/core/AudioEdit.cpp src/core/AudioEditTools.cpp src/core/FlAutoSlicer.cpp src/core/MixerOps.cpp src/core/History.cpp src/core/SearchQuery.cpp src/core/SearchIndex.cpp src/core/SearchService.cpp src/core/BrowserView.cpp src/core/EffectPresets.cpp src/core/PluginPresets.cpp src/core/GeneratorPresets.cpp src/core/ParamHelp.cpp)
 # workflow P2: UI (note tool dialogs, tool windows, undo history, quick-add palette)
 # workflow P2: UI (note tool dialogs, tool windows, undo history, quick-add palette)
-APP_SOURCES+=(src/ui/NoteToolDialogs.cpp src/ui/PianoRollScripts.cpp src/ui/MidiClipboard.cpp src/ui/AudioClipboard.cpp src/ui/EventEditor.cpp src/ui/AudioEditor.cpp src/ui/AudioEditorTools.cpp src/ui/ArticulatorTools.cpp src/ui/ToolWindow.cpp src/ui/TempoTapper.cpp src/ui/TempoDetectionDialog.cpp src/ui/HistoryPanel.cpp src/ui/VersionsPanel.cpp src/ui/PluginsOffPanel.cpp src/ui/QuickAddPalette.cpp src/ui/PluginPickerView.cpp src/ui/PickerLook.cpp src/ui/ProjectPickerView.cpp src/ui/PluginThumbs.cpp)
+APP_SOURCES+=(src/ui/NoteToolDialogs.cpp src/ui/PianoRollScripts.cpp src/ui/MidiClipboard.cpp src/ui/AudioClipboard.cpp src/ui/EventEditor.cpp src/ui/AudioEditor.cpp src/ui/AudioEditorTools.cpp src/ui/ArticulatorTools.cpp src/ui/ToolWindow.cpp src/ui/DeleteFade.cpp src/ui/StartPage.cpp src/ui/TempoTapper.cpp src/ui/TempoDetectionDialog.cpp src/ui/HistoryPanel.cpp src/ui/VersionsPanel.cpp src/ui/PluginsOffPanel.cpp src/ui/QuickAddPalette.cpp src/ui/PluginPickerView.cpp src/ui/PickerLook.cpp src/ui/ProjectPickerView.cpp src/ui/PluginThumbs.cpp)
 # start-up: splash screen and its procedurally synthesised sound
 # start-up: splash screen and its procedurally synthesised sound
 APP_SOURCES+=(src/core/StartupSound.cpp src/core/Speech.cpp src/core/SpeechRules.cpp src/ui/Splash.cpp src/ui/SpeechDialog.cpp)
 APP_SOURCES+=(src/core/StartupSound.cpp src/core/Speech.cpp src/core/SpeechRules.cpp src/ui/Splash.cpp src/ui/SpeechDialog.cpp)
 # main window chrome: hint bar and toolbar widgets
 # main window chrome: hint bar and toolbar widgets

+ 139 - 0
src/ui/DeleteFade.cpp

@@ -0,0 +1,139 @@
+#include "ui/DeleteFade.h"
+
+#include <algorithm>
+#include <cmath>
+
+#include "ui/Motion.h"
+#include "ui/PluginSkin.h"
+
+namespace lynx::ui
+{
+namespace
+{
+constexpr float growPx = 4.0f; // FL: round(4·scale − 0.5) at 100 %, in logical pixels here (JUCE scales them)
+}
+
+bool DeleteFade::enabled()
+{
+    return motion::enabled() && ! skin::reducedEffects();
+}
+
+juce::Colour DeleteFade::ghostColour (juce::Colour c)
+{
+    // FL's FUN_00660dc0 (c, 0.55, 0.80): HSL, the lightness clamped, hue and saturation kept
+    const auto r = c.getFloatRed(), g = c.getFloatGreen(), b = c.getFloatBlue();
+    const auto mx = std::max ({ r, g, b }), mn = std::min ({ r, g, b });
+    const auto l = (mx + mn) * 0.5f;
+    const auto target = std::clamp (l, 0.55f, 0.80f);
+    if (mx - mn < 1.0e-6f)
+        return juce::Colour::fromFloatRGBA (target, target, target, 1.0f);
+    const auto d = mx - mn;
+    const auto s = l > 0.5f ? d / (2.0f - mx - mn) : d / (mx + mn);
+    float h = mx == r ? (g - b) / d + (g < b ? 6.0f : 0.0f) : mx == g ? (b - r) / d + 2.0f : (r - g) / d + 4.0f;
+    h /= 6.0f;
+    const auto q = target < 0.5f ? target * (1.0f + s) : target + s - target * s;
+    const auto p = 2.0f * target - q;
+    const auto hue = [p, q] (float t) {
+        t = t < 0.0f ? t + 1.0f : t > 1.0f ? t - 1.0f : t;
+        return t < 1.0f / 6.0f ? p + (q - p) * 6.0f * t : t < 0.5f ? q : t < 2.0f / 3.0f ? p + (q - p) * (2.0f / 3.0f - t) * 6.0f : p;
+    };
+    return juce::Colour::fromFloatRGBA (hue (h + 1.0f / 3.0f), hue (h), hue (h - 1.0f / 3.0f), 1.0f);
+}
+
+double DeleteFade::alphaAt (double ms) const noexcept
+{
+    if (decay <= 0.0)
+        return 0.0;
+    const auto a = std::pow (0.01, std::max (0.0, ms) / decay);
+    return a < dropAlpha ? 0.0 : a;
+}
+
+double DeleteFade::lifetimeMs() const noexcept { return decay * std::log (dropAlpha) / std::log (0.01); }
+
+void DeleteFade::add (juce::Rectangle<float> area, juce::Colour colour)
+{
+    if (! enabled() || area.isEmpty() || (! view.isShowing() && frozen < 0.0))
+        return;
+    constexpr std::size_t maxGhosts = 256; // (a Delete of thousands of notes fades the first ones only)
+    if (ghosts.size() >= maxGhosts)
+        return;
+    // FL widens a rectangle narrower than 2u by u on each side (u ≈ 2 px)
+    if (area.getWidth() < 4.0f)
+        area = area.withSizeKeepingCentre (area.getWidth() + 4.0f, area.getHeight());
+    if (area.getHeight() < 4.0f)
+        area = area.withSizeKeepingCentre (area.getWidth(), area.getHeight() + 4.0f);
+    ghosts.push_back ({ area, ghostColour (colour), juce::Time::getMillisecondCounterHiRes() });
+    view.repaint (dirtyArea());
+    if (frozen < 0.0 && ! isTimerRunning())
+        startTimerHz (60);
+}
+
+double DeleteFade::ageOf (const Ghost& g) const
+{
+    return frozen >= 0.0 ? frozen : juce::Time::getMillisecondCounterHiRes() - g.start;
+}
+
+void DeleteFade::paint (juce::Graphics& g, juce::Rectangle<int> clip) const
+{
+    if (ghosts.empty())
+        return;
+    juce::Graphics::ScopedSaveState keep (g);
+    if (! clip.isEmpty())
+        g.reduceClipRegion (clip);
+    for (const auto& ghost : ghosts)
+    {
+        const auto a = (float) alphaAt (ageOf (ghost));
+        if (a <= 0.0f)
+            continue;
+        // FL: inflated by 4 px, then inset by a · 4 px: on the item at first, 4 px out at the end
+        const auto area = ghost.area.expanded (growPx * (1.0f - a));
+        const auto corner = std::min (0.5f * std::min (area.getWidth(), area.getHeight()), 8.0f);
+        const auto fill = 224.0f * a - 96.0f;
+        if (fill > 0.0f)
+        {
+            g.setColour (ghost.colour.withAlpha (fill / 255.0f));
+            g.fillRoundedRectangle (area, corner);
+        }
+        const auto pen = std::min (0.5f * std::min (area.getWidth(), area.getHeight()), 3.0f * a + 0.5f);
+        g.setColour (ghost.colour.withAlpha (224.0f * a / 255.0f));
+        g.drawRoundedRectangle (area.reduced (pen * 0.5f), corner, pen);
+    }
+}
+
+juce::Rectangle<int> DeleteFade::dirtyArea() const
+{
+    juce::Rectangle<float> all;
+    for (const auto& ghost : ghosts)
+        all = all.isEmpty() ? ghost.area : all.getUnion (ghost.area);
+    return all.getSmallestIntegerContainer().expanded ((int) growPx + 2);
+}
+
+void DeleteFade::timerCallback()
+{
+    const auto dirty = dirtyArea();
+    const auto life = lifetimeMs();
+    const auto now = juce::Time::getMillisecondCounterHiRes();
+    ghosts.erase (std::remove_if (ghosts.begin(), ghosts.end(), [now, life] (const Ghost& g) { return now - g.start >= life; }), ghosts.end());
+    view.repaint (dirty);
+    if (ghosts.empty() || ! view.isShowing() || ! enabled())
+    {
+        ghosts.clear();
+        stopTimer();
+    }
+}
+
+void DeleteFade::clear()
+{
+    if (ghosts.empty())
+        return;
+    view.repaint (dirtyArea());
+    ghosts.clear();
+    stopTimer();
+}
+
+void DeleteFade::freezeForSnapshot (double ms)
+{
+    frozen = ms;
+    stopTimer();
+}
+} // namespace lynx::ui

+ 69 - 0
src/ui/DeleteFade.h

@@ -0,0 +1,69 @@
+#pragma once
+
+// Issue #250 (round 190oq): FL Studio's fade of deleted clips and notes (REA_rodada190oq §6, FLEngine FUN_00e8fc60 /
+// FUN_00e87e60 / FUN_00e884b0 / FUN_00e88030). With Animations at "Make it pretty" (FL's default) a clip or note removed
+// by Delete, Cut or an erase stroke (the right-click delete, the Delete tool) leaves a "ghost":
+//  - its colour is the item's, its HSL lightness held between 0.55 and 0.80 (hue and saturation kept);
+//  - it starts on the item's rectangle and grows outward to 4 px per side as it fades, never moving;
+//  - a rounded rectangle (corner radius at most half the shorter side, at most 8 px): outline (3·a + 0.5) px wide at
+//    opacity 224·a / 255, fill at opacity (224·a − 96) / 255 while that is above 0, drawn above the remaining items;
+//  - its opacity a starts at 1 and falls as 0.01^(t / T): T = 1000 ms in the Playlist, 500 ms in the Piano roll; it goes
+//    below 0.025 (about 801 / 401 ms).
+// LYNX's Settings › General › Animations is FL's switch (on = FL's default level; off = "Keep it sober": no ghost);
+// "Reduced effects" turns it off too. Cost rules (ui/Motion.h): no ghost, no timer, no paint — the views draw exactly as
+// before; the timer runs only while a ghost is fading and repaints only the ghosts' area. Message thread only.
+
+#include <vector>
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+namespace lynx::ui
+{
+class DeleteFade final : private juce::Timer
+{
+public:
+    static constexpr double playlistMs = 1000.0, pianoRollMs = 500.0; // FL's T per editor
+    static constexpr double dropAlpha = 0.025;
+
+    DeleteFade (juce::Component& owner, double decayMs) : view (owner), decay (decayMs) {}
+    ~DeleteFade() override { stopTimer(); }
+
+    // Whether a deletion fades now (Animations on, Reduced effects off)
+    static bool enabled();
+    // FL's ghost colour: `c` with its HSL lightness held in 0.55..0.80
+    static juce::Colour ghostColour (juce::Colour c);
+    // The ghost's opacity `ms` after the deletion (0 once it is gone)
+    double alphaAt (double ms) const noexcept;
+    // How long a ghost lasts (until its opacity drops below 0.025)
+    double lifetimeMs() const noexcept;
+
+    // A deleted item's area (owner coordinates) and colour; nothing when fades are off or the owner is hidden
+    void add (juce::Rectangle<float> area, juce::Colour colour);
+    // The ghosts, over the owner's own drawing (clipped to `clip` when not empty)
+    void paint (juce::Graphics& g, juce::Rectangle<int> clip = {}) const;
+    bool active() const noexcept { return ! ghosts.empty(); }
+    // Ends every fade now
+    void clear();
+
+    // (tests / shots) the ghosts drawn `ms` after their deletion, timer stopped
+    void freezeForSnapshot (double ms);
+    int count() const noexcept { return (int) ghosts.size(); }
+
+private:
+    struct Ghost
+    {
+        juce::Rectangle<float> area;
+        juce::Colour colour;
+        double start = 0.0;
+    };
+
+    void timerCallback() override;
+    juce::Rectangle<int> dirtyArea() const;
+    double ageOf (const Ghost& g) const;
+
+    juce::Component& view;
+    double decay;
+    std::vector<Ghost> ghosts;
+    double frozen = -1.0; // (snapshots) the fixed age, < 0 = live
+};
+} // namespace lynx::ui

+ 28 - 0
src/ui/PianoRollComponent.cpp

@@ -2609,6 +2609,7 @@ void PianoRollComponent::mouseDown (const juce::MouseEvent& e)
         if (hit >= 0)
         if (hit >= 0)
         {
         {
             erasedSomething = true;
             erasedSomething = true;
+            fadeOut ({ hit }); // (issue #250)
             editNotes ([hit] (Pattern& p) { noteedit::remove (p, { hit }); });
             editNotes ([hit] (Pattern& p) { noteedit::remove (p, { hit }); });
         }
         }
         return;
         return;
@@ -2647,7 +2648,10 @@ void PianoRollComponent::mouseDown (const juce::MouseEvent& e)
             drag = Drag::erase;
             drag = Drag::erase;
             setSelection ({});
             setSelection ({});
             if (hit >= 0)
             if (hit >= 0)
+            {
+                fadeOut ({ hit }); // (issue #250)
                 editNotes ([hit] (Pattern& p) { noteedit::remove (p, { hit }); });
                 editNotes ([hit] (Pattern& p) { noteedit::remove (p, { hit }); });
+            }
             return;
             return;
 
 
         case EditTool::mute:
         case EditTool::mute:
@@ -3131,6 +3135,7 @@ void PianoRollComponent::mouseDrag (const juce::MouseEvent& e)
             if (hit >= 0)
             if (hit >= 0)
             {
             {
                 erasedSomething = true;
                 erasedSomething = true;
+                fadeOut ({ hit }); // (issue #250)
                 editNotes ([hit] (Pattern& p) { noteedit::remove (p, { hit }); });
                 editNotes ([hit] (Pattern& p) { noteedit::remove (p, { hit }); });
             }
             }
             return;
             return;
@@ -5310,10 +5315,33 @@ void PianoRollComponent::deleteSelection()
         return;
         return;
 
 
     const auto doomed = selection;
     const auto doomed = selection;
+    fadeOut (doomed); // (issue #250)
     setSelection ({});
     setSelection ({});
     editNotes ([&doomed] (Pattern& p) { noteedit::remove (p, doomed); });
     editNotes ([&doomed] (Pattern& p) { noteedit::remove (p, doomed); });
 }
 }
 
 
+void PianoRollComponent::fadeOut (const std::vector<int>& notes)
+{
+    // issue #250 (round 190oq): each deleted note in view leaves FL's ghost (nothing at all when Animations are off or
+    // effects reduced: ui/DeleteFade.h)
+    if (! ui::DeleteFade::enabled())
+        return;
+    const auto& pattern = currentPattern (engine.getSong());
+    const auto grid = gridArea().toFloat();
+    for (const auto i : notes)
+        if (i >= 0 && i < (int) pattern.notes.size())
+        {
+            const auto& n = pattern.notes[(std::size_t) i];
+            if (const auto r = noteRect (n.start, n.length, n.key); r.intersects (grid))
+                deleteFade.add (r, theme::noteGroupColour (n.colour, n.velocity));
+        }
+}
+
+void PianoRollComponent::paintOverChildren (juce::Graphics& g)
+{
+    deleteFade.paint (g, gridArea()); // (issue #250: nothing while no note is fading)
+}
+
 void PianoRollComponent::copySelection()
 void PianoRollComponent::copySelection()
 {
 {
     clipboard = noteedit::copy (currentPattern (engine.getSong()), selectionOrAll());
     clipboard = noteedit::copy (currentPattern (engine.getSong()), selectionOrAll());

+ 9 - 0
src/ui/PianoRollComponent.h

@@ -12,6 +12,7 @@
 #include "core/ScaleSnap.h"
 #include "core/ScaleSnap.h"
 #include "engine/AudioEngine.h"
 #include "engine/AudioEngine.h"
 #include "ui/TimerWhileShowing.h"
 #include "ui/TimerWhileShowing.h"
+#include "ui/DeleteFade.h"
 #include "ui/EditorTools.h"
 #include "ui/EditorTools.h"
 #include "ui/FrameTicker.h"
 #include "ui/FrameTicker.h"
 #include "ui/MotionOverlay.h"
 #include "ui/MotionOverlay.h"
@@ -65,6 +66,7 @@ public:
     ~PianoRollComponent() override;
     ~PianoRollComponent() override;
 
 
     void paint (juce::Graphics& g) override;
     void paint (juce::Graphics& g) override;
+    void paintOverChildren (juce::Graphics& g) override; // (round 190oq, issue #250: deleted notes fading)
     void resized() override;
     void resized() override;
     void setTitleBarInsets (int left, int right) override;
     void setTitleBarInsets (int left, int right) override;
     void mouseDown (const juce::MouseEvent& e) override;
     void mouseDown (const juce::MouseEvent& e) override;
@@ -236,6 +238,9 @@ public:
     void setScaleForSnapshot (int root, int scale) { setScale (root, scale); }
     void setScaleForSnapshot (int root, int scale) { setScale (root, scale); }
     // issue #242 (round 190od): the toolbar scale box as a click opens it (JUCE's ComboBox marks the popup active first)
     // issue #242 (round 190od): the toolbar scale box as a click opens it (JUCE's ComboBox marks the popup active first)
     juce::ComboBox& scaleBoxForTests() noexcept { return scaleBox; }
     juce::ComboBox& scaleBoxForTests() noexcept { return scaleBox; }
+    ui::DeleteFade& deleteFadeForSnapshot() noexcept { return deleteFade; } // (round 190oq, issue #250)
+    void deleteSelectionForSnapshot() { deleteSelection(); }
+    juce::Rectangle<int> gridAreaForSnapshot() const { return gridArea(); }
     juce::ComboBox& chordBoxForTests() noexcept { return chordBox; } // (rollup 0.1.31 step 4: #242 with 190nu's stamp box)
     juce::ComboBox& chordBoxForTests() noexcept { return chordBox; } // (rollup 0.1.31 step 4: #242 with 190nu's stamp box)
     // round 190jv: View › Scale highlighting › Automatic on / off, and the key it guessed (scaledetect; -1 none)
     // round 190jv: View › Scale highlighting › Automatic on / off, and the key it guessed (scaledetect; -1 none)
     void setAutoScale (bool on) { scaleBox.setSelectedId (on ? autoScaleId : 1, juce::sendNotificationSync); }
     void setAutoScale (bool on) { scaleBox.setSelectedId (on ? autoScaleId : 1, juce::sendNotificationSync); }
@@ -871,6 +876,10 @@ private:
     int markerAtX (int x) const;          // the pattern marker drawn under x on the ruler, or -1
     int markerAtX (int x) const;          // the pattern marker drawn under x on the ruler, or -1
     void showPatternMarkerMenu (int index);
     void showPatternMarkerMenu (int index);
 
 
+    // issue #250 (round 190oq): deleted notes fade out as FL's do (ui/DeleteFade.h); `fadeOut` before they go
+    ui::DeleteFade deleteFade { *this, ui::DeleteFade::pianoRollMs };
+    void fadeOut (const std::vector<int>& notes);
+
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PianoRollComponent)
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PianoRollComponent)
     std::unique_ptr<ui::TimerWhileShowing> showingTimer; // the polling timer, only while on screen (round 174f)
     std::unique_ptr<ui::TimerWhileShowing> showingTimer; // the polling timer, only while on screen (round 174f)
 };
 };

+ 21 - 0
src/ui/PlaylistComponent.cpp

@@ -3389,8 +3389,23 @@ void PlaylistComponent::paintFolderDrop (juce::Graphics& g)
     }
     }
 }
 }
 
 
+void PlaylistComponent::fadeOut (const std::vector<int>& clips)
+{
+    // issue #250 (round 190oq): each deleted clip in view leaves FL's ghost (nothing at all when Animations are off or
+    // effects reduced: ui/DeleteFade.h)
+    if (! ui::DeleteFade::enabled())
+        return;
+    const auto& song = engine.getSong();
+    const auto grid = gridArea();
+    for (const auto i : clips)
+        if (i >= 0 && i < (int) song.playlist.size())
+            if (const auto r = clipBounds (i); r.intersects (grid))
+                deleteFade.add (r.toFloat(), liveClipColour (song.playlist[(std::size_t) i]));
+}
+
 void PlaylistComponent::paintOverChildren (juce::Graphics& g)
 void PlaylistComponent::paintOverChildren (juce::Graphics& g)
 {
 {
+    deleteFade.paint (g, gridArea()); // (issue #250: nothing while no clip is fading)
     paintDropGhost (g); // (round 190im: a drag's landing place)
     paintDropGhost (g); // (round 190im: a drag's landing place)
     paintFolderDrop (g); // round 190jf (B17)
     paintFolderDrop (g); // round 190jf (B17)
     if (headerGripLit || drag == Drag::headerWidth) // round 190jq (issue #164): the edge being dragged, in the accent
     if (headerGripLit || drag == Drag::headerWidth) // round 190jq (issue #164): the edge being dragged, in the accent
@@ -6436,6 +6451,7 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
         if (hit >= 0)
         if (hit >= 0)
         {
         {
             erasedSomething = true;
             erasedSomething = true;
+            fadeOut ({ hit }); // (issue #250)
             engine.editSong ([hit] (Song& s) { s.playlist.erase (s.playlist.begin() + hit); });
             engine.editSong ([hit] (Song& s) { s.playlist.erase (s.playlist.begin() + hit); });
         }
         }
         return;
         return;
@@ -6490,7 +6506,10 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
             drag = Drag::erase;
             drag = Drag::erase;
             setSelection ({});
             setSelection ({});
             if (hit >= 0)
             if (hit >= 0)
+            {
+                fadeOut ({ hit }); // (issue #250)
                 engine.editSong ([hit] (Song& s) { s.playlist.erase (s.playlist.begin() + hit); });
                 engine.editSong ([hit] (Song& s) { s.playlist.erase (s.playlist.begin() + hit); });
+            }
             return;
             return;
 
 
         case EditTool::mute:
         case EditTool::mute:
@@ -7373,6 +7392,7 @@ void PlaylistComponent::mouseDrag (const juce::MouseEvent& e)
             if (hit >= 0)
             if (hit >= 0)
             {
             {
                 erasedSomething = true;
                 erasedSomething = true;
+                fadeOut ({ hit }); // (issue #250)
                 engine.editSong ([hit] (Song& s) { s.playlist.erase (s.playlist.begin() + hit); });
                 engine.editSong ([hit] (Song& s) { s.playlist.erase (s.playlist.begin() + hit); });
             }
             }
             return;
             return;
@@ -13103,6 +13123,7 @@ void PlaylistComponent::deleteSelection()
         return;
         return;
 
 
     auto doomed = selection;
     auto doomed = selection;
+    fadeOut (doomed); // (issue #250)
     setSelection ({});
     setSelection ({});
     engine.editSong ([&doomed] (Song& s) {
     engine.editSong ([&doomed] (Song& s) {
         std::sort (doomed.rbegin(), doomed.rend());
         std::sort (doomed.rbegin(), doomed.rend());

+ 7 - 0
src/ui/PlaylistComponent.h

@@ -22,6 +22,7 @@
 #include "core/StripSilence.h"
 #include "core/StripSilence.h"
 #include "core/TrackClips.h" // round 190ne
 #include "core/TrackClips.h" // round 190ne
 #include "engine/AudioEngine.h"
 #include "engine/AudioEngine.h"
+#include "ui/DeleteFade.h"
 #include "ui/EditorTools.h"
 #include "ui/EditorTools.h"
 #include "ui/FrameTicker.h"
 #include "ui/FrameTicker.h"
 #include "ui/MotionOverlay.h"
 #include "ui/MotionOverlay.h"
@@ -291,6 +292,8 @@ public:
     juce::Rectangle<int> trackLaneArrowForSnapshot (int track) const { return trackLaneArrow (track); }
     juce::Rectangle<int> trackLaneArrowForSnapshot (int track) const { return trackLaneArrow (track); }
     double xOfTickForSnapshot (double tick) const { return tickToX (tick); }
     double xOfTickForSnapshot (double tick) const { return tickToX (tick); }
     juce::Rectangle<int> clipBoundsForSnapshot (int clip) const { return clipBounds (clip); } // (round 190gi)
     juce::Rectangle<int> clipBoundsForSnapshot (int clip) const { return clipBounds (clip); } // (round 190gi)
+    ui::DeleteFade& deleteFadeForSnapshot() noexcept { return deleteFade; } // (round 190oq, issue #250)
+    void deleteSelectionForSnapshot() { deleteSelection(); }
     // round 190nx (--demo, ui.clipmenu): selects the clip and opens its context menu at the clip, as a right-click on it does,
     // round 190nx (--demo, ui.clipmenu): selects the clip and opens its context menu at the clip, as a right-click on it does,
     // with no mouse needed. Returns the clip's rectangle on screen, or an empty one when the clip is not in view
     // with no mouse needed. Returns the clip's rectangle on screen, or an empty one when the clip is not in view
     juce::Rectangle<int> openClipMenuForDemo (int clip);
     juce::Rectangle<int> openClipMenuForDemo (int clip);
@@ -1189,6 +1192,10 @@ private:
     std::unique_ptr<VideoLanesView> videoLanes;
     std::unique_ptr<VideoLanesView> videoLanes;
     int videoHeight = 0; // 0 = fit the lanes
     int videoHeight = 0; // 0 = fit the lanes
 
 
+    // issue #250 (round 190oq): deleted clips fade out as FL's do (ui/DeleteFade.h); `fadeOut` before they go
+    ui::DeleteFade deleteFade { *this, ui::DeleteFade::playlistMs };
+    void fadeOut (const std::vector<int>& clips);
+
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PlaylistComponent)
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PlaylistComponent)
 };
 };
 // Playlist "Picker" (as in FL): three tabs at the top (patterns, audio clips, automation clips) and the list
 // Playlist "Picker" (as in FL): three tabs at the top (patterns, audio clips, automation clips) and the list