Commit graph

1092 commits

Author SHA1 Message Date
Simon Hausmann
bb81c99ddb Add support for keyboard modifiers in the internal key event 2020-09-21 14:30:16 +02:00
Simon Hausmann
b857eb4671 Add an accepted signal to TextInput and LineEdit 2020-09-21 13:18:53 +02:00
Simon Hausmann
34eae40814 Allow moving the text cursor to the end of the input 2020-09-21 13:15:53 +02:00
Simon Hausmann
083cdd6653 Added a crude backspace and delete handler in TextInput 2020-09-18 18:18:44 +02:00
Simon Hausmann
ade78875ea Fix TextInput::move_cursor to respect character boundaries 2020-09-18 18:13:31 +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
d819541ea3 Fix build 2020-09-18 16:41:37 +02:00
Simon Hausmann
2da84fee46 Add a boilerplate TextInput item 2020-09-18 16:34:24 +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
eeee4794b6 Remove the rest of the RenderingCache wrapper 2020-09-17 13:06:23 +02:00
Simon Hausmann
5080971af8 Replace the hand-made allocator for the rendering cache with a 3rdparty crate
Less code to maintain :)
2020-09-17 11:41:14 +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
Simon Hausmann
1d6af1da09 Prospective CI build fix
Try to ensure that the C functions in items.rs are included in the binary.
2020-09-16 08:38:30 +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
dd8e487acc Fix discrepancy between Text layout info and rendering
The layout_info() would calculate the text metrics based on a different effective pixel
size compared to the rendering.
2020-09-15 16:15:26 +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
37e550e540 Fix inconsistency in Font API
Have just one height() function in the fontkit and canvas version.
2020-09-15 12:28:30 +02:00
Olivier Goffart
4a0a65f113 C++ model that can be changed 2020-09-15 12:18:36 +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
0924519734 Add some missing docs to the input module
Now we can require docs.
2020-09-15 11:16:00 +02:00
Olivier Goffart
0d8a38577d Todo example: make the "add todo" button do something 2020-09-14 16:38:45 +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
Simon Hausmann
5713ea83f3
Minor doc fix
SharedArray holds elements, not a string :-)
2020-09-09 22:10:47 +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
9ecaf11eed Various additions to the Rust Color API
As discussed in the most recent API review.
2020-09-09 18:53:59 +02:00
Olivier Goffart
8761ca80a3 Add SharedArray::push and adjust a bit the API 2020-09-09 18:47:15 +02:00
Olivier Goffart
42aa91e3eb Support for signal with arguments in the interpreter 2020-09-09 11:27:58 +02:00
Simon Hausmann
3bf5d68508 Tweak Rust SharedString docs a bit 2020-09-09 08:15:06 +02:00
Simon Hausmann
da913ae917 Minor doc tweaks for SharedString 2020-09-08 22:58:49 +02:00
Simon Hausmann
52b19606d1 Provide red/green/blue/alpha getters for Rust and C++ Color
And fix up the C++ class docs.
2020-09-08 22:32:15 +02:00
Simon Hausmann
19cce012a0 Add ARGBColor<T> to the color API
As discussed in the last API review, this replaces the as_rgba_f32/u8
"accessor" functions by returning a struct with named fields.
2020-09-08 22:11:23 +02:00
Simon Hausmann
5765a76f44 Remove Color::{WHITE, BLACK, TRANSPARENT}
As discussed in the latest API review.
2020-09-08 21:53:25 +02:00
Olivier Goffart
a192ffe283 Make the C++ Signal class templated on the arguments 2020-09-08 13:11:32 +02:00
Olivier Goffart
e997dff094 Use a reference as a signal argument.
It will be easier to make that work with C++
2020-09-08 12:12:01 +02:00
Olivier Goffart
c8fa3354be Change the implementation of SharedArray so that it can destruct its contents 2020-09-04 15:37:38 +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
3b971a2e2f Remove Color::From<u32>
Instead make it clear on the call site what the encoding is (argb).
2020-09-03 11:17:40 +02:00
Olivier Goffart
5451e0a6fe Fix offset of mouse event when mouse is grabbed
The bug could be seen when dragging a native slider whose x position is not 0
2020-09-02 11:59:48 +02:00
Olivier Goffart
953d3e0422 Fix crash when rendering an empty widget
QPainter does not like to draw in an empty QImage.
And the rendering code does not like to render it.

So we would get this on the console:

```
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::save: Painter not active
QPainter::save: Painter not active
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::save: Painter not active
QPainter::setClipRegion: Painter not active
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
QPainter::restore: Unbalanced save/restore
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
QPainter::restore: Unbalanced save/restore
QPainter::save: Painter not active
QPainter::restore: Unbalanced save/restore
QPainter::restore: Unbalanced save/restore
thread 'main' panicked at 'attempt to subtract with overflow', sixtyfps_runtime/rendering_backends/gl/texture.rs:285:42
```
2020-09-02 11:50:19 +02:00
Simon Hausmann
570e51eaa9 Improve API of color handling of text
Make the text color a rendering variable, so that it can be passed
through as uniform to the glyph shader and applied to the gray
map of the glyphs. This avoids re-creating the glyph runs when
merely the color changes.

This already "worked" for the glyph cache based text rendering,
but it wasn't used because of the wasm canvas code path. This
patch changes that to render the text into a text using simply black
and then render that texture using our existing glyph shader,
which merely uses the alpha channel anyway.

This reduces also #cfg's.
2020-09-02 11:48:41 +02:00
Olivier Goffart
60201b9c7b Update dependencies 2020-08-31 17:38:22 +02:00
Olivier Goffart
6d41b1981d Move the Qt style to a new backend: the Qt backend
Currently the Qt backend still redirect everything to the GL backend,
but the goal is to use QPainter and QWindow

This also adds a "default" backend, whose goal is to select the proper
backend at compile time
2020-08-31 17:26:04 +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
Simon Hausmann
8aae0447fd Minor doc fix
crate -> module
2020-08-31 14:14:48 +02:00
Simon Hausmann
0f052c9008 Minor doc fix for Color 2020-08-31 14:13:37 +02:00
Simon Hausmann
156e788810 Document GraphicsWindow 2020-08-31 14:12:14 +02:00