Commit graph

1923 commits

Author SHA1 Message Date
Florian Blasius
bb9ba91255
moved slint classed to private_api (#3893) 2023-11-09 16:03:08 +01:00
Florian Blasius
9e393a6f74
Florian/node model notify (#3892) 2023-11-09 14:19:15 +01:00
Simon Hausmann
1c0ebe4c0e Node.js docs: Add some missing type mappings 2023-11-08 19:52:50 +01:00
Simon Hausmann
ad21ecb2c5 Node.js docs: Link to SlintBrush, SlintImageData for getters 2023-11-08 19:52:50 +01:00
Simon Hausmann
ad95dc3ad7 Various changes to the Node.js docs
- Make the walkthrough actually work
- Fix incorrect file paths
- Link between loadFile and the component instantiation section, as well as ComponentHandle
- Declare that loadFile may throw an exception
2023-11-08 19:52:50 +01:00
Simon Hausmann
33048000b6 Bump napi dependencies 2023-11-07 11:50:49 +01:00
Simon Hausmann
8dcab7fc71 Fix build with current napi 2023-11-07 11:45:44 +01:00
Simon Hausmann
432103d38f Node.js: Seal modules and component instances 2023-11-06 18:32:01 +01:00
Simon Hausmann
7b61e455eb Initial implementation of a Slint event loop sitting on top of Node.js
At the moment this is implemented using polling.

cc #2477
2023-11-06 11:37:45 +01:00
Olivier Goffart
0efd2fd2a4 janitor: code formating 2023-11-03 15:43:29 +01:00
Olivier Goffart
f043234890 C++: fix (private) properties of type EasingCurve
tests/cases/properties/animation_props_depends.slint in previous commit
added a property<easing> and that didn't work with C++
2023-11-03 15:11:06 +01:00
Ken Carpenter
b20536131f
Add more easing formulas (#3812)
Closes #2655
2023-11-03 09:20:44 +01:00
Olivier Goffart
fd35e24566 Disable FemtoVG on Android
Causes compilation problem with default features otherwise

And doesn't work anyway
2023-11-02 17:06:25 +01:00
Olivier Goffart
243b44d424 Fix C++ after refactoring of the KeyEvent 2023-11-02 12:16:40 +01:00
Olivier Goffart
1efd83621d Refactor: Merge KeyInputEvent and KeyEvent
Both structure are bascially the same and only used internally, no need
to have the two.

The only difference was that one had the modifiers and the other one
not. But we can just set the modifier at the point we were converting
between the two.
2023-11-02 12:16:40 +01:00
Florian Blasius
e3dbefafa5
node: implement access for globals (#3815) 2023-11-02 11:01:40 +01:00
Tobias Hunger
2def4d2495 janitor: Suppress warning about unused native_widgets module
The module is empty when Qt is not around, which triggers a warning in
the nightly compiler.
2023-11-02 10:17:59 +01:00
Aurindam Jana
50a6040c38
Update cpp docs on installing or building slint (#3821) 2023-11-01 19:10:04 +01:00
Olivier Goffart
ac8fd60091 Fix regression with empty array
Regression noticed in this line:
3f97d98bff/ui/tabs/downloads.slint (L77)

The following used to work:

```slint
import { Button, VerticalBox } from "std-widgets.slint";
export component Demo {
    in property <[int]> mods;
    VerticalBox {
        alignment: start;
        for xxx in true ? mods : [] : HorizontalLayout { alignment: center; Button { text: "OK!"; } }
    }
}
```

But we fixed array conversion and this caused a regression with empty
array
2023-11-01 11:30:59 +01:00
Simon Hausmann
d07f87b609 Fix build when installing as dependency in apps
napi and esbuild are not just dev dependencies. Since we distribute source packages, they are in fact
run-time dependencies, as
"npm install" will run "npm run build" and that
requires those two.
2023-11-01 11:05:33 +01:00
Simon Hausmann
1441719f61
Fix cross-compilation of C++ interpreter API to 32-bit architecture (#3810)
cbindgen doesn't reliably tranfser the 64-bit/32-bit #ifdefs around ValueOpaque.
Instead, move Value onto the heap by using a Box.

Fixes #3653
2023-10-31 17:33:49 +01:00
Olivier Goffart
d55803d290 Models: fix writing data doesn't update ListView model data property
This fixes a couple of bug:
 - Bug #3740 happens because `Repeater::model_set_row_data` did not use
   the inner.offset to get the instance (So that's the `val == 106` part
   of the test)
 - But I went ahead and also tested what happenned if you changed the
   model from the "outside" using the `model[i] = `, and that was not
   implemented, hence the move of the code from
   `Repeater::model_set_row_data` to `RepeaterTracker::row_changed`,
   That does need Pin though, so Pin was added everywhere
 - C++ is not affected by bug #3740, because because the C++ listview
   don't do the "allocate only visible" optimization. But the
   "val == 1106" part of the test would fail so this patch also moces
   the update from  `model_set_row_data` to `row_changed`.
   But following that we don't set the state as Dirty in `row_changed`,
   the write_to_model test started filling  because the `row_added`
   function was missing an update of the index on every further items

The change in the interpreter prevent a borrow_mut from causing trouble.
The Value really don't need to be in a RefCell anyway

Fix #3740
2023-10-31 13:41:31 +01:00
Olivier Goffart
3662c39e1d node: Make sure that the test shows why the napi build fails 2023-10-31 12:28:31 +01:00
Florian Blasius
88a814c234 Revert "Implement globals for node"
This reverts commit 8412a971af.
2023-10-31 11:40:39 +01:00
Florian Blasius
8412a971af Implement globals for node 2023-10-31 11:36:25 +01:00
Florian Blasius
62a30a0e2e
node: export classes use interfaces for setters (#3804) 2023-10-31 10:36:00 +01:00
Simon Hausmann
55085d43af
Fix Node.js version of memory game not working properly (#3789)
The rules require comparing if tiles are equal, which used to be a string comparison as we just
converted the image to a path. With ImageData this doesn't
work anymore, so this patch proposes an optional path
property that makes the code also a tad bit more readable.
2023-10-31 08:50:32 +01:00
Florian Blasius
52a0cd5c13
Show warning on duplciatedd properties (#3805) 2023-10-31 07:08:40 +01:00
Olivier Goffart
b2645dff6c Wasm: use the winit spawn() api to run the event loop for the interpreter
This seems to solve the bug that the wasm interpreter (or slintpad) is
not working when compiled in release since the winit0.29 update
2023-10-30 14:17:10 +01:00
Olivier Goffart
0c529cd345 janitor: Some no-brainer deps update 2023-10-27 19:11:38 +02:00
Simon Hausmann
2310015315 janitor: Reformat JS types to match formatting of other files
(Just saved in VS code)
2023-10-27 16:42:54 +02:00
Simon Hausmann
ce0f8ddf7c janitor: reformat these files with vscode
This matches the existing formatting in the files present.
2023-10-27 16:41:06 +02:00
Simon Hausmann
80bb7af08c node: Fix typescript setup for tests
Share tsconfig.json so that ava runs the typescript compiler also on the tests.
Similary, the syntax check now also covers the tests.

Sadly, the exception that the Slint compiler throws is not type declared,
so we have to use any.
Similarly, the object share returned by loadFile() is unknown
in terms of properties, callbacks, etc.
2023-10-27 11:39:44 +02:00
Olivier Goffart
c51fb14a0e Improve the slint! macro with rust-analyzer with -
We currently use the debug representation of Span to know if they are
next touching eachother as there are no stable way currently.
But that doesn't work with rust analyzer as it doesn't have a
representation we can test.
Also Span::source_text is not implemented with rust analyzer.

So just default to identifier with `-` touching instead of not touching
as this happens more often.

One can still use `(foo)-(bar)` when one really need minus

CC #685
2023-10-26 13:13:03 +02:00
Florian Blasius
0045787e1c
node: api review adjustements part I (#3766)
* Update api/node/src/types/brush.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update tests/cases/callbacks/handler_with_arg.slint

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-10-26 10:02:49 +02:00
Simon Hausmann
25b380bcc8 Fix failing test-driver-nodejs based color tests
Same fix as parent commit
2023-10-25 16:16:27 +02:00
Simon Hausmann
4e80faa3b8 Fix tests not passing in debug mode
napi would assert when we extract an object from a reference twice:

```
thread '<unnamed>' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/napi-2.13.3/src/js_values/value_ref.rs:59:5:
assertion `left == right` failed: Ref count is not equal to 0 while dropping Ref, potential memory leak
  left: 1
 right: 0
stack backtrace:
```

Fix this by avoiding the use of Ref.
2023-10-25 16:16:27 +02:00
Simon Hausmann
2fc418251b node: remove workaround for font imports with relative paths
Commit a76c3ec789 fixes the underlying issue.
2023-10-25 15:04:55 +02:00
Simon Hausmann
192e04bea3 Fix broken doc link 2023-10-25 09:05:59 +02:00
Florian Blasius
bf77b064ab
Replace neon node port (#3744)
* Update api/node/README.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-24 15:07:59 +02:00
Olivier Goffart
78d273e599 Revert "Reduce the amount of re-creation of cells in repeaters when the model changes (#1954)"
This reverts commit 1162ebbb79.

Because otherwise if we keep the elements, their internal state is kept
and this causes bug #2598

Fixes #2598
2023-10-23 16:52:03 +02:00
Olivier Goffart
12cd8e71f1 WIP: some polish over the winit update to 0.29 2023-10-23 14:22:48 +02:00
Olivier Goffart
5bf2c7192b Fix panic with very large ListView
In `ItemRc::find_sibling` we currently do:
 1. get the range
 2. check that the next index is within the range
 3. call `get_subtree`

The problem is that get_subtree itselg will call 'ensure_updated' which
will do the relayout of the ListView and may get a different range of
element.

So don't query the range before and just have get_subtree to return an
empty ItemWeak if we are out of the actual range.

Couldn't really find a way to make a test since this is called from
the accessibility code which is hard to test as is

For #3700
2023-10-21 14:03:39 +02:00
J-P Nurmi
c5248c005e Allow specifying paths for @library imports 2023-10-20 16:47:00 +02:00
Tobias Hunger
df544fe1c9 interpreter: Introduce internal feature
... and use it to hide internal functionality so users will notice that
they depend on fucntionality we do not provide any guarantees for.

Make the lsp and viewer request the internal feature when building the
interpreter.
2023-10-20 15:34:49 +02:00
Olivier Goffart
f4dd08783c janitor: C++: make the code more readable by having the type explicit 2023-10-19 18:09:14 +02:00
Olivier Goffart
172dcfa775 C++: fix crash when accessing empty model from Slint
Fixes #3704
2023-10-19 18:09:14 +02:00
Simon Hausmann
403bb6c716
napi: Catch typescript errors in the CI and in debug builds (#3703)
We use esbuild to transform index.ts into index.js, but we also need to
perform a type check. esbuild doesn't do that, this is left to the
typescript compiler. So let's run it with -noEmit as recommended by the
esbuild folks, in debug builds as well as in the CI (which doesn't do
debug builds).
2023-10-19 18:05:32 +02:00
Florian Blasius
f4eb46465b
napi documentation (#3689)
* napi documentation

* Add missing documentation
* Generate documentation with typedoc

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/index.ts

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/src/types/size.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/index.ts

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/index.ts

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/src/types/size.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* code review feedback.

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Code review feedback.

* Update api/napi/index.ts

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* code review feedback.

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/cover.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Code review feedback.

* napi: added slint example to callback

* napi: added example to instantiating a component

* Update api/napi/src/interpreter/diagnostic.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/src/interpreter/diagnostic.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/src/interpreter/diagnostic.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/src/interpreter/diagnostic.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/src/interpreter/diagnostic.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/src/types/brush.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update api/napi/src/types/image_data.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* napi: more code review stuff

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-10-19 11:53:00 +02:00
Simon Hausmann
e0d1d4366d doc: In the type mapping, refer to the angle as "angle", not as "value" 2023-10-17 13:26:04 +02:00