Commit graph

53 commits

Author SHA1 Message Date
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
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
bb81c99ddb Add support for keyboard modifiers in the internal key event 2020-09-21 14:30:16 +02:00
Simon Hausmann
6bcbf082ff Fix backspace handling
On macOS at least, backspace triggers a character input event as well as
key down/release -- the key_* handlers trigger as well as
doCommandBySelector. We're not interested in backspace as an input
character though. More generally, let's exclude control characters. This
could be extended in the future to more categories.
2020-09-18 18:03:16 +02:00
Simon Hausmann
0d751e6627 Render a text cursor for TextInput items
It doesn't look quite perfect yet, but it's a start.
2020-09-18 17:58:14 +02:00
Simon Hausmann
3f438ec3f6 Fix wasm build 2020-09-18 16:29:32 +02:00
Simon Hausmann
39fabdee9e Pass a window reference to Item::key_event
Similar to the input_event.
2020-09-18 16:22:00 +02:00
Simon Hausmann
7053aee0c8 Pass the ComponentWindow to ItemVTable::input_event 2020-09-18 16:18:48 +02:00
Simon Hausmann
79ba5d9de8 Provide a window reference in various ItemVTable functions
Access to the window, in particular the scale factor, will be needed in a few places.
2020-09-15 15:55:47 +02:00
Simon Hausmann
546818ee55 Add key event data structures and event function boiler plate 2020-09-15 11:16:55 +02:00
Simon Hausmann
3c2172d043 Use new-style intra-crate rust-doc links instead of relying on .html links 2020-09-09 18:53:59 +02:00
Simon Hausmann
0bc2e40e28 Add remaining docs for the eventloop crate.
The particularly relevant bit here is the GenericWindow trait since that
heavily relates to the implementation in the graphics module.
2020-08-31 14:34:42 +02:00
Olivier Goffart
e7210d8d6c wasm: send an Exit event when the cursor leave the canvas
We do not get move or release event when the cursor is outside of the canvas
as a result, we would have no way of detecting that the mouse has been released
outside and we would be in a inconsistant state.

Fixes #19
2020-08-29 11:11:16 +02:00
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00
Simon Hausmann
d650cadc02 Release graphics resources of items when deleting components in C++ 2020-08-13 13:31:52 +02:00
Simon Hausmann
b96b627a4f Release graphics resources of items when destroying components
This is only implemented for Rust at the moment.
2020-08-13 13:31:29 +02:00
Simon Hausmann
89953e1957 Replace GenericWindow::window_handle() that returns a Ref with a callback
The std::cell::Ref<> exposes the way a refcell is used in a way that
makes it harder to change.
2020-08-13 11:33:34 +02:00
Simon Hausmann
d3a474af26 Move corelib::Component and friends back into their dedicated component module 2020-08-12 11:39:07 +02:00
Simon Hausmann
b21aa4f9e7 Rename PropertyListenerScope to PropertyTracker 2020-08-12 11:31:33 +02:00
Simon Hausmann
0df86d7eeb Move corelib::abi::datastructures::Component to corelib 2020-08-12 10:53:03 +02:00
Simon Hausmann
62a8b15f09 Move ItemVTable and frieds to corelib::items
To avoid ambiguities regarding the use of FieldOffset, the BuiltinItem
proc-macro uses fully-qualified type names now.
2020-08-12 10:10:51 +02:00
Simon Hausmann
aafb96cb93 Get rid of abi::datastructures::WindowProperties
Instead, pass a reference to the root item when mapping the window,
at which point we can downcast to the new Window item. If we have one,
then we'll read its width/height (for initial values) and install
bindings to keep them up-to-date.
2020-08-12 09:44:42 +02:00
Simon Hausmann
c1f91e38ca Move the window scale factor into GraphicsWindow 2020-08-11 13:42:51 +02:00
Simon Hausmann
5b90f3edf5 Unmap the window after running the component
This gives a timing wise clearly controlled shutdown of the GL context.
2020-08-11 13:27:31 +02:00
Olivier Goffart
571e74d2ce Handle Touch event 2020-08-06 11:41:49 +02:00
Simon Hausmann
5dfb9aa875 Fix initialize size of printer demo
Map it to 800x600 logical pixels for a better initial look.

This implements respecting the initial values for width/height and tries
to apply them to the window begin created.

