Commit graph

144 commits

Author SHA1 Message Date
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Tobias Hunger
99ea465734 c++: use unsigned integers for the index in visit_dynamic_children
This is what rust does, too, and prevents errors when the indices
get big.
2023-06-14 16:24:36 +02:00
Olivier Goffart
0e31f097a4 Un-seal the WindowAdapter trait 2023-06-13 17:44:04 +02:00
Simon Hausmann
cd9994306e Create the window adapter lazily in C++ 2023-06-13 15:13:42 +02:00
Olivier Goffart
18ba3c2ae2 Slint enums in Rust and C++ 2023-06-12 13:02:14 +02:00
Simon Hausmann
e663282c65 Fix support for High-DPI with Qt
Preserve the early backend initialization of commit
f0b047057b
2023-06-10 11:41:04 +02:00
Simon Hausmann
01b00d26eb Rust: Allocate the window adapter lazily
This will be needed for embedding - to avoid creating two window
adapters - and it will be needed for the API to allow creating a
component from an existing window.
2023-06-10 11:41:04 +02:00
Olivier Goffart
12e6b34e2d Translations: support for plurals 2023-06-07 10:34:34 +02:00
Simon Hausmann
1bf05eae7c
Add support for absolute-x and absolute-y properties on any element (#2823)
Fixes #1691
2023-06-06 14:37:53 +02:00
Olivier Goffart
cf746ddf8d WIP: formatting implementation of translate in rust and C++ 2023-06-05 16:34:59 +02:00
Olivier Goffart
dcd8450dfa WIP: start working on translations: @tr()
This commit just do the parsing of the @tr macro.
2023-06-05 16:34:59 +02:00
Amirhossein Akhlaghpour
3a4f3c61d5
Add @rust-attr on scturct (#2785)
Fixes: #2660
2023-06-05 16:29:55 +02:00
Simon Hausmann
0f54b9599b Add support for manually closing PopupWindows
This patch adds a `close()` function that can be called to close a popup
window, and a `close-to-click` boolean that can be set to false to
disable the default behavior.
2023-06-02 18:07:49 +02:00
Simon Hausmann
a0a5294e49 Fix init callbacks not being invoked for PopupWindow 2023-06-02 18:07:49 +02:00
Olivier Goffart
5599bd44e0 Remove Color::opaque
It is not a right name and i don't think it is a so common operation
2023-06-02 17:02:08 +02:00
Olivier Goffart
4845241ebf Rename translucent to transparentize and mixed to mix 2023-06-02 17:02:08 +02:00
Arthur Araruna
64ad1ce357 Add some color and brush manipulation funcs (#2565)
The added functions enable mixing colors and manipulating the opacity
of colors and brushes.

They enable the behavior of some of the available functions from SASS and are
added for future use for adding the Adwaita style (future PR).
2023-06-02 17:02:08 +02:00
Simon Hausmann
c428601370
Add support for select-all(), cut(), copy() and paste() functions on text input elements (#2804)
In the compiler this is still very primitive, but an attempt to start a
generic interface. The basic assumption is that all item functions will
eventually need access to the window adapter and itemrc. Support for
additional arguments is still missing.

Also missing is support for the function access via rtti in the
interpreter, hence the hardcoding at the moment.
2023-06-01 16:04:53 +02:00
Simon Hausmann
6b8214c3f9 Add support for italic and bold text in the software renderer's bitmap font path
In the screenshot tests this works by setting SLINT_DEFAULT_FONT to
pointer to a directory, instead of a file. We then load all fonts in
that directory and consider their families the default unless a family
is specified. This way for "Noto Sans" a regular as well as an italic
version is registered in fontdb and returned in the list of font
fallback ids. embed_glyphs in the compiler then embeds those variants
and we find them at run-time.
2023-05-31 18:47:39 +02:00
Simon Hausmann
ea769cb10c C++: Make sure embedded image data is declared const 2023-04-12 16:14:13 +02:00
Olivier Goffart
a57c7eb6bc Added TextInputInterface.text-input-focused 2023-04-12 14:49:08 +02:00
Olivier Goffart
cdaf2abb47
C++: sort the member of a struct in the same order as in the .slint file 2023-03-29 19:11:33 +02:00
Olivier Goffart
7652097582 Better error message when trying to use private property in native code
If one declare a `property <int> foo;` in Slint, it will be private by
default, and the getter/setter won't be generated, and it may be
confusing as to why

With this change, it still generate private getter and setter so this
gives a better hint to the developer what the problem is.

Replaces #2170
2023-03-27 17:49:07 +02:00
Simon Hausmann
8ffb5131c7
Introduce error handling in the FemtoVG and Skia renderers (#2402)
Avoid unwrap() and expect() and instead propagate errors all the way
down to run_event_loop(), show(), and hide() in the Slint AIP.
2023-03-24 14:18:11 +01:00
Simon Hausmann
00471449b4 Fix compilation of Rust generated code when the generated code uses a return statement inside a block
We cast the result of the body of functions or binding expressions to
the target type via `as _`. When the code contains a return expression,
that works fine, because `return`'s type is the never type, which can be
coerced to a value of any type. However when the return statement is
inside a sub-block, the type becomes `()`, for which the `as _` cast
fails.

Work around this by attempting to detect the situation (return produces
Type::Invalid) and omit the trailing cast.
2023-03-22 18:07:34 +01:00
Olivier Goffart
4cf44ea69d Mark StandardListViewItem and TableColumn as #[non_exhaustive]
Closes #2330
2023-03-18 09:04:48 +01:00
Tobias Hunger
3d87b3ab93 clippy: Allow redundant_clone in generated rust code
This disabled about 70 clippy warnings like this one:

```
warning: redundant clone
     --> target\debug\build\energy-monitor-7b0492feb1633656\out\desktop_window.rs:44279:37
      |
44279 |                      (if (((r#state . clone ()) . r#previous_state as f64) == (1f64 as f64)) {
      |                                     ^^^^^^^^^^^ help: remove this
      |
note: cloned value is neither consumed nor mutated
     --> target\debug\build\energy-monitor-7b0492feb1633656\out\desktop_window.rs:44279:28
      |
44279 |                      (if (((r#state . clone ()) . r#previous_state as f64) == (1f64 as f64)) {
      |                            ^^^^^^^^^^^^^^^^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
```
2023-03-09 12:12:03 +01:00
Tobias Hunger
d1aaba8117 clippy: redundant clone fix in generated rust code
This fixes about half the `redundant clone` issues that clippy reports
in our generated rust code.
2023-03-09 12:12:03 +01:00
Tobias Hunger
0b03a0646a clippy: Allow cmp_owned in generated rust code 2023-03-09 12:12:03 +01:00
Tobias Hunger
7c19cde055 clippy: Allow eq_op in generated rust code
I get the following clippy errors in the energy monitor:

error: equal expressions as operands to `-`
     --> C:\src\slint\target\debug\build\energy-monitor-7b0492feb1633656\out\desktop_window.rs:47254:94
      |
47254 | ...   (slint :: private_unstable_api :: re_exports :: LogicalLength :: new (((((0f64 as f64) - (0f64 as f64)) as f64) * (((1f64 as f64) *...
      |                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op

error: equal expressions as operands to `==`
     --> C:\src\slint\target\debug\build\energy-monitor-7b0492feb1633656\out\desktop_window.rs:45382:18
      |
45382 |                  (((0f64 as f64) == (0f64 as f64))) as bool }
      |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op

I am not surprised that the generated code sometimes produces code like
this (even though the other demos do not!), so I went ahead and silenced
these errors.
2023-03-09 12:12:03 +01:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Olivier Goffart
889b953304 C++: Don't make the global_* member public
This requires adding more friends to the component root

Fixes: #2169
2023-02-17 17:54:03 +01:00
Olivier Goffart
81cb89d374 C++: fix including the generated file in several translation units 2023-02-17 16:42:40 +01:00
Olivier Goffart
6889dfa5f5 Rust: Make new(), run() and show() report errors from the backend
Fixes #2198
2023-02-10 05:00:03 +01:00
Olivier Goffart
acb41d8244 CPP: fix struct which have a field with the same name as the struct
The operator== reference the struct name, so if there is a
field with the same name, we should disambiguate

Fix  tests/cases/issues/name_conflicts.slint that was added in last
commit
2023-02-08 18:34:52 +01:00
Olivier Goffart
11d404a216 Rust: Avoid use statement in the generated code
So we avoid name conflict between user types and internal types

Fixes #2207
2023-02-08 18:34:52 +01:00
Olivier Goffart
eaa9db4911 C++: use size_t everywhere as index in our models
cc #2024
2023-02-07 15:25:44 +01:00
Olivier Goffart
63cc68ea0c C++: Use concepts for the invokables 2023-01-26 11:35:16 +01:00
Olivier Goffart
b55ec6894a Layouting: forward the implicit constraint from the children to the parent
Closes #783
2023-01-17 16:29:13 +01:00
Simon Hausmann
96c80a2dd1
Fix crash when using an int model in a repeater with a negative value (#2063)
Make sure that we return an unsigned for row_count() in C++ and Rust by ensuring an unsigned int model at creation time.

For the interpreter this "worked" by chance as casting a negative floating
number to usize automatically caps at zero, and all values are stored as f64. For safety this patch
applies the same fix though, to be on the safe side.
2023-01-14 21:20:14 +01:00
Olivier Goffart
1ab228c628 Implement calling public functions from native code
This doesn't implement any support for the interpreter yet

CC: #2012
2022-12-22 04:28:32 -08:00
Olivier Goffart
af50c2c2c2 Do not panic if the document contains a global but no normal component
Fixes #2005

(Unfortunately, we can't make a driver test for this becasue the
behavior with the interpreter is different than with the compilers.
The interpreter errors out, while the compiler should just generate
nothing)
2022-12-19 11:54:15 -08:00
Olivier Goffart
52813224a5 Fix rust compilation of functions returning nothing 2022-12-15 14:17:03 +01:00
Olivier Goffart
ccf3e8e9e9 C++: Generate image texture data for software renderer 2022-12-09 09:25:48 +01:00
Olivier Goffart
4672e54f5e Compiler: make calling functions work 2022-12-06 14:56:25 +01:00
Simon Hausmann
d8a1f2cf01 Introduce a rem unit in the type system
This allows specifying font sizes relative to the Window's
default-font-size, similar to CSS rem.
2022-11-24 11:33:38 +01:00
Olivier Goffart
39aebc1f4e Use the std::ops::Range as range in the repeater
And fix the preview highlight to use that
2022-11-17 12:23:23 +01:00
Simon Hausmann
907b58161c Add support for invoking an init callback on component and element construction
This enables imperative code to be run. To be used sparingly :-)
2022-11-17 10:12:08 +01:00
Olivier Goffart
b0d538fe4b Fix rust code generation when comparing percentages
Fixes #1837
2022-11-11 16:28:44 +01:00