Commit graph

220 commits

Author SHA1 Message Date
Noah Sweilem
6ede27a364 Add text stroke properties to Text element 2024-04-26 13:16:19 +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
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
8c2a798630 Android: long press select word 2024-03-26 14:50:55 +01:00
Olivier Goffart
b46effe65c Android: selection handle
Have two selection handle when there is selected text
2024-03-22 09:19:53 +01:00
Olivier Goffart
881da94737 Move the condition to render the text cursor in TextVisualRepresentation
And add a hack to make the screenshot test pass on Mac
2024-03-21 09:34:52 +01:00
Olivier Goffart
5e66fe9dc8 Fixup cursor color and appearence
On mobile and macOs, the cursor is the selection color.
Also don't show the cursor when there is a selection (all platforms)
2024-03-21 09:34:52 +01:00
Olivier Goffart
528f85509b android: Moving cursor handle 2024-03-20 12:46:10 +01:00
Olivier Goffart
9c3ce701ba Fix cursor geometry: we need to account for the TextInput's own geometry 2024-03-20 12:46:10 +01:00
Tobias Hunger
9873cfd7c0 janitor: Run cargo clippy --fix
Only the hand-picked sensible things, not all of it ;-)

Also fix a few typos that cspell complained about when I
tried to commit and some formatting changes that cargo fmt
insisted on when commiting.
2024-03-14 13:42:38 +01:00
Olivier Goffart
1fb162936e Android: simplify the text input with SpannableStringBuilder
Also needed some change on the Text item to avoid sending ime callback
for intermediate states
2024-02-27 18:29:36 +01:00
Paul Zinselmeyer
73e05aebdb Added flicked-Callback on Flickable
As requested in #1462, I've added a `flicked`-Callback that gets
triggered when the `viewport_x`- or `viewport_y` -Properties are changed
by a mouse drag or mouse wheel movement.
2024-02-26 12:17:31 +01:00
Olivier Goffart
5e7ddf3a19 Image Tiling
(Doesn't work yet with 9slice)
2024-02-26 12:16:41 +01:00
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Olivier Goffart
ce6c7f5527 Image: add horizontal and vertical alignment 2024-02-08 18:59:26 +01:00
Waqar Ahmed
d47b50d5af Make UndoItem repr(C)
The code is more classic style now because the fancy enum can't contain
a non-trivial type
2024-02-08 14:51:14 +01:00
Waqar Ahmed
8c6ff74a6e TextInput: Add undo/redo support
#474
2024-02-08 14:51:14 +01:00
Olivier Goffart
b23c605ac1
Refactoring: Use a trait for Item being Images 2024-02-07 13:28:47 +01:00
J-P Nurmi
031742246c Implement clipping 2024-02-06 18:01:35 +01:00
Simon Hausmann
99d87934c0 Fix build with --cfg=web_sys_unstable_apis
Amends fadcbdf726
2024-02-05 11:50:09 +01:00
Olivier Goffart
fadcbdf726 Android: send the input type to the input method
Also avoid flickering of the input method when inserting text by
preventing sending an imput method event right after deleting the
selection
2024-02-02 11:54:47 +01:00
Olivier Goffart
4a4816afb2 Hold a SlintContext in the Window 2024-01-29 15:34:48 +01:00
Olivier Goffart
fa24283cd4 Add a few funciton to make SlintContext usefull
Make it possible to spawn future and run event loop with a SlintContext
handle
2024-01-29 15:34:48 +01:00
Olivier Goffart
18022b16b0 Move the SlintContext to a different module 2024-01-29 15:34:48 +01:00
Olivier Goffart
3ffe7e7be9 Input method: re-send the text if we notice that the text has changed when rendering
Otherwise, programatic changes to the text are not told to the input
methods.
This is important in the case of the todo example on android.
For example if one type
`foo<enter>bar`, the enter will cause foo to be added in the list, and
the text will be cleared. But then when typing bar, the input method
things "foo" is still in the text and "foo" will be re-added
2024-01-26 13:47:33 +01:00
Olivier Goffart
fce2a80a54 TextInput: Only send the IME if we have the focus
As a side effect this fixes the infinite recursion from #4390
because there is a prevention that focus being sent to the element
inside a ComponentContainer (the bug is that this cause the size to be
computed which cause recursion)
2024-01-24 13:10:31 +01:00
Simon Hausmann
5a49c21c25 Remove unnecessary Pin::new_unchecked in ffi for item member functions 2024-01-23 18:08:27 +01:00
Tobias Hunger
fe0ac9d6e8 FIX: lsp: Improve URL encoding 2024-01-15 14:46:39 +01:00
Olivier Goffart
503baf2898 internal: Move the backend global instance in a SlintContext
The SlintContext will hold all the thread_local state.
A small step in the direction of #4294
2024-01-08 21:17:52 +01:00
Olivier Goffart
e90dfdc41c TextInput: fix focus and virtual keyboard behavior on press/release
I've tried to make sure the behavior match the one of native Window (and
Qt on Linux) apps, and android apps.
Windows set the focus on press, but android set the focus on release.
Also, the paste selection on middle click happens on release on Linux.

