Commit graph

312 commits

Author SHA1 Message Date
Tobias Hunger
06346ab2e6
janitor: Derive some Default traits 2022-01-04 18:21:25 +01:00
Tobias Hunger
8d799fe78d
janitor: Simplify x.map(f).flatten() to x.flat_map(f) 2022-01-04 09:39:45 +01:00
Tobias Hunger
6d69c343dc
Revert "Deduplicate use of ptr_eq for Models"
This was not intended to get uploaded without review!

This reverts commit d678f4b1da.
2022-01-03 17:10:27 +01:00
Tobias Hunger
d678f4b1da
Deduplicate use of ptr_eq for Models 2022-01-03 16:22:32 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Lukas Jung
f0a47ff154 Add mouse-cursor property to TouchArea 2021-12-07 22:41:24 +01:00
Olivier Goffart
d1cae710df preprocess the images at compile time
For the MCU port, we need to proccess the image to save them in the binary
in a convenient format.
This patch start this work by trying to anaylyze what format should an image
be using, and saving it as a texture in the binary.

The current graphical backend and the C++ frontend are not yet supported
2021-11-19 15:54:45 +01:00
Olivier Goffart
dd3fa1c221 Make the BindingMap hold RefCell of the BindingExpression
This will allow later to be able to operate on the binding despite the
element is borrowed.

Since the Binding itself is in a RefCell, the analysis don't need to
be anymore.
To do this change, a small change in the binding_analysis logic was required
which means that we will now detect binding loop if a binding was causing
two binding loop. (before, only one binding loop was detected)
2021-11-11 11:14:59 +01:00
Simon Hausmann
7354b17a6a Minor cleanup in ItemTreeBuilder trait
Pass the sub-component as a parameter in enter_component(), as it's needed in the C++
implementation, it's readily available (no need to unwrap again) and Rust will need it, too.
2021-11-04 17:55:39 +01:00
Olivier Goffart
6df78893d6 Use build_item_tree in dynamic_component 2021-11-04 16:40:48 +01:00
Olivier Goffart
4390034d9e Interpreter: properly handle alias to global callback
Fixes test_nodejs_globals_global_callback

A recent change made the aliases to global be kept in the global
in case several components are using it.
2021-11-02 12:41:30 +01:00
Simon Hausmann
67579ec560 Simplify drop implementation of generated components
Avoid creating an intermediate array of items to free the graphics resources.
Instead call run-time function with the item tree as a parameter, which is traversed.

It's practically the same data structure that was previously created, except
that it is shared/global and has little holes for the dynamic tree items, but those are easy to skip.
2021-11-01 08:58:53 +01:00
Simon Hausmann
d57edfbb7c Simplify free_graphics_resources API in the backend
Take an iterator reference instead of a slice, so that we can change the call sites in the future.
2021-10-30 13:03:52 +02:00
Olivier Goffart
567c644a5f Fix PopupWindow position when all elements are not inlined
Pass a reference to the parent item in the show_popup function
so we can compute the exact location at runtime.
2021-10-28 15:52:29 +02:00
Olivier Goffart
7939d834d4 Fix panic in the interpreter if there are properties that are aliased to struct 2021-10-06 18:33:27 +02:00
Simon Hausmann
332b149610 Add support for accessing resources from the embedded widget library in the interpreter 2021-10-05 23:16:46 +02: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
2716e4b4dd TouchArea: add the pointer-event callback
... instead of `pressed-changed`

This allows to see what mouse button was pressed.

Closes #535
2021-10-04 14:39:49 +02:00
Olivier Goffart
671df0f24f New widget: StandardButton 2021-09-29 16:25:44 +02:00
Simon Hausmann
4779c97ba2 Internal cleanup: Keep globals related data together
In ComponentDescription only keep a exported_globals_by_name that
maintains the index in the compiled_globals vector and in there store
the public properties of global singletons.
2021-09-15 07:56:28 +02:00
Simon Hausmann
a855d868fc Add support for introspecting globals in the interpreter Rust API
Add three straight-forward functions:

    * pub fn globals(&self) -> impl Iterator<Item = String> + '_
    * pub fn global_properties( &self,
          global_name: &str,
      ) -> Option<impl Iterator<Item = (String, ValueType)> + '_>
    * pub fn global_callbacks(&self, global_name: &str
      ) -> Option<impl Iterator<Item = String> + '_>

Implementation wise this requires passing along a way to get the
non-normalized (original) export name, as globals() should return the
names as the developer/designer specified them, and
global_properties()/global_callbacks() normalizes.
2021-09-15 07:56:28 +02:00
Simon Hausmann
0d19e2d9b9 Add support for global aliases
When exporting an global multiple times under different names, make sure
that they alias in the generated code.

