Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR / Design idea : Custom Component Extractors #98

Open
baconpaul opened this issue Mar 9, 2024 · 5 comments
Open

FR / Design idea : Custom Component Extractors #98

baconpaul opened this issue Mar 9, 2024 · 5 comments

Comments

@baconpaul
Copy link
Collaborator

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?

@baconpaul
Copy link
Collaborator Author

oh i'm happy to code up all these things by the way but want to ask before i dive into them.

@sudara
Copy link
Owner

sudara commented Mar 9, 2024

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:

Sine Machine v14 - 2024-03-09 44@2x

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!

@baconpaul
Copy link
Collaborator Author

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

@dikadk
Copy link
Collaborator

dikadk commented Mar 11, 2024

I like this idea! Seems like feature that will make melatonin more extensible and will cover more ways for 'styling' apps.

@baconpaul
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants