Initializing a LookAndFeel


#1

Hello,

So I'm following with the book Getting Started With JUCE and I have come across a problem with one of the examples. I'm making a custom LookAndFeel inheriting from LookAndFeel and tring to create a LookAndFeel variable in MainContentComponent.h. The problem is that I get all of these errors. Such as:

Error: object of abstract class type "MainContentComponent::AltLookAndFeel" is not allowed:

    pure virtual function "juce::LookAndFeel::drawSpinningWaitAnimation" has no overrider

    ... and so on with a huge list of member functions.

 

Here's the code I'm using. This code is straight from the book so I'm not sure what I'm doing wrong.


class MainContentComponent   : public Component, 
                               public Button::Listener { 
public: 
    //==============================================================================
    MainContentComponent();
    void buttonClicked(Button* button);  
    void resized(); 

    class AltLookAndFeel : public LookAndFeel { 
    public: 
        AltLookAndFeel() 
        { 
            setColour(Slider::thumbColourId, Colours::red); 
        } 
    }; 

private: 
    Slider slider1; 
    Slider slider2; 
    ToggleButton toggle1; 
    AltLookAndFeel altLookAndFeel; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent) 
};


#2

Hello,

LookAndFeel is now an abstract class so the AltLookAndFeel class in that example needs to inherit from one of the concrete look-and-feel classes: LookAndFeel_V1, LookAndFeel_V2, or LookAndFeel_V3

e.g.:

class AltLookAndFeel : public LookAndFeel_V1 {

I checked the examples a little while ago with recent JUCE updates and that was the only example that casued a real problem so you should be able to continue. Let me know if not.

Martin


#3

Well, I inherited from LookAndFeel_V3 and that seemed to fixed my problem. Maybe it has changed since the book was written?


#4

Ha. Thanks. Looks like I figured out the answer right before you commented. :)


#5

Yes, that's right the JUCE code changed after the book was written. You can use any of those LookAndFeel_V1, _V2, or _V3.


#6

In case ( http://www.juce.com/forum/topic/getting-started-juce/bugs ).