Default LookAndFeel in ProJucer project


#1

Have anyone used default LookAndFeel classes successfully with ProJucer?

It seems to have no effect when I set to my own LookAndFeel.

It seems like the global namespace is...not quite fully global, it might be the core issue don't know. I haven't dug deep in the LookAndFeel handling how it's set.

tweaking GUI stuff like LookAndFeel would be exactly the strength of ProJucer.


JIT and LookAndFeel
#2

If you put your look+feel setup in your normal app or window constructor, then the projucer will never run that code - remember that it just instantiates the component that you open, it doesn't call main().

A more foolproof way to do it would be to use something like a SharedResourcePointer which creates your custom look, and then make your individual components reference that. Then when the projucer uses a component which uses this shared object, it'll get created and used.

We also want to add a REPL to it next, which would be very handy for this kind of thing, as you could just load the look + feel you want from the command-line.


JIT and LookAndFeel
#3

A more foolproof way to do it would be to use something like a SharedResourcePointer which creates your custom look, and then make your individual components reference that. Then when the projucer uses a component which uses this shared object, it'll get created and used.

Please could someone shed some light on what this might actually look like in practice. I'm trying to get a custom LookAndFeel to work inside the Projucer when instantiating individual components, but after several hours and several reads of the SharedResourcePointer example in the docs, I've failed to get it working.

Here's what I expected to work:

  • In my "LookAndFeelCustom.h" header, define a LookAndFeel_Custom class (inherits from LookAndFeel_V2, implementation in .cpp) and a SharedLookAndFeel class containing a LookAndFeel_Custom member variable:

// -- LookAndFeelCustom.h -- //

class LookAndFeel_Custom     : public LookAndFeel_V2
{
public:
    LookAndFeel_Custom();
    ~LookAndFeel_Custom();
};

class SharedLookAndFeel
{
public:
    LookAndFeel_Custom laf;
};
  • In the header for each individual Component, include "LookAndFeelCustom.h", then as a public member variable, create a SharedRescourcePointer to SharedLookAndFeel:
// -- MyCustomComponent.h -- //

// ... code folded ... ///

#include "LookAndFeelCustom.h"
//==============================================================================
class MyCustomComponent    : public Component,
                             public ButtonListener
{
public:
    SharedResourcePointer<SharedLookAndFeel> sharedLookAndFeel;

// ... code folded ... ///
  • Finally, in the constructor for each individual Component, set the default look and feel via the SharedResourcePointer:
// -- MyCustomComponent.cpp -- //
InputListItemComponent::InputListItemComponent ()
{   
    LookAndFeel::setDefaultLookAndFeel (&sharedLookAndFeel->laf);

When I run the entire application from the Projucer, LookAndFeel_Custom is working as expected and affecting the appearance of MyCustomComponent, but when I instantiate MyCustomComponent directly, LookAndFeel_Custom doesn't have any effect.

Thanks in advance for any help!