Commit graph

179 commits

Author SHA1 Message Date
Qubi0-0
f6184ef858
Fix Generated C++ code issue with keywords (#6441)
Fixes #5613

ChangeLog: C++: generated code adds `_` to the end of identifier that would otherwise be keywords
2024-10-08 15:03:03 +02:00
Simon Hausmann
0b028bfb6f
Add support for a font-metrics property to Text/TextInput. (#6452)
The struct held provides access to the design metrics of the font scaled
to the font pixel size used by the element.

ChangeLog: Slint Language: Added font-metrics property to `Text` and `TextInput`.

Closes #6047
2024-10-05 17:00:46 +02:00
Olivier Goffart
d2bd5366f4 Timer::set_interval
Don't return an Option, just return 0 when the timer is not started.
As discussed in the API review, the rational is that the interval is
just like a field in a struct and when the struct is default
constructed, it is initialized to 0
2024-09-18 09:24:39 +02:00
Olivier Goffart
02467bd4cc
Change mod() to always return positive number (#6179)
* Change `mod()` to always return positive number

Closes #6178

ChangeLog: The mod function was changed to always return a positive value (#6178)
2024-09-17 11:37:32 +02:00
Nigel Breslaw
482308f5da
Add Math.atan2 to the inbuilt math function
Math.atan2(y, x) -> angle
2024-08-30 09:55:10 +02:00
Olivier Goffart
5f77808d1c Optimization: improve expression inlining
If a property is only used once, we can inline it with a bigger
threshold.
But this require to first compute the use, and then do the inlining
while adjusting the usages
2024-08-23 17:17:15 +02:00
Simon Hausmann
9bdade0105 Compile the multiple-includes test with a header-only build of appwindow.slint 2024-08-20 15:53:24 +02:00
Simon Hausmann
8146799e8a Fix build with type aliases and generated .cpp files
These need to remain in the header file
2024-08-20 15:53:24 +02:00
Simon Hausmann
4b2d572732 C++ code generator: Fix header-only build when included multiple times
Make sure to mark whatever variables and functions that are left in the header as inline,
even if we don't generate C++ files.
2024-08-20 15:53:24 +02:00
Simon Hausmann
fddb6e30e3 C++: Place embedded resources into generated .cpp files 2024-08-20 15:53:24 +02:00
Simon Hausmann
c25a03d6f7 C++: Make it possible to split up the C++ code generated for a .slint file
Add a COMPILATION_UNITS argument to slint_target_sources that defines into how many .cpp files to split up a .slint file. The new default is now one.
2024-08-20 15:53:24 +02:00
Olivier Goffart
a9f526491a Timer Element
Closes #5724
2024-08-16 16:36:38 +02:00
Simon Hausmann
fb6775b386 When the slint scale factor is provided at compile time, propagate it also as initial value to the slint::Window created 2024-08-14 11:00:50 +02:00
Olivier Goffart
51481b101c
Make conversion from float to int property truncate
- Make sure that in Rust and C++ we also truncate if the properties are
inlined
 - Change the interpreter to truncate

This is a redo of commit f5d003d but truncate instead of round

fixes #5689
2024-08-10 14:51:05 +02:00
Simon Hausmann
8a7db55bb6
Route debug() calls in Slint consistently through Platform's debug_log() (#5718) 2024-07-29 16:31:09 +02:00
Simon Hausmann
9a34789070 Revert "Fix conversion to from float to int"
This reverts commit f5d003d1e2.

We decided to postpone this change until a later release, in maybe a
different shape.
2024-07-25 15:25:00 +02:00
Olivier Goffart
f5d003d1e2 Fix conversion to from float to int
Round the value.

The previous behavior is that

 - For the interpreter, we were rounding (same as new behavior)
 - for Rust and C++ we were truncating, unless the properties were
   inlinined and then we were keeping it as float
2024-07-23 17:32:57 +02:00
Olivier Goffart
e67e46ab47 LLR: merge the popup's x and y property access in one expression 2024-07-10 17:54:03 +02:00
Simon Hausmann
419042f476 Add support for using own properties in PopupWindow's x and y properties
This allows positioning popup windows in a way that takes their width/height into account.
2024-07-10 13:43:41 +02:00
Olivier Goffart
14593a55e1 llr: Don't generate unused globals
Global for which none of the properties are used can be omitted in the
generated code.
2024-07-04 10:24:54 +02:00
Simon Hausmann
0f158e10dd testing api: Avoid bogus warnings about missing debug info
A `Rectangle { clip: true; }` will generate an intermediate `Clip` rectangle, which
certainly has no debug info.

The check whether debug info is present or not should not be done on a per-element
level but it can be done on the level of the compilation unit.
2024-07-03 18:01:24 +02:00
Olivier Goffart
59942df91f Add some tests and fixes for change handler
Make sure that when inlining, the callback in the sub component
is executed before the root

Fix a warning in the generated C++ code
2024-06-28 10:45:45 +02:00
Olivier Goffart
bd18d8dc0a Fix compiler crash when const propagating a property of component-factory with its default value
We couldn't represent an empty component factory in the exrpession tree,
so add Expression::EmptyComponentFactory for that
2024-06-25 20:25:01 +02:00
Olivier Goffart
3764312561
Generate multiple components in Rust and C++ (#5449)
When lowering to the LLR, generate one PulbicComponent for each exported
component in the main file

Closes #784
2024-06-24 10:03:19 +02:00
Olivier Goffart
408637a677 Remove the is_root_component within the component
There will be serveral roots, so this makes no sense.
2024-06-21 11:58:09 +02:00
Olivier Goffart
a4c0cc9f09 Move the used_types from the (root) Component in the Document
Preparation for multi-components

Note that this had to rename one instance of TextStyle because it
conflicts with the struct of the same name used in the FontSettings
in the style. This wasn't a problem before because it shares some
property in common, and the the order of processing of component has
changed leading to the other one being generated.
(But that is a wider bug in the compiler outside of the scope of this
refactoring)
2024-06-20 12:03:38 +02:00
Olivier Goffart
2fd8744cfc compiler: Move embedded_file_resources from the root Component to the Document 2024-06-20 12:03:38 +02:00
Olivier Goffart
d0ed0438ce
LLR: peliminary support for multiple public components
There currently still can only be one because the passes expect that,
but now the LLR and generator should be ready to accept multiple public
component later
2024-06-15 14:44:11 +02:00
Olivier Goffart
d0cdebfee6 C++: move globals in a different struct
So that subcomponent don't depend on the root component name
which will hallow to have several root components
2024-06-14 16:26:53 +02:00
Olivier Goffart
4cc6337c42 Rust: Don't get the default font size through the root component
Planning for multi-component support
2024-06-13 13:53:07 +02:00
Olivier Goffart
445802c46d date_time: simplification and cleanups 2024-06-06 09:03:50 +02:00
Olivier Goffart
3da0ee5bb9 DatePicker: Logic in C++
Had to simplify a bit the rust logic to make it work
2024-06-06 09:03:50 +02:00
Florian Blasius
973ecac989 DatePicker: finished features 2024-06-06 09:03:50 +02:00
Florian Blasius
3ccee816be
Added TimePicker widget (#5251) 2024-06-05 15:23:06 +02:00
Simon Hausmann
15b517a554 Emit a warning to stderr (debug_log) when using the ElementHandle API but there's no debug info present 2024-06-05 01:29:58 -07:00
Simon Hausmann
1a8ce3c659 Add support for optimized rectangles in ElementHandle
Keep merging elements, but remember the boundaries in the debug info, separated by a slash.

Also fixed tests that rely on accessible-label being set only once. For example

```
Button { text: "foo"; }
```

will certainly have "foo" as accessible-label on `Button`, but its internal `Text` element has
an implicit "accessible-label" set to the same
value.

So don't rely on that for now but search by id instead.
2024-06-05 01:29:58 -07:00
Simon Hausmann
4eef2d4936 WIP: Add find_by_element_type_name 2024-06-05 01:29:58 -07:00
Simon Hausmann
a52fe6bbfc Make element debug information configurable
The `SLINT_EMIT_DEBUG_INFO` environment variable needs to be set for Rust and C++ builds. For the interpreter it's always enabled, since ... we have it.
2024-06-05 01:29:58 -07:00
Olivier Goffart
43a336b534 C++ part of element_ids
Simplify a bit the llr generation so that there is less code duplication
between Rust and C++
2024-06-05 01:29:58 -07:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Olivier Goffart
5c3732c74e C++: fix string to float so that it doesn't depends on the current locale 2024-05-07 14:58:07 +02:00
Olivier Goffart
80f37a3acf C++ ChangeTracker implementation 2024-05-02 22:25:53 +02:00
Simon Hausmann
31767eb6ab Add a clear-focus()function on all elements that have a focus() function
This is the counter-part, which removes focus from the element if it's currently focused. The window - if focused - may still be focused towards the windowing system.
2024-04-26 11:09:11 +02:00
Olivier Goffart
5a4713aa17 C++: add #pragma once to generated file 2024-04-22 13:06:05 +02:00
Olivier Goffart
64404ceca2 accessibility: return an Option for accessible string values
So we can know whether the item had the property set at all or not
2024-04-19 11:23:26 +02:00
Olivier Goffart
13127dc71c Accessibility: Add support for accessibility-action-* callback (#5073)
Merge branch 'feature/accessibility'

 Conflicts:
	internal/compiler/widgets/cosmic-base/button.slint
	internal/compiler/widgets/cupertino-base/button.slint
	internal/compiler/widgets/fluent-base/button.slint
	internal/compiler/widgets/material-base/button.slint

Also updated license header in actions.slint
2024-04-16 15:02:25 +02:00
Olivier Goffart
bd112a3021 C++: fix code generation of functions that don't return anything
and whose expression return something. Otherwise we get an error:
`return-statement with a value, in function returning ‘void’`
2024-04-16 14:50:55 +02:00
Olivier Goffart
0f05089d5e Polish the C++ and Rust HSV API 2024-04-15 18:18:00 +02:00
Luke D. Jones
0b1ec5e4c9 Convert to struct field access and make HsvColor public 2024-04-15 18:18:00 +02:00