Commit graph

430 commits

Author SHA1 Message Date
Olivier Goffart
a1b27c47ae Small cleanup
The is_standard_button is alays true because the None path returns a few line before
2021-10-06 10:53:30 +02:00
Simon Hausmann
d43e0a1c83 Qt style: Only show icons in standard buttons if the style permits 2021-10-06 10:45:31 +02:00
Olivier Goffart
aa05e96d22 Native style: properly initialize the layout padding 2021-10-06 10:43:32 +02:00
ogoffart
8b9717633e Bump version number to 0.1.3 2021-10-05 10:31:45 +00:00
Simon Hausmann
0e8efea2ff Further speed up font handling in the GL backend
Use the new fontdb API:

* When registering embedded fonts, we don't need to make a copy of the
  embedded font data anymore.
* We don't have to mmap the font files ourselves anymore, fontdb can
  do this now for us.
2021-10-04 15:11:55 +02:00
Olivier Goffart
2716e4b4dd TouchArea: add the pointer-event callback
... instead of `pressed-changed`

This allows to see what mouse button was pressed.

Closes #535
2021-10-04 14:39:49 +02:00
Olivier Goffart
dc10916129 Attempt to improve a bit the look of the native scrollbar
This tries to adjust the position of the scrollbar depending of the value of
SH_ScrollView_FrameOnlyAroundContents
2021-10-01 12:58:00 +02:00
Olivier Goffart
e858b3e8d5 Fix TabWidget drawing with the Qt Fusion style
- The Tab must be drawn before the contents, because the style draws something under the active tab,
   outside of its region
 - Also set the QStyleOptionTab::HasFrame flag since we are in the equivalent of a QTabWidget
2021-09-30 19:43:53 +02:00
Olivier Goffart
5935b99c73 Fix indentation 2021-09-30 19:11:40 +02:00
Olivier Goffart
c7227f35cc Native style: Fix size of button with icon
Some styles recompute the size based on the contents given in the QStyleOptionButton,
Some styles need to be given the icon in their content size. And this was not done properly
2021-09-30 19:10:00 +02:00
Simon Hausmann
f6f06a8ccb Fix compilation with Qt 6.2.0 and MSVC
Apply the same fix as woboq/qmetaobject-rs@fb6e8cda64
2021-09-30 15:45:14 +02:00
Olivier Goffart
33e0512448 Qt backend: Fix drawing of the TextInput with vertical alignement
This aligns the text properly in the LineEdit
2021-09-30 13:17:16 +02:00
Olivier Goffart
a72c442b58 Native style: use the QPalette for the placeholder color in a LineEdit 2021-09-30 12:50:30 +02:00
Olivier Goffart
465857c42e Handle the Keypad Enter as Return
Fixes #525 : LineEdit::accepted doesn't react on numpad Enter
2021-09-30 11:48:09 +02:00
Olivier Goffart
671df0f24f New widget: StandardButton 2021-09-29 16:25:44 +02:00
Olivier Goffart
3f13c69ca8 Hide the cursor of the disabled TextEdit
Fixes #513
2021-09-23 12:39:57 +02:00
Simon Hausmann
ac0cc85d33 Simplify font resolution in the GL backend
The font resolution function querying fontdb is fast now, so we can
always call it when rendering text. That way we don't need all the
indirection in the text_size(), etc. functions, we don't need an entry
in the item graphics cache for the font and we can avoid a lot of
property dependencies.
2021-09-21 10:10:45 +02:00
Simon Hausmann
cc7ea5b92a GL renderer: fix rendering of Text/TextInput when the text property changes in a way that requires different fonts
Unfortunately the text property was not included in the property dependency chain
for the cached Font.
This is fixed by delaying that with a getter function, but in the mid term
we should be able to remove this again once
femtovg learns lazy font resolution.
2021-09-17 18:27:44 +02:00
Simon Hausmann
c86f2617b3 Fix natively styled list view item active/inactive rendering
Amends commit ed3d848d02
2021-09-15 15:39:15 +02:00
Simon Hausmann
ed3d848d02 Fix native widget rendering when the window is inactive
Set QStyle::State_Active conditional to whether the window is active,
which maps to Qt's active window concept and winit's has-focus (until we
render popups differently).
2021-09-15 15:34:34 +02:00
Simon Hausmann
1b64db70bd Fix rendering of the current tab in the natively styled tab widget on macOS
It was impossible to see which tab was the current tab.
Ensure that we set State_Active, like we do for the other styled controls.

Later, the active state should be tied to whether the window is "active" or not.
2021-09-15 13:35:41 +02:00
Simon Hausmann
85a46c07b7 Fix panic when using height-for-width element in natively styled TabWidget
The metrics properties and the implementation of layout_info needs to
strictly reading cross-axis properties to avoid circular dependencies.

This patch applies a INT_MAX / 2 on the cross-axis to QStyle when
querying. Mostly the styles appear to just add/subtract margins, so this
value should not produce overflows while still providing an
approximation of "infinite" :)

