summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-20 22:16:40 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-20 22:16:40 +0200
commit2a14ba99a77894a42af1551013269aed840fc3d1 (patch)
treefbcfd353d73d57805fb3978f56ad0b365f280a72 /Libraries
parentc59b053ad6197f94a14b0690654684170dc6d85d (diff)
downloadserenity-2a14ba99a77894a42af1551013269aed840fc3d1.zip
LibDraw: Add orientation-based size helpers to Size as well.
Now you can ask for e.g Size::primary_size_for_orientation(Orientation).
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibDraw/Rect.h29
-rw-r--r--Libraries/LibDraw/Size.h27
2 files changed, 31 insertions, 25 deletions
diff --git a/Libraries/LibDraw/Rect.h b/Libraries/LibDraw/Rect.h
index af81bbc294..363f491b11 100644
--- a/Libraries/LibDraw/Rect.h
+++ b/Libraries/LibDraw/Rect.h
@@ -138,31 +138,10 @@ public:
int secondary_offset_for_orientation(Orientation orientation) const { return m_location.secondary_offset_for_orientation(orientation); }
void set_secondary_offset_for_orientation(Orientation orientation, int value) { m_location.set_secondary_offset_for_orientation(orientation, value); }
- int primary_size_for_orientation(Orientation orientation) const
- {
- return orientation == Orientation::Vertical ? height() : width();
- }
-
- void set_primary_size_for_orientation(Orientation orientation, int value)
- {
- if (orientation == Orientation::Vertical)
- set_height(value);
- else
- set_width(value);
- }
-
- int secondary_size_for_orientation(Orientation orientation) const
- {
- return orientation == Orientation::Vertical ? width() : height();
- }
-
- void set_secondary_size_for_orientation(Orientation orientation, int value)
- {
- if (orientation == Orientation::Vertical)
- set_width(value);
- else
- set_height(value);
- }
+ int primary_size_for_orientation(Orientation orientation) const { return m_size.primary_size_for_orientation(orientation); }
+ int secondary_size_for_orientation(Orientation orientation) const { return m_size.secondary_size_for_orientation(orientation); }
+ void set_primary_size_for_orientation(Orientation orientation, int value) { m_size.set_primary_size_for_orientation(orientation, value); }
+ void set_secondary_size_for_orientation(Orientation orientation, int value) { m_size.set_secondary_size_for_orientation(orientation, value); }
int first_edge_for_orientation(Orientation orientation) const
{
diff --git a/Libraries/LibDraw/Size.h b/Libraries/LibDraw/Size.h
index a499dbc2fd..a9209ab448 100644
--- a/Libraries/LibDraw/Size.h
+++ b/Libraries/LibDraw/Size.h
@@ -2,6 +2,7 @@
#include <AK/AKString.h>
#include <AK/LogStream.h>
+#include <LibDraw/Orientation.h>
struct WSAPI_Size;
@@ -50,6 +51,32 @@ public:
return *this;
}
+ int primary_size_for_orientation(Orientation orientation) const
+ {
+ return orientation == Orientation::Vertical ? height() : width();
+ }
+
+ void set_primary_size_for_orientation(Orientation orientation, int value)
+ {
+ if (orientation == Orientation::Vertical)
+ set_height(value);
+ else
+ set_width(value);
+ }
+
+ int secondary_size_for_orientation(Orientation orientation) const
+ {
+ return orientation == Orientation::Vertical ? width() : height();
+ }
+
+ void set_secondary_size_for_orientation(Orientation orientation, int value)
+ {
+ if (orientation == Orientation::Vertical)
+ set_width(value);
+ else
+ set_height(value);
+ }
+
operator WSAPI_Size() const;
String to_string() const { return String::format("[%dx%d]", m_width, m_height); }