Commit graph

15 commits

Author SHA1 Message Date
hippoz
69d8e0a689
tidy: tidy Painter's text() and compute_text_size() methods 2022-06-11 16:19:02 +03:00
hippoz
305279c0f7
add improved style system for widgets 2022-06-11 15:52:23 +03:00
hippoz
94c0be051b
Add "invalidation rectangle"-based repainting
Previously, we were repainting each widget as repainting was needed.
However, this created issues with clipping, since the widgets were not
aware of their parent's clips. It also created many other issues, including
performance problems and the lack of support for overlapping widgets.

This commit improves repainting behavior by adopting a painting model similar
to the one found in SerenityOS's LibGUI. It uses "damage rectangles", which
are translated to the widget coordinate space as needed, since the position of
widgets is relative to their parent's origin.
When a widget needs to be repainted, a repaint event with the damage
rectangle equal to the widget's current geometry translated to the window's coordinate
space is dispatched to the main widget. It will recursively follow the widget tree.
Widgets fully contain their children, thus widgets not contained by the damage
rectangle will reject the event, ensuring repainting is only done where needed.
Relayouting is done on a per-subtree basis only.

This commit should pave the way for things like scrolling
and overlapping widgets.
2022-06-10 19:42:03 +03:00
hippoz
1f04b5d1dc
begin working on adding invalidation rects 2022-06-04 12:12:41 +03:00
hippoz
c85c367e11
Greatly improve performance on startup or when operating on lots of
widgets

This commit introduces "batches", which makes Raven hold off on doing
full reflows until the batch is ended. When a window is created, a batch
is automatically started to ensure that no useless reflows are done
during initialization. The batch is automatically ended in window.run().
Users of the library can create and end batches as well. This commit
also factors out automatic scaling based on text size into set_text for
buttons (should be done for labels as well).
2022-05-13 17:33:53 +03:00
hippoz
e52bbce5e0
fix layouting when button text changes 2022-05-10 21:14:55 +03:00
hippoz
5d672e9eec
add sizing based on text size 2022-05-08 19:31:31 +03:00
hippoz
1aec5d3e44
☢️☢️☢️☢️☢️☢️ 2022-04-30 09:40:09 +03:00
hippoz
7f953a5f40
make lables text left-aligned 2022-03-30 16:12:25 +03:00
hippoz
992ef1e3d6
handle text bounds using pango 2022-03-29 09:27:59 +03:00
hippoz
596b0e530f
switch to different painting method and add label widget 2022-03-26 02:57:41 +02:00
hippoz
9c830c48d6
clean up includes a bit 2022-03-18 03:22:30 +02:00
hippoz
ef85745f58
text, hover, styles and buttons! 2022-03-18 02:49:16 +02:00
hippoz
529c286b8f
dispatch repaint events and lay yet more groundwork 2022-03-09 20:02:18 +02:00
hippoz
2cc5e1c1e0
basic structure 2022-03-08 02:25:22 +02:00