Skip to content

Commit 999fe28

Browse files
committed
Improved repainting
1 parent 4acc223 commit 999fe28

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

modules/yup_gui/component/yup_Component.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void Component::setVisible (bool shouldBeVisible)
108108
if (bailOutChecker.shouldBailOut())
109109
return;
110110

111-
repaint();
111+
internalRepaint();
112112
}
113113

114114
bool Component::isShowing() const
@@ -515,11 +515,10 @@ void Component::repaint (const Rectangle<float>& rect)
515515
{
516516
jassert (! options.isRepainting); // You are likely repainting from paint !
517517

518-
if (rect.isEmpty() || ! isShowing())
518+
if (rect.isEmpty() || ! isShowing())
519519
return;
520520

521-
if (auto nativeComponent = getNativeComponent())
522-
nativeComponent->repaint (rect.translated (getBoundsRelativeToTopLevelComponent().getTopLeft()));
521+
internalRepaint (rect);
523522
}
524523

525524
//==============================================================================
@@ -756,6 +755,10 @@ void Component::removeChildComponent (int index)
756755
return;
757756

758757
auto component = children.removeAndReturn (index);
758+
759+
if (component->isShowing())
760+
repaint (component->getBounds());
761+
759762
component->parentComponent = nullptr;
760763

761764
auto bailOutChecker = BailOutChecker (this);
@@ -1085,7 +1088,7 @@ bool Component::hasOpaqueChildCoveringArea (const Rectangle<float>& area)
10851088
for (int childIndex = children.size(); --childIndex >= 0;)
10861089
{
10871090
auto child = children.getUnchecked (childIndex);
1088-
if (! child->isVisible() || ! child->isOpaque() || child->options.unclippedRendering || child->isTransformed())
1091+
if (! child->isVisible() || ! child->isOpaque() || child->options.unclippedRendering || child->isTransformed())
10891092
continue;
10901093

10911094
auto childBounds = child->getBoundsRelativeToTopLevelComponent();
@@ -1108,6 +1111,22 @@ void Component::internalRefreshDisplay (double lastFrameTimeSeconds)
11081111

11091112
//==============================================================================
11101113

1114+
void Component::internalRepaint()
1115+
{
1116+
internalRepaint (getLocalBounds());
1117+
}
1118+
1119+
void Component::internalRepaint (const Rectangle<float>& rect)
1120+
{
1121+
if (rect.isEmpty())
1122+
return;
1123+
1124+
if (auto nativeComponent = getNativeComponent())
1125+
nativeComponent->repaint (rect.translated (getBoundsRelativeToTopLevelComponent().getTopLeft()));
1126+
}
1127+
1128+
//==============================================================================
1129+
11111130
void Component::internalPaint (Graphics& g, const Rectangle<float>& repaintArea, bool renderContinuous)
11121131
{
11131132
if (! isVisible() || (getWidth() == 0 || getHeight() == 0))

modules/yup_gui/component/yup_Component.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,8 @@ class YUP_API Component
11791179

11801180
private:
11811181
void internalRefreshDisplay (double lastFrameTimeSeconds);
1182+
void internalRepaint();
1183+
void internalRepaint (const Rectangle<float>& rect);
11821184
void internalPaint (Graphics& g, const Rectangle<float>& repaintArea, bool renderContinuous);
11831185
void internalMouseEnter (const MouseEvent& event);
11841186
void internalMouseExit (const MouseEvent& event);

modules/yup_gui/menus/yup_PopupMenu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ PopupMenu::Options& PopupMenu::Options::withMaximumWidth (int maxWidth)
366366
PopupMenu::PopupMenu (const Options& options)
367367
: options (options)
368368
{
369+
setOpaque (false);
369370
}
370371

371372
PopupMenu::~PopupMenu()

0 commit comments

Comments
 (0)