HISE Logo Forum
    • Categories
    • Register
    • Login

    Adding floating tile colours to LAF

    Scheduled Pinned Locked Moved C++ Development
    11 Posts 3 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d.healeyD
      d.healey
      last edited by

      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 addParentFloatingTile function of ScriptingGraphics.cpp

      So 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 type Component* but for the setColourOrBlack function I need the type to be Component& - how should i do this?

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      ustkU 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @d.healey
        last edited by

        @d-healey Why don't you just use c instead of creating ft ?

        Can't help pressing F5 in the forum...

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @ustk
          last edited by

          @ustk I tried that first, c doesn't contain the colour data, I need the parent floating tile.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          ustkU 1 Reply Last reply Reply Quote 0
          • ustkU
            ustk @d.healey
            last edited by

            @d-healey I see... And what about &ft ?

            Can't help pressing F5 in the forum...

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @ustk
              last edited by

              @ustk
              error: cannot convert ‘juce::Component*’ to ‘juce::Component&’

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              ustkU 1 Reply Last reply Reply Quote 0
              • ustkU
                ustk @d.healey
                last edited by ustk

                @d-healey Have you tried auto& ft = c.getParentComponent(); or even auto& ft = getParentComponent();
                Just guessing...

                Can't help pressing F5 in the forum...

                d.healeyD 1 Reply Last reply Reply Quote 0
                • d.healeyD
                  d.healey @ustk
                  last edited by

                  @ustk Yup

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  ustkU 1 Reply Last reply Reply Quote 0
                  • ustkU
                    ustk @d.healey
                    last edited by

                    @d-healey The more I learn C++, the less I understand C++... 😆

                    Can't help pressing F5 in the forum...

                    d.healeyD 1 Reply Last reply Reply Quote 4
                    • d.healeyD
                      d.healey @ustk
                      last edited by d.healey

                      @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

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      Christoph HartC 1 Reply Last reply Reply Quote 1
                      • Christoph HartC
                        Christoph Hart @d.healey
                        last edited by Christoph Hart

                        @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.

                        d.healeyD 1 Reply Last reply Reply Quote 2
                        • d.healeyD
                          d.healey @Christoph Hart
                          last edited by

                          @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.

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          22

                          Online

                          1.8k

                          Users

                          12.1k

                          Topics

                          104.9k

                          Posts