Commit graph

15 commits

Author SHA1 Message Date
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
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
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
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
Olivier Goffart
9782d85fdb Native style works with C++ 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
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
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
Renamed from sixtyfps_runtime/qt_style/lib.rs (Browse further)