Commit graph

220 commits

Author SHA1 Message Date
darknight
5e5bbed8ee Expand InputType to support number & decimal 2023-09-07 14:56:45 +02:00
Olivier Goffart
a29123a498 Remove invalid comments seen in the code review 2023-07-27 12:04:16 +02:00
Tobias Hunger
baa4eb1ea3 Get rid of the window when building an embedded component
... now that we can get the WindowAdapter from the parent component when
we embed it.
2023-07-27 12:04:16 +02:00
Tobias Hunger
9de515b768 Implement embedding in rust 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
05e9ce078a Add a simplistic ComponentContainer element
It just registers the type, nothing more.
2023-07-27 12:04:16 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Olivier Goffart
7a88dba2e7 Add clear-selection() to all our input fields 2023-06-28 17:07:55 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +02:00
Olivier Goffart
a0dd643d83
TextEdit: Discard the preedit when focus change or other text is enter (#3000)
Otherwise we end up with outdated pre-edit data if we change focus while
editing.

Note: Qt doas actually send a "commit" event when the focus change
(but of course that does not happen when changing the focus within
slint)
But firefox does discard the preedit when loosing the focus.

CC #1925
2023-06-28 12:01:41 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Olivier Goffart
0e31f097a4 Un-seal the WindowAdapter trait 2023-06-13 17:44:04 +02:00
Simon Hausmann
01b00d26eb Rust: Allocate the window adapter lazily
This will be needed for embedding - to avoid creating two window
adapters - and it will be needed for the API to allow creating a
component from an existing window.
2023-06-10 11:41:04 +02:00
Simon Hausmann
f9ba8023d4 Fix read-only TextInput reporting input method access
When the TextInput item is read-only, it should not report availability
or any other status to the input method via the window adapter.

This also fixes the order of events when clicking on a TextInput: We
would send the ime position update request before enabling the ime,
because we set the focus _after_ setting the cursor pos.

Fixes #2812
2023-06-05 14:55:22 +02:00
Simon Hausmann
c428601370
Add support for select-all(), cut(), copy() and paste() functions on text input elements (#2804)
In the compiler this is still very primitive, but an attempt to start a
generic interface. The basic assumption is that all item functions will
eventually need access to the window adapter and itemrc. Support for
additional arguments is still missing.

Also missing is support for the function access via rtti in the
interpreter, hence the hardcoding at the moment.
2023-06-01 16:04:53 +02:00
Simon Hausmann
3cf1b38a48 Add basic support for italic font face selection to Text and TextInput
This is implemented for FemtoVG, Skia, and Qt.
2023-05-31 18:47:39 +02:00
Olivier Goffart
a68df6eb70
WindowAdaptor: change the 3 ime call into one single ime request enum (#2747) 2023-05-17 17:50:19 +02:00
Simon Hausmann
8a2b40ca7d Simplify core Renderer trait for easier implementation
Make text_input_byte_offset_for_position and text_input_cursor_rect_for_byte_offset
low-level in the API, where the implementation becomes easier. Two
helper functions in TextInput in turn collect the necessary parameters
and thus also reduce the amount of duplicated code.

This also decouples the renderer further from the window.
2023-05-17 09:01:02 +02:00
Olivier Goffart
6db08553a1 Wasm: Fixup Copy/paste
The PR #2703 wasn't complete and didn't work in practice because the
clipboard is always None.

Using the clipboard event data works
2023-05-16 22:41:38 +02:00
Amirhossein Akhlaghpour
2e8708be87
Feature: Add copy/paste listener on Wasm (#2703) 2023-05-09 15:55:35 +02:00
Olivier Goffart
37e70c302e Refactoring: Pass the size to to the render function
So that we don't need to query the geometry multiple time, and this pave
the way to not have the geometry in the items

Part of #1932

As a drive by, fix the clipping of the Path element which incorrectly
offseted the clip by (x,y).
Similar fixes happen in the Clip element in some renderer, but that
didn't have effect because x and y are always 0 for the Clip element
2023-05-05 19:53:57 +02:00
Simon Hausmann
fde7f0800c Add some doc comments for TextVisualRepresentation 2023-04-26 17:48:46 +02:00
Simon Hausmann
ec6f91b190 Fix up docs for apply_password_character_substitution
Explain the purpose of the password_character_fn
2023-04-26 17:48:46 +02:00
Simon Hausmann
85da840603 Fold TextVisualRepresentation::apply_password_character_substitution into the TextInput's visual_representation() function
That way the call doesn't need to be duplicated on all call sites.
2023-04-26 17:48:46 +02:00
Simon Hausmann
baba08baeb Move the default password character into corelib
And only let Qt customize it
2023-04-26 17:48:46 +02:00
Simon Hausmann
d757456c5a Centralize all password character substitution in corelib
Use TextVisualRepresentation also in text_input_byte_offset_for_position
2023-04-26 17:48:46 +02:00
Simon Hausmann
fd9a2638b7 Use the common TextInputVisualization::apply_password_character_substitution also for the Qt renderer 2023-04-26 17:48:46 +02:00
Simon Hausmann
0bf4916a5f Skia: Add support for password input fields
Fixes #2619
2023-04-25 15:26:39 +02:00
Olivier Goffart
a57c7eb6bc Added TextInputInterface.text-input-focused 2023-04-12 14:49:08 +02:00
Olivier Goffart
35c5325fa5 Review the items that should have a stretch of 1 in a layout 2023-03-24 11:15:05 +01:00
Olivier Goffart
233bc61c8e Flickable: capture the event if the flickable can flick even if it is at the end
When scrolling the printer demo, I often end up closing or opening
element i don't want to because we reached the end and therefore it is
not scrolling and forwarding the event
2023-03-09 11:35:57 +01:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Olivier Goffart
5146c52d20 Flickable: Shift + mouse scroll reverts scroll dirrection
Closes #2228
2023-02-16 14:01:34 +01:00
Olivier Goffart
96c17e9563 TextImput: Shift+Click selects 2023-02-06 09:14:29 +01:00
Olivier Goffart
9e48e5eee3 TextInput: implement double-click and drag
(and tripple-click and drag)
2023-02-06 09:14:29 +01:00
Olivier Goffart
f34b1bda2e Add primary keyboard support on unix (selection copy, middle click paste)
Closes #2146
2023-01-31 16:39:22 +01:00
Florian Blasius
d84de623b4
TextEdit select text with double and dribble click (#2088)
* Select word in `TextEdit` by double click
* Select paragraph in `TextEdit` by dribble click
2023-01-31 15:04:19 +01:00
Simon Hausmann
5ff0278185 Simplify path event extraction
Return the path events for rendering as an Option, so that if the path is empty,
we simply return.

This avoids a double property dependency in the (likely) event the path is not empty.
2023-01-21 13:10:19 +01: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
b165cdb160 Flickable should not accept mouse release event if it was not flicking
We need to continue propagating the release event to other element (eg
other flickable)

Fix the flickable flicking even though the mouse is released if there are
several Flickable in the component.
2022-11-24 14:55:46 +01:00
Simon Hausmann
3d2daf6073
Fix crash when editing text that's rendered using the Skia renderer (#1786)
Olivier found the following steps that reproduce the crash with Skia:

1. Open the gallery and select the "Text Edit" tab.
2. In the first text edit widget, select the first three letters.
3. Click into the second text edit (while the first one shows the selected text)
4. At the beginning of the text, insert the letter "ù" a few times.

This sequence would result in the cursor_position property get out of
sync.  Since it represents a byte offset in the utf-8 text, it would
point straight into a utf-8 sequence, resulting in a panic when the
renderer would try to create a slice of the selected text.

As a remedy, this patch renames the cursor_position and anchor_position
properties and provides wrapper getter accessors for use within the
TextInput to safely bound the stored offset.

Eventually we need to intercept changes to the text property and adjust
the cursor and anchor position properties accordingly, so that they
remain valid.  However this requires that the compiler is aware that a
property is not accessible directly but has a setter that needs to be
called instead.

This likely/hopefully also fixes #1707.
2022-10-27 21:47:14 +02:00
Olivier Goffart
788e24494b Flickable: do not capture the event when moving the mouse bellow threshold
Because an inner item (eg, another Flickable) way still want
to intercept the delayed event
2022-10-27 18:55:47 +02:00
Olivier Goffart
6e87073181 Flickable: only grab the mouse if the flickable can be flicked
We already checked before that we can flick in that direction
(horizontally or vertically), but we did not check that we were not
actually at the end already.
2022-10-27 18:55:47 +02:00
Olivier Goffart
f055afd2de New syntax: allow to create component without base 2022-10-26 18:09:57 +02:00
Simon Hausmann
c16253d29f Use Property<LogicalLength> instead of Property<Coord>
This removes the special code for the generated property getters and
ensures type safety in the run-time library for property value setting.

In the Rust generated code we continue to do arithmetic on the scalar
values, that means we immediately extract the scalar, do arithmetic and
rely on the compiler to only allow compatible units.

Danger zone alert: In the interpreter Value::Number can now be converted
to LogicalLength as-is.
2022-10-24 12:49:37 +02:00
Simon Hausmann
38a55f87a4 Change internal MouseEvent to use logical points 2022-10-13 17:02:18 +02:00
Simon Hausmann
c11b4305c1 Change Item::geometry() to return a LogicalRect 2022-10-13 17:02:18 +02:00
Simon Hausmann
299325370d Change generated accessor functions for Property<Coord> getters to return LogicalLength 2022-10-13 17:02:18 +02:00