Commit graph

165 commits

Author SHA1 Message Date
Simon Hausmann
2fdaa44d51 Load the Noto Sans font from the nodejs printer demo 2021-02-22 11:17:39 +01:00
Olivier Goffart
b75e135459 Support complex product of units
Fixes #68
2021-02-04 12:56:14 +01:00
Simon Hausmann
7982325da4 Change Rectangle::background's type to be a brush
This also introduces the brush type in the compiler and generators. At the
moment only conversion from Color is implemented.
2021-02-03 12:49:44 +01:00
Olivier Goffart
e4a1f50a9a Brush support in the interpreter 2021-02-03 09:28:33 +01:00
Olivier Goffart
ad1e18764a Make angle its own type 2021-02-01 14:49:25 +01:00
Olivier Goffart
5a21f1bd81 Rename emit_ to call_ for callback
Signal was renamed to Callback, but one does not emit a callback, one calls it
2021-01-25 15:59:10 +01:00
Simon Hausmann
5f265ffc09 Split up ComponentWindow::run() into show(), hide() and sixtyfps::run_event_loop()
This allows creating multiple windows for example, and it will allow for
showing windows in those tests that require a mapped window.

As a bonus, the run() function on generated components is not consuming
anymore.
2021-01-19 09:50:22 +01:00
Olivier Goffart
dcb347fb7b Move more functions from the GenericWindow to the Window 2021-01-15 15:02:55 +01:00
Simon Hausmann
0e04149868 Fix single shot timer leaks in the nodejs api
As discussed, don't use the persistent context approach for single
shot timers but store the callback directly in the global object
and "delete" it afterwards.
2020-12-19 13:49:41 +01:00
Olivier Goffart
0d2d48be4f Rename "signal" to "callback" 2020-12-18 09:51:01 +01:00
Simon Hausmann
c2a0cd7000 Added a node version of the memory puzzle game
This also implements a basic single shot timer support, which has
one caveat: it leaks the closures right now.
2020-12-11 17:17:28 +01:00
Simon Hausmann
ee2e08f98d Fix creating an image resource from JS
We allow converting strings to Type::Resource, but we have to provide a
Value::Resource then, not Value::String.
2020-12-11 13:53:04 +01:00
Simon Hausmann
87e0cc7d85 Fix resource embedding doing a wasm build of a project using the sixtyfps! macro
We need to embed resources in wasm builds. Unfortunately we can't detect
that we're called by say wasm-pack and "TARGET"/"HOST" only works inside
build.rs. So instead, to keep things simple, this change always embeds
the image resources when targeting Rust.

The `SIXTYFPS_EMBED_RESOURCES` environment variable can be used to
override this anywhere for any language.

Fixes #130
2020-12-10 15:09:32 +01:00
Olivier Goffart
bff55d4f1b Return value for signal 2020-12-01 18:52:51 +01:00
Olivier Goffart
e73bbbcd10 More work on signal returning value 2020-12-01 18:47:49 +01:00
Olivier Goffart
276e11a101 More work on signals with return value 2020-12-01 18:47:49 +01:00
Olivier Goffart
8a64f10e84 Remove ComponentVtable::input_event
And the custom handling of the mouse grabber
2020-11-24 16:23:37 +01:00
Simon Hausmann
c258a907f0 Simplify event loop start-up
Move the layout constraint tracker into the window where we can apply
the constraints right before drawing, instead of doing that from within
the event loop. This allows to remove the component parameter from the
run function.
2020-11-12 15:04:48 +01:00
Simon Hausmann
a2dadf8fe8 Remove the component parameter from GenericWindow::process_key_input 2020-11-11 19:16:26 +01:00
Simon Hausmann
5d744c86c2 Begin passing the VRC<ComponentVTable, Dyn> into the run-time library
First by changing the signature of run() and by adding a self_weak
to the C++ struct.
2020-11-11 18:31:51 +01:00
Simon Hausmann
a9791c390d Wrap the main component in a VRc 2020-11-11 18:14:15 +01:00
Simon Hausmann
02904c4014 Simplify signature of Component::run
We don't need to pass the root item anymore since ComponentVTable
has now get_item_ref.
2020-11-11 15:55:03 +01:00
Olivier Goffart
e5302e0b7b Remove unused Type::EnumerationValue
Values are not their own types
2020-11-03 12:34:17 +01:00
Olivier Goffart
e4e7ae46f4 Support for for in box layout in the interpreter 2020-10-31 11:24:31 +01:00
Olivier Goffart
359f42c5f7 Prepare the compiler to be async
This will allow the online editor to load imports from URL asynchroniously later

