Forum

    • Register
    • Login
    • Search
    • Categories

    Added getTrimmedBounds()

    C++ Development
    bounds area panel
    3
    5
    43
    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.healey
      d.healey last edited by

      This function is similar to getLocalBounds except you can specify an individual reduction for the top, left, bottom, and right of the rectangle.

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

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

        @d-healey Hmm that is a very interesting one 😉

        Tired to press F5 in the forum...
        Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

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

          @ustk Peek 2022-02-02 18-47.gif

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

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

            @d-healey Not sure if this needs to be part of the component class though. If you want to do some rectangle processing, you can easily write some helper functions in HiseScript. I've written a few helper classes that mimic the juce::Rectangle class:

            namespace Rect
            {
            	inline function reduced(area, amount)
            	{
            		return [ area[0] + amount, 
            				 area[1] + amount, 
            				 area[2] - 2 * amount, 
            				 area[3] - 2 * amount];
            	}
            	
            	inline function withSizeKeepingCentre(area, width, height)
            	{
            		return [ area[0] + (area[2] - width) / 2, 
            				 area[1] + (area[3] - height) / 2, 
            				 width, 
            				 height];
            	}
            	
            	inline function removeFromLeft(area, amount)
            	{
            		area[0] += amount;
            		area[2] -= amount;
            		return [area[0] - amount, area[1], amount, area[3]];
            	}
            	
            	inline function removeFromRight(area, amount)
            	{
            		area[2] -= amount;
            		return [area[0] + area[2], area[1], amount, area[3]];
            	}
            	
            	inline function removeFromTop(area, amount)
            	{
            		area[1] += amount;
            		area[3] -= amount;
            		return [area[0], area[1] - amount, area[2], amount];
            	}
            	
            	inline function removeFromBottom(area, amount)
            	{
            		area[3] -= amount;
            
            		return [area[0], area[1] + area[3], area[2], amount];
            	
            	}
            	
            	inline function translated(area, xDelta, yDelta)
            	{
            		return [area[0] + xDelta, area[1] + yDelta, area[2], area[3]];
            	}
            }
            

            Especially the removeFromXXX() methods are super awesome for layouting because you can slice the interface area.

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

              @christoph-hart Are there any downsides to including in the component class?

              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

              7
              Online

              740
              Users

              5.4k
              Topics

              50.4k
              Posts