Commit graph

110 commits

Author SHA1 Message Date
Olivier Goffart
c7ff67d0fc Move the ItemRenderer to the item_rendering module 2021-01-14 08:52:22 +01:00
Simon Hausmann
de4194c9ba Make ItemRenderer take &mut again
It's cleaner and indeed possible
2021-01-14 08:52:22 +01:00
Olivier Goffart
16a1b7b2bd Cache the pixmap in the native style 2021-01-14 08:52:22 +01:00
Simon Hausmann
43127cb059 Implement releasing of textures when items are destroyed
This means going back to an immutable renderer reference and interior
mutability for the canvas and the gpu cache. This is because while
traversing the item tree for rendering we may end up destroying
other items due to the lazyness of the models.
2021-01-14 08:52:22 +01:00
Olivier Goffart
b157648ab2 More work towards getting native widget with the femtovg backend 2021-01-14 08:52:22 +01:00
Olivier Goffart
f7c8d53e7a Port the Qt Native item to the new API
this mostly restores code that was removed in commit 1a260b9dce13db38128f1f489633ba96f264d461
2021-01-14 08:52:22 +01:00
Olivier Goffart
4e9021b550 Use a type alias so that cbindgen generates the ItemVTable 2021-01-14 08:52:22 +01:00
Simon Hausmann
d92fe445d5 Remove the old GL renderer
and try to stub in the hooks to trigger the new one
2021-01-14 08:52:22 +01:00
Simon Hausmann
d4f603246c WIP: Start a femtovg backend 2021-01-14 08:52:22 +01:00
Simon Hausmann
8dea0c88d1 Beginning of a different way of rendering items
This is the start of a different rendering abstraction, the result of a
separate discussion.

The objective is to provide a better backend encapsulation, that will
make it easier to implement other backends and let the backend decide
what to cache and what not. This is done by passing the struct with the
Property<> fields directly to the backend, so that it can decide what
the cache and what to use every time.
2021-01-14 08:52:22 +01:00
Olivier Goffart
b126d2056a Remove the color property from clip 2021-01-07 17:06:50 +01:00
Olivier Goffart
40ebf16257 Fix build without the rtti feature 2021-01-05 09:48:04 +01:00
Olivier Goffart
61399e566a Add a title to the Window
also add a color, but not yet implemented
2020-12-18 16:47:14 +01:00
Olivier Goffart
16f5a03c14 Run cargo fmt 2020-12-18 10:29:15 +01:00
Olivier Goffart
dfa25b96f7 Rename SharedArray to SharedVector 2020-12-18 10:26:07 +01:00
Olivier Goffart
0d2d48be4f Rename "signal" to "callback" 2020-12-18 09:51:01 +01:00
Simon Hausmann
ca1fb8ab0d Fix GPU primitive vs. rendering variable division for Rectangle
Changing the border radius or border width does not require uploading a new geometry.
Therefore these can become rendering variables.
2020-12-15 18:08:33 +01:00
Olivier Goffart
2b5213c408 Refactor the rendering variables in a enum instead of an array
And finish the ImageFit::contain implementation
2020-12-15 12:16:44 +01:00
Simon Hausmann
447bc9aa6d Split the text and image items into text.rs/image.rs 2020-12-08 17:19:31 +01:00
Olivier Goffart
3ae7c6e0b5 Hover effect 2020-11-24 18:09:32 +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
Olivier Goffart
124eec9960 Introfuce ItemRc and ItemWeak
Wrapper around ComponentRc and index
2020-11-24 13:42:34 +01:00
Simon Hausmann
d80868bbf4 Add support for font_weight to Text and TextInput
This allows implementing another sliding puzzle theme feature, the
boldness of the tile number text in the simple theme when the tile is in
the correct position. For the other themes the weight is constant and
it's bold.

More cleanup to follow later: unify the font handle and FontCacheKey
handling, improve the API to allow for the use of symbolic constants
(normal, bold, etc.) instead of the CSS number values.
2020-11-24 10:10:00 +01:00
Simon Hausmann
f0289192b7 More font handling cleanup
Group all fields we need to determine a physical font into one FontRequest
structure and use that throughout.

That way adding more fields will require less changes.
2020-11-24 09:00:07 +01:00
Simon Hausmann
05204a3185 Font handling cleanup
To make adding of more font related properties easier in the future, and
to simplify the text code a little, define a HasFont trait and implement
it for Pin<&Text|&TextInput> so that we can more easily get an Rc<Font>.
2020-11-23 20:39:12 +01:00
Simon Hausmann
3d85e45ec3 Add support for source clipping to the Image element
This allows rendering only a sub-rectangle of the original image, which
we can use right away in the sliding puzzle demo.
2020-11-23 15:46:59 +01:00
Olivier Goffart
4383566db9 slide puzzle: Animation on checkbox 2020-11-20 17:14:04 +01:00
Simon Hausmann
4e36ba3ed9 Fix build
Adjust to vtable changes
2020-11-20 15:50:35 +01:00
Olivier Goffart
08fe5f6c72 Add a Clip 2020-11-20 15:45:45 +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
c05b71c4ee Fix default text font size
16 points is a lot, 12 is a lot closer to default system sizes.
We can also pull this out of the style in the future.
2020-11-04 17:39:47 +01:00
Olivier Goffart
f940292182 Rename the builtinf file 2020-11-04 17:11:29 +01:00
Olivier Goffart
281a744e86 Load the builtin from a fake .60 file 2020-11-04 16:56:35 +01:00
Olivier Goffart
183f300a85 Implement the temperature converter in the .60 code
A edited signal was required on the line edit
2020-11-03 18:23:37 +01:00
Olivier Goffart
8a95b806c7 Strawman implementation of a combo box 2020-11-03 17:55:49 +01:00
Olivier Goffart
59707f068c add a enabled property on the line edit 2020-11-02 18:20:01 +01:00
Olivier Goffart
aabd13b5a9 Adjust the ugly style default stretches 2020-10-27 07:24:04 +01:00
Olivier Goffart
47be71e16d Introduce layout stretching 2020-10-26 16:40:35 +01:00
Simon Hausmann
a98da9ecc9 Draw rounded rectangles with anti-aliasing
Draw rounded rectangles using a distance function. This removes the need
to use lyon to tesselate the rounded corners and as a bonus it gives
anti-aliased borders.
2020-10-21 09:35:35 +02:00
Simon Hausmann
853a74043f Add support for moving/selecting to beginning/end of line 2020-10-13 13:20:26 +02:00
Simon Hausmann
2d387d4c3b Fix hang when pressing the right arrow to go back the end of text input
str::is_char_boundary() returns true at text.len() but beyond that it'll return false.
2020-10-13 13:20:26 +02:00
Simon Hausmann
a37d42fa0e Add an init function to the Item vtable
This will be called by the run-time and will allow items to set up
bindings that rely on internals that should not be exposed to the
compiler/runtime.
2020-10-12 16:49:44 +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
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
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
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