Browse Source

Added a couple of reduced/expanded methods to Rectangle.

tags/2021-05-28
jules 13 years ago
parent
commit
bddebf3433
5 changed files with 24 additions and 4 deletions
  1. +1
    -1
      extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp
  2. +1
    -1
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.h
  3. +1
    -1
      extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp
  4. +1
    -1
      extras/JuceDemo/Source/demos/WidgetsDemo.cpp
  5. +20
    -0
      modules/juce_graphics/geometry/juce_Rectangle.h

+ 1
- 1
extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp View File

@@ -567,7 +567,7 @@ IntrojucerLookAndFeel::IntrojucerLookAndFeel()
Rectangle<int> IntrojucerLookAndFeel::getPropertyComponentContentPosition (PropertyComponent& component)
{
if (component.findParentComponentOfClass<AppearanceEditor::EditorPanel>() != nullptr)
return component.getLocalBounds().reduced (1, 1).removeFromRight (component.getWidth() / 2);
return component.getLocalBounds().reduced (1).removeFromRight (component.getWidth() / 2);
return LookAndFeel::getPropertyComponentContentPosition (component);
}


+ 1
- 1
extras/Introjucer/Source/Utility/jucer_MiscUtilities.h View File

@@ -280,7 +280,7 @@ public:
const Colour colour (getColour());
g.fillAll (Colours::grey);
g.fillCheckerBoard (getLocalBounds().reduced (2, 2),
g.fillCheckerBoard (getLocalBounds().reduced (2),
10, 10,
Colour (0xffdddddd).overlaidWith (colour),
Colour (0xffffffff).overlaidWith (colour));


+ 1
- 1
extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp View File

@@ -94,7 +94,7 @@ public:
if (thumbnail.getTotalLength() > 0)
{
thumbnail.drawChannels (g, getLocalBounds().reduced (2, 2),
thumbnail.drawChannels (g, getLocalBounds().reduced (2),
startTime, endTime, 1.0f);
}
else


+ 1
- 1
extras/JuceDemo/Source/demos/WidgetsDemo.cpp View File

@@ -940,7 +940,7 @@ public:
g.setColour (Colours::green);
g.fillPath (p, RectanglePlacement (RectanglePlacement::centred)
.getTransformToFit (p.getBounds(), getLocalBounds().reduced (2, 2).toFloat()));
.getTransformToFit (p.getBounds(), getLocalBounds().reduced (2).toFloat()));
}
void mouseDown (const MouseEvent&)


+ 20
- 0
modules/juce_graphics/geometry/juce_Rectangle.h View File

@@ -319,6 +319,16 @@ public:
return Rectangle (pos.x - deltaX, pos.y - deltaY, nw, nh);
}
/** Returns a rectangle that is larger than this one by a given amount.
Effectively, the rectangle returned is (x - delta, y - delta, w + delta * 2, h + delta * 2).
@see expand, reduce, reduced
*/
Rectangle expanded (const ValueType delta) const noexcept
{
return expanded (delta, delta);
}
/** Shrinks the rectangle by a given amount.
Effectively, its new size is (x + deltaX, y + deltaY, w - deltaX * 2, h - deltaY * 2).
@@ -341,6 +351,16 @@ public:
return expanded (-deltaX, -deltaY);
}
/** Returns a rectangle that is smaller than this one by a given amount.
Effectively, the rectangle returned is (x + delta, y + delta, w - delta * 2, h - delta * 2).
@see reduce, expand, expanded
*/
Rectangle reduced (const ValueType delta) const noexcept
{
return reduced (delta, delta);
}
/** Removes a strip from the top of this rectangle, reducing this rectangle
by the specified amount and returning the section that was removed.


Loading…
Cancel
Save