Commit graph

4616 commits

Author SHA1 Message Date
Simon Hausmann
21f9850b43 Small spelling fix 2021-09-29 14:55:08 +02:00
Simon Hausmann
fc491b167f Add a doctest for sixtyfps::Image::path() 2021-09-28 08:52:27 +02:00
Simon Hausmann
4eef8c7688 Add API to sixtyfps::Image in Rust and C++ to access the optional path 2021-09-28 08:52:27 +02:00
Olivier Goffart
bbe178aadf Add links to the template repositories 2021-09-28 08:24:44 +02:00
Simon Hausmann
cbefe741fc Link to the template repos from the README 2021-09-27 10:47:37 +02:00
Olivier Goffart
f2774a41a5 Document logical and comparison operators 2021-09-24 09:43:23 +02:00
Olivier Goffart
28932a32a5 Mention the bool type in the docs 2021-09-24 09:26:00 +02:00
Olivier Goffart
0eb223b2ca Update tools/viewer/main.rs
Co-authored-by: Simon Hausmann <simon.hausmann@sixtyfps.io>
2021-09-24 09:23:48 +02:00
Olivier Goffart
321d985242 Viewer: add ability to load and save property values from/to json
issue #238
2021-09-24 09:23:48 +02:00
Simon Hausmann
fa89758dc5 Fix background color of window when viewing non-window elements
The synthetic window we "inject" in the ensure_window() pass did not
have the window-background from the style applied. This is visible
for example when viewing something like

    Rectangle { background: blue; border-radius: height / 2 }
2021-09-23 19:19:06 +02:00
Olivier Goffart
730cbf1ef9 Interpreter: add type checking for declared properties
issue #512
2021-09-23 19:17:17 +02:00
Olivier Goffart
3f13c69ca8 Hide the cursor of the disabled TextEdit
Fixes #513
2021-09-23 12:39:57 +02:00
Simon Hausmann
5ee005c972 Fix panic in LSP when declaring animation on layout controlled property
When an animate foo {} declaration ends up creating an synthetic, invalid BindingExpression,
we still need to give it a span, to ensure that the diagnostics
produced later have *some* location set.

Fixes #515
2021-09-22 16:01:29 +02:00
Simon Hausmann
7edf19d5b2 Fix GL backend build without x11
Copypasta's wayland clipboard requires a different API that we don't cater to yet, so
for now to fix the build, disable the clipboard (use in-app nop).
2021-09-22 11:52:42 +02:00
Simon Hausmann
043c1932ad Make it possible to disable x11 support
The GL backend defaults to enabling X11. The default crate depends on
the GL backend but it doesn't specify default-features = false,
therefore x11 is basically always enabled.

In line with commit 1fd8c7236a, this
change makes sure that the defaults are defined in the tree entry
points: The Rust API crate, the interpreter crate and the CMake project
define the defaults. The latter already enabled X11 by default, but the
first two did not.
2021-09-22 11:32:51 +02:00
Simon Hausmann
8fea1bf52e GL backend: Fix missing glyphs in the slide puzzle demo
The checkmark and reload have always been missing in some circumstances.
The recent fixes with glyph coverage check helped, but they do not account for the fact that
characters like the check mark map to the same script (Common). So for these scripts
we need to perform an exact glyph coverage check.
2021-09-21 14:12:44 +02:00
Simon Hausmann
1214e444f0 GL backend: minor speed up for font fallback handling
Avoid the dance of using font-kit to re-discover the same .ttf file and
read it all into memory every time we need to render text where the primary font
provides insufficient coverage.
2021-09-21 11:09:37 +02:00
Simon Hausmann
b5de610eb6 GL backend: minor speed up in text rendering
Only query fallback fonts from the system if we really need to.
2021-09-21 10:50:09 +02:00
Simon Hausmann
ac0cc85d33 Simplify font resolution in the GL backend
The font resolution function querying fontdb is fast now, so we can
always call it when rendering text. That way we don't need all the
indirection in the text_size(), etc. functions, we don't need an entry
in the item graphics cache for the font and we can avoid a lot of
property dependencies.
2021-09-21 10:10:45 +02:00
Simon Hausmann
2f1db396e8 GL backend: Speed up glyph coverage checking
Instead of always mapping the face (from disk), first fan out existing
cached coverage information. Any unchecked scripts are then checked
in the slow code path with `with_face_data` later.
2021-09-21 10:07:21 +02:00
Simon Hausmann
b021152fcc GL backend: Fix internal variable name
The available families is used on all platforms and doesn't need a _ prefix anymore.
2021-09-21 09:20:01 +02:00
Simon Hausmann
45aa93f1b1 Make it possible to use the C++ build with Qt 6
Since we require Qt 5.15, we can use the versionless CMake targets and also
find Qt 6 first.
2021-09-20 17:02:35 +02:00
Simon Hausmann
324fb48499 Clean up generated C++ include directory handling
Don't generate the headers by default in the source directory, put them
into a sub-directory in OUT_DIR instead and convey that location via
links to the C++ test driver.
2021-09-18 07:32:53 +02:00
Simon Hausmann
499ab6645c Disable the examples build by default again
This reverts commit a79ee93ea9 and
re-instates the change of 3358841ab0, as
the dependency issue with generating the header files in time for make
install is fixed by running cbindgen in build.rs of sixtyfps-cpp,
instead of via xtask from cmake.
2021-09-18 07:32:53 +02:00
Simon Hausmann
4f158618a1 Fix make install in the C++ build running cbindgen
Make install would still trigger the generated_headers_target CMake
custom command - due to the use of add_dependencies - and that would end
up running cbindgen. That in turn breaks "make install" when it's run in
an environment that doesn't have cargo in PATH (for example when using
"sudo make install").

This patch folds the generation of the C++ header files into the build
of the sixtyfps-cpp crate - via build.rs. By default the headers are
placed in api/sixtyfps-cpp/generated_include but the CMake build
redirects that into the build directory.

Note: Due to the way that corrosion works, cargo is still run when
running "make install", but it's path is absolute and there should not
be any reliance on the PATH environment variable.
2021-09-18 07:32:53 +02:00
Simon Hausmann
562842f19e Bump minimum required CMake version from 3.16 to 3.19
The upcoming re-organization of the C++ header generation requires the
use of the CORROSION_ENVIRONMENT_VARIABLES target property, which in
turn requires CMake >= 3.19.
2021-09-18 07:32:53 +02:00
Simon Hausmann
d2923d51f6 GL backend: add basic font fallback support for Linux
Use the static (but long) fallback list that we get from fontconfig in the beginning.

This works, but can be optimized to operate on a trimmed and shorter list,
which will speed up the fallback. But for now this makes it work.
2021-09-17 18:58:18 +02:00
Simon Hausmann
cc7ea5b92a GL renderer: fix rendering of Text/TextInput when the text property changes in a way that requires different fonts
Unfortunately the text property was not included in the property dependency chain
for the cached Font.
This is fixed by delaying that with a getter function, but in the mid term
we should be able to remove this again once
femtovg learns lazy font resolution.
2021-09-17 18:27:44 +02:00
Simon Hausmann
db842e1b6b Fix font fallback handling on macOS
Permit processing the entire font cascade list and load fonts from there
lazily by checking their glyph coverage and remembering it.
2021-09-17 18:27:40 +02:00
Simon Hausmann
6130e04e84 Rework the font loading in the GL backend
The basic idea is to use fontdb's load_system_fonts() mechanism, in
conjunction with its built-in mmap support, to get an overview over all
installed fonts on macOS, Windows and Linux.

This isn't quite perfect in terms of discovering systems defaults, but
it's much faster than font-kit's approach of querying the system (good)
but reading the matched files into memory (not using mmap). And we have
the option of perfecting it by using fontconfig directly on Linux (where
the backend is most important).

This also paves the way for better fallback handling, as now we have a
list of all available families and we can use system APIs to query for
fallbacks.
2021-09-17 14:41:14 +02:00
Simon Hausmann
a79ee93ea9 Fix install in default cmake build
Disabling the build of any artefacts (examples, tests) that depend on the SixtyFPS target somehow
prevents generated_headers_target from being run.

