Commit graph

444 commits

Author SHA1 Message Date
Olivier Goffart
fabebaa009 Adjust the look of the native StandatdTableView
- The header should be within the frame
 - Use the NativeStandardListViewItem so we have the right alternative
   row coloring and hover
2023-01-23 16:26:49 +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
Simon Hausmann
b6b2a0e555 Fix rendering of #1988's testcase with Qt
Don't rely on the pen not being set when drawing the background of a rectangle
with transparent border. On my machine with the test case the pen has some other
color from previous drawing (or Qt internal?).
2023-01-18 18:05:53 +01:00
Olivier Goffart
4bc7571506
Qt backend: Fix drawing of the border rectangle with non-opaque borders (#2079)
Also fix the border radius to be the outer radius of the rectangle

Qt renderer part of #1988  (minus clipping)
2023-01-18 14:05:12 +01:00
Olivier Goffart
dab95b4220 Native button: highlight on mouse over 2023-01-16 03:12:35 -08:00
Florian Blasius
f2aab576f4
Add StandardTableView widget (#2032)
* Text only StandardTableView with column and rows
* Text editing of cells
* Sort by column ascending and descending
* Variants of the TableView for native, fluent and material
2023-01-12 19:41:12 +01:00
Simon Hausmann
09659eaa42 Improve Qt input event handling
As suggested by @wengxt, we should always clear the preedit when instructed by the IME (via
an empty preedit string). We do that with winit, too.

Relates to #1925
2022-12-22 10:31:01 +01: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
ogoffart
ce07d078ce Bump version number to 0.3.4 2022-12-16 09:36:15 +00:00
Simon Hausmann
b2ebac63c2 Remove component_destroyed from winit's internal renderer interface
The default impl of unregister_component in WindowAdapterSealed would call free_graphics_resources
on the rendere. Any re-implementation would have to do the same,
which the winit backend forwarded through
the winit backend specific internal renderer interface.

Instead, the original call site for unregister_component now calls
free_graphics_resources and unregister_component (for accessibility tree dirty notification).
2022-12-09 09:03:27 +01:00
Simon Hausmann
f5bbca9fce Remove default_font_size() from internal winit renderer interface
Replace register_root_component in the WindowAdapterSealed altogether with
a default font size getter on the renderer.

This is overall simpler and allows removing the doc-hidden getter in the software renderer.
2022-12-09 09:03:27 +01:00
ogoffart
fb02b4118b Bump version number to 0.3.3 2022-11-28 13:11:11 +00:00
Simon Hausmann
247772104a Move WindowEvent, PointerEventButton and Key to the platform module
For `Key` this is a move, as it is a new type. For `WindowEvent` and `PointerEventButton` deprecated aliases
are provided.
2022-11-24 11:34:28 +01:00
Simon Hausmann
0f25000610 internal: Replace calls to the internal process_key_input with the public dispatch_event API
This can be done for key press and release events, for composition we
need to extend the API first.
2022-11-16 09:47:54 +01:00
Florian Blasius
61c39b5fa1 Add support for dispatching key events through the public platform API
This change adds `KeyPress` and `KeyRelease` variants to the
`WindowEvent` enum, along with the new `slint::Key` enum, that allows
encoding keys.
2022-11-15 10:34:17 +01:00
Simon Hausmann
39121994ca Always set Window.default-font-size
Permit the style metrics to provide a `default-font-size` and bind that
to the `Window` if set. If not provided, then the backend can set a
`default-font-size`. By ensuring that the value is non-zero at run-time,
we can later introduce a rem unit that can act as factor relative to
this non-zero font size.
2022-11-03 17:15:44 +01:00
Simon Hausmann
b835290f83 Use LogicalRect for the geometry of popups in WindowAdapterSealed 2022-11-01 12:15:51 +01:00
David John
82278a5742 api: add Window::is_visible 2022-10-29 09:21:26 +02:00
ogoffart
2171773a3e Bump version number to 0.3.2 2022-10-28 09:30:14 +00: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
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
Olivier Goffart
2e08b7dd1e Fix the rendering size of svg
- On the web, to return the image size, we need to use the natural size
   of the image, and not its dom size, as the later get modified since
   commit  b727aba4a0

 - The target size did not take in account the image fit, that's because
   former version of resvg could only render by respecting the aspect
   ratio. But since the web don't have this limitation, we now need to
   take it into account. And new version of resvg can also scale with
   any aspect ratio
2022-10-24 10:05:38 +02:00
Florian Blasius
c58c704f16
Change type of Window background from color to brush (#1755) 2022-10-21 16:17:22 +02:00
Olivier Goffart
6ee932883a Rename stark-style to dark-color-scheme
That's the term used by CSS
2022-10-19 15:23:41 +02:00
Olivier Goffart
0ba468c236 Use a builtin function to access the dark-style
instead of a property on NativeStyleMetrics
2022-10-19 15:23:41 +02:00
Olivier Goffart
eb879a80b5 Ensure that the Qt's NativeStyleMetrics don't crash when called from different threads
The test system may run tests in threads using the fluent style and the
testing backend.  But because the Qt backend is compiled in, the
NativeStyleMetrics is going to be Qt's and it will potentially be
constructed several times in parallel from different thread, causing
warnings and crashes within Qt.
So don't initialize the StyleMetrics, it is only used for the dark style
anyway
2022-10-18 15:54:57 +02:00
Simon Hausmann
0577d8a20d Use physical lengths for the image cache rendering
This avoids accidental use of logical pixels, esp. for SVG, elimiates
one call to `to_untyped()` as well as an untyped scale factor in the
femtovg renderer.
2022-10-13 17:02:18 +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
Simon Hausmann
6913aa16e9 Fix placement of IME suggestions popup with Qt
The suggestions popup from the input method was off by the y-coordinate. This was due to
text_input_cursor_rect_for_byte_offset returning the y position of the line only.
However QTextLine::y() is relative to QTextLayout::position().y(),
which needs to be added to take any vertical alignment into account.
2022-10-13 11:13:13 +02:00
Simon Hausmann
41855b38cf Initial IME support for Qt
This comes with the same caveats as the winit one: The composition is
not committed when clicking with the mouse or generally aborting the
composition.
2022-10-13 11:13:13 +02:00
Simon Hausmann
8cba0622f5 Initial input method support for the winit backend and the FemtoVG/Skia renderers
Known caveats:

- winit doesn't forward mouse events to the IME, so clicking
  with the mouse while composing results in funny effects such
  as the pre-edit text following the cursor.
- With FemtoVG there's no text decoration support, thus no underlining
  of the preedit area.
2022-10-07 11:16:36 +02:00
Simon Hausmann
c40b82c509 Add ItemRc to focus_event and key_event
This will be needed to compute the cursor rectangle in window coordinates, by
traversal of the parent chain.
2022-10-07 11:16:36 +02:00
Simon Hausmann
2da2511f13
Use a vector for ItemRenderer::translate (#1700)
This simplifes call sites and implementations.
2022-10-02 10:06:20 +02:00
Simon Hausmann
37a8c50c12 Simplify FontRequest
It doesn't have to be generic as mostly the frontend code creates it with logical lengths.
2022-09-30 23:31:32 +02:00
Simon Hausmann
cc8ff56d98 Remove more uses of LogicalRect::from_untyped() 2022-09-30 13:00:37 +02:00
Simon Hausmann
a52d633b59 Change FontRequest to be a generic over the length
The API uses a logical length for pixel sizes and letter spacing,
but the renderer will need the physical length eventually.
2022-09-30 13:00:37 +02:00
Simon Hausmann
1624a66ebc Change the Renderer trait's text related functions to explicitly operate on logical lengths 2022-09-30 13:00:37 +02:00
Simon Hausmann
59368363c9 Change the ItemRenderer trait to use logical lengths 2022-09-30 13:00:37 +02:00
ogoffart
261614b914 Bump version number to 0.3.1 2022-09-15 14:39:51 +02:00
Simon Hausmann
dba137e3ba
Rename RequestedSize to WindowSize and RequestedPosition to WindowPosition (#1640) 2022-09-14 12:59:53 +02:00
Tobias Hunger
53a3c72b57
api: Change logical/physical position and size on window (#1620)
* Add `RequestedSize` and `RequestedPosition` enum to enable asking for
  logical or physical size/position.
* Rename `Window::size()` to `Window::physical_size()`
* Make `Window::set_size(...)` take an `Into<RequestedSize>`
* Rename `Window::position()` to `Window::physical_position()`
* Make `Window::set_position(...)` take an `Into<RequestedPosition>`
* Change `WindowAdapter` and related classes to be able to handle
  requests being made in the either physical or logical units.

Implement this for C++, Rust and node.
2022-09-13 08:55:31 +02:00
Olivier Goffart
911515bfd0 Fix the initial window size when the height depends on the width
We need to assign the width beofre computing the preferred height
otherwise zero or very small value can be assumed and it will case the
text engine return a huge preferred height.

Testcase:

```
export App := Window {
  VerticalLayout {
    padding: -10px;
    Text {
        text: "Lots of text with\nnewlines etc.\n lorem ipsum dolor sit amet";
        wrap: word-wrap;
    }
  }
}
```

In particular, this fixes the gallery window size being too high when
using the skia renderer, because when given a zero width, skia return
a big size for the height, (contrary to the Qt backend that consider 0
as infinite, or the femtovg backend that will stop rendering once a line
can't fit)

Replaces #1621
2022-09-12 12:12:18 +02:00
Olivier Goffart
6ede77436b api: Return an error from invoke_from_event_loop and quit_event_loop 2022-09-07 10:13:58 +02:00
Simon Hausmann
7967bf1ab0 Replace the internal WindowHandleAccess trait with a helper function on WindowInner
The reversal of ownership removes the need for the glue trait in the
publicly visible API.
2022-09-06 16:17:06 +02:00
ogoffart
05a49da906 Bump version number to 0.3.0 2022-09-06 13:00:22 +02:00
Simon Hausmann
7e5de3d5d3 Remove use of euclid types and tags for logical/physical position and size in the public API
Instead provide our own types.
2022-09-02 11:05:53 +02:00
Simon Hausmann
85461d380d Remove euclid from the public re-export of the Slint crate 2022-09-02 11:05:53 +02:00
Olivier Goffart
fcca38e0f6 Rename set_event_loop_quit_on_last_window_closed to remove EventLoopQuitBehavior
For the winit backend, also make the function work after a call to run()
2022-09-01 12:08:05 +02:00