Commit graph

1092 commits

Author SHA1 Message Date
Olivier Goffart
503a9b3722 Avoid spurious "cancel" event sent to TouchArea.pointer-event 2021-10-11 10:19:59 +02:00
Olivier Goffart
40e0698373 TouchArea: Grab the mouse regardless of the button 2021-10-11 10:19:59 +02:00
Olivier Goffart
3b6e0e5802 Fixes the PointerEvent.kind always being down
Fixes #558
2021-10-08 16:56:35 +02:00
ogoffart
77fcd5221b Bump version number to 0.1.4 2021-10-07 09:36:43 +00:00
Simon Hausmann
e987a4aba3 Fix granularity of run-time borrows in GL backend window handling
When processing window specific events, or generally when accessing
the ALL_WINDOWS refcell, keep the time for borrow to an absolute
miniumum. That way any subsequent method calls may further acquire the
refcell.

This patch re-organizes the entire deeply nested window event handling
in a function with slightly less indentation.

Fixes a panic when calling hide on a Window from within a callback
handler.

Fixes #539
2021-10-05 12:43:11 +02:00
ogoffart
8b9717633e Bump version number to 0.1.3 2021-10-05 10:31:45 +00:00
Olivier Goffart
ae3e1b4680 Allow normal Element to be in the Dialog's button row with dialog-button-role 2021-10-05 09:46:20 +02:00
Olivier Goffart
8150bb027b Fix ListView not always making the window to be redrawn when a model change
Example: expending or collapsing the cargo-ui dependency tree after scrolling.
2021-10-04 16:15:36 +02:00
Olivier Goffart
94f55ba29e Janitor: Make sure the variable means what it says
The variable "geometry_changed" was true when the geometry was not updated.
Rename the variable and make it sure it has a proper meaning.
(Doesn't change the logic of the program)
2021-10-04 15:53:51 +02: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
0aecece4ef Add moved and pressed-changed callback to TouchArea 2021-10-01 14:53:25 +02:00
Olivier Goffart
9936dfc0eb Apply suggestions from code review
Co-authored-by: Simon Hausmann <simon.hausmann@sixtyfps.io>
2021-09-29 16:25:44 +02:00
Olivier Goffart
7f05bfa309 Add the Dialog element 2021-09-29 16:25:44 +02:00
Olivier Goffart
671df0f24f New widget: StandardButton 2021-09-29 16:25:44 +02:00
Simon Hausmann
fc491b167f Add a doctest for sixtyfps::Image::path() 2021-09-28 08:52:27 +02:00
Simon Hausmann
4eef8c7688 Add API to sixtyfps::Image in Rust and C++ to access the optional path 2021-09-28 08:52:27 +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
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
5fc5563c99 Minor cleanup: Replace expect() with unwrap() and comment
That's the more common pattern we use currently.
2021-09-15 08:49:27 +02:00
Simon Hausmann
5742a122ed Fix listview not updating its geometry in Rust when the entire model is changed
The geometry tracker did not track the model property itself, so it did not become dirty.

Fixes #500
2021-09-15 08:49:27 +02:00
Simon Hausmann
ce1e5fa19d Minor code cleanup
For item rendering, place the rendere into a refcell only for the time
we're visiting the tree.
2021-09-14 15:20:21 +02:00
Olivier Goffart
fafcbfde2c Fix panic when trying to access layout cache of destroyed items
This can be reproduced by deleting the last item of the printer queue in the
printer demo.
It is a regression showing up because we now emit the MouseExit event after
the mouse grab as released.
The problem is that we upgrade the weak item, and call geometry() on it.
Calling geometry will re-evaluate the layout cache which will re-evaluate
the model which will result in the component being removed and the cache
entry having less item than expected.

It is ok to simply return 0. for these layout location since the item will
disapear anyway.
2021-09-08 14:42:08 +02:00
Simon Hausmann
17b20dd5c4 text input: Add support for ctrl+a to select all text
cc #474
2021-09-07 11:33:28 +02:00
Olivier Goffart
42ffecad15 Properly send the exit event when releasing the grab
Might help to solve #456
2021-09-06 19:15:28 +02:00
Simon Hausmann
dd043fc51b Fix texture caching for images with the same source but different image-rendering properties
As tests/cases/examples/image_rendering.60 itself demonstrates, the png file
should be loaded into the CPU side image cache once, but the two textures
should be cached independently.

cc #465
2021-09-06 13:47:41 +02:00
Olivier Goffart
5b0c8cec5c Add a comment in the code
Normaly, fields od structure exposed to .60 need to be in lexicographic order
for themto work in C++ with agregate initialization, but since that field is not
in the .60 Struct, it needs to be last so it is default initilalized
2021-09-06 12:10:33 +02:00
Ryan Van Gilder
4d1d0e73a4 Rename image-scaling to image-rendering to align with CSS 2021-09-06 10:03:51 +02:00
Ryan Van Gilder
a03a27ae0d Add image-scaling property to Images to control how they are scaled
Like CSS image-rendering it has "smooth" and "pixelated" options.
Only OpenGL has been tested right now, have not tested WASM or Qt.
Right now the first instance of a @image-url() will set the scaling
for that specific image. The same image used from memory on the otherhand
can all have a different scaling property.
2021-09-06 10:03:51 +02:00
Olivier Goffart
619ce6c4f7 Struct exposed to .60 as struct need to be layed out in alphabetical order
because that's the order in which the C++ code generator pass the argument
to the agregate initialization
2021-09-05 09:29:00 +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
Simon Hausmann
5ae6d308be Minor cleanup in Window::draw_contents
The component rendering closure can be FnOnce, it doesn't have to be
FnMut.
2021-09-02 12:16:35 +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
e1be599bc0 Print an warning in stderr when modifying read-only model
... and improve the documentation of Model
2021-08-31 10:36:22 +02:00
Simon Hausmann
f50ba4a40f Fix doc build with nightly
The lack of docs for the debug_log macro produces a warning now (and
an error for us). Add some basic docs as remedy.
2021-08-30 18:36:07 +02:00
Simon Hausmann
dbc8b34494 Internal cleanup
Simplify if condition for entering the branch in the item graphics cache that
may update an existing entry.
2021-08-27 15:10:27 +02:00
Simon Hausmann
88af441321 Fix panic in the GL backend when text has complex bindings to sizes
Avoid borrowing the rendering cache while evaluating property bindings.

Fixes #410
2021-08-27 15:10:27 +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
Olivier Goffart
76ca2eed6b Fix intra-doc links
It should be ``[`...`]``, not `` `[...]` ``
2021-08-19 09:17:30 +02:00
Tobias Hunger
d26707e41e Janitor: Fix clippy::bool_assert_comparison 2021-08-18 00:24:51 +02:00
Olivier Goffart
a2966bdafa Fix warning generating internal docs
references to non-existing items
2021-08-16 18:27:35 +02:00