mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
LibGUI: Add double type to Variant
This commit is contained in:
parent
f35791343e
commit
3acbffabf9
2 changed files with 9 additions and 2 deletions
|
@ -21,7 +21,7 @@ namespace Detail {
|
|||
struct Boolean {
|
||||
bool value;
|
||||
};
|
||||
using VariantUnderlyingType = AK::Variant<Empty, Boolean, float, i32, i64, u32, u64, DeprecatedString, Color, Gfx::IntPoint, Gfx::IntSize, Gfx::IntRect, Gfx::TextAlignment, Gfx::ColorRole, Gfx::AlignmentRole, Gfx::FlagRole, Gfx::MetricRole, Gfx::PathRole, NonnullRefPtr<Gfx::Bitmap const>, NonnullRefPtr<Gfx::Font const>, GUI::Icon>;
|
||||
using VariantUnderlyingType = AK::Variant<Empty, Boolean, float, double, i32, i64, u32, u64, DeprecatedString, Color, Gfx::IntPoint, Gfx::IntSize, Gfx::IntRect, Gfx::TextAlignment, Gfx::ColorRole, Gfx::AlignmentRole, Gfx::FlagRole, Gfx::MetricRole, Gfx::PathRole, NonnullRefPtr<Gfx::Bitmap const>, NonnullRefPtr<Gfx::Font const>, GUI::Icon>;
|
||||
}
|
||||
|
||||
class Variant : public Detail::VariantUnderlyingType {
|
||||
|
@ -76,6 +76,7 @@ public:
|
|||
bool is_u32() const { return has<u32>(); }
|
||||
bool is_u64() const { return has<u64>(); }
|
||||
bool is_float() const { return has<float>(); }
|
||||
bool is_double() const { return has<double>(); }
|
||||
bool is_string() const { return has<DeprecatedString>(); }
|
||||
bool is_bitmap() const { return has<NonnullRefPtr<Gfx::Bitmap const>>(); }
|
||||
bool is_color() const { return has<Color>(); }
|
||||
|
@ -102,7 +103,7 @@ public:
|
|||
[](Gfx::IntPoint const& v) { return !v.is_zero(); },
|
||||
[](OneOf<Gfx::IntRect, Gfx::IntSize> auto const& v) { return !v.is_empty(); },
|
||||
[](Enum auto const&) { return true; },
|
||||
[](OneOf<float, DeprecatedString, Color, NonnullRefPtr<Gfx::Font const>, NonnullRefPtr<Gfx::Bitmap const>, GUI::Icon> auto const&) { return true; });
|
||||
[](OneOf<float, double, DeprecatedString, Color, NonnullRefPtr<Gfx::Font const>, NonnullRefPtr<Gfx::Bitmap const>, GUI::Icon> auto const&) { return true; });
|
||||
}
|
||||
|
||||
i32 as_i32() const { return get<i32>(); }
|
||||
|
@ -139,6 +140,7 @@ public:
|
|||
return fallback;
|
||||
}
|
||||
|
||||
double as_double() const { return get<double>(); }
|
||||
Gfx::IntPoint as_point() const { return get<Gfx::IntPoint>(); }
|
||||
Gfx::IntSize as_size() const { return get<Gfx::IntSize>(); }
|
||||
Gfx::IntRect as_rect() const { return get<Gfx::IntRect>(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue