* Set the Enabled state throughout the "widgets". This corrects the visual appearance of Button and CheckBox in particular.
* Render a button that's not down as raised, in order to show its outline.
The Q_WS_MAC pre-processor macro does not exist anymore. The original
reason for the widget was erroneously applied - the cocoa controls
themselves are NSViews and it's just that the backing store view in the
style will be nil -- that seems to make no visual difference though.
Similar to the parent commit, don't calculate the native_padding_* as a side-effect of calling
layout_info(), but calculate it property through a binding.
Setting the value of the native_padding_{left, right, top, bottom}
properties *during* the layout_info() call is too late, as the calling
compute_layout implementation has already queried for those properties.
Instead, this patch moves the padding calculation into a shared property
binding that's queried from bindings to the individual native_padding_*
properties and layout_info() just uses the properties, too.
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.
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.
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
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.
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.
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).
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.
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.
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
```
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)