Commit graph

157 commits

Author SHA1 Message Date
Olivier Goffart
a9f526491a Timer Element
Closes #5724
2024-08-16 16:36:38 +02:00
Olivier Goffart
3a12ebf7ab Report an error when accessing a function within a PopupWindow
instead of panicking

Fixes #5852
2024-08-16 10:31:13 +02:00
Olivier Goffart
9b71cf1a36 Math postfix member functions on numbers
Closes #5328
2024-08-15 14:52:13 +02:00
Olivier Goffart
875d20f1ac Add test for deprecated import
Should have been part of a0dd978f8a
2024-07-03 16:44:31 +02:00
Olivier Goffart
66370b6bda
Add export { ... } from "....slint"; syntax. (#5533) 2024-07-03 12:50:40 +02:00
Simon Hausmann
7896e645b2 Permit rotation properties on Text elements without children
This works with Skia, Qt, and FemtoVG.

cc #1481
2024-07-03 09:08:23 +02:00
Olivier Goffart
a63618fcfe Fix error messages with invalid change callback 2024-06-28 10:45:45 +02:00
Olivier Goffart
42a2c6a569
Only generate code for the exported Window
Have a warning when a component is exported from the main file and
doesn't inherit Window.
Unless it's the last component, for compatibility with Slint 1.6

Also don't warn in the interpreter
2024-06-25 15:13:06 +02:00
Olivier Goffart
539abfc550 Revert "Add a warning if a PopupWindow is in a layout"
This reverts commit 66652cdc1d.

The warning in the gallery are hard to fix because the component inherit
from a layout and there is nowhere to place the popups
2024-06-24 16:38:37 +02:00
Olivier Goffart
8933f3308c Remove the error when using @children on the root component
This complicates multi-component handling
2024-06-21 11:58:09 +02:00
Olivier Goffart
acb7da11d2 fix missing warning of missing export
... for last component when globals are exported
2024-06-21 11:57:49 +02:00
Olivier Goffart
47a61dda10 Fix compiler crash with invalid code 2024-06-11 19:22:59 +02:00
Olivier Goffart
42704eee65 Fix @children in a PopupWindow
Fixes #5375
2024-06-10 22:18:06 +02:00
Olivier Goffart
66652cdc1d Add a warning if a PopupWindow is in a layout
This is not intuitive since the position of the PopupWindow will not be
handled by the Layout
2024-06-04 13:31:36 +02: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
8221e2e4b2 Fix stack overflow in purity check
Fix #5220
2024-05-29 06:42:37 +02:00
Olivier Goffart
bc8e18e148 Fix compiler panic when trying to set a function in a state
Fixes #5246
2024-05-28 17:25:15 +02:00
Olivier Goffart
61233d8f6b Only mark builtin StyleMetrics as deprectated.
User defined component or global named StyleMetrics shouldn't be deprecated
2024-05-28 13:45:56 +02:00
Olivier Goffart
25ef8f8711 Fix declaring callback alias that override a property
Do the check for existing property before handling of callback aliases

Fixes #5205
2024-05-10 13:50:04 +02:00
Olivier Goffart
0929e3dfc1 Slint: make the abs work with unit types 2024-05-08 19:04:22 +02:00
Olivier Goffart
af1aa2991e
Fix component that inherits from PopupWindow
This regressed in commit 12d904a71c
which changed the order of the pass to get the lower_popup pass before
the first inlining pass.
If by chance (which is likely if one have children), the component that
inherits from PopupWindow was inlined in that pass, it would be as
if it was not a component, and it would be removed from its parent.
But since it is no longer inlined, we need to support that case and
delay the removal when processing the component that holds that popup.
2024-05-06 13:20:25 +02:00
Olivier Goffart
2e4d1f2427 WIP: work on changed callback 2024-05-02 22:25:53 +02:00
Simon Hausmann
10e5c228b7 Fix calling clear-focus() on non-focusable elements not producing an error 2024-04-26 11:09:11 +02:00
Olivier Goffart
0f05089d5e Polish the C++ and Rust HSV API 2024-04-15 18:18:00 +02:00
Simon Hausmann
ae2e0197f8
Deprecate the use of StyleMetrics for users of the public API (#4947) 2024-04-15 17:07:05 +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
ea0227098a Throw an error when a callback aliases itself
Instead of panicking
Fixes #4938
2024-03-26 18:14:31 +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
Olivier Goffart
42a4286048 Fix missing error when calling argb() with too many arguments
This is technically a breaking change if someone was calling it with too
many args by mistake, but i think it's fine to do this as a bugfix
2024-03-22 14:57:07 +01:00
Olivier Goffart
c553eb4398
compiler: Don't panic when using foo.focus(something)
Just ignore the case where focus has more argument that planed as it has
been reported as an error earlier.

Also fix the error message for calling member function with the wrong
number of argument to not include the base in the count.

Fix #4883
2024-03-19 11:06:08 +01:00
Olivier Goffart
255dc59ef4 Rename @image-url(..., 9slice(...)) to @image-url(..., nine-slice(...))
As per API review:
 - In the Rust and C++ API we use `set_nine_slice_edges` because the getter couldn't start with 9
 - in english we spell number less than 10 with letters and this is a name
2024-03-07 17:01:57 +01:00
Olivier Goffart
11e8070726 Compiler: fix lookup of the model not seeing that the element is being repeated
The problem is that we were taking the whole `repeated` field and as a
result we wouldn't see that the element was being repeated and that we
shouldn't have to lookup id within it

Fix #4683
2024-02-26 12:16:51 +01:00
Olivier Goffart
22d9fc9cf9 @image-url: Semantic analysis of the 9slice 2024-02-13 14:46:27 +01:00
Olivier Goffart
6e2280ece3 Parse 9slice in @image-url 2024-02-13 14:46:27 +01:00
Simon Hausmann
7ce0bd493a Fix panic when using foward-focus with non-element binding
Since commit 6fefe75a1c the handling
of forward-focus bindings happens before the resolve_expressions pass,
which means that we cannot rely on type mismatch
error handling yet.

Fixes #4475
2024-01-30 10:09:07 +01:00
Simon Hausmann
6fefe75a1c Don't require components that use forward-focus to be inlined
Achieve this by generating a `focus()` function for such components
and call it from the outside.

This replaces the previous focus handling with what should be cleaner:

- Any `forward-focus: some-element;` is basically syntactic sugar for
 `public function focus() { some-element.focus(); }`.
- The init code gets simplified to calling focus() on the root, if it's
  available.

Since the `focus()` functions are now generated in the imports pass,
they become visible in the style checker. That means the checker
requires consistent focus handling between the styles.
2024-01-26 12:16:09 +01:00
Olivier Goffart
2564eede9f Compiler: avoid two error message when trying to call a non-existing function 2024-01-24 20:06:48 +01:00
Olivier Goffart
638985612c Test purity of model expression 2024-01-11 15:13:01 +01:00
Olivier Goffart
2ce161ced8 Parser: Hint for the mod function when parsing %
Was reported several times:
 - https://github.com/slint-ui/slint/discussions/4190
 - https://github.com/slint-ui/slint/issues/3980
2023-12-19 17:23:30 +01:00
Olivier Goffart
85526d772e Fix detection of properties when they are only used in two way bindings
Fixes #2166
2023-12-19 11:14:53 +01:00
Olivier Goffart
5d4c390b0f
Compiler: Error when assigning to compile time properties
Some property need to be known at compile time. We already had checks
that the binding is a compile time constant, but there was no check to
prevent, say

    self.row = 42;

which wouldn't work or could even cause panic or miscompilation of
generated code

Closes #4037
2023-12-12 21:51:56 +01:00
Tobias Hunger
2ad8774a61 Add clamp function to slint language 2023-11-22 12:27:54 +01:00
Olivier Goffart
678afb3ba0 Throw an error when returning no value when one is expected.
Previously we were likely to get error in the compiled code anyway.
(although the interpreter worked fine)

Fixes #3962
2023-11-20 13:50:57 +01:00
Olivier Goffart
ac8fd60091 Fix regression with empty array
Regression noticed in this line:
3f97d98bff/ui/tabs/downloads.slint (L77)

The following used to work:

```slint
import { Button, VerticalBox } from "std-widgets.slint";
export component Demo {
    in property <[int]> mods;
    VerticalBox {
        alignment: start;
        for xxx in true ? mods : [] : HorizontalLayout { alignment: center; Button { text: "OK!"; } }
    }
}
```

But we fixed array conversion and this caused a regression with empty
array
2023-11-01 11:30:59 +01:00
Olivier Goffart
85ca10d32e Disallow access to internal globals (NativeStyleMetrics and SlintInternal)
It only stay accessible in our builtin styles

Fixes #3793
2023-10-28 16:07:38 +02:00
Olivier Goffart
ae4debafe2 Compiler: Don't panic when a Row is repeated in a GridLayout
Fixes #3729
2023-10-23 19:43:46 +02:00
Olivier Goffart
166f19aeff
Fix compiler panic when trying to resolve aliases in invalid import
Fixes #3674
2023-10-16 16:37:49 +02:00
Tobias Hunger
b12575a4c4 janitor: Go over our spell checking setup
* Extend the cspell word list
* Remove those extensions from individual source files
* white-list licenses and such as we should not meddle with those
* Fix spelling
2023-10-16 09:01:51 +02:00
Olivier Goffart
8f001ac490 Add support for protected functions
Protected function can only be called from the direct base

Issue #3636
2023-10-11 10:50:50 +02:00