summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrHun <28605587+frhun@users.noreply.github.com>2022-06-29 00:39:08 +0200
committerAndreas Kling <kling@serenityos.org>2022-06-30 11:53:50 +0200
commitfddd2bf6ff8d51f686627bb6a7f571a6d1adddc6 (patch)
tree2c6a508825f80126674a1b5994411d77b3d61eda
parent247e3ef6e74c0e9c4fb794162fe092a76e29f77b (diff)
downloadserenity-fddd2bf6ff8d51f686627bb6a7f571a6d1adddc6.zip
LibGUI: Add min_content_size debug property to AbstractScrollableWidget
This helps with debugging subclasses of AbstractScrollableWidget
-rw-r--r--Userland/Libraries/LibCore/Object.h12
-rw-r--r--Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp2
2 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h
index 9faee795fc..7e361b4fd7 100644
--- a/Userland/Libraries/LibCore/Object.h
+++ b/Userland/Libraries/LibCore/Object.h
@@ -294,6 +294,18 @@ T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOf<O
[this] { return this->getter(); }, \
{});
+#define REGISTER_READONLY_SIZE_PROPERTY(property_name, getter) \
+ register_property( \
+ property_name, \
+ [this] { \
+ auto size = this->getter(); \
+ JsonArray size_array; \
+ size_array.append(size.width()); \
+ size_array.append(size.height()); \
+ return size_array; \
+ }, \
+ {});
+
#define REGISTER_RECT_PROPERTY(property_name, getter, setter) \
register_property( \
property_name, \
diff --git a/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp b/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp
index 5466f5f3fc..013541faf4 100644
--- a/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp
+++ b/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp
@@ -13,6 +13,8 @@ namespace GUI {
AbstractScrollableWidget::AbstractScrollableWidget()
{
+ REGISTER_READONLY_SIZE_PROPERTY("min_content_size", min_content_size);
+
m_vertical_scrollbar = add<AbstractScrollableWidgetScrollbar>(*this, Orientation::Vertical);
m_vertical_scrollbar->set_step(4);
m_vertical_scrollbar->on_change = [this](int) {