mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibDraw: Add orientation-based size helpers to Size as well.
Now you can ask for e.g Size::primary_size_for_orientation(Orientation).
This commit is contained in:
parent
c59b053ad6
commit
2a14ba99a7
2 changed files with 31 additions and 25 deletions
|
@ -138,31 +138,10 @@ public:
|
||||||
int secondary_offset_for_orientation(Orientation orientation) const { return m_location.secondary_offset_for_orientation(orientation); }
|
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); }
|
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
|
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); }
|
||||||
return orientation == Orientation::Vertical ? height() : width();
|
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); }
|
||||||
|
|
||||||
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 first_edge_for_orientation(Orientation orientation) const
|
int first_edge_for_orientation(Orientation orientation) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <AK/AKString.h>
|
#include <AK/AKString.h>
|
||||||
#include <AK/LogStream.h>
|
#include <AK/LogStream.h>
|
||||||
|
#include <LibDraw/Orientation.h>
|
||||||
|
|
||||||
struct WSAPI_Size;
|
struct WSAPI_Size;
|
||||||
|
|
||||||
|
@ -50,6 +51,32 @@ public:
|
||||||
return *this;
|
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;
|
operator WSAPI_Size() const;
|
||||||
|
|
||||||
String to_string() const { return String::format("[%dx%d]", m_width, m_height); }
|
String to_string() const { return String::format("[%dx%d]", m_width, m_height); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue