1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

LibGUI: Introduce widget content margins + improve splitters

A GUI::Widget can now set an optional content margin (4x0 by default.)
Pixels in the content margin will be ignored for hit testing purposes.

Use this to allow frame-like widgets (like GUI::Frame!) to ignore any
mouse events in the frame area, and instead let those go to parent.

This allows GUI::Splitter to react "sooner" to mouse events that were
previously swallowed by the child widgets instead of ending up in the
splitter. The net effect is that 2 more pixels on each side of a
splitter handle are now interactive and usable for splitting! :^)
This commit is contained in:
Andreas Kling 2020-04-24 18:55:29 +02:00
parent 9badcff1ba
commit 42f0b2522b
6 changed files with 57 additions and 17 deletions

View file

@ -30,6 +30,7 @@
#include <LibCore/Object.h>
#include <LibGUI/Event.h>
#include <LibGUI/Forward.h>
#include <LibGUI/Margins.h>
#include <LibGfx/Color.h>
#include <LibGfx/Forward.h>
#include <LibGfx/Orientation.h>
@ -266,6 +267,11 @@ public:
Gfx::Palette palette() const;
void set_palette(const Gfx::Palette&);
const Margins& content_margins() const { return m_content_margins; }
void set_content_margins(const Margins&);
Gfx::Rect content_rect() const;
protected:
Widget();
@ -324,6 +330,7 @@ private:
SizePolicy m_horizontal_size_policy { SizePolicy::Fill };
SizePolicy m_vertical_size_policy { SizePolicy::Fill };
Gfx::Size m_preferred_size;
Margins m_content_margins;
bool m_fill_with_background_color { false };
bool m_visible { true };