cginternals / libzeug

deprecated: C++ sanctuary for small but powerful and frequently required, stand alone features.
MIT License
16 stars 13 forks source link

Propertyguizeug cleanup #98

Closed mjendruk closed 9 years ago

mjendruk commented 9 years ago

things done:

Tested on Windows and Mac. Solves #83.

Info about PropertyEditorPlugin and PropertyPainterPlugin:

You can know add your custom Editors as well as paint code by complying to the following implicit interface:

using namespace reflectionzeug;
using namespace propertyguizeug;

class CustomType;

class CustomTypeEditor : 
    public PropertyEditor // inheritance from PropertyEditor optionally, must however inherit from QWidget
{
public:
    using Type = Property<CustomType>;

    // only needed if you want to add custom paint code
    static void paint(
        QPainter * painter, 
        const QStyleOptionViewItem & option, 
        Property<CustomType> & property);

    CustomTypeEditor(
        Property<CustomType> * property,
        QWidget * parent = nullptr);
};

You can then add your Editor like this:

PropertyBrowser browser;
browser.addEditorPlugin<CustomTypeEditor>();
browser.addPainterPlugin<CustomTypeEditor>();

// note: if you have multiple editors to add, pass all editors as params to the PropertyEditorPlugin template
browser.addEditorPlugin<CustomType1Editor, CustomType2Editor, CustomType3Editor>();
cgcostume commented 9 years ago

works on windows, looks good - concerning guidelines, we are probably going to reference the following book from now on http://www.amazon.de/dp/B00F8CWGOS (which states, that uniform initialization is the way to go, also in member initializer lists) - PR works on windows, as expected :smile: - :ship:

mjendruk commented 9 years ago

thanks for your approval :). i have it already in my wishlist ;) this one is also great: http://www.amazon.de/dp/1491903996