Simon Hausmann
91b3765e97
Improve method naming in ItemRenderer
...
Use `visit_` for the pattern where the trait offers a default implementation that calls other
methods to do the actual work.
2022-03-18 15:42:49 +01:00
Simon Hausmann
f04f0a3e48
GL backend: use direct layers for non-rectangular clips
...
Delegate the decision how to implement the Clip element entirely into the backend,
where the GL backend can now explicitly render
children into a layer, instead of the hack with a layer in the renderer's
state and the extra save/restore pair.
2022-03-18 15:42:49 +01:00
Simon Hausmann
6a6a26569d
Add support for rendering complex clip paths into cached layers
...
If the renderer supports it, clip elements with a complex clip render
the sub-tree into a cached layer.
2022-03-18 15:42:49 +01:00
Simon Hausmann
75949e702c
Prepare item rendering for children self-handling
...
The render function now takes a self_rc and returns a enum that permits
the implementation to handle rendering of children on its own and
thus make the caller skip that traversal step.
2022-03-18 15:42:49 +01:00
Olivier Goffart
fa1fad931b
Properties: Save one usize for each binding
...
Use a Cell instead of a RefCell
2022-03-18 09:23:52 +01:00
Olivier Goffart
ca5151de11
C++: implement Window::on_close_requested
2022-03-17 14:49:12 +01:00
Olivier Goffart
fd2d82e0a3
Flickable: adjust the thresholds
...
There must be a high enough threshold because the driver
of our screen is fuzzy and report changing numbers. We
don't want to be moving the Flickable too fast.
2022-03-17 14:12:31 +01:00
Simon Hausmann
3a3ce15970
Add a unit test that verifies that VecModel::set_vec
notifies the view correctly
2022-03-17 09:47:10 +01:00
Ray Redondo
b265f721f2
add a test
2022-03-17 09:15:58 +01:00
Ray Redondo
94cbaa55d7
add VecModel::set_vec
2022-03-17 09:15:58 +01:00
Lukas Jung
9a0f67575b
remove redundant sentence in doc for on_close_requested()
...
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-03-17 08:51:00 +01:00
Lukas Jung
e6b39aea40
remove unnecessary derive macros from CloseRequestResponse
2022-03-17 08:51:00 +01:00
Lukas Jung
0046c1a754
run rustfmt on api.rs and window.rs
2022-03-17 08:51:00 +01:00
Lukas Jung
17066615bb
remove mut from on_close_requested() to remove warning
2022-03-17 08:51:00 +01:00
Lukas Jung
3ce937f4df
Add documentation to functions for close callback handling
2022-03-17 08:51:00 +01:00
Lukas Jung
a7e798842a
add close_requested() closure and request_close() function to Window
2022-03-17 08:51:00 +01:00
Simon Hausmann
a3830e785a
janitor: remove unused return value from render_item_children
2022-03-16 09:28:33 +01:00
Simon Hausmann
c94c223c3b
Simplify item rendering loop
...
Instead of using the generic visitor, call `visit_children_item` directly on the Component.
This way we avoid the RefCell for the renderer and this will make it
easier to introduce items that decide to render the children themselves, with
their own property tracker.
2022-03-16 09:18:09 +01:00
Tobias Hunger
ea684fa4de
Add item_tree function to Component VTable
2022-03-14 17:19:31 +01:00
Tobias Hunger
bdc3778cec
Rename init/free item functions back
2022-03-14 09:43:50 +01:00
Tobias Hunger
095537e3fd
Remove item from ItemTreeNode
...
... and make ItemTreeNode non-generic this way.
The Item is now only in the extra ItemArray struct and we are free to
expose the ItemTree further.
2022-03-14 09:43:50 +01:00
Tobias Hunger
1240c1d0b8
Remove the Component functions that initialize and free items
...
... based in the ItemTree. Leave only the variants that take the
ItemArray.
2022-03-14 09:43:50 +01:00
Tobias Hunger
1fd14272cf
Use item_array in C++
2022-03-14 09:43:50 +01:00
Tobias Hunger
b95342551b
Add index into item_array into ItemTreeNode
2022-03-14 09:43:50 +01:00
Tobias Hunger
99364e26a9
Add helper functions to init/free arrays of items
2022-03-14 09:43:50 +01:00
Tobias Hunger
227ce31992
Use component::get_item_ref to access items
2022-03-14 09:43:50 +01:00
Lukas Jung
4c61a16c08
add From<&str> and From<SharedString> to StandardListViewItem
2022-03-11 15:45:59 +01:00
Simon Hausmann
cfe2bc1329
Fix comment
2022-03-10 10:51:32 +01:00
Simon Hausmann
20597a0296
Simplify line layout callback signature
...
The last argumen is unused
2022-03-10 10:51:32 +01:00
Simon Hausmann
4e18291290
Rename linebreak_ascii to linebreak_simple
...
It's not just strict ascii
2022-03-10 10:51:32 +01:00
Simon Hausmann
7cf5a6a197
Simplify line layout API
...
Use a struct for all the parameters
2022-03-10 10:51:32 +01:00
Simon Hausmann
5e9a3b8ed1
Remove unnecessary refcell/vec
2022-03-10 10:51:32 +01:00
Simon Hausmann
1d1b13e4d6
Clean up line break "abstraction"
...
Use unicode-linebreak's enum directly and ony use a custom enum in the fake
module.
2022-03-10 10:51:32 +01:00
Simon Hausmann
004a09b64d
Fix incorrect comment in the "ascii" line breaker
...
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2022-03-10 10:51:32 +01:00
Simon Hausmann
7ba8ea156b
Fix up small TODO comments
2022-03-10 10:51:32 +01:00
Simon Hausmann
51e0d17092
Add a test for elision
2022-03-10 10:51:32 +01:00
Simon Hausmann
33ae882506
Avoid shaping text twice per line when drawing paragraphs
...
Track the glyph range in the TextLine and use that to access the glyph buffer,
instead of calling shape_text() again.
2022-03-10 10:51:32 +01:00
Simon Hausmann
247847cb54
Avoid unnecessary glyph buffer re-allocations
...
Store the result of all text shaping calls in one glyph buffer when laying out a
a paragraph of text.
This paves the way of avoiding unnecessary shape_text calls when processing lines.
2022-03-10 10:51:32 +01:00
Simon Hausmann
35f245687a
Make it possible to build the text layout without unicode linebreak tables
2022-03-10 10:51:32 +01:00
Simon Hausmann
187294c00e
Simplify glyph interface in TextShaper
...
* Impose no bounds on the associated Glyph type
* Report the byte offset only in shape_text - it doesn't belong into an aritrary glyph
* Move querying the advance into the TextShaper, where the MCU implementation can deal with missing glyphs
without storing fallback values in the Glyph type
2022-03-10 10:51:32 +01:00
Simon Hausmann
87431eea95
Make it possible to build without unicode-script
2022-03-10 10:51:32 +01:00
Simon Hausmann
38e26f25ef
Basic elision support
...
TODO:
* alignment for rtl/ltr
* elide only last line for multi-line
2022-03-10 10:51:32 +01:00
Simon Hausmann
8d4c645346
Change the paragraph text layout callback to take glyphs
...
This is needed in the future to avoid duplication shaping and
implementation of features like elision or letter spacing in a shared code.
2022-03-10 10:51:32 +01:00
Simon Hausmann
ff2b38eefb
Minor clean up in paragraph layout
...
Encapsulate the entire loop body in the process_line helper
2022-03-10 10:51:32 +01:00
Simon Hausmann
a947ec1441
Simplify glyph interface
...
The textlayout module does not need to impose the exact glyph struct layout.
This paves the way for glyph based rendering.
2022-03-10 10:51:32 +01:00
Simon Hausmann
42a0f605ad
Add an paragraph layout helper function to the corelib textlayout
...
The objective is to use this in the MCU backend and replace layout_text_lines() in the GL backend in the future.
2022-03-10 10:51:32 +01:00
Simon Hausmann
6748563dc6
Fix non-wrapped text with multiple break opportunities
2022-03-10 10:51:32 +01:00
Simon Hausmann
62d633a572
Add convenience function for measuring paragraph sizes
2022-03-10 10:51:32 +01:00
Simon Hausmann
72186cd891
Make the available width an option
2022-03-10 10:51:32 +01:00
Simon Hausmann
1a73460a6a
Add basic text layout module for use with the MCU
...
This is based on the unicode line breaking algorithm (uses crate for
that), which also supports forced line breaks. The shaping is generic,
so on the MCU side we can do without at first.
2022-03-10 10:51:32 +01:00