Commit graph

2023 commits

Author SHA1 Message Date
Simon Hausmann
0f7ba74abe Added some documentation for the font module
More to come :-)
2020-11-24 22:54:14 +01:00
Simon Hausmann
4e4d456687 Remove dead code 2020-11-24 22:40:58 +01:00
Simon Hausmann
f9ed6df123 Avoid unnecessary font loading with font-kit
Load (mmap) the font_kit::font::Font only once, not per pixel size.
2020-11-24 22:40:19 +01:00
Simon Hausmann
65e09c723a Use hover effects in the ugly style
Use a darker shade between the unpressed and the pressed shade when hovering
over controls that can be activated.
2020-11-24 22:12:17 +01:00
Simon Hausmann
727ab2ee9d Minor tweak to the ugly style
Don't use the shiny blue when pressing items - it's seemingly pretty
but it won't go well with a color change on hover.
2020-11-24 22:02:16 +01:00
Simon Hausmann
236bb0996a Add the slide puzzle to the README 2020-11-24 18:37:26 +01:00
Simon Hausmann
b711473b6a Re-order the demos in the README
Printer demo, todo and widget gallery
2020-11-24 18:35:19 +01:00
Olivier Goffart
68d6791814 slide puzzle: Fix the pressed state 2020-11-24 18:15:45 +01:00
Olivier Goffart
3ae7c6e0b5 Hover effect 2020-11-24 18:09:32 +01:00
Olivier Goffart
8a64f10e84 Remove ComponentVtable::input_event
And the custom handling of the mouse grabber
2020-11-24 16:23:37 +01:00
Olivier Goffart
845627c6b4 Implement the mouse_input in a generic way so we can remove the one in the component 2020-11-24 15:40:41 +01:00
Olivier Goffart
0c97b4f296 More use of the ItemRc 2020-11-24 13:42:34 +01:00
Olivier Goffart
124eec9960 Introfuce ItemRc and ItemWeak
Wrapper around ComponentRc and index
2020-11-24 13:42:34 +01:00
Simon Hausmann
d80868bbf4 Add support for font_weight to Text and TextInput
This allows implementing another sliding puzzle theme feature, the
boldness of the tile number text in the simple theme when the tile is in
the correct position. For the other themes the weight is constant and
it's bold.

More cleanup to follow later: unify the font handle and FontCacheKey
handling, improve the API to allow for the use of symbolic constants
(normal, bold, etc.) instead of the CSS number values.
2020-11-24 10:10:00 +01:00
Simon Hausmann
f0289192b7 More font handling cleanup
Group all fields we need to determine a physical font into one FontRequest
structure and use that throughout.

That way adding more fields will require less changes.
2020-11-24 09:00:07 +01:00
Simon Hausmann
05204a3185 Font handling cleanup
To make adding of more font related properties easier in the future, and
to simplify the text code a little, define a HasFont trait and implement
it for Pin<&Text|&TextInput> so that we can more easily get an Rc<Font>.
2020-11-23 20:39:12 +01:00
Simon Hausmann
79b7e825bb Minor cleanup of font cache handling
Store the font family as a SharedString, as that allows us to make a
lookup without a string copy.
2020-11-23 18:23:22 +01:00
Olivier Goffart
55c21c71fa Slide puzzle: add numbers
To infer the number of lines of code without comments:

```
cat ... | grep -v "^ *$" | grep -v "^ *//" | wc -l
```

This does not account for the `/* ... */` comments which we use for the lisense,
which are deduced manually
2020-11-23 18:06:24 +01:00
Olivier Goffart
ecd7f7dd7a Some changes to the Changelog 2020-11-23 16:58:42 +01:00
Olivier Goffart
7c159c2284 slide_puzzle: Add the last tile on the image when the puzzle is finished 2020-11-23 16:39:43 +01:00
Simon Hausmann
bad7734c21 Avoid leaking cached texture allocations
Let the texture cache hold weak references and drain them each time
the rendering primitives builder finishes.
2020-11-23 16:26:21 +01:00
Olivier Goffart
34e555f422
Add the slide_puzzle in examples/README.md 2020-11-23 16:07:17 +01:00
Simon Hausmann
ad99dc6475 Add support for image loading caching for embedded images
Extend the texture cache in the GL rendering backend to has by either
the path on disk or by the address of the static data.
2020-11-23 15:50:00 +01:00
Simon Hausmann
fdeda0d0ed Add some basic image loading caching for images loaded from the file system
Place them in a HashMap that's indexed by the path. This needs further
tuning, for example to also be applied to embedded images, and the cache
shouldn't hold a strong reference. But it makes the berlin page
playable.
2020-11-23 15:49:57 +01:00
Simon Hausmann
3d85e45ec3 Add support for source clipping to the Image element
This allows rendering only a sub-rectangle of the original image, which
we can use right away in the sliding puzzle demo.
2020-11-23 15:46:59 +01:00
Simon Hausmann
7583394751 Remove unnecessary image_size field of the Texture low-level primitive
Since our atlas allocator has an alignment of 1, the texture coordinates
(non-normalized) are identical.
2020-11-23 13:53:35 +01:00
Simon Hausmann
fa95064363 Fix resource embedding across component boundaries
When referencing an image a repeated element and were targeting a
configuration that requires resource embedding, then that image would
not embedded.

