Commit graph

140 commits

Author SHA1 Message Date
Simon Hausmann
3b971a2e2f Remove Color::From<u32>
Instead make it clear on the call site what the encoding is (argb).
2020-09-03 11:17:40 +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
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Olivier Goffart
420fc2dc36 Fix bug in rust code generation for *= 2020-08-24 08:56:10 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00
Simon Hausmann
4a74f6d0a3 Implement releasing graphics resources in Rust via Drop
Further enhances #12
2020-08-14 13:44:53 +02:00
Simon Hausmann
3b4bcd51d4 Clean up window field initialization in the Rust generator
Use an option instead of a vector sequence expansion to achieve the effect
of an optional token expansion.
2020-08-14 10:27:49 +02:00
Olivier Goffart
fb5a82b6c7 Fix acessing repeater variable in a nested repeater, and fix array as property 2020-08-13 15:38:28 +02:00
Simon Hausmann
fc6c35bb3f
Fix formatting of generated code
Second attempt, remove all trialing spaces
2020-08-13 13:59:05 +02:00
Simon Hausmann
c394a10a85
Remove trailing spaces 2020-08-13 13:51:00 +02:00
Simon Hausmann
b96b627a4f Release graphics resources of items when destroying components
This is only implemented for Rust at the moment.
2020-08-13 13:31:29 +02:00
Olivier Goffart
7e1af72a2e Implement minimum/maximum width/height properties 2020-08-12 14:00:51 +02:00
Olivier Goffart
092411ccef Attempt to merge the layout code between rust and C++
This does not actually merge so much but it is better than nothing.

I was not able to merge the code from the interpreter because of the life time issues
2020-08-12 11:53:39 +02:00
Simon Hausmann
b21aa4f9e7 Rename PropertyListenerScope to PropertyTracker 2020-08-12 11:31:33 +02:00
Simon Hausmann
aafb96cb93 Get rid of abi::datastructures::WindowProperties
Instead, pass a reference to the root item when mapping the window,
at which point we can downcast to the new Window item. If we have one,
then we'll read its width/height (for initial values) and install
bindings to keep them up-to-date.
2020-08-12 09:44:42 +02:00
Simon Hausmann
9fd7d35b0d Remove stray scale_factor properties 2020-08-11 15:10:43 +02:00
Simon Hausmann
c1f91e38ca Move the window scale factor into GraphicsWindow 2020-08-11 13:42:51 +02:00
Simon Hausmann
f2eec61968 Add a window to the top-level component
This means that we always have a window and for the C++
API we don't require this ComponentWindow use anymore.
2020-08-11 13:38:38 +02:00
Olivier Goffart
36243ccdf7 Traverse item front to back for input events 2020-08-10 10:45:02 +02:00
Olivier Goffart
0a56912d0f Mouse grab in rust 2020-08-07 16:06:49 +02:00
Olivier Goffart
5aa7ee86fe Use a newtype for VisitChildrenResult instead of just isize
Makes the code easier to unserstand
2020-08-07 16:06:49 +02:00
Olivier Goffart
55ec533c40 WIP input events
Compile and passes tests. But the mouse event are currently not working
2020-08-07 16:06:49 +02:00
Simon Hausmann
829990f9b1 WIP
Co-authored-by: Olivier Goffart <ogoffart@woboq.com>
2020-08-07 16:06:49 +02:00
Simon Hausmann
5b9c41b76b Add referenced image resources to the dependencies for the rust build 2020-08-07 13:35:44 +02:00
Simon Hausmann
fcc819e395 Add support for enums to the compiler
This replaces the duplicated text alignment enums
2020-08-07 13:15:43 +02:00
Simon Hausmann
aecf6a8878 Center text in buttons in the demo and gallery
This adds horizontal_alignment/vertical_alignment properties, along with
width/height to Text.

This still uses a hard-coded enumeration in the compiler, which is meant
to go away in favor of general enum support.
2020-08-07 10:02:52 +02:00
Olivier Goffart
479173c22f Implement spacing in GridLayout 2020-08-05 15:42:38 +02:00
Simon Hausmann
5dfb9aa875 Fix initialize size of printer demo
Map it to 800x600 logical pixels for a better initial look.

