Add UDim::FromPixels and UDim::FromScale constructors

This commit is contained in:
2025-06-26 06:03:27 -05:00
parent 505c2c70e6
commit beb5c97c13
2 changed files with 7 additions and 0 deletions

View File

@@ -26,6 +26,9 @@ namespace JUI
UDim() : Pixels(0), Scale(0.f) {}
UDim(int pixels, float scale) : Pixels(pixels), Scale(scale) {}
UDim(const UDim& u) = default;
static UDim FromPixels(int pixels);
static UDim FromScale(float scale);
public:
UDim operator + (const UDim& rhs) const;

View File

@@ -16,6 +16,10 @@ JUI::UDim JUI::UDimLiterals::operator ""_px(unsigned long long px) {
return {static_cast<int>(px), 0.f};
}
JUI::UDim JUI::UDim::FromPixels(int pixels) { return {pixels, 0.f}; }
JUI::UDim JUI::UDim::FromScale(float scale) { return {0, scale}; }
JUI::UDim JUI::UDim::operator+(const UDim &rhs) const {
return {Pixels + rhs.Pixels, Scale + rhs.Scale};
}