Commit graph

304 commits

Author SHA1 Message Date
Olivier Goffart
cae0503fbb Update outdated dependencies 2020-10-12 10:29:07 +02:00
Olivier Goffart
9a909142a8 Disable wayland dependency by default 2020-10-10 16:10:22 +02:00
Olivier Goffart
9dbe1f874f One need image 0.23.10 to use image::ImageBuffer::as_raw 2020-10-09 12:08:18 +02:00
Simon Hausmann
51f9fc0e61 Refresh the window when loading of an HTML image completed 2020-10-09 10:44:15 +02:00
Simon Hausmann
f4b6eea646 Implement the rest of the dynamic image loading for the online editor
This works except that there's a mechanism missing for refreshing the
canvas when the image was loaded.
2020-10-09 10:10:48 +02:00
Simon Hausmann
785f23f01a Make the tex__image_2d call work
* Set cross origin for the image to "anonymous" to ask the server for permission
* Pass RGBA as internal format
2020-10-09 09:57:45 +02:00
Olivier Goffart
6c9f0691aa WIP: Attempt to get image loading in wasm
Not working
2020-10-09 09:57:45 +02:00
Simon Hausmann
0f07684fcf Clean up GLFrame::render_primitive
Move the main match out into a separate helper function in GLFrame and
keep render_primitive to just be the loop. This will also make it easier
to implement the dynamic primitives later.
2020-10-09 09:56:32 +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
4ff3bf4ebf Fix crash with native style and large widgets
The native style typically allocates a texture for its surface, and if that
exceeds the size of the texture atlas, then we need to adjust instead
of crash.
2020-10-05 12:52:04 +02:00
Olivier Goffart
57ccd26393 Update winit 2020-10-03 14:55:25 +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
Simon Hausmann
97f8dd0d1b Use a tight bounding box around rasterized glyphs
Fixes #8
2020-10-01 13:27:14 +02:00
Simon Hausmann
fdebd8427d Improve texture atlas handling
Avoid the manual padding of images in the texture atlas. This is a
CPU-side expensive operation and we can avoid doing that by instead
adjusting the texture coordinates to map to the center of the texels.
This is also described nicely in
https://docs.microsoft.com/en-us/windows/win32/direct3d9/directly-mapping-texels-to-pixels
2020-10-01 09:51:18 +02:00
Simon Hausmann
88b94a26ea Add support for clip rectangles in the GL rendering backend 2020-09-29 11:42:02 +02:00
Olivier Goffart
6662e1ff00 Proper Scrollbar on the native style 2020-09-28 18:13:13 +02:00
Simon Hausmann
f05d3c58e2 Revert "Fix crash on start-up of rusttest2"
This reverts commit 7e5b6843a4. Lyon
0.16.2 contains the fix.
2020-09-28 13:30:17 +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
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