Commit graph

87 commits

Author SHA1 Message Date
Olivier Goffart
844c5cf7ec Gate the Path item behind the 'std' feature 2021-11-25 16:53:07 +01:00
Olivier Goffart
763065fd0e Disable the std feature from strum
also use its derive feature
2021-11-25 12:02:16 +01:00
Olivier Goffart
80c0602277 WIP: start making the corelib crate a no_std crate
Does not compile yet with no_std because of the lack of
alternative for thread_local
2021-11-25 12:02:16 +01:00
Olivier Goffart
ae3e1b4680 Allow normal Element to be in the Dialog's button row with dialog-button-role 2021-10-05 09:46:20 +02:00
Olivier Goffart
9936dfc0eb Apply suggestions from code review
Co-authored-by: Simon Hausmann <simon.hausmann@sixtyfps.io>
2021-09-29 16:25:44 +02:00
Olivier Goffart
7f05bfa309 Add the Dialog element 2021-09-29 16:25:44 +02:00
Olivier Goffart
fafcbfde2c Fix panic when trying to access layout cache of destroyed items
This can be reproduced by deleting the last item of the printer queue in the
printer demo.
It is a regression showing up because we now emit the MouseExit event after
the mouse grab as released.
The problem is that we upgrade the weak item, and call geometry() on it.
Calling geometry will re-evaluate the layout cache which will re-evaluate
the model which will result in the component being removed and the cache
entry having less item than expected.

It is ok to simply return 0. for these layout location since the item will
disapear anyway.
2021-09-08 14:42:08 +02:00
Olivier Goffart
619ce6c4f7 Struct exposed to .60 as struct need to be layed out in alphabetical order
because that's the order in which the C++ code generator pass the argument
to the agregate initialization
2021-09-05 09:29:00 +02:00
Simon Hausmann
0852a7661b Fix mutable slice API
* Change SharedVector::as_mut_slice() to SharedVector::make_mut_slice()
* SharedPixelBuffer::as_mut_slice and SharedPixelBuffer::make_mut_slice()
* SharedPixelBuffer::as_bytes_mut() to SharedPixelBuffer::make_mut_bytes()

This is consistent with Rc::make_mut() and is supposed to emphasize
that, unlike the usual as_* operations, it is not a free operation but
may involve work (detaching the data by cloning it).

