fix: mark parent dirty

This commit is contained in:
Simon Hardt
2022-03-06 22:49:12 +01:00
parent 4c70f3440d
commit 9bb296f233
7 changed files with 11 additions and 10 deletions

View File

@@ -26,7 +26,7 @@ int main()
export_font["sizes"] = json::object(); export_font["sizes"] = json::object();
std::vector<uint32_t> sizes = std::vector<uint32_t> sizes =
{12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 100, 250}; {12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 35, 40, 100, 250};
for(auto& size : sizes) for(auto& size : sizes)
{ {

View File

@@ -17,6 +17,7 @@ namespace frame::widgets
void ContainerWidget::setSlot(size_t slot, Widget::shared_ptr ptr) void ContainerWidget::setSlot(size_t slot, Widget::shared_ptr ptr)
{ {
ptr->setParent(this);
widgets[slot] = ptr; widgets[slot] = ptr;
} }

View File

@@ -3,7 +3,7 @@
namespace frame::widgets namespace frame::widgets
{ {
Widget::shared_ptr Widget::getParent() const Widget::week_ptr Widget::getParent() const
{ {
return mParent; return mParent;
} }

View File

@@ -11,7 +11,7 @@ namespace frame::widgets
{ {
public: public:
using shared_ptr = std::shared_ptr<Widget>; using shared_ptr = std::shared_ptr<Widget>;
using week_ptr = std::shared_ptr<Widget>; using week_ptr = Widget*;
public: public:
virtual ~Widget() = default; virtual ~Widget() = default;
@@ -20,7 +20,7 @@ namespace frame::widgets
virtual void Render(render::RenderTarget& rt) = 0; virtual void Render(render::RenderTarget& rt) = 0;
virtual void ComputeChildSize(Vector size){}; virtual void ComputeChildSize(Vector size){};
shared_ptr getParent() const; week_ptr getParent() const;
void setParent(week_ptr ptr); void setParent(week_ptr ptr);
void setSize(Vector size); void setSize(Vector size);
@@ -34,8 +34,8 @@ namespace frame::widgets
void setClear(); void setClear();
private: private:
week_ptr mParent; week_ptr mParent = nullptr;
bool mDirty = true; bool mDirty = true;
Vector mRelativePosition; Vector mRelativePosition;
Vector mSize; Vector mSize;

View File

@@ -127,8 +127,6 @@ namespace frame::widgets
// Top // Top
rt.setInvert(true);
auto top = getSlot(0); auto top = getSlot(0);
if(top) if(top)
{ {
@@ -147,8 +145,6 @@ namespace frame::widgets
rt.popViewport(); rt.popViewport();
} }
rt.setInvert(false);
// Text // Text
/*auto font = font::GetFont("Fira Code"); /*auto font = font::GetFont("Fira Code");

View File

@@ -41,12 +41,14 @@ namespace frame::widgets
auto font_size = font->getOptimalSize(text, draw); auto font_size = font->getOptimalSize(text, draw);
rt.setInvert(true);
rt.DrawText(draw, rt.DrawText(draw,
text, text,
*font, *font,
font_size, font_size,
AlignHorizontal::CENTER, AlignHorizontal::CENTER,
AlignVertical::CENTER); AlignVertical::CENTER);
rt.setInvert(false);
setClear(); setClear();
} }

View File

@@ -43,12 +43,14 @@ namespace frame::widgets
auto font_size = font->getOptimalSize(text, draw); auto font_size = font->getOptimalSize(text, draw);
rt.setInvert(true);
rt.DrawText(draw, rt.DrawText(draw,
text, text,
*font, *font,
font_size, font_size,
AlignHorizontal::CENTER, AlignHorizontal::CENTER,
AlignVertical::CENTER); AlignVertical::CENTER);
rt.setInvert(false);
setClear(); setClear();
} }