summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorGlenford Williams <gw_dev@outlook.com>2021-01-02 17:27:15 -0500
committerAndreas Kling <kling@serenityos.org>2021-01-03 10:34:55 +0100
commitb795f582cf0bba86694e3fb7a622bc2d831eafcf (patch)
treeb78897db0e6c4c88d1e6d2e5887428c7df4a2588 /Libraries/LibGUI
parent39908fd56989024b2684a5e8e1052e8f93bdbc09 (diff)
downloadserenity-b795f582cf0bba86694e3fb7a622bc2d831eafcf.zip
LibGUI: Add missing properties to Widget gml
Add a few properties to Widget class for usage when in a gml environment
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/Widget.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp
index 5a60d1c87e..4b95039d1f 100644
--- a/Libraries/LibGUI/Widget.cpp
+++ b/Libraries/LibGUI/Widget.cpp
@@ -94,15 +94,20 @@ Widget::Widget()
REGISTER_SIZE_PROPERTY("min_size", min_size, set_min_size);
REGISTER_SIZE_PROPERTY("max_size", max_size, set_max_size);
+ REGISTER_INT_PROPERTY("width", width, set_width);
REGISTER_INT_PROPERTY("min_width", min_width, set_min_width);
REGISTER_INT_PROPERTY("max_width", max_width, set_max_width);
REGISTER_INT_PROPERTY("min_height", min_height, set_min_height);
+ REGISTER_INT_PROPERTY("height", height, set_height);
REGISTER_INT_PROPERTY("max_height", max_height, set_max_height);
REGISTER_INT_PROPERTY("fixed_width", dummy_fixed_width, set_fixed_width);
REGISTER_INT_PROPERTY("fixed_height", dummy_fixed_height, set_fixed_height);
REGISTER_SIZE_PROPERTY("fixed_size", dummy_fixed_size, set_fixed_size);
+ REGISTER_INT_PROPERTY("x", x, set_x);
+ REGISTER_INT_PROPERTY("y", y, set_y);
+
register_property(
"focus_policy", [this]() -> JsonValue {
auto policy = focus_policy();
@@ -136,6 +141,32 @@ Widget::Widget()
}
return false;
});
+
+ register_property(
+ "foreground_color", [this]() -> JsonValue { return palette().color(foreground_role()).to_string(); },
+ [this](auto& value) {
+ auto c = Color::from_string(value.to_string());
+ if (c.has_value()) {
+ auto _palette = palette();
+ _palette.set_color(foreground_role(), c.value());
+ set_palette(_palette);
+ return true;
+ }
+ return false;
+ });
+
+ register_property(
+ "background_color", [this]() -> JsonValue { return palette().color(background_role()).to_string(); },
+ [this](auto& value) {
+ auto c = Color::from_string(value.to_string());
+ if (c.has_value()) {
+ auto _palette = palette();
+ _palette.set_color(background_role(), c.value());
+ set_palette(_palette);
+ return true;
+ }
+ return false;
+ });
}
Widget::~Widget()