sudara / melatonin_inspector

A JUCE module that gives you the ability to inspect and visually edit (non-destructively) components in your UI.
MIT License
156 stars 18 forks source link

Paint Timings WIP #45

Closed sudara closed 1 year ago

sudara commented 1 year ago

Opening this for feedback. /cc @dikadk @FigBug

Finally got some paint timings in place.

https://github.com/sudara/melatonin_inspector/assets/472/3d11d4bc-e5db-4849-b3f4-4f3959d17289

What works:

What doesn't / Need feedback on

For the prototype I'm using a std::deque, storing the last 100 of them and push new timings on the front, but this isn't going to be friendly for others I think. I was interested in creating tooling that would show more of a timeline, but that's going to take more work than stuffing a few things into properties.

Just for clarity is what I currently have in the component I derive everything from.

    // derived classes no longer implement this
    void paint (juce::Graphics& g) final
    {
        juce::int64 startTimeTicks = juce::Time::getHighResolutionTicks();

        // Call derived class paintContent method
        timedPaint (g);

        static auto scalar = 1.0 / static_cast<double> (juce::Time::getHighResolutionTicksPerSecond());
        paintTimings.push_front (static_cast<double> (juce::Time::getHighResolutionTicks() - startTimeTicks) * scalar);

        // limit to 100 entries
        if (paintTimings.size() > 3)
            paintTimings.pop_back();

        setProperty ("timing1", paintTimings[0]);
        setProperty ("timing2", paintTimings[1]);
        setProperty ("timing3", paintTimings[2]);
    }
sudara commented 1 year ago

Also might be cool to be able to click a button to force repaint...

sudara commented 1 year ago

Superseded by #48