Commit graph

67 commits

Author SHA1 Message Date
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Olivier Goffart
310bf897cd Native ComboBox: style the background of the popup
Fixes: #720
2021-12-06 18:52:10 +01:00
Olivier Goffart
80c0602277 WIP: start making the corelib crate a no_std crate
Does not compile yet with no_std because of the lack of
alternative for thread_local
2021-11-25 12:02:16 +01:00
Olivier Goffart
becb4574c1 Qt backend: don't set Qt::AA_PluginApplication when using the backend
Otherwise Qt won't set the hidpi mode on windows, for example
2021-11-17 09:05:24 +01:00
Simon Hausmann
e305f0e61c Fix sixtyfps::quit_event_loop() not exiting the event loop with Qt 6 on macOS
As per commit 0c02f133f3daee146b805149e69bba8cee6727b2 in qtbase (qt6),
quit() on QCoreApplication on macOS calls [NSApp terminate], which will
not return to main. The latter however is documented behavior, and
sixtyfps-viewer for example relies on it.
2021-10-11 16:55:32 +02:00
Simon Hausmann
0e8efea2ff Further speed up font handling in the GL backend
Use the new fontdb API:

* When registering embedded fonts, we don't need to make a copy of the
  embedded font data anymore.
* We don't have to mmap the font files ourselves anymore, fontdb can
  do this now for us.
2021-10-04 15:11:55 +02:00
Tobias Hunger
604f91681b Janitor: Fix clippy::needless_return 2021-08-18 00:24:51 +02:00
Tobias Hunger
a387c0f60f Janitor: Fix clippy::needless_borrow 2021-08-18 00:24:51 +02:00
Olivier Goffart
a094ce7a2a Add a warning on the internal crates documentation that we don't follow semver 2021-08-16 18:26:33 +02:00
Simon Hausmann
f25f85844d Remove SharedImageBuffer from the public Rust API
and instead fold the constructor functions into Image as `new_rgb8`/`new_rgba8` and `new_rgba8_premultiplied`.
2021-08-10 15:56:01 +02:00
Simon Hausmann
b6254d2fd7 Fix doc error
In a non-Qt build ImageInner would be unused and trigger a warning that's an error.
2021-08-10 15:56:01 +02:00
Simon Hausmann
64522d9d17 Qt backend: speed up determining the size of embedded images
Don't go through the dance of copying the image buffer into a QImage just to determine the size.
2021-08-10 15:56:01 +02:00
Olivier Goffart
3d7ce0fed8 Rename the qt/widgets.rs to qt/qt_widgets.rs
there are other files wih widgets in their name, so disambiguate
2021-08-06 18:48:58 +02:00
Olivier Goffart
9d40779d69 WIP work for TabWidget 2021-08-06 15:58:13 +02:00
Simon Hausmann
eaddbe664e internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
2021-07-21 20:33:02 +02:00
Simon Hausmann
1c285694d7 internal cleanup: Remove the use of ComponentWindow in the interpreter 2021-07-21 17:41:12 +02:00
Simon Hausmann
2553dd1459 Trim the Rust ComponentWindow API and implementation a little bit
* Remove the `new` function from the main impl and use the slightly
  less visible From conversion trait
* Make the inner Rc<Window> pub(crate) instead of pub
* Instead, provide a public as_any() accessor that the Qt backend can use
2021-07-21 17:41:12 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Simon Hausmann
0fdb87cc69 Add Image::size()
This requires the image size query to be window independent and go
through the backend instead.

This implies minor changes for the Qt backend and bigger ones for the GL
backend:

* There exists now a thread-local IMAGE_CACHE, which is used by the
  backend's image_size() function as well as by the renderer for
  loading CPU side images.
* The image remain as decoded images in there (including SVG tree)
  and the window now has a texture_cache, which holds CachedImage
  with ImageData::Texture.
* Rendering an image item therefore fetches the CPU side image,
  calls upload_to_gpu() on it, which creates a new Rc<CachedImage>
  and that's stored in the texture_cache.
* The texture cache continues to be pruned when hiding the window.
2021-06-20 11:18:28 +02:00
Simon Hausmann
27dcfa0f11 Improved rendering of drop shadow for Qt
Use QGraphicsBlurEffect as public API to take the blur into account
2021-05-21 17:33:21 +02:00
Olivier Goffart
1f46fd05ec Allow the qt_viewer to compile if cmake finds qt, but not qttypes
This can happen when setting the SIXTYFPS_NO_QT env variable

cc #232
2021-05-21 07:45:38 +02:00
Olivier Goffart
2e09a58fd7 Use the qttypes crate 2021-04-20 12:41:44 +02:00
Simon Hausmann
a792b52515 Load custom fonts from disk only once with Qt
Amends commit 4cf3fa5179
2021-04-13 10:53:21 +02:00
Simon Hausmann
1e4921de13 Fix LSP server staying alive when closing preview window
* Provide an internal behavior parameter to run_event_loop() that we can use
from the preview to not quit when the last window was closed.
* Fix Drop for the winit event loop GraphicsWindow to drop the backend window correctly
  when unmapping, not when the graphics window dies. Otherwise QuitOnLastWindowClosed doesn't work.
2021-04-06 12:11:55 +02:00
Olivier Goffart
d76ee8371f Fix warning when Qt is not built 2021-04-03 10:23:41 +02:00
Olivier Goffart
309a9274e1 LSP: preview window
Currently not yet live preview from the open document content, but that should totaly be doable
2021-04-03 10:00:12 +02:00
Olivier Goffart
c3046f5a55 Add a way to send an event to the GUI thread from any thread
The idea is that the callback is meant to be run in the gui thread

(untested)
2021-04-03 10:00:12 +02:00
Simon Hausmann
4cbcf2611f Fix recurring C++ timers
* sixtyfps_timer_start needs to *take* the timer id out of the Rust
  timer to avoid that the subsequent drop stops the timer again
* For the Qt event loop, call `timer_event()` once before entering
  QCoreApplication::exec(), to schedule any timers that were started
  beforehand.
* Added a way to quit the event loop gently, in order to use that
  from the C++ unit test.
2021-03-25 20:07:12 +01:00
Simon Hausmann
e63baa5766 Re-organize Window and PlatformWindow construction and referencing
Initialize the self_weak in the PlatformWindow impl using the
Rc::new_cyclic pattern with a construction parameter.
2021-03-25 09:43:59 +01:00
Olivier Goffart
1dba04721a Add a qt_viewer example that uses QWidget 2021-03-23 17:13:41 +01:00
Olivier Goffart
35cce45cbc Add a fii feature so that we don't compile in the ffi code if not required 2021-03-16 18:09:57 +01:00
Simon Hausmann
f087cc18bc Remove extern "C" functions from wasm module
We don't need these functions and their export. They account for ~20kb in
the optimized .wasm - plus JS glue code.
2021-02-26 17:04:49 +01:00
Simon Hausmann
d5d537b1ce Remove redundant to_string() call 2021-02-17 15:28:58 +01:00
Simon Hausmann
3ba92bdc6d Add API to the wasm interpreter to download and register fonts 2021-02-17 15:21:30 +01:00
Simon Hausmann
445ddd58d5 API cleanup
Remove the `application` infix from `register_application_font`, to
reduce the changes that it might be interpreted to be a function that
also changes the default font in all text elements.
2021-02-17 14:37:31 +01:00
Simon Hausmann
f7ab4625e4 Prospective build fix
Use the same to_string_lossy() code path on all platforms
2021-02-17 14:32:02 +01:00
Simon Hausmann
45fe6c3e8d Add the ability to load application fonts by path
The viewer command line tool also gains the ability to specify them via `--app-font=/path/to/font.ttf` , which can be specified multiple times.
2021-02-17 14:16:52 +01:00
Olivier Goffart
9eac131ae5 Add the logo in the docs 2021-02-12 08:24:42 +01:00
Olivier Goffart
86d40ad5e0 Some warning fix in the CI
- re-enable Qt for the C++ part now that the download server is back up
 - Use the proper way to set env variable on Windows
 - Silent deprecated warning for alloc::LayoutError
 - Silent warning in qt/lib.rs when Qt is not there
 - remove LD_LIBRARY_PATH workaround as the install-qt-action is fixed
2021-01-22 17:58:53 +01:00
Olivier Goffart
9eedb730d2 Fix build when Qt is not available 2021-01-22 17:11:21 +01:00
Simon Hausmann
9e0927f324 Move the clipboard access from corelib to the backend
This way the backend doesn't need to depend on copypasta.
2021-01-22 15:25:06 +01:00
Simon Hausmann
5f265ffc09 Split up ComponentWindow::run() into show(), hide() and sixtyfps::run_event_loop()
This allows creating multiple windows for example, and it will allow for
showing windows in those tests that require a mapped window.

As a bonus, the run() function on generated components is not consuming
anymore.
2021-01-19 09:50:22 +01:00
Olivier Goffart
d65a655333 Fix Wasm build error and warnings 2021-01-15 15:23:17 +01:00
Olivier Goffart
f1ce103c7b WIP: start splitting Window and PLatformWindow 2021-01-15 15:02:55 +01:00
Olivier Goffart
547b2a7f6e Introduce Backend trait
Such that the font are properly registered when the GL backend is chosen at runtime
2021-01-15 12:20:32 +01:00
Olivier Goffart
a069ceae7f Fix warning with wasm 2021-01-14 08:53:14 +01:00
Olivier Goffart
62150cba1a Basic text input 2021-01-14 08:53:13 +01:00
Olivier Goffart
0b20d13401 Qt backend: Implement register_application_font_from_memory 2021-01-14 08:53:13 +01:00
Olivier Goffart
46dbb1ee9e By default, enable the GL backend also on desktop
So it can be chosen with an env variable or if Qt is not available
2021-01-14 08:53:13 +01:00
Olivier Goffart
49c9881d10 fix compile 2021-01-14 08:53:13 +01:00