Commit graph

7412 commits

Author SHA1 Message Date
Olivier Goffart
425b477874 Always keep the binding of the right in a two way binding
When having a binding such as
```
  foo <=> bar
```
The default value will always be the value of `bar` regardless what's
the value of foo.

This change of behavior is the only one that makes sense bacause if we
are having repeater or if, this will be a problem. eg:
```
property <xxx> bar;
if (some_cndition) : SomeElement {
   foo <=> bar;
}
```
Then we can't possibly take the default value of foo for the value of
bar since it depends on the condition. (and it is even worse in case of
repeater)

This is a change of behevior, this is why the tests have changed. The
cse of tests/cases/bindings/* were already covered by a warning since
0.3.0 so that should be fine. But the warning did not trigger for
builtin property such as `visible`  (eg, input/visible_mouse test)

Also some internal two way bindings had to be reversed.

cc: #1394
2022-11-04 15:32:20 +01:00
Simon Hausmann
0ea7c136f3 Fix location of material style in changelog 2022-11-04 10:53:26 +01:00
Simon Hausmann
39121994ca Always set Window.default-font-size
Permit the style metrics to provide a `default-font-size` and bind that
to the `Window` if set. If not provided, then the backend can set a
`default-font-size`. By ensuring that the value is non-zero at run-time,
we can later introduce a rem unit that can act as factor relative to
this non-zero font size.
2022-11-03 17:15:44 +01:00
Simon Hausmann
a95504ad4f Remove stray and duplicated call to request_window_properties() 2022-11-03 17:15:44 +01:00
Tobias Hunger
4c8b9856b5 lsp: Borrow Position and Url
No need to transfer ownership!

Also use `Url` directly instead of wrapping that into a
`TextDocumentIdentifier`. That way we can burrow the URL and do not need
to clone a `Url` into a `TextDocumentIdentifier` just so we can borrow
that.
2022-11-03 14:54:45 +01:00
Olivier Goffart
0d598ed1e4 Cleanups 2022-11-03 13:15:45 +01:00
Olivier Goffart
cf71b181a3 vscode extension: Share the properties view adaptation with the web extension 2022-11-03 13:15:45 +01:00
Olivier Goffart
6e2e2f0217 vscode extension: implements the property view 2022-11-03 13:15:45 +01:00
Olivier Goffart
d21fb071f7 Online editor: Move the property view code in a shared location
So that it can be re-used by the vscode extension
2022-11-03 13:15:45 +01:00
Tobias Hunger
268edcf07d LSP: Unify LSP server initialize result
Report the same LSP server `InitializeResult` to all users. This
improves on what was reported from the WASM LSP flavor to its users
before.
2022-11-03 11:41:54 +01:00
Tobias Hunger
c237144400 chore: Configure prettier and reformat the online_editor 2022-11-03 10:51:07 +01:00
Olivier Goffart
d84516b843 lsp: janitor: return None instead of Some with an empty vec when the operation is not supported
https://github.com/slint-ui/slint/pull/1809#pullrequestreview-1165414494
2022-11-03 08:29:29 +01:00
Jonathan Schwender
4ade9faa0d Update Corrosion to v0.3
This requires the following changes:
- Delay configuring SlintConfig.cmake:
  Corrosion sets the `IMPORTED` locations late to allow us to set
  OUTPUT_DIRECTORY target properties. The configuration of
  SlintConfig.cmake must be deferred until after Corrosion set the
  locations. Since we are writing to a config file Generator expressions
  are not an option.
- Remove BUILD_TYPE mapping from SlintConfig.cmake:
  As discussed in https://github.com/slint-ui/slint/pull/1785#issuecomment-1294630845
  remove the mapping of the build types since corrosion now always sets
  the `IMPORTED_LOCATION` property.

User facing improvements enabled by the update:
- Corrosion will not fail anymore if the user has a Rust toolchain >=1.60
  installed, but the default toolchain is < 1.60.
- Corrosion will respect OUTPUT_DIRECTORY properties and move target
  artifacts to the expected locations
2022-11-02 21:38:39 +01:00
Florian Blasius
7a01e3c0cb
md: adjust GroupBox, CheckBox and SpinBox (#1812)
Now it's also possible to toggle checked by click on the text of the CheckBox similar to fluent design

GroupBox now respect the minimum width of the title, to avoid elision

Adopt SpinBox: set focus when buttons are clicked #1795 on md SpinBox
2022-11-02 17:25:44 +01:00
Tobias Hunger
217fa9a337 LSP: features overhaul
* Do not use wasm build in conjunction with `preview` to keep code lense
  support on. Add `preview-lense` feature instead.
* Improve which parts of the LSP are kept based on these features.

With this patch a LSP built for the online-editor is about 10KB smaller
than before.
2022-11-02 15:48:26 +01:00
Olivier Goffart
a9c48e3350 CI: prospective fix of the build by setting the Python version
Python recently was updated to 3.11 and the build of the node binding is
now failing.
(Apparently still using a quite old version of node-gyp, because this
was fixed in `https://github.com/nodejs/node-gyp/issues/2219`)

```
     File "/home/runner/work/slint/slint/target/debug/build/neon-sys-4b140f4af6e7aeb3/out/native/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 239, in LoadOneBuildFile
      build_file_contents = open(build_file_path, "rU").read()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ValueError: invalid mode: 'rU' while trying to load binding.gyp
```
2022-11-02 11:33:47 +01:00
Simon Hausmann
a1f9e39054 doc: prospective fix for rendering of example snippet in C++ generated code docs
The sample component in the docs has nothing to see, disable preview.
2022-11-02 09:54:03 +01:00
Simon Hausmann
41e3e27bff doc: Fix rendering of slint::interpreter::ComponentInstance::set_global_callback
Don't use a preview for the Slint snippet that just shows a global. There's
nothing to render.
2022-11-02 09:51:12 +01:00
Simon Hausmann
fa8959c7bc doc: Fix rendering of generated docs for restart()
The `--` was converted into a HTML entity, which was escaped again and shown raw.
2022-11-02 09:48:02 +01:00
Olivier Goffart
8aa377fe87 LSP: skip output properties in the queryProperties call 2022-11-01 19:04:37 +01:00
Olivier Goffart
a8ee3ca710 vscode extension: move browser-language-server/browserServerMain.ts
It doesn't need to be in a different folder with a different
package.json
2022-11-01 16:49:03 +01:00
Simon Hausmann
34b39a2a60 Remove slint::testing from the C++ API Docs
We already avoid parsing `slint_testing.h`. But we have a variant of
`send_keyboard_string_sequence` in `slint_interpreter.h` because the
function takes a ComponentInstance. Exclude all symbols from that
namespace from the docs to continue the intent.
2022-11-01 15:34:35 +01:00
Olivier Goffart
2ceafc6392 New syntax: Make it an error to set the value of a builtin output property
With the old syntax, this becomes a warning
2022-11-01 12:51:45 +01:00
Olivier Goffart
8dbe745fc4 Builtin elements: use the input output syntax 2022-11-01 12:51:45 +01:00
Simon Hausmann
63cd49fb46 Use LogicalPoint for the internal popup location 2022-11-01 12:15:51 +01:00
Simon Hausmann
64588c70f1 Make popup related data structures internal to the window module 2022-11-01 12:15:51 +01:00
Simon Hausmann
b835290f83 Use LogicalRect for the geometry of popups in WindowAdapterSealed 2022-11-01 12:15:51 +01:00
Simon Hausmann
65e4e7bf15 Bump resvg/usvg/tiny-skia dependencies 2022-11-01 10:44:33 +01:00
Simon Hausmann
cecdb330f8 material design style: Replace remaining uses of pt with px
This is consistent with the use of `px` for the sizes and matches the expected
conversion to css pixels.
2022-10-31 21:12:52 +01:00
Simon Hausmann
1d8c5ac53f Fix serialization of LSP types into wasm
Use a JSON friendly representation that uses JS object instead of ES
maps, as the latter appear to confuse at least the monaco lsp
integration.
2022-10-31 17:34:11 +01:00
Olivier Goffart
5613fc4416 Rename inout property to input output
`inout` and `input` are too similar, so use a longer form for `inout`

CC https://github.com/slint-ui/slint/issues/191#issuecomment-1296176978
2022-10-31 14:57:52 +01:00
Florian Blasius
072d8fabcb
Add material, material-light and material-dark widgets (#1784)
Add material, material-light and material-dark widgets and make it available by the `env` `SLINT_STYLE`.
2022-10-31 14:54:50 +01:00
Olivier Goffart
53090ab489 Forbid usage of @children in repeated or conditional element
It leads to compiler panic, or errors in the generated code.
2022-10-31 14:13:42 +01:00
Simon Hausmann
01d666083f doc: Remove the experimental tag from the Skia renderer
Should've done that for 0.3.1, but better late than never :)
2022-10-31 10:50:28 +01:00
Olivier Goffart
6579336d43
Update CHANGELOG.md
previous commit added its entry in the wrong section
2022-10-29 09:30:49 +02:00
David John
82278a5742 api: add Window::is_visible 2022-10-29 09:21:26 +02:00
Tasuku Suzuki
6c4e4850f9 SpinBox: set focus when buttons are clicked 2022-10-29 09:19:55 +02:00
Tobias Hunger
1353870ea6 online editor: Allow to edit existing properties from properties editor
Just allow to replace existing values of existing properties.
2022-10-28 17:56:30 +02:00
Tobias Hunger
41e742bef7 online editor: Implement text replacement for the editor_widget
Implement textual replacement on the editor widget. This is supposed to
drive replacement operations later.
2022-10-28 17:56:30 +02:00
Tobias Hunger
bd8ad30dbd online editor: Add text input to properties editor
Add a input field into the properties editor table and apply styling to
it.
2022-10-28 17:56:30 +02:00
Olivier Goffart
84ae4d2928 New syntax: Only allow children if the component has @children
For compatibility reason, this is also allowed when inheriting
2022-10-28 17:45:37 +02:00
Tasuku Suzuki
64b248cfa9 doc: remove duplicated backticks 2022-10-28 17:44:48 +02:00
Olivier Goffart
426ccf3293 Update syntax highlighter for the new keyword in the new syntax 2022-10-28 14:21:38 +02:00
Simon Hausmann
ab1341878f
Make SlintInternal.dark-color-scheme a property instead of a function (#1790)
That's a more idiomatic API - the compiler can map the lookup straight
to a function call.
2022-10-28 14:20:20 +02:00
Simon Hausmann
7742512a80 janitor: Remove bogus return statement 2022-10-28 14:05:14 +02:00
Tobias Hunger
9311978244 online editor: Extract LSP to editor conversion function
Extract the LSP to Editor conversion function that @tr0nical fixed to
handle non-ASCII characters and use that consistently.
2022-10-28 13:16:45 +02:00
Tobias Hunger
f67015537e online editor: Fix off-by-one errors in the property editor
LSP is 0 based wrt. lines and columns, Monaco is 1 based.

LSP encodes the end of a Range as the first character *outside* of the
range, while Monaco expects the last character still *inside* the range.
2022-10-28 13:16:45 +02:00
Tobias Hunger
eca66c9423 online editor: Fix typo in CSS 2022-10-28 12:15:54 +02:00
Tobias Hunger
d36276d772 online editor: Remove dead CSS
Remove some dead CSS sections.
2022-10-28 12:15:54 +02:00
Tobias Hunger
c3a2c7a9e9 online_editor: Extract defaults into variables
Extract values for colors and fonts into colors.css file and use those
variables.

Also adapt some of the color values to match those used on the web site
more closely.

This prepares our side of the code for changing themes later.
2022-10-28 12:15:54 +02:00