As a consequence, the compiler maintains the original unique name and in
Rust and C++ makes only the exported names public. In the interpreter
the internal name is theoretically still accessible from the outside.
2021-08-31 17:09:11 +02:00
Olivier Goffart
a1803ec3a0 Interpreter: return a proper error from set_property instead of panic 2021-08-27 13:36:48 +02:00
Olivier Goffart
5f8cea5926 WIP interpreter API to access globals 2021-08-27 13:36:48 +02:00
Olivier Goffart
b42c187ed1 Refactor the way the two-ways biding are represented internaly
Don't put them in a fake expression.
This simplifies a bit the expression handling, and will make
possible to fix analysis that needs a vew into the aliases
2021-08-20 18:26:36 +02:00
Olivier Goffart
5efa5bbf1d Added a commented out debug comment which I often use
It allows dumping the lowered object tree
2021-08-19 09:57:13 +02:00
Olivier Goffart
a39dd6ac4f Interpreter API: preserve the dashes and underscore when listing properties 2021-08-17 18:47:41 +02:00
Simon Hausmann
01c3347d19 Make fluent the new default style
It's not ugly :-)
2021-08-10 15:56:38 +02:00
Tobias Hunger
9dcd107e84 Janitor: Fix clippy::single_match 2021-08-09 13:19:34 +02:00
Olivier Goffart
16325d5474 Remove dbg! 2021-08-09 12:40:21 +02:00
Olivier Goffart
8728052578 Fix panic when typing into the line edit in the gallery
The problem was that the item array's parent was not properly
computed. Leading to corrupted item when getting the parent of the
focus item.
2021-08-09 12:00:17 +02:00
Olivier Goffart
c58ffe1589 Better panic message when we reference a property that does not exist 2021-08-06 15:58:13 +02:00
Tobias Hunger
04738a900f Janitor: Fix clippy::map_clone 2021-08-04 22:50:35 +02:00
Tobias Hunger
ce976a1dbb Janitor: Fix clippy::useless_conversion 2021-08-04 22:50:35 +02:00
Tobias Hunger
c74565a883 Janitor: Fix clippy::needless_return 2021-08-04 22:50:35 +02:00
Tobias Hunger
24a2021226 Janitor: Fix clippy::needless_borrow 2021-08-04 22:50:35 +02:00
Simon Hausmann
29f5853332 Provide sixtyfps::Window by reference in the Rust API
This also removes Clone from the Window again, to avoid having to face
the question: Does cloning a window duplicate it on the screen?
2021-08-03 10:32:04 +02:00
Olivier Goffart
6a32a8b37a Don't error on empty documents 2021-07-29 17:40:20 +02:00
Olivier Goffart
ba32777cab Refactoring: move the animation in the PropertyBinding struct
Since they always belong together.

This will help for issue #193
2021-07-23 15:25:53 +02:00
Tobias Hunger
97be634b9b Janitor: Fix clippy::match_like_matches_macro 2021-07-23 13:48:52 +02:00
Tobias Hunger
3e0534afea Janitor: Fix clippy::needless_lifetimes 2021-07-23 13:48:52 +02:00
Tobias Hunger
8b022cd917 Janitor: Fix remaining instance of clippy::iter_cloned_collect 2021-07-21 19:44:57 +02:00
Simon Hausmann
1c285694d7 internal cleanup: Remove the use of ComponentWindow in the interpreter 2021-07-21 17:41:12 +02:00
Simon Hausmann
77ea5b7a15 API cleanup: hide the rest of the ComponentWindow "internals" 2021-07-21 17:41:12 +02:00
Simon Hausmann
4c1d9dc03e internal cleanup: Remove the poup functions from ComponentWindow
Use WindowHandleAccess instead. Also the clone()
isn't needed anymore since the function take a self reference instead of an Rc<Self> by value.
2021-07-21 17:41:12 +02:00
Simon Hausmann
e005058285 internal cleanup: remove free_graphics_resource from the public ComponentWindow API
Use the WindowHandleAccess backdoor instead.
2021-07-21 17:41:12 +02:00
Simon Hausmann
492af0f67c Rename the implementation of the Window item to WindowItem
If we were to add `sixtyfps:🪟:Window` to the re_exports, then
this clashes. We might rename the former, but this is a cleaner naming
in any case.

Relates to #333
2021-07-20 17:50:17 +02:00
Tobias Hunger
efc0d63e8b Janitor: iter().cloned().collect() on a slice to create a Vec == to_vec()
This is clippy::iter_cloned_collect
2021-07-15 07:55:06 +02:00
Olivier Goffart
a987b225b5 Collect all used components before inlining
And do some passes before inlining

We will need the list of components before inlining in order to generate
them if we disable inlining

So we can do some passes on each component before they are inlining

I tried to put the flickable pass in that list, but it did not work
if the Flickable itself is the root of a component
2021-07-07 17:58:43 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00