Commit graph

167 commits

Author SHA1 Message Date
hippoz
6d87a782ca
add the new box layouts to the meson build file 2022-06-15 18:24:17 +03:00
hippoz
c997f632c6
add widget accent style 2022-06-15 04:45:21 +03:00
hippoz
9a739d7cb4
improve performance when modifying text 2022-06-15 04:45:12 +03:00
hippoz
91a3ed6a87
add unfinished vertical box layout 2022-06-15 04:44:55 +03:00
hippoz
96a7739341
add horizontal box layout 2022-06-15 04:44:37 +03:00
hippoz
93b33c433b
remove redundant computation for window_relative 2022-06-14 01:48:02 +03:00
hippoz
ac340869a7
switch to older example program for testing 2022-06-14 01:46:58 +03:00
hippoz
2a5ae1f100
add a simpler example program 2022-06-12 23:40:04 +03:00
hippoz
c96fc98f37
export colors 2022-06-12 23:39:48 +03:00
hippoz
cd38bad6ea
fix DocumentLayout 2022-06-12 23:39:38 +03:00
hippoz
23bde79967
improve styles 2022-06-12 22:16:26 +03:00
hippoz
3a9b530a08
remove automatic event propagation 2022-06-11 20:42:21 +03:00
hippoz
69d8e0a689
tidy: tidy Painter's text() and compute_text_size() methods 2022-06-11 16:19:02 +03:00
hippoz
9ee4acfba5
tidy: rename current_geometry to rect and tidy includes 2022-06-11 15:56:26 +03:00
hippoz
305279c0f7
add improved style system for widgets 2022-06-11 15:52:23 +03:00
hippoz
bfe126ab3c
cleanup 2022-06-10 20:28:03 +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
f14d88c776
fix bounds check for focus event 2022-06-06 00:03:01 +03:00
hippoz
1f04b5d1dc
begin working on adding invalidation rects 2022-06-04 12:12:41 +03:00
hippoz
b781db009a
clean up class header files 2022-05-15 10:54:30 +03:00
hippoz
a01a3c1927
add an property to widgets to make them omit layout...
and add on_event function pointer that users can set on any widgets to
act upon various events manually
2022-05-14 15:44:05 +03:00
hippoz
fbece08638
make fitting widgets to text a generic function and add it to label 2022-05-14 13:05:52 +03:00
hippoz
8251532938
don't dispatch activation/focus events if the status did not change
This commit prevents the dispatch of activation/focus events if the
status did not change. This eliminates useless repaints when mousing
around inside a button.
2022-05-14 11:31:57 +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
5e436b5463
replace the separate layout and repaint events with a single "reflow"
event
2022-05-12 17:05:16 +03:00
hippoz
e52bbce5e0
fix layouting when button text changes 2022-05-10 21:14:55 +03:00
hippoz
fcb4556a4e
test many widgets at the same time 2022-05-10 16:17:12 +03:00
hippoz
3039646b6b
make DocumentLayout responsive in regards to the parent's width 2022-05-09 23:03:56 +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
4145115697
add syntax sugar and fix some safety issues 2022-04-24 02:59:47 +03:00
hippoz
0aebfd6465
convenience function for adding layouts to a widget 2022-04-03 15:46:38 +03:00
hippoz
60a4dc51a7
Move logic from Layout into DocumentLayout 2022-04-03 13:25:09 +03:00
hippoz
eedf38f9a8
add relayout event 2022-04-02 21:41:35 +03:00
hippoz
441d4091cb
make test program more interesting 2022-04-01 07:13:36 +03:00
hippoz
eec776ba46
layouts: margins! 2022-04-01 07:08:21 +03:00
hippoz
f8a91f3a83
remove old file 2022-03-30 16:21:53 +03:00
hippoz
7f953a5f40
make lables text left-aligned 2022-03-30 16:12:25 +03:00
hippoz
4401b7b5b2
add very basic layout system 2022-03-30 14:49:31 +03:00
hippoz
9efac54ffa
changing the text on a label does not require a full repaint 2022-03-30 09:53:09 +03:00
hippoz
156d876364
make widgets inherit background color, making for a cleaner demo program 2022-03-29 09:53:58 +03:00
hippoz
992ef1e3d6
handle text bounds using pango 2022-03-29 09:27:59 +03:00
hippoz
5744ee7add
make the demo program more interactive 2022-03-29 07:08:19 +03:00
hippoz
e10daab4d0
perform full repaint when a label changes text 2022-03-29 07:00:03 +03:00
hippoz
596b0e530f
switch to different painting method and add label widget 2022-03-26 02:57:41 +02:00
hippoz
24c139b917
Keep track of active widgets inside the Window 2022-03-21 21:51:51 +02:00
hippoz
9c267cc87b
add on_click to buttons 2022-03-20 03:05:21 +02:00
hippoz
736cef4667
Fix activation and use toplevelstyles inside of widgets 2022-03-20 02:47:15 +02:00
hippoz
61b76df08b
keep track of focused widget on parent 2022-03-19 21:32:15 +02:00
hippoz
d6dcff2b7c
improve style prop macro name 2022-03-19 19:01:51 +02:00