summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-12-18 11:15:38 -0500
committerAndreas Kling <kling@serenityos.org>2020-12-18 17:35:30 +0100
commit573d5b7ff2698811c1a69d4502a84842c8346607 (patch)
treec8a155229c8f9d53d85dba99183101f1affe1bac
parentb67eed5b8090353553a185ea25bb4d36c50bf342 (diff)
downloadserenity-573d5b7ff2698811c1a69d4502a84842c8346607.zip
LibGfx: Give Size and Rect * and *= operators
-rw-r--r--Libraries/LibGfx/Rect.h9
-rw-r--r--Libraries/LibGfx/Size.h9
2 files changed, 18 insertions, 0 deletions
diff --git a/Libraries/LibGfx/Rect.h b/Libraries/LibGfx/Rect.h
index 37693555d3..d485804a80 100644
--- a/Libraries/LibGfx/Rect.h
+++ b/Libraries/LibGfx/Rect.h
@@ -364,6 +364,15 @@ public:
return !(*this == other);
}
+ Rect<T> operator*(T factor) const { return { m_location * factor, m_size * factor }; }
+
+ Rect<T>& operator*=(T factor)
+ {
+ m_location *= factor;
+ m_size *= factor;
+ return *this;
+ }
+
void intersect(const Rect<T>&);
static Rect<T> from_two_points(const Point<T>& a, const Point<T>& b)
diff --git a/Libraries/LibGfx/Size.h b/Libraries/LibGfx/Size.h
index 09d15db3a4..f91887900d 100644
--- a/Libraries/LibGfx/Size.h
+++ b/Libraries/LibGfx/Size.h
@@ -98,6 +98,15 @@ public:
return *this;
}
+ Size<T> operator*(T factor) const { return { m_width * factor, m_height * factor }; }
+
+ Size<T>& operator*=(T factor)
+ {
+ m_width *= factor;
+ m_height *= factor;
+ return *this;
+ }
+
T primary_size_for_orientation(Orientation orientation) const
{
return orientation == Orientation::Vertical ? height() : width();