On android, when taping a text edit that currently has the focus,
we should show the virtual keyboard again if it was hidden by the user.

Having platform specific behavior like this in i-slint-core is not
optimal, but on the other hand, I'm not sure this deserve a new function
in the Platform trait
2024-01-07 12:42:13 +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
908c68f2a1 TextInput: inserting empty string should do nothing
So that we don't erase selection or call edited unless there is
something typed.

Workaround a bug in which plasma/wayland sends many empty ime event:
```
WindowEvent { window_id: WindowId(WindowId(94309690701616)), event: Ime(Preedit("", None)) }
```

Fixes #4184
2023-12-19 15:36:59 +01:00
Tobias Hunger
2ad9e07225 component_container: Add has-component property
... that returns a bool when a component is set up in the
ComponentContainer.
2023-11-28 10:38:46 +01:00
Olivier Goffart
84202f6af3 Fix ComponentContainer causing panic when using forward-focus
The ComponentContainer is usually instentiated when trying to evaluate a
property such as the geometry or moving the focus. But the init code of
the ComponentContainer would then tries to change the focus which will
indirectly re-visit items and recurse into some property which are being
evaluated.

We do not need to set the focus on instentiation of the
ComponentContainer anyway, intentiating it shouldn't change the current
focus.

This fixes the LSP preview crashing when trying to preview a component
that has forward-focus

Fixes: #3950
2023-11-22 14:13:27 +01:00
Olivier Goffart
5f36eaca9a Android: handle InputEvent::TextEvent 2023-11-02 12:16:40 +01:00
Olivier Goffart
243b44d424 Fix C++ after refactoring of the KeyEvent 2023-11-02 12:16:40 +01:00
Olivier Goffart
f24014a2dd Refactor the internal IME event
Base the info on what's discussed in #3811
but this is just the internal event and not the public API
2023-11-02 12:16:40 +01:00
Olivier Goffart
bebec49398 Refactor input_method_request
Part of #3811

But this is still on the internal trait for now
2023-11-02 12:16:40 +01:00
Tobias Hunger
83e37f7c51 component_container: Do not auto-match the parent's size
This fixes the widget having the right size and sifes some strange
issues I had been wondering about for a while now!

Pass own size to children instead, so that they will always have
matching sizes.
2023-11-01 17:25:42 +01:00
Tobias Hunger
b6b3337430 component_container: Fix background being rendered too big
... and simplify the code, getting rid of the width/height/x/y properties.
2023-10-24 14:12:35 +02:00
Olivier Goffart
5bf2c7192b Fix panic with very large ListView
In `ItemRc::find_sibling` we currently do:
 1. get the range
 2. check that the next index is within the range
 3. call `get_subtree`

The problem is that get_subtree itselg will call 'ensure_updated' which
will do the relayout of the ListView and may get a different range of
element.

So don't query the range before and just have get_subtree to return an
empty ItemWeak if we are out of the actual range.

Couldn't really find a way to make a test since this is called from
the accessibility code which is hard to test as is

For #3700
2023-10-21 14:03:39 +02:00
Tobias Hunger
d6ec7f23a1 Change component factory API
... to avoid winit panicing on us when embedding some item tree.
2023-10-20 15:34:49 +02:00
Tobias Hunger
c1456e5153 component_container: Add background rectangle 2023-10-19 13:22:39 +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
Olivier Goffart
4c0a435196 Implement TouchArea::scroll-event
Closes #1280
2023-10-07 07:59:53 +02:00
Guilhem Vallat
6134d6d873 Clear TextInput selection on FocusOut 2023-09-28 13:11:11 +02:00
Guilhem Vallat
5cf1a45e41 Remove duplicated geometry properties from items 2023-09-13 16:08:37 +02:00
Olivier Goffart
06fc251729 Remove the geometry on ItemVTable 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