mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
Theming: Add alignment section
This commit removes the IsTitleCenter property and replaces it with the TitleAlignment property that supports "Left", "Right" & "Center".
This commit is contained in:
parent
2bb32a87f9
commit
35dac843b4
21 changed files with 181 additions and 32 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -48,6 +49,8 @@ const char* to_string(Variant::Type type)
|
|||
return "TextAlignment";
|
||||
case Variant::Type::ColorRole:
|
||||
return "ColorRole";
|
||||
case Variant::Type::AlignmentRole:
|
||||
return "AlignmentRole";
|
||||
case Variant::Type::FlagRole:
|
||||
return "FlagRole";
|
||||
case Variant::Type::MetricRole:
|
||||
|
@ -99,6 +102,12 @@ Variant::Variant(Gfx::ColorRole value)
|
|||
m_value.as_color_role = value;
|
||||
}
|
||||
|
||||
Variant::Variant(Gfx::AlignmentRole value)
|
||||
: m_type(Type::AlignmentRole)
|
||||
{
|
||||
m_value.as_alignment_role = value;
|
||||
}
|
||||
|
||||
Variant::Variant(Gfx::FlagRole value)
|
||||
: m_type(Type::FlagRole)
|
||||
{
|
||||
|
@ -355,6 +364,9 @@ void Variant::copy_from(const Variant& other)
|
|||
case Type::ColorRole:
|
||||
m_value.as_color_role = other.m_value.as_color_role;
|
||||
break;
|
||||
case Type::AlignmentRole:
|
||||
m_value.as_alignment_role = other.m_value.as_alignment_role;
|
||||
break;
|
||||
case Type::FlagRole:
|
||||
m_value.as_flag_role = other.m_value.as_flag_role;
|
||||
break;
|
||||
|
@ -406,6 +418,8 @@ bool Variant::operator==(const Variant& other) const
|
|||
return m_value.as_text_alignment == other.m_value.as_text_alignment;
|
||||
case Type::ColorRole:
|
||||
return m_value.as_color_role == other.m_value.as_color_role;
|
||||
case Type::AlignmentRole:
|
||||
return m_value.as_alignment_role == other.m_value.as_alignment_role;
|
||||
case Type::FlagRole:
|
||||
return m_value.as_flag_role == other.m_value.as_flag_role;
|
||||
case Type::MetricRole:
|
||||
|
@ -451,6 +465,7 @@ bool Variant::operator<(const Variant& other) const
|
|||
case Type::Font:
|
||||
case Type::TextAlignment:
|
||||
case Type::ColorRole:
|
||||
case Type::AlignmentRole:
|
||||
case Type::FlagRole:
|
||||
case Type::MetricRole:
|
||||
case Type::PathRole:
|
||||
|
@ -512,6 +527,8 @@ String Variant::to_string() const
|
|||
}
|
||||
case Type::ColorRole:
|
||||
return String::formatted("Gfx::ColorRole::{}", Gfx::to_string(m_value.as_color_role));
|
||||
case Type::AlignmentRole:
|
||||
return String::formatted("Gfx::AlignmentRole::{}", Gfx::to_string(m_value.as_alignment_role));
|
||||
case Type::FlagRole:
|
||||
return String::formatted("Gfx::FlagRole::{}", Gfx::to_string(m_value.as_flag_role));
|
||||
case Type::MetricRole:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -35,6 +36,7 @@ public:
|
|||
Variant(const Gfx::Font&);
|
||||
Variant(const Gfx::TextAlignment);
|
||||
Variant(const Gfx::ColorRole);
|
||||
Variant(const Gfx::AlignmentRole);
|
||||
Variant(const Gfx::FlagRole);
|
||||
Variant(const Gfx::MetricRole);
|
||||
Variant(const Gfx::PathRole);
|
||||
|
@ -68,6 +70,7 @@ public:
|
|||
Font,
|
||||
TextAlignment,
|
||||
ColorRole,
|
||||
AlignmentRole,
|
||||
FlagRole,
|
||||
MetricRole,
|
||||
PathRole,
|
||||
|
@ -90,6 +93,7 @@ public:
|
|||
bool is_font() const { return m_type == Type::Font; }
|
||||
bool is_text_alignment() const { return m_type == Type::TextAlignment; }
|
||||
bool is_color_role() const { return m_type == Type::ColorRole; }
|
||||
bool is_alignment_role() const { return m_type == Type::AlignmentRole; }
|
||||
bool is_flag_role() const { return m_type == Type::FlagRole; }
|
||||
bool is_metric_role() const { return m_type == Type::MetricRole; }
|
||||
bool is_path_role() const { return m_type == Type::PathRole; }
|
||||
|
@ -254,6 +258,13 @@ public:
|
|||
return m_value.as_color_role;
|
||||
}
|
||||
|
||||
Gfx::AlignmentRole to_alignment_role() const
|
||||
{
|
||||
if (type() != Type::AlignmentRole)
|
||||
return Gfx::AlignmentRole::NoRole;
|
||||
return m_value.as_alignment_role;
|
||||
}
|
||||
|
||||
Gfx::FlagRole to_flag_role() const
|
||||
{
|
||||
if (type() != Type::FlagRole)
|
||||
|
@ -325,6 +336,7 @@ private:
|
|||
Gfx::RGBA32 as_color;
|
||||
Gfx::TextAlignment as_text_alignment;
|
||||
Gfx::ColorRole as_color_role;
|
||||
Gfx::AlignmentRole as_alignment_role;
|
||||
Gfx::FlagRole as_flag_role;
|
||||
Gfx::MetricRole as_metric_role;
|
||||
Gfx::PathRole as_path_role;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue