Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
C++
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#include "Panel.h"
namespace UI {
Panel::Panel(Size size) { focusable = false; padding = Thickness(0.0f, 0.0f); if (size.width > 0.0f || size.height > 0.0f) { minSize = size; maxSize = size; }}
void Panel::RefreshPrimitives() { // this needs optimize bgRect = std::make_unique<Rectangle>(globalBounds.X, globalBounds.Y, globalBounds.Width, globalBounds.Height); bgRect->SetColor(bgColor.r, bgColor.g, bgColor.b, bgColor.a); bgRect->SetBorderColor(borderColor.r, borderColor.g, borderColor.b, borderColor.a); bgRect->SetBorderWidth(borderThickness); bgRect->SetRoundness(borderRoundness); previousColor = bgColor;}
void Panel::Measure(Size availableSpace) { Widget::Measure(availableSpace);}
void Panel::Arrange(Rect finalBounds) { Rect oldGlobal = globalBounds; bool needsRefresh = IsDirty(DirtyFlags::Render | DirtyFlags::Layout); Widget::Arrange(finalBounds);
if (needsRefresh || globalBounds != oldGlobal) { RefreshPrimitives(); }}
void Panel::Draw() { if (!visible) return;
if (!bgRect || IsDirty(DirtyFlags::Layout)) { RefreshPrimitives(); }
if (bgColor != previousColor) { bgRect->SetColor(bgColor.r, bgColor.g, bgColor.b, bgColor.a); previousColor = bgColor; }
if (bgRect) { bgRect->Render(); }
Widget::Draw();}
}