Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
944 B · 31 lines
C++
1234567891011121314151617181920212223242526272829303132#include "DirtyManager.h"
namespace UI {
static bool CheckSubtreeDirty(const Widget* widget, DirtyFlags flags) { if (!widget) return false; if (widget->IsDirty(flags)) return true;
for (const auto& child : widget->GetChildren()) { if (CheckSubtreeDirty(child.get(), flags)) return true; } return false;}
void DirtyManager::SetRootWidget(Widget* root) { rootWidget = root; }
void DirtyManager::UpdateLayout(Size viewportSize) { // this needs optimize if (!rootWidget) return;
if (rootWidget->IsDirty(DirtyFlags::Layout) || CheckSubtreeDirty(rootWidget, DirtyFlags::Layout)) { rootWidget->Measure(viewportSize); rootWidget->Arrange(Rect(0.0f, 0.0f, viewportSize.width, viewportSize.height)); }}
bool DirtyManager::NeedsRender() const { if (!rootWidget) return false; return rootWidget->IsDirty(DirtyFlags::Render) || CheckSubtreeDirty(rootWidget, DirtyFlags::Render);}
}