Commit graph

661 commits

Author SHA1 Message Date
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
Olivier Goffart
0cb827a901 Two ways binding with optimized public property in the interpreter 2020-09-25 09:50:03 +02:00
Olivier Goffart
8361ef4019 Start code egeneration for the two ways binding
This is only meant to include the cases in which the property are optimized.
Does not work yet for the dynamic component
2020-09-24 14:37:16 +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
Olivier Goffart
315fd7a881 Start doing a ScrollArea element
Unfortunately something is wrong with the Qt style, it looks like the Qt style
does not respect the rect given for the sub components

Also Input is not handled yet.
2020-09-22 20:05:41 +02:00
Olivier Goffart
8561106a15 Fix $children when there are two levels of insertion 2020-09-22 17:39:51 +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
93a08c5207 Add a LineEdit widget to the ugly and native style 2020-09-18 18:54:37 +02:00
Simon Hausmann
2da84fee46 Add a boilerplate TextInput item 2020-09-18 16:34:24 +02:00
Olivier Goffart
bfe2bf2478 Ability to read properties of a struct 2020-09-17 13:53:00 +02:00
Olivier Goffart
8134fe5088 Support for named type as property 2020-09-17 13:14:01 +02:00
Olivier Goffart
d4e1bfe360 Fix using local exported components
Components need to be processed in source order.
Not exported last as it was before.
2020-09-17 09:09:38 +02:00
Olivier Goffart
913d680333 Recactor rust Model after first round of API review
- Remove EmptyModel and use an Option
 - Make ModelRc a type alias
 - Rename ArrayModel into VecModel
2020-09-16 14:25:57 +02:00
Simon Hausmann
ad77896312 Change the way Text's default color is implemented
Instead of via an item constructor, implement support for default
bindings in the compiler.
2020-09-16 13:41:18 +02:00
Olivier Goffart
04e2910344 Test appending data in a model and modifying it 2020-09-16 10:41:18 +02:00
Simon Hausmann
625cb6c6b8 Add a constructor to Text and let the color default to black
We really shouldn't require specifying a color for every Text {} element just in order
to see *some* text.

For Rectangle OTOH transparent is a good default (and thus for Color), hence
this change just to Text.

Right now the constructor bit is also a bit repetitive, this could
perhaps be folded into BuiltinItem to generate the ffi, default impl and
forward to an init function if it exists.
2020-09-16 08:20:13 +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
Olivier Goffart
4da5f5eee6 C++: Make a model based on a SharedArray like in C++
And make the SharedArray editable
2020-09-15 15:01:33 +02:00
Olivier Goffart
2275cd638a C++ Test: make sure to re-run cbindgen in case of changes
Also add -g to ease debugging
2020-09-15 12:18:36 +02:00
Olivier Goffart
4a0a65f113 C++ model that can be changed 2020-09-15 12:18:36 +02:00
Olivier Goffart
f69d88cddd Change all the C++ tests to the new assert macro
```
sed -i "s/assert(\(.*\) == \(.*\));/assert_eq(\1, \2);/" tests/cases/*
```

(But reverting th changes in color.60 because color can't be printed)
2020-09-15 10:28:49 +02:00
Olivier Goffart
b41e80b7db C++ Tests add an assert_eq macro
More consistency with rusts tests
2020-09-15 10:19:22 +02:00
Olivier Goffart
932d0f23a0 Test changing the model from rust code 2020-09-15 09:36:45 +02:00
Olivier Goffart
05f8f6ba92 Add small testcase for the debug function 2020-09-15 09:13:21 +02:00
Olivier Goffart
4de2e57175 Use a Model trait in the rust backend 2020-09-14 14:02:34 +02:00
Simon Hausmann
26ae1bfdb2 Add From<String> and Into<String> for SharedString 2020-09-14 08:49:41 +02:00
Olivier Goffart
42aa91e3eb Support for signal with arguments in the interpreter 2020-09-09 11:27:58 +02:00
Olivier Goffart
2ffef9b31a Signal handler with arguments works in C++ 2020-09-09 11:27:58 +02:00
Olivier Goffart
5df2c157fc Rust signal with arguments are working 2020-09-09 11:27:58 +02:00
Olivier Goffart
6065127581 Some progress towards signal with arguments
Generated code compile, but i haven't tested if it works yet
2020-09-08 17:41:20 +02:00
Olivier Goffart
a192ffe283 Make the C++ Signal class templated on the arguments 2020-09-08 13:11:32 +02:00
Olivier Goffart
16f5cf42e3 Actually compute the layout of elements within a for loop 2020-09-07 14:04:14 +02:00
Olivier Goffart
d924ec6bd9 Fix a bug when using layout within a for loop 2020-09-07 14:03:46 +02:00
Olivier Goffart
67764f8250 Fix the build of the C++ testcases 2020-09-06 14:50:56 +02:00
Olivier Goffart
c80975c85c Use C++17 in the msvc tests 2020-09-06 00:07:53 +02:00
Olivier Goffart
5759e912d0 On windows, we must close the file otherwise the compiler won't be able to open it 2020-09-05 23:47:08 +02:00
Olivier Goffart
82bfcc388a Add some debug to find out why the test is failling to compile 2020-09-05 23:12:08 +02:00
Olivier Goffart
9c32de9fac Attempt to pass the right options to MSVC 2020-09-05 22:40:40 +02:00
Olivier Goffart
103e5659e4 More escaping for slashes in path 2020-09-05 19:56:56 +02:00
Olivier Goffart
4845920dea On windows, the files are checked in with \r\n, and the test must accept that 2020-09-05 19:27:35 +02:00
Olivier Goffart
8465773b9b More fix for windows, make sure that slashes are escaped in the sixtyfps macro 2020-09-05 18:34:04 +02:00
Olivier Goffart
3c46df46d9 Attempt to fix window build by properly escaping backslashes 2020-09-05 17:42:12 +02:00
Olivier Goffart
4f5e8c7aff Do not print the warnings from tests.
Warning as expected as even code with warning need to be tested.
If anything, we could ensure that warning were indeed expected
by testing against a `^warning` comment
2020-09-05 17:29:00 +02:00
Simon Hausmann
2a9c962b8d Exclude exposure of easing and duration typed properties
We decided that their type mapping is not ready for public API yet. For
example for duration we'd like to replace the opaque i64 with another
opaque type that however has convenient conversions to
std::time::Duration or std::chrono::milliseconds. We can't use either
directly because we need ffi compatibility, in order to create an
instance in C++ and pass it to the Rust run-time.

So this hides such properties and instead produces a warning.
2020-09-04 21:25:11 +02:00
Simon Hausmann
ff9c118e07 Propagate warnings to the end of the compilation step and print them 2020-09-04 20:34:20 +02:00
Olivier Goffart
f5032ab0f8 Allow array as property
Also fix the lookup rules for the model property in a repeated element
2020-09-03 18:05:20 +02:00
Simon Hausmann
628426aded Rename cpp.rs to cppdriver.rs
This makes completion better :-)
2020-09-03 12:58:52 +02:00
Olivier Goffart
bb11f83131 Fix license headers 2020-09-03 09:38:12 +02:00