sudara / melatonin_inspector

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

Custom Properties prototype #44

Closed sudara closed 1 year ago

sudara commented 1 year ago

Here's a rough implementation of custom properties. The idea is to call this helper from your component:

// someComponent.h
#include "melatonin_inspector/melatonin/helpers/misc.h"
.
.
.
        melatonin::setCustomInspectorProperty(this, "Flavor", flavorNames[static_cast<int> (flavor)]);
        melatonin::setCustomInspectorProperty(this, "Theme Key", themeKey);

Behind the scene, this just adds 2 properties to the component, for example inspectorPropertyName1 and inspectorPropertyValue1 — their values then show up at the top of the property inspector:

AudioPluginHost - 2023-08-03 56@2x

@dikadk / @FigBug would either of you use this or have implementation opinions?

Implementation Qs:

This isn't the first time I've wished a JUCE Component's properties were backed by a first class data store vs a flat NamedValueSet..

FigBug commented 1 year ago

I'm currently working on something complementary / conflicting: https://github.com/reFX/melatonin_inspector/tree/refx/property_improvements

My idea was to just to take the Component::getProperties(), iterate over them and then and then add properties for each of them. Maybe your custom components could be added to this same list?

image
sudara commented 1 year ago

Glad I brought it up!

My implementation is ugly in comparison since it relies on adding 2 properties (for key/value) following a naming convention.

Displaying getProperties seems more elegant! But I have a few thoughts:

sudara commented 1 year ago

Also, we current display rgb in the color picker, so if we do go with displaying jcclr, i guess we should align those and/or maybe allow the user to set (and remember) which color format they prefer. We don't have a place to store settings, I'd be happy to style a right click menu or something for that.

FigBug commented 1 year ago

I'd be ok getting rid of the sizes. What would be in properties and what would be in flags? Originally I was going to add another class like properties for the named properties from Component, but couldn't think of a good was to resize to lists with scroll bars.

sudara commented 1 year ago

I was thinking just all the existing stuff that's now in PROPERTIES would go in FLAGS, since especially after removing dimensions it's mostly that (with a few extra cosmetic things like alpha, lookandfeel).

Not sure what you mean re: resizing. Like, having two collapsable panels with scrollbars gets awkward?

What about jcclr — are those useful for you?

sudara commented 1 year ago

@FigBug Looking at your branch it looks like you are wanting to inspect/modify colors, so I'd say just make things how you want them, submit a PR and I'll do any UI cleanup/config stuff to make sure we're both happy!

sudara commented 1 year ago

Superseded by #48