mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-15 19:52:05 +00:00
Move Manager::invalidateDisplayRegion() to Manager::onInvalidateRegion()
This commit is contained in:
parent
767897d665
commit
2ffb708be8
@ -484,7 +484,7 @@ bool CustomizedGuiManager::onProcessMessage(Message* msg)
|
||||
|
||||
case kTimerMessage:
|
||||
if (static_cast<TimerMessage*>(msg)->timer() == defered_invalid_timer) {
|
||||
invalidateDisplayRegion(defered_invalid_region);
|
||||
invalidateRegion(defered_invalid_region);
|
||||
defered_invalid_region.clear();
|
||||
defered_invalid_timer->stop();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -1530,9 +1531,18 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
|
||||
return used;
|
||||
}
|
||||
|
||||
void Manager::invalidateDisplayRegion(const gfx::Region& region)
|
||||
// It's like Widget::onInvalidateRegion() but optimized for the
|
||||
// Manager (as we know that all children in a Manager will be windows,
|
||||
// we can use this knowledge to avoid some calculations).
|
||||
void Manager::onInvalidateRegion(const gfx::Region& region)
|
||||
{
|
||||
// TODO intersect with getDrawableRegion()???
|
||||
if (!isVisible() || region.contains(bounds()) == gfx::Region::Out)
|
||||
return;
|
||||
|
||||
// Intersect only with manager bounds, we don't need to use
|
||||
// getDrawableRegion() because each window will be processed in the
|
||||
// following for() loop (and it's highly probable that a desktop
|
||||
// Window will use the whole manager portion anyway).
|
||||
gfx::Region reg1;
|
||||
reg1.createIntersection(region, gfx::Region(bounds()));
|
||||
|
||||
@ -1549,19 +1559,23 @@ void Manager::invalidateDisplayRegion(const gfx::Region& region)
|
||||
// There is desktop?
|
||||
if (window->isDesktop()) {
|
||||
withDesktop = true;
|
||||
break; // Work done
|
||||
break; // Work done
|
||||
}
|
||||
|
||||
// Clip this window area for the next window.
|
||||
gfx::Region reg3;
|
||||
window->getRegion(reg3);
|
||||
reg1.createSubtraction(reg1, reg3);
|
||||
gfx::Region reg2;
|
||||
window->getRegion(reg2);
|
||||
reg1.createSubtraction(reg1, reg2);
|
||||
}
|
||||
|
||||
// Invalidate areas outside windows (only when there are not a
|
||||
// desktop window).
|
||||
if (!withDesktop)
|
||||
Widget::invalidateRegion(reg1);
|
||||
if (!withDesktop) {
|
||||
// TODO we should be able to modify m_updateRegion directly here,
|
||||
// so we avoid the getDrawableRegion() call from
|
||||
// Widget::onInvalidateRegion().
|
||||
Widget::onInvalidateRegion(reg1);
|
||||
}
|
||||
}
|
||||
|
||||
LayoutIO* Manager::getLayoutIO()
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -82,8 +83,6 @@ namespace ui {
|
||||
void removeMessageFilter(int message, Widget* widget);
|
||||
void removeMessageFilterFor(Widget* widget);
|
||||
|
||||
void invalidateDisplayRegion(const gfx::Region& region);
|
||||
|
||||
LayoutIO* getLayoutIO();
|
||||
|
||||
bool isFocusMovementMessage(Message* msg);
|
||||
@ -109,6 +108,7 @@ namespace ui {
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(Message* msg) override;
|
||||
void onInvalidateRegion(const gfx::Region& region) override;
|
||||
void onResize(ResizeEvent& ev) override;
|
||||
void onSizeHint(SizeHintEvent& ev) override;
|
||||
void onBroadcastMouseMessage(WidgetsList& targets) override;
|
||||
|
@ -1480,21 +1480,22 @@ bool Widget::onProcessMessage(Message* msg)
|
||||
|
||||
void Widget::onInvalidateRegion(const Region& region)
|
||||
{
|
||||
if (isVisible() && region.contains(bounds()) != Region::Out) {
|
||||
Region reg1;
|
||||
reg1.createUnion(m_updateRegion, region);
|
||||
{
|
||||
Region reg2;
|
||||
getDrawableRegion(reg2, kCutTopWindows);
|
||||
m_updateRegion.createIntersection(reg1, reg2);
|
||||
}
|
||||
reg1.createSubtraction(region, m_updateRegion);
|
||||
if (!isVisible() || region.contains(bounds()) == Region::Out)
|
||||
return;
|
||||
|
||||
setDirtyFlag();
|
||||
|
||||
for (auto child : m_children)
|
||||
child->invalidateRegion(reg1);
|
||||
Region reg1;
|
||||
reg1.createUnion(m_updateRegion, region);
|
||||
{
|
||||
Region reg2;
|
||||
getDrawableRegion(reg2, kCutTopWindows);
|
||||
m_updateRegion.createIntersection(reg1, reg2);
|
||||
}
|
||||
reg1.createSubtraction(region, m_updateRegion);
|
||||
|
||||
setDirtyFlag();
|
||||
|
||||
for (auto child : m_children)
|
||||
child->invalidateRegion(reg1);
|
||||
}
|
||||
|
||||
void Widget::onSizeHint(SizeHintEvent& ev)
|
||||
|
@ -673,7 +673,7 @@ void Window::moveWindow(const gfx::Rect& rect, bool use_blit)
|
||||
invalidateRegion(reg1);
|
||||
}
|
||||
|
||||
manager->invalidateDisplayRegion(invalidManagerRegion);
|
||||
manager->invalidateRegion(invalidManagerRegion);
|
||||
|
||||
onWindowMovement();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user