Commit graph

183 commits

Author SHA1 Message Date
Olivier Goffart
19106b13e6 Another attempt to fix CI 2020-09-22 21:37:42 +02:00
Olivier Goffart
56f2592815 Attempts to fix compiler error on the CI:
cargo:warning=widgets.rs:983:31: error: reference to local binding 'rect' declared in enclosing function '__cpp_closure_1878168448326367357_impl'
  cargo:warning=                option.rect = rect;
  cargo:warning=                              ^
  cargo:warning=widgets.rs:978:24: note: 'rect' declared here
  cargo:warning=            auto [img, rect] = offline_style_rendering_image(size, dpr);
  cargo:warning=                       ^
  cargo:warning=1 error generated.

Also revert the QStyle::State_Horizontal in the spinbox that should not have been part of the previous patch
2020-09-22 20:25:12 +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
Simon Hausmann
fe079c644e Simplify byte offset vs. char index handling in the font code
Use char_indices() already for string_to_glyphs.
2020-09-22 18:47:15 +02:00
Simon Hausmann
1e450abc9c Change layer contents placement policy to reduce visual mess when resizing
This makes window resizing much smoother. Great advice from an anonymous
Norwegian friend ;-)
2020-09-22 14:30:27 +02:00
Simon Hausmann
7e5b6843a4 Fix crash on start-up of rusttest2
Mysteriously the path tesselation of hello.60 fails with Lyon 0.16.0, so pin
it to the previous release.

Reported also in nical/lyon#607
2020-09-22 14:24:40 +02:00
Simon Hausmann
4f25b0942f Draw text selections 2020-09-21 18:43:59 +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
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
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
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
9a24113acb Use the winit window DPR instead of the QGuiApplication one
A per-window setting will allow correct values when moving windows across screens.
2020-09-15 16:03:58 +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
02d18b09cf Fix warning about x not needing to be mutable 2020-09-15 11:21:01 +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
c69781ace2 Upgrade glow 2020-09-15 11:14:23 +02:00
Simon Hausmann
4f5d491bf7 Minor cleanup
Remove GL context parameters from texture functions that aren't needed.
2020-09-15 09:02:34 +02:00
Simon Hausmann
7c6fd90924 Fix layouting_info with QStyle and High-DPI displays
QStyle returns logical coordinates while SixtyFPS operates on physical
coordinates, so an extra multiplication is needed.

This is a temporary fix until we have access to the concrete (winit)
window we're rendering to, in order to apply the correct DPR.
2020-09-11 08:31:38 +02:00
Simon Hausmann
b82f39ad84 Fix rendering into the QImage with QStyle on high-dpi displays
Apply the DPR to the QImage and reduce the logical rect accordingly.
This ensures that text is scaled well.
2020-09-11 08:18:37 +02:00
Simon Hausmann
bf396ad578 Draw *something* with the mac style
A CGBitmapContext can only be created on a 32bpp/8bpc QImage if the
alpha channel is pre-multiplied.  That context is needed to draw cocoa
controls to the QImage. So create a QImage with pre-multipled alpha.
Fortunately our blend mode in the GL renderer already supports that.

Also a QWidget is needed to have an NSView (through the widget's backing store).
2020-09-11 08:18:37 +02:00
Simon Hausmann
0c2a557b95 Remove QtQuick and QtQml linkage for the Qt backend
We don't need these libraries at the moment.
2020-09-11 08:18:07 +02:00
Simon Hausmann
23ba165752 Remove the use of QApplication::globalStrut()
That is AFAIK a deprecated concept.
2020-09-09 18:55:43 +02:00
Simon Hausmann
ca16b6c082 Clean up the QImage setup for rendering with QStyle
Centralize the code in one function, so that we can later change it to
deal with different device pixel ratios. The function returns an image
and a QRect that contains the logical size.
2020-09-09 18:55:33 +02:00
Olivier Goffart
8761ca80a3 Add SharedArray::push and adjust a bit the API 2020-09-09 18:47:15 +02:00
Simon Hausmann
5801b90f66 Don't crash when Qt and winit fight for application delegates
winit sets an NSApplicationDelegate on the NSApplication and expects it
to remain there. We must instruct Qt not to install its own application delegate, to avoid
winit being confused.
2020-09-09 15:45:27 +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
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
Simon Hausmann
220dc2ee47 Fix rendering of rounded rectangles in examples preview
For something like

    Window {
        GridLayout {
            Rectangle {
                border_width: 2lx;
                border_radius: 2lx;
                border_color: black;
            }
        }
    }

The border was not fully visible and partly obscured by the window
frame, the canvas element in the case of the preview in the examples.
That looks bad, and this patch fixes it by respecting the border width
in the geometry used to stroke and fill the rectangle.
2020-09-04 14:27:58 +02:00
Simon Hausmann
b50e42a7ba Avoid large empty canvas elements in the html docs
Some of the example code does not include a Window {} element with a
size.  The html says <canvas width=100 height=100> but it turns out that
winit is not interested in these values and any newly created window
with a canvas will get an initial size of 1024x768.

This is not quite the behavior we want, preserving the canvas size may
be more sensible -- it certainly is for our docs. So this patch tries to
preserve that.
2020-09-04 10:12:34 +02:00
Olivier Goffart
1cf6d81169 Impletment GroupBox with the Qt style 2020-09-02 17:05:28 +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
9782d85fdb Native style works with C++ 2020-09-01 12:25:11 +02:00
Olivier Goffart
f1ad78bc25 Qt style support for the rust backend
Need to set the SIXTYFPS_STYLE=native env variable while compiling
2020-09-01 12:25:11 +02:00
Olivier Goffart
9d5f27db0b Rename QtStyle to Native 2020-09-01 12:25:11 +02:00
Olivier Goffart
27288c65e2 fixup previous commit
I had inverted the condition to test locally
2020-09-01 10:15:31 +02:00
Olivier Goffart
b27f64756e In the Qt backend, having Qt is the default and not having it is the exception
Simplify the config
2020-09-01 09:58:25 +02:00
Simon Hausmann
ebada75431 Fix build without Qt 2020-09-01 09:01:01 +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
07fa020e81 Fix flickering in gallery example when pressing spin box buttons
The path shader uses only one attribute array, while the others use two.
First rendering with say the glyph shader and then the path one may leave
odd artifacts around with GLES, which is fixed by properly disabling the
vertex attribute arrays after use.

Closes: #17
2020-08-28 17:49:45 +02:00
Olivier Goffart
65acdd78b0 Use xtask to generate the headers instead of build.rs of each lib
Fixes #14
2020-08-27 11:50:09 +02:00
Olivier Goffart
80dd7dcb04 Allow to specify the canvas id when creating a new window with wasm 2020-08-26 17:01:17 +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
14fe897086 Move all cbindgen generated code into
sixtyfps::cbindgen_private

Having private in the name makes it clear that this is ... private,
and cbindgen helps remember that it's generated.
2020-08-25 15:29:48 +02:00
Olivier Goffart
ea1f215367 Some polishinbg of the .toml files
- Give all the sixtyfps-* create a 0.0.1 version
 - Make sure that the internal dependences are using the exact same version
   (so "=0.0.1")
 - Add the description/homepage/repository fields in the .toml files
 - Set publish=false  to crates that are not meant to be published on crates.io
2020-08-24 16:28:11 +02:00
Simon Hausmann
7f1d9f5252 Commit correct license tags to Cargo.toml
For now that's GPL-3.0 only, but this can be changed :-)
2020-08-18 10:12:59 +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
a54f222e52 Clean up glyph run creation code
Move more into the glyph cache module
2020-08-13 10:48:27 +02:00