Commit graph

77 commits

Author SHA1 Message Date
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
Simon Hausmann
178d83b305 Fix wrong initial window size on macOS/Windows and endless repaints
Setting the size will trigger a repaint, even if it didn't change.
2020-10-30 14:23:24 +01:00
Olivier Goffart
a4671502ab Allow to speccify a fixed width/height in the layout by setting the height or width 2020-10-26 19:09:01 +01:00
Olivier Goffart
47be71e16d Introduce layout stretching 2020-10-26 16:40:35 +01:00
Olivier Goffart
7ff0b4b73f Vertical layout 2020-10-26 14:19:12 +01:00
Olivier Goffart
aeade826fe New runtime implementation for the box layout
Currently only horizontal layout is supported
2020-10-26 14:19:12 +01:00
Simon Hausmann
0f10202ff0 Partially implement row/colspans via cell distribution
This patch distributes the constraints evenly to the occupied cells.
That is not entirely correct, but it's an improvement for the appearance
of the todo app.
2020-10-20 18:06:58 +02:00
Simon Hausmann
56d763cdcf Implement GridLayout using stretch's FlexBox implementation
Unfortunately nesting the boxes to model a grid does't seem to quite
work, so this approach simply creates two boxes for each direction --
similar to the existing algorithm.
2020-10-02 14:54:05 +02:00
Simon Hausmann
5dbd0b213c Add support for grid layout padding 2020-08-28 15:06:14 +02:00
Simon Hausmann
7976a4057f Improve handling of nested layouts
We support directly nested layouts, but we did not support indirect
nesting:

    GridLayout {
        Rectangle {
            l2 := GridLayout { ... }
        }
    }

This patch fixes that by detecting this scenario and merging the layout
info of the element (Rectangle) and the layout inside (l2). This makes
it much easier to create re-usable components that use layouts
themselves and allows placing them in layouts.
2020-08-28 15:06:14 +02:00
Simon Hausmann
4054402418 Fix layout info calculation for grid layouts
When the spacing was zero, the constraints would always be zero due to
accidental multiplication with the accumulated spacing widths/heights.
That was meant to be an addition.
2020-08-28 08:34:36 +02:00