The PinnedOptionalProp wrapper is needed because while cbindgen mapped
the previous Option<&...> to a raw pointer, the new Option<Pin<&...>> is
not detected as a pointer.
2020-08-05 13:22:53 +02:00
Olivier Goffart
1741b90b4e Implement a SIXTYFPS_SLOW_ANIMATIONS env variable
that can be set to a factor to reduce the speed of animations
2020-08-05 13:21:29 +02:00
Simon Hausmann
0f1b1fd0db Fix initial value of the scale factor window property
We need to initialize it property once we have a platform window.
2020-08-05 10:49:53 +02:00
Simon Hausmann
4f0bf0b982 Rename dpi to (window) scale_factor 2020-08-04 09:01:30 +02:00
Simon Hausmann
9b13b363c3 Move corelib::abi::properties to corelib::properties
And the bits that are only there for the C binding are now in an ffi sub-module.
2020-08-03 17:32:28 +02:00
Simon Hausmann
76adda0abd Move ComponentWindow and friends from datastructures into eventloop 2020-08-03 14:26:47 +02:00
Simon Hausmann
37fa04098f Move MouseEvent and MouseEventType from datastructures into input 2020-08-03 13:55:33 +02:00
Simon Hausmann
fa87363dc5 Move Point, Rect and Size into graphics
And move the expanded structures for cbindgen into an ffi sub-module.
2020-08-03 13:24:39 +02:00
Olivier Goffart
9760cf4969 Begin to implement a Flickable
The implementation is still very rough and will need to be improved
2020-07-30 14:36:21 +02:00
Simon Hausmann
c847a7b924 Fix values of width/height properties on initial show on macOS 2020-07-28 14:45:17 +02:00
Olivier Goffart
96a2efcb93 Only recompute the layout when needed 2020-07-28 10:43:06 +02:00
Olivier Goffart
dfd4a35e35 Set the DPI property according to the window's screen 2020-07-15 18:46:55 +02:00
Simon Hausmann
ddc4fb6e1f WIP: window size
Just playing around with propagating the width/height of the window.
2020-07-15 17:52:14 +02:00
Olivier Goffart
90ed79e39f Remove unused code in the animation driver 2020-07-02 17:36:34 +02:00
Olivier Goffart
9d852f802e Property refactoring
The tests are working and everything seems to be back normal.
But there is still some cleanup required
2020-07-02 14:14:49 +02:00
Simon Hausmann
fb74a8ddd4 Fix animations for the wasm build
Use the instant crate that has a transparent fall-back to performance.now().
2020-06-25 09:07:04 +02:00
Olivier Goffart
caca0d0ba4 Put the component in a Pin<>
Removed the drop and create from the ComponentVTable:
since we are not using VBox<ComponentVTable>, this simplifies a bit
the code of the interpreter and everything else.

But there is still a lot of changes everywhere to support that the Component
is pinned.
This is just for the component. Which would be required if later we want
to access the properties as Pin<Property<_>>. But we have not yet ability
to do projections
2020-06-24 14:13:27 +02:00
Simon Hausmann
d99972a77a Simplify animation driver handling
Instead of passing it through the event loop, make it accessible as a
thread local variable.
2020-06-23 13:03:35 +02:00
Simon Hausmann
f98b18d327 Fix animation integration into the event loop
* Allow closing the window even when animations are still running (*facepalm*)
* Remember to update animations with each frame (*facepalm again*)
2020-06-20 16:24:17 +02:00
Simon Hausmann
072bff1871 Introduce the animation driver in the event loop
This re-applies commit 1ef269305e but with
an Rc<RefCell<>> to make the borrow checker happy :-)
2020-06-20 16:24:17 +02:00
Simon Hausmann
8f613685ba Expose a ComponentWindow in C++
This paves a way for a more modular API.
2020-06-17 19:15:18 +02:00
Simon Hausmann
d78c93bfee Revert "Integrate the animation driver into the event loop"
This reverts commit 1ef269305e. Breaks the
wasm build, to be fixed later.
2020-06-17 18:58:32 +02:00
Simon Hausmann
1ef269305e Integrate the animation driver into the event loop 2020-06-17 15:16:46 +02:00
Simon Hausmann
85bf8a195a Improve EventLoop encapsulation
Hide the winit loop and extract it only in the GL renderer
2020-06-17 15:16:46 +02:00