Commit graph

1059 commits

Author SHA1 Message Date
Simon Hausmann
096fbab93d Simplify the destructor of generated C++ components
Similar to the parent commit, avoid creating an array of item refs and pass the item tree instead
to a run-time helper function.
2021-11-01 10:19:17 +01:00
Simon Hausmann
67579ec560 Simplify drop implementation of generated components
Avoid creating an intermediate array of items to free the graphics resources.
Instead call run-time function with the item tree as a parameter, which is traversed.

It's practically the same data structure that was previously created, except
that it is shared/global and has little holes for the dynamic tree items, but those are easy to skip.
2021-11-01 08:58:53 +01:00
Simon Hausmann
d57edfbb7c Simplify free_graphics_resources API in the backend
Take an iterator reference instead of a slice, so that we can change the call sites in the future.
2021-10-30 13:03:52 +02:00
Olivier Goffart
567c644a5f Fix PopupWindow position when all elements are not inlined
Pass a reference to the parent item in the show_popup function
so we can compute the exact location at runtime.
2021-10-28 15:52:29 +02:00
ogoffart
b25ae6fbcd Bump version number to 0.1.5 2021-10-26 07:36:54 +00:00
Simon Hausmann
7b687d020c Fix compatibility of attach_peer on ModelHandle for older models
If the model doesn't implement `model_tracker` then we must
forward `attach_peer`.
2021-10-21 13:39:38 +02:00
Olivier Goffart
cc1205742d Move the image dependency down in the dependency tree
Corelib only need the image crate for doc test
the Qt bakcned don't use the image crate
2021-10-21 12:42:04 +02:00
Olivier Goffart
56d592100e Update a few dependencies 2021-10-21 12:24:48 +02:00
Simon Hausmann
2ba469cf2a Fix vector model example docs
Re-implement model_tracker instead of attach_peer.
2021-10-20 15:33:37 +02:00
Simon Hausmann
d420d5efd7 internal cleanup: Rename Property::set_dirty() to mark_dirty() 2021-10-20 15:25:28 +02:00
Simon Hausmann
a494eafa9c Make Property::set_dirty public
Property is not public API yet, there's not much value in playing hide and seek.

Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-10-20 15:25:28 +02:00
Simon Hausmann
7d12fd7b4e Add support for tracking the length of a model in C++
Similar to the parent commit, the model tracks changes to the rows and
marks an internal property dirty. Since we have a base class this is a
little less intrusive.

cc #98
2021-10-20 15:25:28 +02:00
Simon Hausmann
63bf1af093 Add support for tracking the length of a model in Rust
This is done by exposing the ModelNotify to the caller via the new
ModelTracker trait, which has a function that allows "hooking" into the
dirty tracking of the size.

By extension, this also works in JavaScript.

cc #98
2021-10-20 15:25:28 +02:00
Olivier Goffart
e3d9abb1f7 ListView: Attempt to account for ListView with different item height
As an attempt to fix part of https://github.com/sixtyfpsui/cargo-ui/issues/10
2021-10-20 14:10:19 +02:00
Olivier Goffart
bb4e5d8b55 Fix animation not starting when set from a callback
Two problems:
 - We were not marking the property as dirty, so dependent property would not
   update themselves
 - In the generated rust/c++ code, we would not call set_animated_value
2021-10-13 14:33:40 +02:00
Olivier Goffart
b74ab8969e Implement Model::set_row_data for ModelHandle 2021-10-12 14:05:33 +02:00
Robert Broketa
c3c7765f80 Add no-frame property for a borderless/frameless window 2021-10-11 10:21:21 +02:00
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