Adding floating tile colours to LAF
-
Currently when we have a LAF function that affects a floating tile, the colour properties from that tile are not available in the LAF function.
I'm pretty sure these properties need to be added the
addParentFloatingTilefunction ofScriptingGraphics.cppSo I tried this:
bool ScriptingObjects::ScriptedLookAndFeel::Laf::addParentFloatingTile(Component& c, DynamicObject* obj) { auto id = getIdOfParentFloatingTile(c); if (id.isValid()) { // Stuff I added auto ft = c.getParentComponent(); setColourOrBlack(obj, "bgColour", ft, HiseColourScheme::ComponentOutlineColourId); setColourOrBlack(obj, "itemColour1", ft, HiseColourScheme::ComponentFillTopColourId); setColourOrBlack(obj, "itemColour2", ft, HiseColourScheme::ComponentFillBottomColourId); setColourOrBlack(obj, "textColour", ft, HiseColourScheme::ComponentTextColourId); obj->setProperty("parentType", id.toString()); return true; } return false; }This line
auto ft = c.getParentComponent();is returning the typeComponent*but for thesetColourOrBlackfunction I need the type to beComponent&- how should i do this? -
@d-healey Why don't you just use
cinstead of creatingft? -
@ustk I tried that first,
cdoesn't contain the colour data, I need the parent floating tile. -
@d-healey I see... And what about
&ft? -
@ustk
error: cannot convert ‘juce::Component*’ to ‘juce::Component&’ -
@d-healey Have you tried
auto& ft = c.getParentComponent();or evenauto& ft = getParentComponent();
Just guessing... -
@ustk Yup
-
@d-healey The more I learn C++, the less I understand C++...

-
@ustk I found part of the solution. I have to dereference the pointer:
auto& ft = *c.findParentComponentOfClass<FloatingTile>();However this now returns all the colours are
0 -
@d-healey It's better to dereference the pointer in the function calls as habit. If you forget to add the
&-operator, it will create a copy of the object the pointer was targeting and this can be only detected on runtime. It's one of the more annoying things in C++auto ft = c.getParentComponent(); setColourOrBlack(obj, "bgColour", *ft, HiseColourScheme::ComponentOutlineColourId);In this special case there are some mechanism in place that prevent copying the FloatingTile object, but this is not true for more lightweight objects that just hold some data.
-
@Christoph-Hart Thanks for the tip! Still all the colours are coming through as
0. I assume I'm misunderstanding where the floating tile's colour data is stored.