Since currently the compiler is only working on a single thread, and that we
never await on a future that could block, it is allowed to use the spin_on executor
2020-10-30 15:00:04 +01:00
Olivier Goffart
70d6648880 Remove some remains of code that allowed to use Component as Object 2020-10-27 16:25:21 +01:00
Olivier Goffart
333c96fd79 Change Type::Object to be able to hold a name
Internally, structure will be represented with a Type::Object with a name
instead of a Component with a void base type
2020-10-27 16:09:05 +01:00
Olivier Goffart
27a6ff1227 Move Type and related concepts in a different module
Leaving only the TypeRegister in the typeregister module
2020-10-23 11:17:14 +02:00
Olivier Goffart
ac6d4007ab Node: Add setHandler features on signals 2020-10-21 12:22:22 +02:00
Simon Hausmann
7905285562 Change the Model API for the NodeJS Integration to use CamelCase 2020-10-20 16:40:49 +02:00
Simon Hausmann
3b051f2176 Clarify hexadecimal color encoding
We parse hex colors as per CSS, including the #RRGGBBAA variant, as per
https://www.w3.org/TR/css-color-4/#hex-notation . This is now documented
and the JS conversion also generates that instead of #AARRGGBB.
2020-10-19 16:38:58 +02:00
Olivier Goffart
14198052ac ArrayModel support in JS 2020-10-17 13:33:22 +02:00
Simon Hausmann
071ab9fda1 Prepare for use of percentages as widths in layouts
Delay the conversion of percentage to the float to code generation type
by inserting the multiplication into the syntax tree. That way we will
be able to detect plain uses of percetages and interpret them
differently.
2020-10-16 15:38:35 +02:00
Olivier Goffart
cdc6a34eaf Support for array in JS 2020-10-16 12:58:27 +02:00
Olivier Goffart
3ea524694e Support for color in JS (as string) 2020-10-16 12:58:27 +02:00
Olivier Goffart
67dddd69e7 JS: implement conversion to Type::Object 2020-10-16 12:58:27 +02:00
Olivier Goffart
d57ad389e0 Default to the native style in the viewer if it is available 2020-10-14 14:51:47 +02:00
Simon Hausmann
6190d197dd Fix formatting 2020-09-30 15:26:24 +02:00
Simon Hausmann
9ad8968529 Add support for the initial_focus synthetic property
Setting it will translate to a set_focus_item call in the constructor.

This implements parts of #55
2020-09-30 15:11:01 +02:00
Simon Hausmann
e5dfb3a4c0 Implement basic focus handling
Similar to the mouse_grabber, we use a VisitChildrenResult field to
track the focus item within a component. Unlike the mouse grabber
however, it is set/cleared using dedicated focus events.

The key event now routes the key event directly to the focus item.

The focus can be requested via set_focus_item on a window, which the
TextItem does.
2020-09-25 10:43:47 +02:00
Simon Hausmann
7053aee0c8 Pass the ComponentWindow to ItemVTable::input_event 2020-09-18 16:18:48 +02:00
Olivier Goffart
8134fe5088 Support for named type as property 2020-09-17 13:14:01 +02:00
Simon Hausmann
26ae1bfdb2 Add From<String> and Into<String> for SharedString 2020-09-14 08:49:41 +02:00
Olivier Goffart
42aa91e3eb Support for signal with arguments in the interpreter 2020-09-09 11:27:58 +02:00
Olivier Goffart
9f026c820d Parse declaration of signal with arguments 2020-09-07 17:41:24 +02:00
Simon Hausmann
ff9c118e07 Propagate warnings to the end of the compilation step and print them 2020-09-04 20:34:20 +02:00
Olivier Goffart
f1ad78bc25 Qt style support for the rust backend
Need to set the SIXTYFPS_STYLE=native env variable while compiling
2020-09-01 12:25:11 +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
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