Amends commit 7384ebdc32
2021-08-10 16:37:34 +02:00
Simon Hausmann
7384ebdc32 Deprecated SharedVector::as_slice_mut() in favor of SharedVector::as_mut_slice()
The standard library uses the latter name.
2021-08-09 14:51:09 +02:00
Tobias Hunger
b24e52e0fa Janitor: Remove useless addition on 0
This quietens a clippy warning, but also breaks symmetry:-(
2021-07-12 15:01:19 +02:00
Tobias Hunger
ede172b758 Janitor: Spell out local variable names 2021-07-12 15:01:19 +02:00
Tobias Hunger
925afb2ba4 Janitor: Remove unnecessary lifetimes 2021-07-12 15:01:19 +02:00
Tobias Hunger
5f488bd7fc Janitor: Spell out local variable name 2021-07-12 15:01:19 +02:00
Tobias Hunger
70f4eff2d5 Janitor: !(a > 0) is a <= 0 2021-07-12 15:01:19 +02:00
Tobias Hunger
d68ac7a664 Janitor: CSpell ignore coord in document 2021-07-12 15:01:19 +02:00
Tobias Hunger
ad98137c17 Janitor: Mark up float comparisons where we want bitwise identity
Mark up test cases where we want bitwise identity of float values and
use `assert_eq!` since that produces better output in the error case.
2021-07-09 17:00:46 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Olivier Goffart
9faf16ebe1 GridLayout: fix layout with rowspan and colspan
One should not simply distribute the maximum and minimum sizes amongst
the spans, one should make sure that each coinstraints is respected
2021-07-02 12:30:07 +02:00
Olivier Goffart
032a158615 GridLayout and span: ensure that the preferred size is properly distributed 2021-06-29 14:54:47 +02:00
Simon Hausmann
504bad7109 Drive-by typo fixes 2021-06-29 14:32:02 +02:00
Olivier Goffart
a4b9c0ced5 Old printer demo: fix the layout
Also, make sure empty cell in a GridLayout stretches
2021-06-29 12:33:01 +02:00
Olivier Goffart
aed0e9849a Remove debug output 2021-06-18 20:31:33 +02:00
Olivier Goffart
4e0a91c35a Test for Flickable layout and small layout fix
Test for issue #194 which was already fixed.
And also fix a small other issue where the preferred size was not properly
computed in layouts.

Closes #194
2021-06-18 14:27:01 +02:00
Olivier Goffart
a0bea36e43 Fix preferred size of the Window with a layout
A few problem:
 - the horizontal and vertical property were swapped
 - The implementation of the "preferred_xxx" property was not materialized properly
   because the `bindings` were borrowed in the materialize_fake_properties pass
 - Since the Window has a stretch factor of 0., the preferred size of the inner layout
   was not taken into account when merging the LayoutInfo.  I believe taking the
   maximum preferred size is the right solution when merging them.
2021-06-18 13:51:25 +02:00
Olivier Goffart
51d532d209 Fix grid layout tests
One must make sure the initial preferred size is clamped within the
max and min size
2021-06-18 11:37:58 +02:00
Olivier Goffart
ef84923285 Get rid of the stretch dependency
Since we split the horizontal and vertical part, the stretch dependency is a bit overkill
and we can re-implement it ourselves.

This will also allow us to support colspan and rowspan properly
2021-06-18 10:28:43 +02:00
Olivier Goffart
a95ed99c4e Layout: properly propagate the preferred size 2021-06-17 11:23:58 +02:00
Olivier Goffart
ce37cd2552 Rename a function to avoid confusion with a field 2021-06-16 15:14:07 +02:00
Olivier Goffart
deaa0fddb0 WIP layout: split vertical and horizontal cache
Split the vertical and horizontal pass into different property cache
This will allow to implement "height for with"

This patch does not port the Rust or C++ binding yet
2021-06-16 15:14:07 +02:00
Simon Hausmann
e7bc91c804 Add support for specifying the viewbox of path elements 2021-05-21 19:51:00 +02:00
Olivier Goffart
ba1aff84d0 Layout refactoring: C++ part 2021-05-11 14:59:57 +02:00
Olivier Goffart
b01884f3b9 Layout refactor: do the rust part 2021-05-11 14:59:57 +02:00
Olivier Goffart
8da6c8cdb3 Lower PathLayout
As part of the layout refactoring, most of the path layout lowering
was gone. Add it back
2021-05-11 14:59:57 +02:00
Olivier Goffart
f06bf8d5a7 Fix repeater in box layout 2021-05-11 14:59:57 +02:00
Olivier Goffart
b463e3cca4 WIP refactor layout
This commit add support for the box layout
2021-05-11 14:59:57 +02:00
Olivier Goffart
21a80f4562 WIP: Layout refactoring
Instead of using a solve_layout function in the component, use property to hold
a layout cache.

This commit only implement the GridLayout and only the interpreter part
2021-05-11 14:59:57 +02:00
Olivier Goffart
1f64f7ab27 Also set the preferred size for the GridLayout
Issue #182
2021-04-21 18:56:28 +02:00
Simon Hausmann
7c1738eeea Fix height of image in horizontal layout
Commit 843f52b3c5 erroneously applied the cross-axis
preferred size, which breaks the
images in buttons in the printer demo.

Also use the same value for shrink as for flex-grow, as advised by Olivier :-)
2021-04-08 15:09:35 +02:00
Simon Hausmann
843f52b3c5 Implement preferred size for images in box layouts
This partially implements #168 as well as #182
2021-04-08 12:06:42 +02:00
Olivier Goffart
35cce45cbc Add a fii feature so that we don't compile in the ffi code if not required 2021-03-16 18:09:57 +01:00
Simon Hausmann
f087cc18bc Remove extern "C" functions from wasm module
We don't need these functions and their export. They account for ~20kb in
the optimized .wasm - plus JS glue code.
2021-02-26 17:04:49 +01:00
Olivier Goffart
13a2138022 GridLayout: Don't divide the max cell size by the colspan or rowspan
Otherwise we end up contraining the layout too much.
The result is still wrong, but probably better. (see #42)
2021-02-17 18:59:49 +01:00
Olivier Goffart
096f55e365 Change behavior of percent sice within the layout
So that size with percentages don't affect the maximum/minimum size

Fixes #117
2021-02-11 20:32:26 +01:00
Simon Hausmann
57d3a34996 Prospective fix for doc errors
In the nightly it appears that `no_mangle` is now considered "unsafe",
so we need to allow that in the ffi modules. For the layout code this
patch also creates that ffi module with prefixed function names, like in
the other modules and only allows unsafe in there.
2021-02-10 11:26:28 +01:00
Simon Hausmann
2ce672bd68 Reduce dependencies
Use only specific lyon packages instead of pulling all of them in.
This slightly speeds up compilation as well as for example lyon_tesselation
doesn't need to be compiled anymore.
2021-02-09 17:22:01 +01:00
Olivier Goffart
d30f5138b8 Box layout: ensure max size is >= min
Fixes #160
2021-02-05 19:18:09 +01:00
Simon Hausmann
fd3c8bf9fa Simplify path event iteration code
* Always apply a transformation (less variants)
* Let the path data iterator take ownership of the data. That will
  make it possible to return a PathDataIterator from a function in the
  future
2021-02-04 09:08:00 +01:00
Olivier Goffart
4a182ef4d0 Layout alignment 2020-11-03 12:22:34 +01:00
Olivier Goffart
e4e7ae46f4 Support for for in box layout in the interpreter 2020-10-31 11:24:31 +01:00