LibGfx: Return StringView for SystemTheme Roles

This will simplify upcoming Label porting in ThemeEditor.
This commit is contained in:
thankyouverycool 2023-04-29 10:41:29 -04:00 committed by Andreas Kling
parent 9a03e4dd73
commit 3d53dc8228
Notes: sideshowbarker 2024-07-17 03:03:37 +09:00

View file

@ -157,15 +157,15 @@ enum class ColorRole {
DisabledText = ThreedShadow1,
};
inline char const* to_string(ColorRole role)
inline StringView to_string(ColorRole role)
{
switch (role) {
case ColorRole::NoRole:
return "NoRole";
return "NoRole"sv;
#undef __ENUMERATE_COLOR_ROLE
#define __ENUMERATE_COLOR_ROLE(role) \
case ColorRole::role: \
return #role;
return #role##sv;
ENUMERATE_COLOR_ROLES(__ENUMERATE_COLOR_ROLE)
#undef __ENUMERATE_COLOR_ROLE
default:
@ -184,15 +184,15 @@ enum class AlignmentRole {
__Count,
};
inline char const* to_string(AlignmentRole role)
inline StringView to_string(AlignmentRole role)
{
switch (role) {
case AlignmentRole::NoRole:
return "NoRole";
return "NoRole"sv;
#undef __ENUMERATE_ALIGNMENT_ROLE
#define __ENUMERATE_ALIGNMENT_ROLE(role) \
case AlignmentRole::role: \
return #role;
return #role##sv;
ENUMERATE_ALIGNMENT_ROLES(__ENUMERATE_ALIGNMENT_ROLE)
#undef __ENUMERATE_ALIGNMENT_ROLE
default:
@ -211,15 +211,15 @@ enum class FlagRole {
__Count,
};
inline char const* to_string(FlagRole role)
inline StringView to_string(FlagRole role)
{
switch (role) {
case FlagRole::NoRole:
return "NoRole";
return "NoRole"sv;
#undef __ENUMERATE_FLAG_ROLE
#define __ENUMERATE_FLAG_ROLE(role) \
case FlagRole::role: \
return #role;
return #role##sv;
ENUMERATE_FLAG_ROLES(__ENUMERATE_FLAG_ROLE)
#undef __ENUMERATE_FLAG_ROLE
default:
@ -238,15 +238,15 @@ enum class MetricRole {
__Count,
};
inline char const* to_string(MetricRole role)
inline StringView to_string(MetricRole role)
{
switch (role) {
case MetricRole::NoRole:
return "NoRole";
return "NoRole"sv;
#undef __ENUMERATE_METRIC_ROLE
#define __ENUMERATE_METRIC_ROLE(role) \
case MetricRole::role: \
return #role;
return #role##sv;
ENUMERATE_METRIC_ROLES(__ENUMERATE_METRIC_ROLE)
#undef __ENUMERATE_METRIC_ROLE
default: