diff --git a/libstarlight/source/starlight/datatypes/Vector2.cpp b/libstarlight/source/starlight/datatypes/Vector2.cpp index b92b77c..29c40e6 100644 --- a/libstarlight/source/starlight/datatypes/Vector2.cpp +++ b/libstarlight/source/starlight/datatypes/Vector2.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -11,6 +12,11 @@ using starlight::Vector2; float Vector2::Length() const { return sqrtf(x * x + y * y); } Vector2 Vector2::Normalized() const { float m = Length(); return m == 0.0f ? Vector2::zero : Vector2(x / m, y / m); } +Vector2 Vector2::ClampLength(float max) const { + float len = Length(); + return *this * (std::min(len, max) / len); +} + Vector2 Vector2::Reciprocal() const { return Vector2(y, x); } Vector2 Vector2::IntSnap() const { return Vector2(roundf(x), roundf(y)); } diff --git a/libstarlight/source/starlight/datatypes/Vector2.h b/libstarlight/source/starlight/datatypes/Vector2.h index fcd2759..496cb58 100644 --- a/libstarlight/source/starlight/datatypes/Vector2.h +++ b/libstarlight/source/starlight/datatypes/Vector2.h @@ -19,6 +19,8 @@ namespace starlight { Vector2 Normalized() const; inline float Area() const { return x * y; } + Vector2 ClampLength(float max = 1) const; + Vector2 Reciprocal() const; Vector2 IntSnap() const; diff --git a/libstarlight/source/starlight/ui/Label.cpp b/libstarlight/source/starlight/ui/Label.cpp index 749cbfd..33b99f4 100644 --- a/libstarlight/source/starlight/ui/Label.cpp +++ b/libstarlight/source/starlight/ui/Label.cpp @@ -34,6 +34,7 @@ void Label::SetText(const std::string& text) { void Label::SetFont(const std::string& fontName) { textConfig->font = ThemeManager::GetFont(fontName); + textConfig->Measure(""); // force load AutoSize(); } diff --git a/libstarlight/source/starlight/ui/UIContainer.cpp b/libstarlight/source/starlight/ui/UIContainer.cpp index e634eaa..cf534c2 100644 --- a/libstarlight/source/starlight/ui/UIContainer.cpp +++ b/libstarlight/source/starlight/ui/UIContainer.cpp @@ -71,6 +71,7 @@ void UIContainer::RemoveAll() { it->parent = std::weak_ptr(); // clear parent } children.clear(); + MarkForRedraw(); } void UIContainer::Update() { diff --git a/libstarlight/todo.txt b/libstarlight/todo.txt index 0e795bf..7ab48ee 100644 --- a/libstarlight/todo.txt +++ b/libstarlight/todo.txt @@ -11,6 +11,13 @@ roadmap to v0.5.1 { make button glyphs usable in conjunction with text (left edge, margin etc.) give glyphs a color mode where they aren't set to text color + predrawoffscreen on hidden forms + + paged field + + figure out why first-draw in a given font sometimes derps up? + ^ mitigate with a force-load-on-set for now + - libctru console as ui element - pngcrush the biggest assets (default and osk backdrops etc.)