Commit graph

390 commits

Author SHA1 Message Date
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
Florian Blasius
f2aab576f4
Add StandardTableView widget (#2032)
* Text only StandardTableView with column and rows
* Text editing of cells
* Sort by column ascending and descending
* Variants of the TableView for native, fluent and material
2023-01-12 19:41:12 +01:00
Olivier Goffart
7947d44e59 Run the syntax_updater on our widgets
This is commit is just the output of running the syntax updater on the
files in the internal/compiler/widgets directory.
No extra manual steps were done.

Note: In order to run the updater, I did a hack so that the updater wouldn't
choke on internal item used by the styles by commenting out the check in
ElementType::lookup_type_for_child_element
2023-01-11 10:52:48 +01:00
Olivier Goffart
5fbf68a647 Compiler: use the empty type more often instead of the Rectangle
We have that type now, so it should be used when we don't really need a
rectangle
2023-01-10 22:23:53 +01:00
Simon Hausmann
c04bc00d34 Add initial support for rendering text in the screenshot test driver
This uses the approach discussed in Mattermost: The compiler understands
a SLINT_DEFAULT_FONT environment variable that can point to a path,
which overrides the fallback font that would otherwise come from the
system (and differ between test systems).
2023-01-09 14:12:33 +01:00
Olivier Goffart
4cf6690e5a syntax_updater: also parse slint,no-preview code block in md files
This include a fix to make sure the diagnostics has access to the
sources even if there is no path
2023-01-07 14:18:10 +01:00
Olivier Goffart
a0d057b8b8 Enable the new syntax by default 2023-01-07 14:18:10 +01:00
Olivier Goffart
8d7b8df922 Fix conversions of array literal containing struct with array literal
Fixes #2023
2023-01-02 23:53:22 +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
a0d6199391 Updater: annotate pure to all function and callback that returns something 2022-12-22 00:26:27 -08:00
Olivier Goffart
dace899cc5 Pure function: make it a warning in legacy context instead of an error 2022-12-22 00:26:27 -08:00
Olivier Goffart
8fc7c2dafc Error when mixing purity in callback aliases
Also adjust the way we report error while infering to avoid double
reporting errors
2022-12-22 00:26:27 -08:00
Olivier Goffart
1cbd61145e WIP: pure qualifier for callback and functions 2022-12-22 00:26:27 -08:00
Olivier Goffart
8a09043e63 Properly remember the location of builtin member function call
So we can report an error if they are called in a pure context
2022-12-22 00:26:27 -08:00
Olivier Goffart
3dc560be06 Make source-clip-width/height defaults to the size of the image
And use that to compute the ratio

Whilte technically a breaking change, i don't think anyone rely on the
previous behavior.

Fixes #664
2022-12-20 08:42:47 -08:00
Olivier Goffart
5cd38adb14 Move the colorize property to the Image item
Instead of the ClippedImage. Because we use the colorize property more
often than the source property, and these are soon going to be even more
expensive
2022-12-20 08:42:47 -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
69df22e2fb Update resvg dependencies 2022-12-18 08:49:19 -08:00
ogoffart
ce07d078ce Bump version number to 0.3.4 2022-12-16 09:36:15 +00:00
Olivier Goffart
57d2e99723 Fix panic when a PopupWindow is a children of an optimized element 2022-12-15 07:01:58 -08:00
Olivier Goffart
3e8a681f36 Don't optimize properties used by functions 2022-12-15 05:43:24 -08:00
Olivier Goffart
52813224a5 Fix rust compilation of functions returning nothing 2022-12-15 14:17:03 +01:00
Olivier Goffart
aeed3b48fc Parser: fix parsing of "public function" in release mode
`consume()` does not advance whitespace, while `peek()` does.  And the
`peek()` in the debug_assert meant that the behavior was different in
release and debug mode.
Use `expect` instead of consume as it skip over white space
2022-12-15 12:52:21 +01:00
Simon Hausmann
554d153e35 Limit re-exporting of types
- Only allow one module re-export per file
- Warn when a re-exported type clashes with a locally exported type, and prioritize the local type.
2022-12-09 11:05:08 +01:00
Simon Hausmann
8faf57fa40 Minor fix to export * from "blah" parsing
Use the star token directly.
2022-12-09 11:05:08 +01:00
Simon Hausmann
b38fe7c5f0 Clean up internal Exports struct
- Use deref instead of `.0` tuple access (looks neater)
- Provide a convenience find() function that also makes use of the sorting
2022-12-09 11:05:08 +01:00
Simon Hausmann
6f19ab38e7 Use re-exports in the styles to simplify their code 2022-12-09 11:05:08 +01:00
Simon Hausmann
03fe599890 Add support for re-exporting modules
Use `export * from "somewhere.slint"` to avoid having to repeat all the
types of an existing module in order to re-export all of the types.
2022-12-09 11:05:08 +01:00
Simon Hausmann
6c01ad858c Clean up setup of exported names and components/types
Replace the intermediate NamedExport and SeenExport structs and the hash
table to find duplicates with a simpler algorithm:

1. Collect all exports into a vector, sorted, with duplicates
2. Eliminate duplicates and issue warnings accordingly and insert the
   result into a second vector.

As a bonus, the resulting vector of exports is now sorted.
2022-12-09 11:05:08 +01:00
Olivier Goffart
ccf3e8e9e9 C++: Generate image texture data for software renderer 2022-12-09 09:25:48 +01:00
Olivier Goffart
b2e22dc7cd Apply suggestions from code review
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2022-12-06 14:56:25 +01:00
Olivier Goffart
3c5aeb5897 Test for binding loops involving functions 2022-12-06 14:56:25 +01:00
Olivier Goffart
ed07cd825d Make functions private by default unless annotated with 'public' 2022-12-06 14:56:25 +01:00
Olivier Goffart
dfdbc942f6 Split Expression::CallbackReference and Expresison::FunctionReference 2022-12-06 14:56:25 +01:00
Olivier Goffart
4672e54f5e Compiler: make calling functions work 2022-12-06 14:56:25 +01:00
Olivier Goffart
851a910e41 Parser: Parse functions 2022-12-06 14:56:25 +01:00
Olivier Goffart
fdf5d4c0dd Fix in/out/private property on global
This is technicly a breking change. But this is also a bug and it was only
allowed since 0.3.2, so it is probably fine.

The problem is that any property access to a global was considered as being
local.
Now, change that so that property access to a global object is no longer
local, and other components can't access private property anymore
2022-12-06 10:29:44 +01:00
Simon Hausmann
755cd66398 Revert "Prospective build fix for arm cross build" and "With Rust 1.64 we can use core:ffi types instead of depending on libc"
This reverts commit 000d95670b and commit
d764796e0c to fix arm cross build and
x86-64 linux.

Let's use the core::ffi types when fontconfig-sys switches to it.
2022-12-06 09:16:03 +01:00
Simon Hausmann
11f46906a2 Centralize rust-version in Cargo.toml
Require 1.64 in the workspace and inherit the setting in package
Cargo.toml files.
2022-12-05 12:39:14 +01:00
Simon Hausmann
d764796e0c With Rust 1.64 we can use core:ffi types instead of depending on libc 2022-12-05 10:33:50 +01:00
Simon Hausmann
7122d22c88 janitor: use the new default attribute for enums 2022-12-05 10:20:39 +01:00
Olivier Goffart
20bc567b6d Don't match builtin type purely on it's base type name
Make sure this is the actual builtin type we are looking at and not a
re-defined component

Doesn't work for ListView unfortunately because ListView is not a
builtin type

CC #861
2022-12-01 12:56:59 +01:00
Olivier Goffart
d468bbec05 ListView: Warn when we have other elements than just a for
This is not supported right now, the other elements will not be part of
the layout, and two `for` will be in the same listview, creating bad
situation with the scrollbar.

This is a warning since it would be a breaking change to make it an
error.

For example, we used a FocusScope in the StandardListView implementation so
I had to go trough one level of indirection

CC: #860
2022-11-30 11:17:22 +01:00
Olivier Goffart
151df7167d Fix visibility on drop shadow
`visible:false` would't hide the drop shadow

Fixes: #1460
2022-11-29 17:00:52 +01:00
Olivier Goffart
261e612555 Janitor: dependencies update 2022-11-28 15:59:45 +01:00
Olivier Goffart
eee2a3d012 Fix two ways binding between globals
The previous code did not remove two ways binding that were between two
globals. Now we do the remove_aliases pass over the whole document at
once which allos to simplify aliases between globals.
2022-11-28 14:39:47 +01:00
ogoffart
fb02b4118b Bump version number to 0.3.3 2022-11-28 13:11:11 +00:00
Simon Hausmann
f2c5184bf2 Fix embedding of images referenced in globals
When doing builds that require image embedding (such as for WASM), it's crucial
to also visit the globals (after they've been collected) to catch all image references.
2022-11-24 15:04:25 +01:00
Simon Hausmann
885fcc1ac8 Express material design typographic tokens in relative-font-size
The spec at https://m3.material.io/styles/typography/type-scale-tokens defines
label-large, label-medium, etc.
relative to 16px.
2022-11-24 13:56:31 +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