melatonin_inspector
melatonin_inspector copied to clipboard
FR / Design idea : Custom Component Extractors
I have a style system for my widgets which is different than the Look and Feel. It has pros and cons but I'm using it in a couple of places. Cool
What I'd like is to be able to see that custom style info in melatonin. I can easily write this code to get items given a Component * and a dynamic cast.
But that made me think it would be great if we could add per-application component extractors into the properties pane. I'm considering something like this (but haven't read the code enough to know exact syntax)
Add to Inspector addCustomComponentExtractor(const juce::String &name, std::function<some_t(juce::Component *)>). When you make the properties plane, call the list of custom functions and put them as sub-trees or some such in the properties list under name.
That would let me do something like
inspector = std::make_unique<Inspector>(*this);
inspector->addCustomCompoenntExtractor("set-stylesheets", [](auto *c) { if (auto s = dynamic_cast<stylething*>(c)) { return { {"style", c->style()->blah}, {"this that", theother}}
then i can make it so i can extend melatonin for particular application or widget set views from the outside.
Thoughts?
oh i'm happy to code up all these things by the way but want to ask before i dive into them.
I also don't use look and feels. What I do right now is expose style information to the inspector by adding properties to components:
setProperty ("Theme Key", themeKey);
which just calls getProperties().set (key, value); and shows up like so:
That being said, I have thought about and do like a better supported way of acquiring data from components. Let me marinate on it a few!
Yeah I saw that! It useful but would have me lift loads of information into properties just for melatonin which is why I thought of a custom lambda
I’ll ponder also as I poke around
I like this idea! Seems like feature that will make melatonin more extensible and will cover more ways for 'styling' apps.
Thanks!
From poking around I think the right function for the callback function is
std::function<bool(juce::Array<juce::Var> &, juce::Array<PropertyComponent *>&)
that is you get sent a Var and Component array to populate and return whether or not you added anything.