Commit graph

402 commits

Author SHA1 Message Date
James Blacklock
cc4105e274 no need for InferredGenericType! 2021-10-18 10:21:06 +02:00
James Blacklock
ab665ba7b6 enable scripts to access the length of arrays 2021-10-18 10:21:06 +02:00
Olivier Goffart
bb4e5d8b55 Fix animation not starting when set from a callback
Two problems:
 - We were not marking the property as dirty, so dependent property would not
   update themselves
 - In the generated rust/c++ code, we would not call set_animated_value
2021-10-13 14:33:40 +02:00
Simon Hausmann
88ad176008 Improve diagnostics when images cannot be located for embedding
This is a two-stage change, that first centralizes the file I/O code
path for on-disk and builtin:/ files. Secondly the resource embedding
pass now produces diagnostics if a file cannot be located.
2021-10-05 23:16:46 +02:00
Simon Hausmann
4b267a8e9b Internal cleanup: Simplify string handling when accessing compiler-embedded files
For loading images that are included in the widget library that's included in turn
in the compiler binary, we need to create ImageInner::EmbeddedData
with &'static data and &'static file extension. The latter was
created using string interning, but we can also access the path of the
widget library data structure.
2021-10-05 23:16:46 +02:00
Simon Hausmann
df9e9dd1de Minor cleanup in C++ code generator
Use Cow<[u8]> to avoid making a copy of the file data embedded in the compiler.
2021-10-05 23:16:46 +02:00
Simon Hausmann
4a26faef9a Add AboutSixtyFPS element 2021-10-05 23:16:46 +02:00
Simon Hausmann
4058f95ebb C++: Improve the embedded image generation code
* Allocate less by using only two format!() calls
* Escape the extension properly and mark the string as u8 literal, like
  we also do for paths.
2021-10-05 15:05:50 +02:00
Simon Hausmann
7cb30e1e07 C++: Reduce extra allocations when formatting string for data embedding 2021-10-05 15:05:50 +02:00
Simon Hausmann
19b2415ba4 Minor formatting cleanups 2021-10-05 15:05:50 +02:00
Simon Hausmann
c91a38cdce Add support for embedding data in generated C++ code
This allows compiling with SIXTYFPS_EMBED_RESOURCES=true and
images/fonts are embedded as inline variables.

Generated data is emitted into the header file as

   inline uint8_t sfps_embedded_resources_123[789] = {
       0x1, 0x2, 0x3,
   };
2021-10-05 15:05:50 +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
dedc9b3b9b C++: Fix struct literal for builtin structs 2021-09-05 09:29:00 +02:00
Olivier Goffart
131d14058b Fix C++ generated code when the numbers are too big 2021-09-05 09:29:00 +02:00
Simon Hausmann
ee8e5699e5 Clean up global alias handling
Remove the internal name again and pick the first exported one when
assigning ids. This avoids internal names showing up in code completion
or the internal types leaking into generated code.
2021-08-31 17:09:11 +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
Simon Hausmann
9868b693e2 Only publish exported globals in C++ and Rust 2021-08-27 13:36:48 +02:00
Olivier Goffart
81688906f7 C++ Interpreter: add API to get/set global value 2021-08-27 13:36:48 +02:00
Simon Hausmann
5e833e5d23 Add support for accessing globals from C++ 2021-08-27 13:36:48 +02:00
Olivier Goffart
b07d52cd23 Support aliases to callbacks in globals 2021-08-24 12:36:16 +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
Simon Hausmann
2458ac5d02 Fix panic when calling focus() on a repeated element
When trying to reference an instance of a repeated item, for use with
ItemRc or VRef<Item>, the item_index (or id) of the ElementRc is not
directly what we want.

Adjust any element references to the repeater to to the inner instance
after creating them. Also make sure that the enclosing component is
respected in the C++ and Rust generators.

