Added getTrimmedBounds()
-
This function is similar to
getLocalBounds
except you can specify an individual reduction for the top, left, bottom, and right of the rectangle. -
@d-healey Hmm that is a very interesting one ;)
-
-
@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. -
@christoph-hart Are there any downsides to including in the component class?