Fixes #412
2021-09-14 10:05:15 +02:00
Olivier Goffart
cbf22d494e TextEdit 2021-09-06 21:52:12 +02:00
Olivier Goffart
56200fe296 Fixup previous commit 2021-09-06 14:59:19 +02:00
Olivier Goffart
b8c586e96e Qt backend Properly rebuild the c++ source code on changes 2021-09-06 14:58:27 +02:00
Olivier Goffart
f8876fe2b2 Implement the image-rendering in the Qt backend
cc #465
2021-09-06 10:49:56 +02:00
Olivier Goffart
ed24492db7 Only emit click when clicking and releasing the mouse within the TouchArea
Closes #455
2021-09-04 12:36:13 +02:00
ogoffart
e54e03148f Bump version number to 0.1.2 2021-09-04 10:08:51 +02:00
Olivier Goffart
4f1eacd6d8 LineEdit is now able to scroll to keep the cursor visible 2021-09-02 17:20:44 +02:00
Olivier Goffart
50ca8a924c Split qt_widgets.rs in several modules
It was the bigger rust file in the repository
2021-09-02 12:18:21 +02:00
Simon Hausmann
8114e187b0 Unify mouse input event and draw handling between Qt and the GL backend
The unification reduces back-end specific fields for the window and
allows making all the property trackers in the run-time window private.
2021-09-01 18:20:23 +02:00
Simon Hausmann
5dff29ef67 Internal cleanup: Centralize code to determine default font properties
If the root item is a Window, then we use the default-font-* properties as the basis
for all unspecified font properties in text rendering.

This patch centralizes the code for retrieving that in the runtime window.

If this becomes a performance bottleneck, then we could cache it in a
box-pinned property in the run-time window.
2021-09-01 18:20:23 +02:00
Simon Hausmann
549fcb049b Internal cleanup: Move the scale factor property into the shared runtime Window 2021-09-01 18:20:23 +02:00
Olivier Goffart
6e12b4504a A few fixup for the multi-line edit
- Have the cursor at the right place when clicking on end of line
 - make sure not to render new lines if there are some when in single-line mode
 - Enter should make a new line
2021-09-01 16:52:37 +02:00
Olivier Goffart
b2392c25c7 Basic support for Multi-line TextInput 2021-09-01 16:52:37 +02:00
Olivier Goffart
861edf94fd Remove FontMetrics trait
since there is only one function in it, just put that function in the Window
then there is no need to heap alocate a dyn FontMetrics just to call this function.
2021-08-31 13:27:32 +02:00
Olivier Goffart
c1fc242a9a Move the text_input_byte_offset_for_position from the FontMetrics to the Window
In preparation of having mutiple-lines TextInput, we will need to give more
data to this function so it no longer belong in FontMetrics

Also remove the unused FontMetric::line_height()
2021-08-31 13:27:32 +02:00
Olivier Goffart
b04581b64e Fix panic on mouse wheel on a NativeSlider
move the handle instead of panicking
2021-08-31 09:38:21 +02:00
Simon Hausmann
6db89e3468 Fix key events the control modifier on Windows, X11 and Wayland
Under these windowing systems, we receive a QString text from Qt that
contains a terminal control character (like \u{3} for ctrl+c). We
decided to supply the character for the key (for example 'c' for Ctrl+C)
to the application, so activate the conversion from the key code when
control characters are present.

With winit, we receive first a key down input event with the virtual key
code (for example C for Ctrl+C), followed by a ReceivedCharacter event
with a terminal control character. We choose to ignore that and instead
take the previously received key code and try to use that instead.

Fixes #441
2021-08-30 19:07:32 +02:00
Simon Hausmann
90765a97ce Further clean up item graphics cache handling
The RenderCache (slab and generation) is always in a refcell, so we can
just pass that through. This also eliminates the ItemGraphicsCache
wrapper in the GL backend.

This will allow more fine grained borrowing in the future.
2021-08-26 13:46:37 +02:00
Simon Hausmann
cdca921469 Apply the default text color from the style for the color of Text and TextInput elements
We apply a default window background from the palette to all `Window`
elements, and likewise we need to apply the default text color to Text
elements to ensure a readable contrast.

This also fixes the default text color when using Qt/native style in
dark mode on macOS.
2021-08-23 15:03:18 +02:00
Tobias Hunger
60575e7878 Janitor: Fix clippy::iter_skip_next 2021-08-18 00:24:51 +02:00
Tobias Hunger
604f91681b Janitor: Fix clippy::needless_return 2021-08-18 00:24:51 +02:00
Tobias Hunger
a387c0f60f Janitor: Fix clippy::needless_borrow 2021-08-18 00:24:51 +02:00
Tobias Hunger
aea4ecca99 Apply pre-commit hooks to all files 2021-08-17 22:38:16 +02:00
Olivier Goffart
a094ce7a2a Add a warning on the internal crates documentation that we don't follow semver 2021-08-16 18:26:33 +02:00
Olivier Goffart
5ac8010346 NativeButton: set the right icon style 2021-08-13 18:13:16 +02:00
Olivier Goffart
ec529f088b Fix the native style drawn from the GL backend
Femtovg wants RGBA, not ARGB
2021-08-13 18:12:18 +02:00
Simon Hausmann
0852a7661b Fix mutable slice API
* Change SharedVector::as_mut_slice() to SharedVector::make_mut_slice()
* SharedPixelBuffer::as_mut_slice and SharedPixelBuffer::make_mut_slice()
* SharedPixelBuffer::as_bytes_mut() to SharedPixelBuffer::make_mut_bytes()

This is consistent with Rc::make_mut() and is supposed to emphasize
that, unlike the usual as_* operations, it is not a free operation but
may involve work (detaching the data by cloning it).

Amends commit 7384ebdc32
2021-08-10 16:37:34 +02:00
Simon Hausmann
2a420d7a86 Remove imgref dependency from the public Image API
There's only one place where we need this ourselves and that's also
easily done by hand. Otherwise the `as_bytes(_mut)()` accessor provides the
functionality along with `width()` and `height()`.

Other than that the API is mostly consuming, given that `sixtyfps::Image`
has no way of extracting the data again.
2021-08-10 15:56:01 +02:00