This implements respecting the initial values for width/height and tries
to apply them to the window begin created.

The PinnedOptionalProp wrapper is needed because while cbindgen mapped
the previous Option<&...> to a raw pointer, the new Option<Pin<&...>> is
not detected as a pointer.
2020-08-05 13:22:53 +02:00
Simon Hausmann
254df328d0 Add support for images (resources) in models
This also allows replacing the emojis (not working due to lack of fallback) with images
2020-08-04 16:09:33 +02:00
Simon Hausmann
ee3765e115 Print out the type we failed to convert to rust if it happens 2020-08-04 15:10:58 +02:00
Simon Hausmann
41671e3efb Represent the window scale factor conversions in the IR
That means less code in the generators and easier to extend in the
future with more built-in functions.
2020-08-04 12:49:37 +02:00
Simon Hausmann
4f0bf0b982 Rename dpi to (window) scale_factor 2020-08-04 09:01:30 +02:00
Olivier Goffart
da11b33e9b Version check
Compilation error when the compiler and the runtime are not on the same version
2020-08-03 18:44:36 +02:00
Olivier Goffart
1bfd708784 Change the field_offsets() function to a FIELD_OFFSETS associated const 2020-08-03 16:04:55 +02:00
Olivier Goffart
de188e0a54 Add the as_weak to rust generated component 2020-08-03 15:36:54 +02:00
Olivier Goffart
b8d440a6db Rust: default visibility of everything to private 2020-08-03 15:01:10 +02:00
Olivier Goffart
8aef208340 Rust: add on_* to set signal handler 2020-08-03 15:01:10 +02:00
Olivier Goffart
cb67e40c32 Rename WeakPin -> PinWeak 2020-07-31 18:19:26 +02:00
Simon Hausmann
480a8470f5 Remove dead code 2020-07-30 19:51:33 +02:00
Simon Hausmann
884af3c88f Implement support for nested layouts in the Rust generator 2020-07-30 19:41:29 +02:00
Olivier Goffart
9760cf4969 Begin to implement a Flickable
The implementation is still very rough and will need to be improved
2020-07-30 14:36:21 +02:00
Simon Hausmann
e881d89bf9 Get rid of visible x/y properties in GridLayout
It doesn't really make sense to have them in the API, the grid layout is
supposed to "own" the surrounding space. That can be an element and then
it should be a (0, 0) and distribute the element's width/height, or in
the future it can be a cell of a grid layout. Then there's an (x/y), but
that's implicit / hidden.
2020-07-29 18:52:22 +02:00
Simon Hausmann
4fccbba29d Prepare for "virtualizing" the grid layout's width/height
Instead of storing the "within" element that we unconditionally take the
"width" and "height" properties from, let's pass through a property
reference expression to the width/height to use. For now that's still
the layout parent's width/height, but with this it can be replaced in
the future to refer to a "virtual" property that belongs to parent cell.
2020-07-29 18:52:22 +02:00
Simon Hausmann
00271a3746 Extend the layout data structure in the compiler to allow nesting 2020-07-29 18:52:22 +02:00
Simon Hausmann
f853843bc4 Store layouts in a common enum and vector
That'll make it easier later to allow for nesting them.
2020-07-29 18:52:02 +02:00
Olivier Goffart
46a011683f Implement easing curve in the runtime 2020-07-29 15:20:28 +02:00
Olivier Goffart
feec73674f Start implementing easing curve 2020-07-29 15:19:41 +02:00
Olivier Goffart
b57f3775c9 Refactor GridLayout 2020-07-28 10:31:05 +02:00
Simon Hausmann
88fb491837 Add support for mapping elements to different native classes
The Rectangle element has properties for a border outline. If those are
used, then the generated code should use BorderRectangle. But if they are
not used, then we can fall back to just generating a Rectangle.
2020-07-24 17:48:19 +02:00