The plan is to get rid of that target and run cbindgen in build.rs of the cpp
crate, but meanwhile re-enable the examples build by default.
2021-09-16 11:50:22 +02:00
Simon Hausmann
26ed010146 Bump run-cmake Github Action version in the CI
The new version promises improved diagnostics (log files) and security
fixes.
2021-09-16 11:28:40 +02:00
Simon Hausmann
fb26ad777e Prospective fix for cmake args not being appended 2021-09-16 10:47:19 +02:00
Simon Hausmann
0e191caf78 Improve cmake diagnostics
Print a feature summary. This also helps diagnose CI builds.
2021-09-16 10:41:33 +02:00
Simon Hausmann
3358841ab0 Disable the build of tests and examples by default
Re-enable them in the CI (naturally), but with them off by default any
spurious compiler warnings in the tests won't break the build of users
and we don't clone catch2 and fmtlib by default.
2021-09-16 09:53:59 +02:00
Simon Hausmann
c86f2617b3 Fix natively styled list view item active/inactive rendering
Amends commit ed3d848d02
2021-09-15 15:39:15 +02:00
Simon Hausmann
ed3d848d02 Fix native widget rendering when the window is inactive
Set QStyle::State_Active conditional to whether the window is active,
which maps to Qt's active window concept and winit's has-focus (until we
render popups differently).
2021-09-15 15:34:34 +02:00
Simon Hausmann
1b64db70bd Fix rendering of the current tab in the natively styled tab widget on macOS
It was impossible to see which tab was the current tab.
Ensure that we set State_Active, like we do for the other styled controls.

Later, the active state should be tied to whether the window is "active" or not.
2021-09-15 13:35:41 +02:00
Simon Hausmann
fa294c9b02 Fix C++ warning about unused variable
The insert_it variable is unused, and some compilers warn about it, causing -Werror builds to fail.
2021-09-15 12:59:17 +02:00
Simon Hausmann
5fc5563c99 Minor cleanup: Replace expect() with unwrap() and comment
That's the more common pattern we use currently.
2021-09-15 08:49:27 +02:00
Simon Hausmann
5742a122ed Fix listview not updating its geometry in Rust when the entire model is changed
The geometry tracker did not track the model property itself, so it did not become dirty.

Fixes #500
2021-09-15 08:49:27 +02:00
Simon Hausmann
cd5385887b Internal cleanup: Replaces more uses of **foo with foo.as_str()
Same as commit 0b7dc17644, this makes it easier to see where the deref leads to.
2021-09-15 07:56:28 +02:00
Simon Hausmann
4779c97ba2 Internal cleanup: Keep globals related data together
In ComponentDescription only keep a exported_globals_by_name that
maintains the index in the compiled_globals vector and in there store
the public properties of global singletons.
2021-09-15 07:56:28 +02:00
Simon Hausmann
70581ccb37 Internal cleanup: simplify string comparison 2021-09-15 07:56:28 +02:00
Simon Hausmann
c3d0fd04af Add C++ API to introspect exported global singletons in the interpreter
This adds the necessary shims to expose the same API as Rust.
2021-09-15 07:56:28 +02:00
Simon Hausmann
a855d868fc Add support for introspecting globals in the interpreter Rust API
Add three straight-forward functions:

    * pub fn globals(&self) -> impl Iterator<Item = String> + '_
    * pub fn global_properties( &self,
          global_name: &str,
      ) -> Option<impl Iterator<Item = (String, ValueType)> + '_>
    * pub fn global_callbacks(&self, global_name: &str
      ) -> Option<impl Iterator<Item = String> + '_>

Implementation wise this requires passing along a way to get the
non-normalized (original) export name, as globals() should return the
names as the developer/designer specified them, and
global_properties()/global_callbacks() normalizes.
2021-09-15 07:56:28 +02:00
Simon Hausmann
ce1e5fa19d Minor code cleanup
For item rendering, place the rendere into a refcell only for the time
we're visiting the tree.
2021-09-14 15:20:21 +02:00
Simon Hausmann
9b5a86fbaa Mention the TabWidget fix in the ChangeLog 2021-09-14 10:43:44 +02:00
Simon Hausmann
85a46c07b7 Fix panic when using height-for-width element in natively styled TabWidget
The metrics properties and the implementation of layout_info needs to
strictly reading cross-axis properties to avoid circular dependencies.

This patch applies a INT_MAX / 2 on the cross-axis to QStyle when
querying. Mostly the styles appear to just add/subtract margins, so this
value should not produce overflows while still providing an
approximation of "infinite" :)

Fixes #412
2021-09-14 10:05:15 +02:00
Simon Hausmann
37464a45c5 Fix rustdoc build in the CI
The nightly has become a bit more picky about seemingly unused variables
:-)
2021-09-13 14:19:17 +02:00