New filmstrip solution?


#1

Hi, noob here. 

I'm trying to add a custom filmstrip PNG to an slider. I already have a custom background image (following the "Getting started with JUCE" book example") and a basic slider. Now I want to replace the standard slider with my png stripped image. 
I've been searching in the forum for two days about filmstrips and I've found several threads in which I've seen that Jules doesn't like skeumorphic GUIs, but he says that he will implement an easy way to have filmstrip knobs/sliders on Introjucer since it's a common request. That was a thread from 2009 and, since I've seen no easy way explained in the forum, I'm wondering if this functionality has been already implemented. 

If not, the examples in other threads seem outdated. 

Thanks, 
Jesús


#2

Hello, if you're looking for a pretty standard solution use something like this:


class Knob
    : public juce::Slider
{
public:
    Knob(juce::Image stripToShow)
        : filmStrip(stripToShow)
    {
        // careful with empty images (zero division) and/or non-square images.
        // also, strips with one image wont work as well.
        // strips are vertical stacked images of the same size.
        sideLength = filmStrip.getWidth();
        numFrames = filmStrip.getHeight() / sideLength;
    }
    void paint(juce::Graphics & g) override
    {
        std::size_t imageNumber = static_cast<std::size_t>(0.5 + (getValue() - getMinimum()) / (getMaximum() - getMinimum()) * (numFrames - 1));
        g.drawImage(filmStrip, 0, 0, sideLength, sideLength, 0, imageNumber * sideLength, sideLength, sideLength);
    }
private:
    std::size_t numFrames, sideLength;
    juce::Image filmStrip;
};


There is afaik no 'direct' way to do it, although the above is pretty simple.


#3

We have a FilmStrip class in our ScopeSync system, which we use for various Slider images. You can see it here: https://github.com/bcmodular/scopesync/blob/master/Juce/ScopeSyncShared/Components/BCMLookAndFeel.h and here: https://github.com/bcmodular/scopesync/blob/master/Juce/ScopeSyncShared/Components/BCMLookAndFeel.cpp


#4

Thanks! But how would I link a binary called "knob_png" to this slider?
I'm sorry but I'm reaaally noob. 


#5

loading an image from memory..

Image myKnobImage = ImageCache::getFromMemory (knob_png, knob_pngSize);

#6

I know the differents parts of the puzzle but I don't know how to arrange them. I'm lost. 
So "myKnobImage" would be my flimstrip. If I name it "stripToShow", Mayae's code would work?


#7

I think you could pass the imagecache function directly as a constructor to the filmstripknob class