This was due to the fact that we didn't recurse into sub-components in
the resource collection phase and the generators made a per-component
embedding decision. The field responsible for that was also not
propagated to sub-components.

This patch addresses these two bugs by cleaning up the entire mechanism:

The compiler first generates the new ResourceReference::AbsolutePath for
all img!"foo.png" expressions. If the compiler is configured to embed
resources, then the embed_resources pass will traverse all
sub-components and expressions in them to change them to
ResourceReference::EmbeddedData with a unique integer id. Simultaenously
all the resources to be embedded get also collected in the root
component, so that the build script as well as the generator can take
care of dependency handling and actual resource embedding.
2020-11-23 13:47:16 +01:00
Olivier Goffart
2d6751a87a Puzzle: stop the auto-play when resetting 2020-11-23 13:41:48 +01:00
Olivier Goffart
807dbb3c00 Puzzle: Kick animation
Also support timer that can be cancelled from the timer event
2020-11-23 13:38:44 +01:00
Olivier Goffart
2e60afec39 Run cargo fmt 2020-11-23 12:08:23 +01:00
Olivier Goffart
596b740b62 Rename ARGBColor to RgbaColor 2020-11-23 11:47:47 +01:00
Olivier Goffart
3f111ecd30 Fix a few doc typo 2020-11-23 11:47:16 +01:00
Olivier Goffart
20b4d8826b Make the extra documentation page a bit more visible 2020-11-23 10:55:05 +01:00
Olivier Goffart
32f23f4c3e Add semi colon on the docs.
The run statement returns `()` so it is easier to copy/paste it if it has the semicolon
2020-11-23 10:31:34 +01:00
Olivier Goffart
4383566db9 slide puzzle: Animation on checkbox 2020-11-20 17:14:04 +01:00
Olivier Goffart
df318d9104 Fix states in the root of other components 2020-11-20 17:14:04 +01:00
Olivier Goffart
781e92941c Slide puzzle: move the checkbox to its own component 2020-11-20 17:14:04 +01:00
Simon Hausmann
9283a43d3e Small typo fixes 2020-11-20 16:19:00 +01:00
Simon Hausmann
4e36ba3ed9 Fix build
Adjust to vtable changes
2020-11-20 15:50:35 +01:00
Olivier Goffart
08fe5f6c72 Add a Clip 2020-11-20 15:45:45 +01:00
Simon Hausmann
89e0b57627 Rework and simplify the focus handling
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.

This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.

This also fixes the duplicate line edit focus in the 7gui cells
test case.
2020-11-20 15:33:15 +01:00
Olivier Goffart
2cc1070b7b Slide puzzle circle animation 2020-11-20 15:15:42 +01:00
Simon Hausmann
7ddf3a9b31 Minor cleanup to item visitor API
While visit_items/visit_internal allows an isize index (because of -1 to indicate the root),
the callback should always take a valid item index, thus usize.
2020-11-20 13:37:45 +01:00
Olivier Goffart
551c50560f Fix warning with clang 2020-11-20 12:47:32 +01:00
Olivier Goffart
57cf4e0988 Use transitions in the printer demo for the color level 2020-11-20 12:40:09 +01:00
Olivier Goffart
3cd84473e2 Transitions in the interpreter 2020-11-20 12:32:43 +01:00
Olivier Goffart
d5c4885955 Transitions in C++ 2020-11-20 11:38:03 +01:00
Olivier Goffart
091a0834d3 Transitions in rust (C++ and interpreter not implemented yet) 2020-11-20 10:30:17 +01:00
Olivier Goffart
865e6055f2 Work on transition: lower the transitions 2020-11-20 09:39:06 +01:00
Olivier Goffart
88ceeeb3e6 Error when a transition reffers to a state that does not exist 2020-11-20 09:39:06 +01:00