Commit graph

611 commits

Author SHA1 Message Date
Lukas Jung
f0a47ff154 Add mouse-cursor property to TouchArea 2021-12-07 22:41:24 +01:00
Olivier Goffart
f27a2b8c74 Fix issues related to alias to globals
two problems
 - For the interpreter, properly handle the case of an alias to a global
 - For the rust generator, we can't return a reference to a property held
   in a global, so we must 'inline' the get_xx funciton on sub-components
2021-12-06 14:30:47 +01:00
Olivier Goffart
464ba195a8 Don't use deprecated API 2021-12-06 13:00:32 +01:00
Olivier Goffart
e4bd6bbfb8 Native style: respond to the StyleChange event
So that color scheme is updated when switching to the dark style, for example

Fixes #687
2021-11-29 17:18:23 +01:00
Olivier Goffart
a5ea6dd087 Models: re-implement the internal of model tracking
Don't rely on the weak-table that does not work with no_std,
instead, use the same data structure as for the property dependency
tracking
2021-11-29 17:15:56 +01:00
ogoffart
3278b39549 Bump version number to 0.1.6 2021-11-24 14:19:09 +00: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
73e753f091 sixtyfps-interpreter test: use the fluent style
because the native style can't run in tests because it cannot draw from
different threads
2021-11-17 14:09:55 +01:00
Olivier Goffart
2bf3e00a35 Make sure sixtyfps-interpreter tests are run with the testing backend
Because the Qt backend don't support being run in threads and the tests are
in threads and in parallel
2021-11-17 09:55:18 +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
13de800ba3 Internal cleanup: Rename layouting_info to layout_info
That's making the call on the Component VTable consistent(ish) with the Item VTable.
2021-11-08 10:24:30 +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
ogoffart
b25ae6fbcd Bump version number to 0.1.5 2021-10-26 07:36:54 +00:00
Simon Hausmann
8596cca549 Fix model length tracking in the interpreter
Added the missing tracking call and fix the test to cover this properly.
2021-10-20 15:25:28 +02:00
Simon Hausmann
63bf1af093 Add support for tracking the length of a model in Rust
This is done by exposing the ModelNotify to the caller via the new
ModelTracker trait, which has a function that allows "hooking" into the
dirty tracking of the size.

By extension, this also works in JavaScript.

cc #98
2021-10-20 15:25:28 +02:00
James Blacklock
745abe7019 handle array length in eval.rs 2021-10-18 10:21:06 +02:00
ogoffart
77fcd5221b Bump version number to 0.1.4 2021-10-07 09:36:43 +00: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
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
332b149610 Add support for accessing resources from the embedded widget library in the interpreter 2021-10-05 23:16:46 +02:00
ogoffart
8b9717633e Bump version number to 0.1.3 2021-10-05 10:31:45 +00: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
7f05bfa309 Add the Dialog element 2021-09-29 16:25:44 +02:00
Olivier Goffart
671df0f24f New widget: StandardButton 2021-09-29 16:25:44 +02:00
Olivier Goffart
730cbf1ef9 Interpreter: add type checking for declared properties
issue #512
2021-09-23 19:17:17 +02:00
Simon Hausmann
043c1932ad Make it possible to disable x11 support
The GL backend defaults to enabling X11. The default crate depends on
the GL backend but it doesn't specify default-features = false,
therefore x11 is basically always enabled.

In line with commit 1fd8c7236a, this
change makes sure that the defaults are defined in the tree entry
points: The Rust API crate, the interpreter crate and the CMake project
define the defaults. The latter already enabled X11 by default, but the
first two did not.
2021-09-22 11:32:51 +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
c3d0fd04af Add C++ API to introspect exported global singletons in the interpreter
This adds the necessary shims to expose the same API as Rust.
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
Olivier Goffart
fe015a8086 Allow the sixtyfps-compiler and sixtyfps-viewer to read from stdin
By specifing `-` as a path
2021-09-09 15:30:52 +02:00
Olivier Goffart
954dedf4f5 Fix publishing
the testing backend is not on crates.io, so the dev-dependency must not
have a version field
2021-09-09 09:27:31 +02:00
Simon Hausmann
1fd8c7236a Make it possible to disable the GL backend in the CMake build
Even if SIXTYFPS_BACKEND_GL is set to OFF, we would default to enabling
X11, which translates to enabling the x11 feature, which in turn
implicitly activates the GL backend. In addition, the interpreter Rust
API crate also enables the GL backend in its defeaults.

In order to make it possible to turn off the GL backend, three changes are necessary:

* The default backend no more selects a default :-). Instead the Rust
  API crate, Rust interpreter API crate and the CMake project define
  the same features and defaults.
* The C++ crate depends on the interpreter without its defaults (which enable GL)
* In CMake the X11 and Wayland features become dependent options, that
  are only show in the CMake configure UI if the GL backend is enabled.
  This way a GL-disabled build won't also pass --features x11.
2021-09-08 17:13:10 +02:00
Simon Hausmann
23eac421d6 Make the reuse_window() test more reliable
Always explicitly pick the testing backend for it, since it will create
a window in the rendering backend.
2021-09-06 15:56:59 +02:00
Olivier Goffart
4aeb9bcd08 Interpreter: fix comparison of enums
We need to normalize native enum to use dashes
2021-09-06 12:22:24 +02:00
Ryan Van Gilder
4d1d0e73a4 Rename image-scaling to image-rendering to align with CSS 2021-09-06 10:03:51 +02:00
Ryan Van Gilder
a03a27ae0d Add image-scaling property to Images to control how they are scaled
Like CSS image-rendering it has "smooth" and "pixelated" options.
Only OpenGL has been tested right now, have not tested WASM or Qt.
Right now the first instance of a @image-url() will set the scaling
for that specific image. The same image used from memory on the otherhand
can all have a different scaling property.
2021-09-06 10:03:51 +02:00
ogoffart
e54e03148f Bump version number to 0.1.2 2021-09-04 10:08:51 +02:00
Olivier Goffart
4f1eacd6d8 LineEdit is now able to scroll to keep the cursor visible 2021-09-02 17:20:44 +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
Olivier Goffart
e1be599bc0 Print an warning in stderr when modifying read-only model
... and improve the documentation of Model
2021-08-31 10:36:22 +02:00
Simon Hausmann
4b8259017b Doc fixes
Try to use the term "global singleton" consistently. That's also the
term we use in the language reference.
2021-08-27 13:46:44 +02:00
Olivier Goffart
70c57844b7 Add invoke_global_callback to the C++ interpreter API 2021-08-27 13:36:48 +02:00