Commit graph

77 commits

Author SHA1 Message Date
Olivier Goffart
763065fd0e Disable the std feature from strum
also use its derive feature
2021-11-25 12:02:16 +01:00
Olivier Goffart
80c0602277 WIP: start making the corelib crate a no_std crate
Does not compile yet with no_std because of the lack of
alternative for thread_local
2021-11-25 12:02:16 +01:00
Philipp Gesang
cd3717af9a handle tab keycode in backend
Treating the Tab key as text disallows handling Shift-Tab because
the shift modifier will not be passed down. This makes the
handling of Tab analogous to Escape, Return and other non-text
keycodes.
2021-11-08 16:04:37 +01: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
42ffecad15 Properly send the exit event when releasing the grab
Might help to solve #456
2021-09-06 19:15:28 +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
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
a2966bdafa Fix warning generating internal docs
references to non-existing items
2021-08-16 18:27:35 +02:00
Tobias Hunger
9539a53480 Janitor: Fix clippy::redundant_clone 2021-07-23 13:48:52 +02:00
Simon Hausmann
eaddbe664e internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
2021-07-21 20:33:02 +02:00
Tobias Hunger
aeebbb1d96 Janitor: Fix remaining clippy::option_map_unit_fn 2021-07-21 19:44:57 +02:00
Olivier Goffart
1eb54a4743 The clip property now clips the mouse events
Fixes #180

Note that there is still a small issue that the clipped element may
not recieve the MouseExit event because it is still considered
having the mouse.
2021-07-12 15:39:39 +02:00
Tobias Hunger
35dd3ed282 Janitor: Remove redundant clone() calls 2021-07-08 20:43:38 +02:00
Tobias Hunger
c56e20233b Janitor: Fix clippy error about a loop that never loops
This code abuses a loop for flow control. Split this out into a separate
function instead, using a custom enum to transfer the information back.

This is necessary since we need to transfer ownership of the
mouse_input_state back to the caller.

This change should not cause a behavior change.
2021-07-05 09:44:41 +02:00
Tobias Hunger
39984b27db Janitor: Fix spelling in comments 2021-07-03 15:49:43 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Olivier Goffart
7b2653db23 MouseWheel support for the Flickable
cc #222
2021-05-12 13:28:39 +02:00
Olivier Goffart
5f74475224 Refactor the MouseEvent 2021-05-12 12:03:03 +02:00
Olivier Goffart
1f318f2d10 Use the new mouse event API for the flickable
Issue #166
2021-02-13 16:58:04 +01:00
Olivier Goffart
a71edafa33 Refactor the way the mouse events are processed
Have a function first called before the children, and then the main function
called after the children if they did not accept the event.  This will allow
processing the Flickable gesture properly
2021-02-12 20:47:59 +01:00
Olivier Goffart
f1300a7f2d Fix propagation of mouse event.
Process the event in the post visit if the children did not intercept the event
2021-02-08 14:08:14 +01:00
Olivier Goffart
8b535991ec Handle Esc in the GL backend
Issue #165
2021-02-08 09:00:09 +01:00
Olivier Goffart
802383cd6b Propagate key event to parent if the item don't handle it
Does not work for C++ because binary compatibility issue
2021-01-26 13:17:04 +01:00
Simon Hausmann
2801e82658 Changed the KeyEvent in .60 to be an object
This exposes the text as well as the keyboard modifiers and is a little
more extensible.
2021-01-22 18:05:34 +01:00
Simon Hausmann
2d5f5fb821 Fix copy & paste shortcuts with Qt
* Rename logo to the more generic meta as keyboard modifier.
* Use control as the real modifier and map command key to it with
  winit and keep Qt semantics as-is.
2021-01-22 17:06:35 +01:00
Simon Hausmann
d022dc1293 Make KeyEvent a struct
This way it's easier to expose to .60
2021-01-22 13:47:52 +01:00
Simon Hausmann
ae1178dd55 Make the modifiers simple booleans in the key event
This will give a nicer API to expose to .60. If the struct weren't
repr(C) then the booleans would be nicely packed, but alas that's not
happening. On the other hand we're not keeping many instances of them
around.
2021-01-22 13:47:52 +01:00
Simon Hausmann
886dd425fc Rename KeyEvent::KeyPress::string to text
It's the textual representation of the key
2021-01-22 13:47:52 +01:00
Simon Hausmann
22749d4240 Remove the winit dependency from corelib
The last dependency were the keyboard modifiers, which we can map
manually.
2021-01-22 10:15:05 +01:00
Simon Hausmann
9ca87ab312 Simplify KeyEvent
Fold CharacterInput into KeyPressed/KeyReleased and store the "key" as a string.

Also, instead of exposing the KeyCode we're encoding special characters
into the string.
2021-01-22 10:15:05 +01:00
Olivier Goffart
dcb347fb7b Move more functions from the GenericWindow to the Window 2021-01-15 15:02:55 +01:00
Simon Hausmann
c8065060c5 Fix doc warnings during build
Add some docs for the text cursor blinker, which is public now
due to the use in the rendering backends.
2021-01-14 11:16:09 +01:00
Olivier Goffart
62150cba1a Basic text input 2021-01-14 08:53:13 +01:00
Olivier Goffart
d4c357195d Qt backend: make clicking on a TextInput not panic 2021-01-14 08:53:13 +01:00
Olivier Goffart
9050c29305 Don't use the window through the eventloop module 2021-01-14 08:53:13 +01:00
Olivier Goffart
3ae7c6e0b5 Hover effect 2020-11-24 18:09:32 +01:00
Olivier Goffart
8a64f10e84 Remove ComponentVtable::input_event
And the custom handling of the mouse grabber
2020-11-24 16:23:37 +01:00
Olivier Goffart
845627c6b4 Implement the mouse_input in a generic way so we can remove the one in the component 2020-11-24 15:40:41 +01:00
Olivier Goffart
0c97b4f296 More use of the ItemRc 2020-11-24 13:42:34 +01:00
Simon Hausmann
89e0b57627 Rework and simplify the focus handling
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.

This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.

This also fixes the duplicate line edit focus in the 7gui cells
test case.
2020-11-20 15:33:15 +01:00
Simon Hausmann
78fae068dd Use ComponentRc during item tree traversal
This is in preparation for allowing the run-time / items to clone VRc's
of the component.

ComponentVTable functions like visit_children_item contine to take a
ComponentRefPin as "self" parameter type, as a VRc would not be
supported by rust right now. That means the implementation then uses
self_weak to obtain a strong self-reference.
2020-11-19 17:04:01 +01:00
Olivier Goffart
57ccd26393 Update winit 2020-10-03 14:55:25 +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
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
Olivier Goffart
b7796b1c49 Slightly better way to avoid repeating one self 2020-09-23 14:06:08 +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
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