Commit graph

239 commits

Author SHA1 Message Date
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
Luke D. Jones
d4a3f77877 feat: color: add HSV methods to slint 2024-04-15 18:18:00 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Olivier Goffart
523e1a161c WIP: More on support for accessibility actions
Continue with the core library support and the compiler support.

This hasn't been tested yet and is missing implementation in the
backends
2024-03-28 11:28:56 +01:00
Florian Blasius
b0549b50c6 (wip) Added accessibility_action and supported_accessibility_action to ItemTreeVTable 2024-03-28 11:28:56 +01:00
Simon Hausmann
68083243b2
Add an in-out boolean color-scheme property to Palette (#4701)
This allows applications to force dark/light mode, as well as determine
which mode is active.
2024-03-26 15:44:22 +01:00
Tobias Hunger
28b96ca6f6 janitor: manual cargo clippy fixes
Semi-random selection of clippy topics that were
uncontroversial before:-).

Leaves about 84 deduplicated issues in the code base
according to clippy from nightly.
2024-03-14 13:42:38 +01:00
Olivier Goffart
b844f76842 Add test and fixup color red/green/blue fields 2024-03-12 11:36:30 +01:00
Luke D. Jones
8c60cc74be feat: color: add channel properties to color
Add extra properties to the `color` type.
- `red`
- `green`
- `blue`
- `alpha`
2024-03-12 09:42:30 +01:00
Wilston Oreo
bef532b5fc
Optional C++ namespaces (#4759)
Co-authored-by: Michael Winkelmann <michael@winkelmann.site>
2024-03-06 19:43:11 +01:00
Olivier Goffart
5fe68e1746 Fix animation when started from a different item tree
Fixes #4741

This commit move the property_binding_and_analysis from the inlining
pass to an associated funciton in the context.
Then re-use that from the rust and c++ generator to actually get the
right animation
2024-03-05 12:27:11 +01:00
Olivier Goffart
190273d293 C++: fix enum with dashes 2024-02-22 10:41:45 +01:00
Olivier Goffart
b5abee6c8d C++: fix compilation when class name has an underscore
Fixes: #4659
2024-02-22 10:41:45 +01:00
Olivier Goffart
dab4ea44cd Fix C++ compilation with nightly rust
```
error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
    --> internal/core/item_tree.rs:1035:32
     |
1035 |             Pin::new_unchecked(&*(&**component as *const Dyn as *const u8)),
     |                                ^^^^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |                                    |
     |                                    backing allocation comes from here
     |
     = note: casting from `vtable::Dyn` (0 bytes) to `u8` (1 bytes)
     = note: `#[deny(invalid_reference_casting)]` on by default
```
2024-02-14 10:15:07 +01:00
Olivier Goffart
97067c3d65 Add 9slice information at runtime 2024-02-13 14:46:27 +01:00
Brandon Fowler
3e8940660b
Add set-selection-offsets function to TextInput, TextEdit, and LineEdit (#4197)
The function accepts two arguments that specify the start and the end of the text to select.

Fixes #4164
2024-01-06 11:12:53 +01:00
Olivier Goffart
6195fc8567 Fix compilation when dividing by zero at compile time
Rust would have panicked and C++ generated wrong code.

CC #3982
2023-11-27 17:09:57 +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
172dcfa775 C++: fix crash when accessing empty model from Slint
Fixes #3704
2023-10-19 18:09:14 +02:00
Olivier Goffart
4bbfbd541b Prospective fix for MSVC warnings
Warning looks like that

```
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\tuple(144,47): warning C4244: 'initializing': conversion from '_Ty' to '_Ty', possible loss of data [D:\a\slint\cppbuild\examples\virtual_keyboard\cpp\virtual_keyboard.vcxproj]
            with
            [
                _Ty=int
            ]
            and
            [
                _Ty=float
            ]
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\tuple(239): message : see reference to function template instantiation 'std::_Tuple_val<_This>::_Tuple_val<_Ty>(_Other &&)' being compiled [D:\a\slint\cppbuild\examples\virtual_keyboard\cpp\virtual_keyboard.vcxproj]
            with
            [
                _This=float,
                _Ty=int,
                _Other=int
            ]
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\tuple(239,81): message : see reference to function template instantiation 'std::_Tuple_val<_This>::_Tuple_val<_Ty>(_Other &&)' being compiled [D:\a\slint\cppbuild\examples\virtual_keyboard\cpp\virtual_keyboard.vcxproj]
            with
            [
                _This=float,
                _Ty=int,
                _Other=int
            ]
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\tuple(802): message : see reference to function template instantiation 'std::tuple<float,float,float,float>::tuple<std::_Exact_args_t,int,float,float,int,0>(_Tag,_This2 &&,float &&,float &&,int &&)' being compiled [D:\a\slint\cppbuild\examples\virtual_keyboard\cpp\virtual_keyboard.vcxproj]
            with
            [
                _Tag=std::_Exact_args_t,
                _This2=int
            ]
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\tuple(802,12): message : see reference to function template instantiation 'std::tuple<float,float,float,float>::tuple<std::_Exact_args_t,int,float,float,int,0>(_Tag,_This2 &&,float &&,float &&,int &&)' being compiled [D:\a\slint\cppbuild\examples\virtual_keyboard\cpp\virtual_keyboard.vcxproj]
            with
            [
                _Tag=std::_Exact_args_t,
                _This2=int
            ]
```
2023-10-09 17:25:24 +02:00
Olivier Goffart
a5488d6285 Rename RepeatedComponent -> RepeatedItemTree
And some more cleanups
2023-10-09 11:01:56 +02:00
Olivier Goffart
852b4d906d Rename ComponentVTable to ItemTreeVTable
and their related name.
Also move the component module in the item_Tree module
register_component -> register_item_tree
ComponentItemTree -> ItemTreeNodeArray

For #3323

Rationale from that issue:

Right now, we use the term `component` in the Slint language and in the compiler to be a a tree of elements that can be used as an element in a .slint file.

The term is also currently used in the runtime as a tree of runtime Items that are allocated together. (declared in ComponentVTable)

But there are no 1 to 1 mapping between a `component` in the slint language, and a runtime Component.
(for example, the items behind a `if` or `for` or `PopupMenu` are in a different runtime component. And `component` declared in Slint are often inlined)

So we should rename the internal runtime `Component` to  `ItemTree`

The currently public `slint::ComponentHandle` wraps the "root" of the ItemTree, but that's ok because it is generated from a .slint `component`,  so it doesn't change name
2023-10-09 11:01:56 +02:00
J-P Nurmi
8dd51f76f1
Fix named exports in native code (#3602) 2023-10-05 16:41:10 +02:00
Olivier Goffart
f546d22861 C++: Fix crash when deleting a component from the click event within a sub component
The parent is already deleted when we delete the component that is kept
alive by the `grabber` ItemRc in `handle_mouse_grab`
When the ItemRc goes out of scope, we delete the component, but the
parent was already gone.

This doesn't solve a broader issue that we use the parent in many place
and it is not kept alive (for example when using properties of the
parent)
2023-09-14 11:34:18 +02:00
Olivier Goffart
e04835d209 Fix computation of the item sub range
We need to account for the repeater count in the item sub-range
2023-09-13 16:08:37 +02:00
Olivier Goffart
e0fd9a6105 WIP: Add item_geometry to the ComponentVTable
(unused yet)
2023-09-13 16:08:37 +02:00
Olivier Goffart
2a8ebb9752 Flickable: don't make the viewport special
Instead: add the viewport propety directly in the Flickable

Simplifies the compiler's code generation a bit
2023-09-13 16:08:37 +02:00
Simon Hausmann
3652f58a3f Change item indices from usize to u32
So that the compiler and run-time can never disagree on the
number of bytes the item index can use.
2023-09-12 08:53:58 +02:00
Olivier Goffart
cf19749943
Make a pass to remove the Expression::Return instruction
So it doesn't appear in the LLR and the C++ codegen can be simplified.
In particular, this removes the need to throw/catch exception to handle return
across generated lambdas
2023-09-06 14:10:26 +02:00
Simon Hausmann
21d44e3a31 Fix data section placement for pre-compiled textures in C++
Place pre-rendered textures into read-only data, instead of the data
section.

Amends 3db168d03d
2023-08-23 18:57:40 +02:00
Simon Hausmann
e683a6338a Make inclusion of various C++ header files optional
Only include iostream, cmath, and cstdlib if needed.
2023-08-21 17:56:50 +02:00
Simon Hausmann
8d0a73c1d4 C++: Add iostream to the list of included header files
When using debug() we generate calls to `std::cout`.
2023-08-21 17:56:50 +02:00
Simon Hausmann
ad84114bae Fix build of generated C++ code with older macOS versions
Avoid the use of std::optional<T>::value.

Amends 0ba6ef1c24
2023-07-31 14:37:45 +02:00
Tobias Hunger
a362b7a1ae Add window_adapter to ComponentVTable
Make it duplicate as `maybe_window_adapter` with a boolean `do_create`
parameter.
2023-07-27 12:04:16 +02:00
Tobias Hunger
d47d52bf52 ItemVTable::init(...): Take an ItemRc so that the itan can know where in the Item Tree it is located 2023-07-27 12:04:16 +02:00
Tobias Hunger
74ef877f70 Add embed_component to ComponentVTable 2023-07-27 12:04:16 +02:00
Olivier Goffart
bde0ae7585 Compiler: Fix access_item_rc in the generator for complex path
Fixes #3148
2023-07-26 13:45:20 +02:00
Guiguiprim
ef8ddaaa1d
Add native support for min/max 2023-07-21 16:26:41 +02:00
Simon Hausmann
0b760cc7f7 Fix C++ embedded glyphset generation
Declare the correct array length

Amends 917cecff85
2023-07-20 18:17:05 +02:00
Simon Hausmann
3db168d03d C++: Attempt to place embedded into read-only data sections 2023-07-20 16:20:51 +02:00