Fixes #422
2021-08-20 15:39:54 +02:00
Tobias Hunger
a387c0f60f Janitor: Fix clippy::needless_borrow 2021-08-18 00:24:51 +02:00
Olivier Goffart
c25538c982 Normalize identifiers to - instead of _
As a result
 - The error messages will now show the error with `-` instead of `_`
 - The LSP will auto-complete with -
 - The interpreter's list of properties will list the property with '-'
   (but we made the change so that set_property, get_property, and so on
   work also if passed a '-')
2021-08-10 22:21:01 +02:00
Tobias Hunger
c3ce321429 Janitor: Fix clippy::ptr_arg 2021-08-09 13:19:34 +02:00
Tobias Hunger
61af35afe1 Janitor: Fix clippy::needless_update
This leaves some of these issues in, which may be triggered depending on
selected features. `#[allow(needless_update)]` is used to silence those.
2021-08-05 23:41:56 +02:00
Tobias Hunger
24a2021226 Janitor: Fix clippy::needless_borrow 2021-08-04 22:50:35 +02:00
Olivier Goffart
1dab4c35d9 For embedded data, store the extension in the binary
This is usefull for the detection of SVG
2021-08-03 16:15:31 +02:00
Simon Hausmann
b55931e601 Make the new window() accessor in generated C++ code const 2021-08-03 10:32:04 +02:00
Simon Hausmann
e97ecea480 Fix constness in generated C++ API
run(), show() and hide() should not be const, as well as the window() accessor.
2021-08-03 10:32:04 +02:00
Simon Hausmann
341387c8d0 Provide sixtyfps::Window by reference in the generated C++ API 2021-08-03 10:32:04 +02:00
Simon Hausmann
23da97bc75 minor cleanup
Rename window_ to window_rc for the private window member in the generated C++ struct.
2021-08-03 10:32:04 +02:00
Simon Hausmann
66891a299c Start a new sixtyfps::Window API for Rust, C++, the interpreters and JS
The generated component now provides access to a Window type
via the window() accessor function.

This is part of #333
2021-08-03 10:32:04 +02:00
Tobias Hunger
ec7b7f751b Janitor: Fix clippy::or_fun_call 2021-07-30 09:27:48 +02:00
Tobias Hunger
f7f5a33c67 Janitor: Fix clippy::useless_format 2021-07-30 09:27:48 +02:00
Tobias Hunger
f9f05c3c58 Janitor: Fix clippy::map_clone 2021-07-30 09:27:48 +02:00
Olivier Goffart
807377ed40 fix warnings 2021-07-23 15:40:11 +02:00
Olivier Goffart
01f11695a7 Properly merge the animation when inlining and removing aliases
Fix #193
Fix #345
2021-07-23 15:25:53 +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
9e224f579c Janitor: Fix clippy::comparison_to_empty 2021-07-23 13:48:52 +02:00
Olivier Goffart
19ad14b6f2 C++: Fix assigning a @linear-gradient to a color property 2021-07-22 14:38:58 +02:00
Simon Hausmann
eaddbe664e internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
2021-07-21 20:33:02 +02:00
Tobias Hunger
ca53abdbc7 Janitor: calls to push immediately after creation
This is clippy::vec_init_then_push.
2021-07-15 07:55:06 +02:00
Olivier Goffart
cc8249212d Fix name conflict when having two global with the same name in different files
Give globals an unique id so two global with the same name imported
from different file don't clash

Fixes #159
2021-07-13 14:36:38 +02:00
Olivier Goffart
7193cbeec1 Revert "C++ Fix struct with a field that has the same name as the struct itself"
This reverts commit 9e70e009a2.

This turns out to break CI

Changed the test not to use the same name for a field and the struct
2021-07-09 15:52:28 +02:00
Olivier Goffart
9e70e009a2 C++ Fix struct with a field that has the same name as the struct itself 2021-07-09 14:37:42 +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
Tobias Hunger
ac207428dc Janitor: CSpell fixes
Mark up some special words in documents (like C++ lingo in rust files).
2021-07-06 22:44:09 +02:00
Tobias Hunger
39984b27db Janitor: Fix spelling in comments 2021-07-03 15:49:43 +02:00