Commit graph

56 commits

Author SHA1 Message Date
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
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00
Olivier Goffart
479173c22f Implement spacing in GridLayout 2020-08-05 15:42:38 +02:00
Simon Hausmann
0252d2ac34 Move slice out of abi 2020-08-03 17:41:16 +02:00
Simon Hausmann
30d7a0b36d Move PathData and friends from datastructure to
graphics
2020-08-03 13:43:44 +02:00
Simon Hausmann
b05a11945e Move datastructures::LayoutInfo into layout 2020-08-03 13:31:43 +02:00
Simon Hausmann
a2cec9e86f Clean up LyonPathIterator API
* Remove Lyon from the name and instead call it PathDataIterator.
* Remove the fit() function and just provide two factory functions.
2020-08-03 13:18:38 +02:00
Simon Hausmann
c32114cee6 Add helper function to calculate the layout info for a grid layout
The minimum/maximum widths/heights are the sum of the cells.
2020-07-30 10:25:08 +02:00
Olivier Goffart
b57f3775c9 Refactor GridLayout 2020-07-28 10:31:05 +02:00
Simon Hausmann
00f2d384b2 Fix formatting 2020-07-24 07:52:18 +02:00
Olivier Goffart
debd2b5839 Smaller workaround for the fact that some function are not exported 2020-07-23 17:11:00 +02:00
Olivier Goffart
6c54dfb67d Layout the item in a PathLayout if they are part of a repeater 2020-07-17 15:00:12 +02:00
Olivier Goffart
5e7d5369aa Few fixes to the layout and add a test that the items are well positioned 2020-07-16 17:22:29 +02:00
Simon Hausmann
39359a4e26 Add support for an offset to PathLayout
This allows animating items on their position along the path.
2020-07-14 15:12:03 +02:00
Simon Hausmann
1845e495fe Fix path layout positioning
The local parameter t on a path segment wasn't normalized to the length
of the segment itself.
2020-07-14 14:23:43 +02:00
Simon Hausmann
a3f365417c Center items on a path layout 2020-07-14 09:43:59 +02:00
Simon Hausmann
1a0d053889 Align default path layout tolerance
Use the same tolerance as when rendering
2020-07-13 16:12:38 +02:00
Simon Hausmann
992f990fa8 Allow for fitting paths into a given bounding rectangle
... by applying a transformation. This allows designing a path in some
other path design tool and then make it fit using bindings.
2020-07-13 15:41:11 +02:00
Simon Hausmann
6243df1702 Avoid unnecessary path building
When the path was constructed from events (SVG commands), then we don't really need to build an intermediate path,
neither for rendering nor for path layouting.
2020-07-10 13:59:40 +02:00
Simon Hausmann
1f7ae1b318 Rename PathElements to PathData
as it can now consists of elements or events.
2020-07-10 13:01:05 +02:00
Simon Hausmann
1a70213c05 Fix path layout implementation to allow positioning
This is not exposed in the API yet though.
2020-07-09 15:38:26 +02:00