Commit graph

61 commits

Author SHA1 Message Date
Olivier Goffart
0c97b4f296 More use of the ItemRc 2020-11-24 13:42:34 +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
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
0389893df5 Add enabled state to CheckBox/SpinBox/Slider/GroupBox in the native style 2020-11-06 11:09:40 +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
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
a82c23fc41 Add ability for the native style to export native Globals 2020-11-02 16:13:04 +01:00
Olivier Goffart
d2255327fe Properties: make sure that the falue is different before marking all dependencies dirty
Fix the animation of the gauge in the printer demo
2020-10-31 12:58:11 +01:00
Simon Hausmann
c3ba5a0808 Clean up NativeButton
Eliminate native_button_enabled
2020-10-30 16:28:06 +01:00
Simon Hausmann
6b7630963f Add support for disabling a Button
This also removes the funny binding on the button in the gallery.
UI wise it's confusing that a button changes its size when pressed, and we can
show off bindings somewhere else :-)
2020-10-30 15:55:18 +01:00
Simon Hausmann
7e305a53fe Fix rendering of NativeButton and NativeCheckBox
* 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.
2020-10-30 15:55:18 +01:00
Simon Hausmann
7d3337e1d1 Add missing comment I forgot to stage 2020-10-29 14:56:26 +01:00
Simon Hausmann
aa303d29c5 Fix rendering of scrollbars on macOS
The NSScroller is drawn completely disregarding the painter's translation.

So this patch goes for an intermediate image buffer instead.
2020-10-29 14:53:16 +01:00
Simon Hausmann
f010f62ad2 Remove dead code
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.
2020-10-29 14:47:53 +01:00
Olivier Goffart
47be71e16d Introduce layout stretching 2020-10-26 16:40:35 +01:00
Olivier Goffart
9f08492258 Make sure that the ListView is not scrolled when there is enough room for all contents
Fixes #93
2020-10-21 09:47:33 +02:00
Olivier Goffart
e46e0b683c Fix the size of the native CheckBox 2020-10-20 19:00:40 +02:00
Olivier Goffart
2f9bc39010 Qt style: use a shared array everywhere 2020-10-19 11:52:03 +02:00
Olivier Goffart
b60567d7f2 Qt style: Use an QImage that is backed by a SharedArray
This way we have one copy less of the data
2020-10-19 11:35:57 +02:00
Olivier Goffart
7984e45a1f Fix ListView snapping to the bottom instead of the top
When there are not enough elements to fill the viewport
2020-10-16 11:21:59 +02:00
Olivier Goffart
e4e601de83 Draw the frame properly around the native scrollview 2020-10-16 10:45:17 +02:00
Olivier Goffart
e48f0b7621 Add a current item to the StandardListView 2020-10-14 14:32:18 +02:00
Olivier Goffart
478bae93e1 Fix native scroolbar looking like sliders :-/ 2020-10-13 14:37:48 +02:00
Simon Hausmann
2f7839e326 Remove unused BuiltinItem derivation
It's not needed :-)
2020-10-12 18:21:36 +02:00
Simon Hausmann
e1fdef73b1 Remove unused data structure
Added accidentally in parent commit
2020-10-12 18:20:25 +02:00
Simon Hausmann
805ba494ba Fix native padding calculation for NativeLineEdit
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.
2020-10-12 16:49:44 +02:00
Simon Hausmann
fa982b9380 Fix calculation of native group box padding
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.
2020-10-12 16:49:44 +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
Olivier Goffart
3bdd71b36f Start working on the Native ListView
Currently only the interpret part
2020-10-08 15:51:33 +02:00
Simon Hausmann
3c7e1e414b Fix native button size with new gridlayout
Make the button size fixed, like in the ugly style.
2020-10-02 15:55:56 +02:00
Olivier Goffart
6662e1ff00 Proper Scrollbar on the native style 2020-09-28 18:13:13 +02:00
Olivier Goffart
6dd0d178a0 Rename ScrollArea to ScrollView 2020-09-28 10:52:29 +02:00
Simon Hausmann
b7299af5d9 Attempt to make the focus ring of line edits also visible for the native style
On macOS that's not visible though due to the margins not being included in the rendering somehow.
2020-09-25 11:23:43 +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
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
93a08c5207 Add a LineEdit widget to the ugly and native style 2020-09-18 18:54:37 +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
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
546818ee55 Add key event data structures and event function boiler plate 2020-09-15 11:16:55 +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
23ba165752 Remove the use of QApplication::globalStrut()
That is AFAIK a deprecated concept.
2020-09-09 18:55:43 +02:00