mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03: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
Notes:
sideshowbarker
2024-07-19 13:07:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2a14ba99a77
@ -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
|
||||
{
|
||||
|
@ -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); }
|
||||
|
Loading…
Reference in New Issue
Block a user