Simon Hausmann
ade110894d
Fix borrow error when destroying an item during rendering
...
Destroying a component releases the item's graphics resources, which requires
a mutable reference to the rendering cache. That reference is acquired fine grained,
but when rendering items itself we also acquired a mutable reference
at the start of the rendering phase. That is too early and too long, and not necessary.
2020-10-02 17:43:18 +02:00
Simon Hausmann
56d763cdcf
Implement GridLayout using stretch's FlexBox implementation
...
Unfortunately nesting the boxes to model a grid does't seem to quite
work, so this approach simply creates two boxes for each direction --
similar to the existing algorithm.
2020-10-02 14:54:05 +02:00
Simon Hausmann
97f8dd0d1b
Use a tight bounding box around rasterized glyphs
...
Fixes #8
2020-10-01 13:27:14 +02:00
Simon Hausmann
9ad8968529
Add support for the initial_focus synthetic property
...
Setting it will translate to a set_focus_item call in the constructor.
This implements parts of #55
2020-09-30 15:11:01 +02:00
Simon Hausmann
633275c3cd
Fix formatting
2020-09-29 14:46:05 +02:00
Simon Hausmann
c1d1dc8193
Make the flickable clip by default
2020-09-29 14:41:40 +02:00
Simon Hausmann
ab0524fb1a
Fix missing clipping docs
2020-09-29 13:07:24 +02:00
Simon Hausmann
88b94a26ea
Add support for clip rectangles in the GL rendering backend
2020-09-29 11:42:02 +02:00
Simon Hausmann
edf7418370
Add support for visiting the item tree with a post_visit callback
...
The callback will be invoked *after* visiting the item's children.
2020-09-29 09:37:45 +02:00
Olivier Goffart
6662e1ff00
Proper Scrollbar on the native style
2020-09-28 18:13:13 +02:00
Simon Hausmann
ec91e4c933
Make ComponentWindow::set_focus_item ffi friendly
...
Take a Pin<VRef<ItemVTable>>, which is easier to map from C++ than a generic method...
2020-09-28 15:59:29 +02:00
Olivier Goffart
c0473a7c94
Forgot to implement intercept_set_binding in the rust case
2020-09-28 14:36:03 +02:00
Simon Hausmann
f05d3c58e2
Revert "Fix crash on start-up of rusttest2"
...
This reverts commit 7e5b6843a4
. Lyon
0.16.2 contains the fix.
2020-09-28 13:30:17 +02:00
Olivier Goffart
3b6679ed4b
Two ways binding works also work as three ways binding and more
...
A side effect is that the order of calling set_binding and link_two_ways is no longer relevant
2020-09-28 10:42:27 +02:00
Olivier Goffart
60cf022b69
Fix the two ways binding being flacky in the interpreter
...
The two way binding must be set at the end.
It is flacky because the order currently depends on the order in the Hashmap
2020-09-25 17:07:22 +02:00
Olivier Goffart
2d4f3ff50b
Two way bindings in the interpreter
2020-09-25 16:21:48 +02:00
Olivier Goffart
abe24e2e9e
C++ two way bindings
2020-09-25 15:21:37 +02:00
Simon Hausmann
cc3ac5fbed
Simplify path iterator code a little
...
Using auto_enums we can return impl Iterator for a transformed or an
untransformed path without having to Box it away.
2020-09-25 14:18:32 +02:00
Olivier Goffart
20430566c1
Implement two ways binding in the runtime.
2020-09-25 12:46:21 +02:00
Simon Hausmann
acb6eddeaf
Expose the focused property on TextInput correctly
...
As per #55 introduce a has_focus property on the TextInput.
2020-09-25 11:22:32 +02:00
Simon Hausmann
e5dfb3a4c0
Implement basic focus handling
...
Similar to the mouse_grabber, we use a VisitChildrenResult field to
track the focus item within a component. Unlike the mouse grabber
however, it is set/cleared using dedicated focus events.
The key event now routes the key event directly to the focus item.
The focus can be requested via set_focus_item on a window, which the
TextItem does.
2020-09-25 10:43:47 +02:00
Simon Hausmann
aa5babffe1
Prepare for key event delivery to a specific focus item
...
Begin by routing key events through the component. In the future that
will direct the event to the focus item.
2020-09-25 10:06:15 +02:00
Simon Hausmann
2b76e9277a
Prepare for allowing an item mouse handler to request focus
...
In the future the TextInput will request focus on mouse click,for
example.
Pass the outer-most component through to ItemVTable's input_event.
For the purpose of disambiguating this component from any nested
component instantiated by a repeater or so, it's called the
app_component.
The ComponentVTable takes a reference to a ComponentRefPin instead of a
ComponentRefPin by value, as the vtable macro gets confused otherwise
and thinks it's a self argument.
2020-09-25 10:06:15 +02:00
Olivier Goffart
0cb827a901
Two ways binding with optimized public property in the interpreter
2020-09-25 09:50:03 +02:00
Simon Hausmann
b5d7adef7d
Fix mouse event handling with multiple text input elements
...
Don't grab the mouse, otherwise clicking between text inputs will require
multiple clicks.
2020-09-25 08:27:54 +02:00
Simon Hausmann
0e2c845ff7
Add a test for multi-byte text input
...
Also fix an incorrect unwrap() at the same time.
2020-09-23 18:55:17 +02:00
Simon Hausmann
7ca66d62b9
Fix crash in TextInput when deleting a left-directed selection
...
When selecting to the left, the anchor remains to the right of the cursor.
When deleting such a selection, we fetch the cursor and anchor using a helper
method, which ensures that the anchor is to the left of the cursor.
Finally when setting the cursor then to the anchor, we need to also
set the anchor, since both were swapped.
This also add an automated test for this scenario.
2020-09-23 17:33:09 +02:00
Simon Hausmann
1b71b3d8ca
Try to disable wayland proper in copypasta
...
This has the added benefit of reducing the cargo metadata output again
and working around issue #1573 in parcel-bundler/parcel.
2020-09-23 14:31:50 +02:00
Olivier Goffart
cfa172f5c9
Add an explaining comment for properties
2020-09-23 14:06:08 +02:00
Olivier Goffart
768fece0a3
Optimize SharedArray from slice
2020-09-23 14:06:08 +02:00
Olivier Goffart
b7796b1c49
Slightly better way to avoid repeating one self
2020-09-23 14:06:08 +02:00
Simon Hausmann
d70acce73f
Prospective fix to remove wayland dependency
...
Apparently wayland is pulled in by copypasta and a second time through winit.
Disable it from copypasta since the API isn't unified anyway:
There's no FooClipboardContext::new() for wayland, instead an unsafe function must be used to create the provider.
2020-09-23 13:15:52 +02:00
Simon Hausmann
c96a955f81
Fix doc warning
2020-09-23 12:31:47 +02:00
Simon Hausmann
babfd17813
Add support for copy & paste in TextInput
2020-09-23 11:46:38 +02:00
Simon Hausmann
8f63c0dc53
Fix character input handling with modifiers
...
For a sequence of pressing and releasing Ctrl+C, winit sends up press, character input
and release.
We're not interested in
processing the character input when control, alt or logo are pressed.
2020-09-23 11:31:13 +02:00
Simon Hausmann
7238e0d01c
Minor TextInput cleanup
...
Treat the cursor and anchor positions as usize within functions, only store it
as i32 in the Property<>.
2020-09-23 11:02:50 +02:00
Simon Hausmann
fe079c644e
Simplify byte offset vs. char index handling in the font code
...
Use char_indices() already for string_to_glyphs.
2020-09-22 18:47:15 +02:00
Simon Hausmann
49edd69a3a
Fix multi-byte handling hit testing
...
Return a byte offset within the string for the hit test in TextInput.
2020-09-22 18:43:00 +02:00
Simon Hausmann
adfadd12fa
TextInput cleanup
...
Reduce the amount of char vs. byte offset fiddling
2020-09-22 18:29:21 +02:00
Olivier Goffart
fa55c1f015
Flickable: properly grab the mouse
...
otherwise the Flickable think the mouse stay pressed forever if it is released while outside of it.
2020-09-22 17:39:51 +02:00
Simon Hausmann
722fce61f2
Add support for selecting text with the mouse to TextInput
2020-09-22 15:37:54 +02:00
Simon Hausmann
141224bf28
Minor fixes for entering text in TextInput
...
Delete any selected text and update anchor and cursor after insertion.
2020-09-22 15:35:40 +02:00
Simon Hausmann
7e5b6843a4
Fix crash on start-up of rusttest2
...
Mysteriously the path tesselation of hello.60 fails with Lyon 0.16.0, so pin
it to the previous release.
Reported also in nical/lyon#607
2020-09-22 14:24:40 +02:00
Simon Hausmann
bf970b3ace
Fix build without rtti
2020-09-22 13:59:03 +02:00
Olivier Goffart
2ee861365c
Flickable: expose the viewport property as viewport_*
...
The code generator forward that the the viewport
2020-09-22 13:52:27 +02:00
Simon Hausmann
30987dd588
Add missing docs
2020-09-21 20:28:17 +02:00
Simon Hausmann
4f25b0942f
Draw text selections
2020-09-21 18:43:59 +02:00
Simon Hausmann
4a6a617ca5
Add logic for selection handling by cursor keys and shift
...
The mouse handling is still missing as well as the selection rendering.
2020-09-21 15:12:27 +02:00
Simon Hausmann
e3eeb5e23d
Don't let backspace at the beginning of text delete it
2020-09-21 15:04:20 +02:00
Simon Hausmann
19c53c6b19
Fix C++ build
...
Add missing #[repr(C)]
2020-09-21 14:58:16 +02:00