mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 23:27:22 +00:00
Rename the sixtyfps C++ namespaces
This commit is contained in:
parent
5226feab01
commit
7d297da2fc
96 changed files with 747 additions and 753 deletions
|
@ -25,7 +25,7 @@ fn default_config() -> cbindgen::Config {
|
|||
cbindgen::Config {
|
||||
pragma_once: true,
|
||||
include_version: true,
|
||||
namespaces: Some(vec!["sixtyfps".into(), "cbindgen_private".into()]),
|
||||
namespaces: Some(vec!["slint".into(), "cbindgen_private".into()]),
|
||||
line_length: 100,
|
||||
tab_width: 4,
|
||||
// Note: we might need to switch to C if we need to generate bindings for language that needs C headers
|
||||
|
@ -59,21 +59,21 @@ fn default_config() -> cbindgen::Config {
|
|||
fn gen_item_declarations(items: &[&str]) -> String {
|
||||
format!(
|
||||
r#"
|
||||
namespace sixtyfps::private_api {{
|
||||
#define SIXTYFPS_DECL_ITEM(ItemName) \
|
||||
namespace slint::private_api {{
|
||||
#define SLINT_DECL_ITEM(ItemName) \
|
||||
extern const cbindgen_private::ItemVTable ItemName##VTable; \
|
||||
extern SIXTYFPS_DLL_IMPORT const cbindgen_private::ItemVTable* sixtyfps_get_##ItemName##VTable();
|
||||
extern SLINT_DLL_IMPORT const cbindgen_private::ItemVTable* slint_get_##ItemName##VTable();
|
||||
|
||||
extern "C" {{
|
||||
{}
|
||||
}}
|
||||
|
||||
#undef SIXTYFPS_DECL_ITEM
|
||||
#undef SLINT_DECL_ITEM
|
||||
}}
|
||||
"#,
|
||||
items
|
||||
.iter()
|
||||
.map(|item_name| format!("SIXTYFPS_DECL_ITEM({});", item_name))
|
||||
.map(|item_name| format!("SLINT_DECL_ITEM({});", item_name))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
)
|
||||
|
@ -179,7 +179,7 @@ fn gen_corelib(
|
|||
.with_config(string_config)
|
||||
.with_src(crate_dir.join("string.rs"))
|
||||
.with_src(crate_dir.join("slice.rs"))
|
||||
.with_after_include("namespace sixtyfps { struct SharedString; }")
|
||||
.with_after_include("namespace slint { struct SharedString; }")
|
||||
.generate()
|
||||
.context("Unable to generate bindings for sixtyfps_string_internal.h")?
|
||||
.write_to_file(include_dir.join("sixtyfps_string_internal.h"));
|
||||
|
@ -187,7 +187,7 @@ fn gen_corelib(
|
|||
cbindgen::Builder::new()
|
||||
.with_config(config.clone())
|
||||
.with_src(crate_dir.join("sharedvector.rs"))
|
||||
.with_after_include("namespace sixtyfps { template<typename T> struct SharedVector; }")
|
||||
.with_after_include("namespace slint { template<typename T> struct SharedVector; }")
|
||||
.generate()
|
||||
.context("Unable to generate bindings for sixtyfps_sharedvector_internal.h")?
|
||||
.write_to_file(include_dir.join("sixtyfps_sharedvector_internal.h"));
|
||||
|
@ -205,7 +205,7 @@ fn gen_corelib(
|
|||
.with_config(properties_config)
|
||||
.with_src(crate_dir.join("properties.rs"))
|
||||
.with_src(crate_dir.join("callbacks.rs"))
|
||||
.with_after_include("namespace sixtyfps { class Color; class Brush; }")
|
||||
.with_after_include("namespace slint { class Color; class Brush; }")
|
||||
.generate()
|
||||
.context("Unable to generate bindings for sixtyfps_properties_internal.h")?
|
||||
.write_to_file(include_dir.join("sixtyfps_properties_internal.h"));
|
||||
|
@ -281,9 +281,9 @@ fn gen_corelib(
|
|||
special_config.structure.derive_eq = true;
|
||||
special_config.structure.derive_neq = true;
|
||||
// Put the rust type in a deeper "types" namespace, so the use of same type in for example generated
|
||||
// Property<> fields uses the public `sixtyfps::Blah` type
|
||||
// Property<> fields uses the public `slint::Blah` type
|
||||
special_config.namespaces =
|
||||
Some(vec!["sixtyfps".into(), "cbindgen_private".into(), "types".into()]);
|
||||
Some(vec!["slint".into(), "cbindgen_private".into(), "types".into()]);
|
||||
cbindgen::Builder::new()
|
||||
.with_config(special_config)
|
||||
.with_src(crate_dir.join("graphics.rs"))
|
||||
|
@ -302,7 +302,7 @@ fn gen_corelib(
|
|||
|
||||
// Generate a header file with some public API (enums, etc.)
|
||||
let mut public_config = config.clone();
|
||||
public_config.namespaces = Some(vec!["sixtyfps".into()]);
|
||||
public_config.namespaces = Some(vec!["slint".into()]);
|
||||
public_config.export.item_types = vec![cbindgen::ItemType::Enums, cbindgen::ItemType::Structs];
|
||||
public_config.export.include = vec!["TimerMode".into(), "IntSize".into()];
|
||||
public_config.export.exclude.clear();
|
||||
|
@ -321,13 +321,13 @@ fn gen_corelib(
|
|||
.with_src(crate_dir.join("graphics.rs"))
|
||||
.with_after_include(format!(
|
||||
r"
|
||||
/// This macro expands to the to the numeric value of the major version of SixtyFPS you're
|
||||
/// This macro expands to the to the numeric value of the major version of Slint you're
|
||||
/// developing against. For example if you're using version 1.5.2, this macro will expand to 1.
|
||||
#define SLINT_VERSION_MAJOR {}
|
||||
/// This macro expands to the to the numeric value of the minor version of SixtyFPS you're
|
||||
/// This macro expands to the to the numeric value of the minor version of Slint you're
|
||||
/// developing against. For example if you're using version 1.5.2, this macro will expand to 5.
|
||||
#define SLINT_VERSION_MINOR {}
|
||||
/// This macro expands to the to the numeric value of the patch version of SixtyFPS you're
|
||||
/// This macro expands to the to the numeric value of the patch version of Slint you're
|
||||
/// developing against. For example if you're using version 1.5.2, this macro will expand to 2.
|
||||
#define SLINT_VERSION_PATCH {}
|
||||
",
|
||||
|
@ -386,10 +386,10 @@ fn gen_corelib(
|
|||
.with_include("sixtyfps_generated_public.h")
|
||||
.with_after_include(
|
||||
r"
|
||||
namespace sixtyfps {
|
||||
namespace slint {
|
||||
namespace private_api { class WindowRc; }
|
||||
namespace cbindgen_private {
|
||||
using sixtyfps::private_api::WindowRc;
|
||||
using slint::private_api::WindowRc;
|
||||
using namespace vtable;
|
||||
struct KeyEvent; struct PointerEvent;
|
||||
using private_api::Property;
|
||||
|
@ -497,7 +497,7 @@ fn gen_interpreter(
|
|||
|
||||
// Generate a header file with some public API (enums, etc.)
|
||||
let mut public_config = config.clone();
|
||||
public_config.namespaces = Some(vec!["sixtyfps".into(), "interpreter".into()]);
|
||||
public_config.namespaces = Some(vec!["slint".into(), "interpreter".into()]);
|
||||
public_config.export.item_types = vec![cbindgen::ItemType::Enums, cbindgen::ItemType::Structs];
|
||||
|
||||
public_config.export.exclude = IntoIterator::into_iter([
|
||||
|
@ -528,11 +528,11 @@ fn gen_interpreter(
|
|||
.with_include("sixtyfps_interpreter_generated_public.h")
|
||||
.with_after_include(
|
||||
r"
|
||||
namespace sixtyfps::cbindgen_private {
|
||||
namespace slint::cbindgen_private {
|
||||
struct Value;
|
||||
using sixtyfps::interpreter::ValueType;
|
||||
using sixtyfps::interpreter::PropertyDescriptor;
|
||||
using sixtyfps::interpreter::Diagnostic;
|
||||
using slint::interpreter::ValueType;
|
||||
using slint::interpreter::PropertyDescriptor;
|
||||
using slint::interpreter::Diagnostic;
|
||||
}",
|
||||
)
|
||||
.generate()
|
||||
|
@ -543,7 +543,7 @@ fn gen_interpreter(
|
|||
}
|
||||
|
||||
/// Generate the headers.
|
||||
/// `root_dir` is the root directory of the sixtyfps git repo
|
||||
/// `root_dir` is the root directory of the slint git repo
|
||||
/// `include_dir` is the output directory
|
||||
/// Returns the list of all paths that contain dependencies to the generated output. If you call this
|
||||
/// function from build.rs, feed each entry to stdout prefixed with `cargo:rerun-if-changed=`.
|
||||
|
|
|
@ -28,7 +28,7 @@ author = "info@sixtyfps.io"
|
|||
# The full version, including alpha/beta/rc tags
|
||||
version = "0.2.0"
|
||||
|
||||
cpp_index_common_prefix = ["sixtyfps::", "sixtyfps::interpreter::"]
|
||||
cpp_index_common_prefix = ["slint::", "slint::interpreter::"]
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
|
@ -37,8 +37,8 @@ cpp_index_common_prefix = ["sixtyfps::", "sixtyfps::interpreter::"]
|
|||
# ones.
|
||||
extensions = ["breathe", "myst_parser", "exhale", "sphinx_markdown_tables"]
|
||||
|
||||
breathe_projects = {"SixtyFPS": "./docs/xml"}
|
||||
breathe_default_project = "SixtyFPS"
|
||||
breathe_projects = {"Slint": "./docs/xml"}
|
||||
breathe_default_project = "Slint"
|
||||
|
||||
exhale_args = {
|
||||
"containmentFolder": "./api",
|
||||
|
@ -47,12 +47,12 @@ exhale_args = {
|
|||
"afterTitleDescription": textwrap.dedent(
|
||||
"""
|
||||
The following sections present the C++ API Reference. All types are
|
||||
within the :ref:`sixtyfps<namespace_sixtyfps>` namespace and are accessible by including
|
||||
within the :ref:`slint<namespace_slint>` namespace and are accessible by including
|
||||
the :code:`sixtyfps.h` header file.
|
||||
|
||||
If you choose to load :code:`.slint` files dynamically at run-time, then
|
||||
you can use the classes in :ref:`sixtyfps::interpreter<namespace_sixtyfps__interpreter>`, starting at
|
||||
:cpp:class:`sixtyfps::interpreter::ComponentCompiler`. You need to include
|
||||
you can use the classes in :ref:`slint::interpreter<namespace_slint__interpreter>`, starting at
|
||||
:cpp:class:`slint::interpreter::ComponentCompiler`. You need to include
|
||||
the :code:`sixtyfps_interpreter.h` header file.
|
||||
"""
|
||||
),
|
||||
|
@ -60,7 +60,7 @@ exhale_args = {
|
|||
"createTreeView": True,
|
||||
"exhaleExecutesDoxygen": True,
|
||||
"exhaleDoxygenStdin": """INPUT = ../../api/cpp/include generated_include
|
||||
EXCLUDE_SYMBOLS = sixtyfps::cbindgen_private* sixtyfps::private_api* vtable* SIXTYFPS_DECL_ITEM
|
||||
EXCLUDE_SYMBOLS = slint::cbindgen_private* slint::private_api* vtable* SLINT_DECL_ITEM
|
||||
EXCLUDE = ../../api/cpp/include/vtable.h ../../api/sixtyfps-cpp/include/sixtyfps_testing.h
|
||||
ENABLE_PREPROCESSING = YES
|
||||
PREDEFINED += DOXYGEN
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <condition_variable>
|
||||
#include <span>
|
||||
|
||||
namespace sixtyfps::cbindgen_private {
|
||||
namespace slint::cbindgen_private {
|
||||
// Workaround https://github.com/eqrion/cbindgen/issues/43
|
||||
struct ComponentVTable;
|
||||
struct ItemVTable;
|
||||
|
@ -35,7 +35,7 @@ struct ItemVTable;
|
|||
/// See the :doc:`Overview <../overview>` documentation for the C++ integration how
|
||||
/// to load :code:`.slint` designs.
|
||||
/// \endrst
|
||||
namespace sixtyfps {
|
||||
namespace slint {
|
||||
|
||||
// Bring opaque structure in scope
|
||||
namespace private_api {
|
||||
|
@ -60,7 +60,7 @@ using cbindgen_private::StandardListViewItem;
|
|||
/// thread is indeed called from the main thread, or abort the program otherwise
|
||||
///
|
||||
/// Most API should be called from the main thread. When using thread one must
|
||||
/// use sixtyfps::invoke_from_event_loop
|
||||
/// use slint::invoke_from_event_loop
|
||||
inline void assert_main_thread()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
|
@ -70,7 +70,7 @@ inline void assert_main_thread()
|
|||
"thread."
|
||||
<< std::endl;
|
||||
std::cerr << "Most API should be called from the main thread. When using thread one must "
|
||||
"use sixtyfps::invoke_from_event_loop."
|
||||
"use slint::invoke_from_event_loop."
|
||||
<< std::endl;
|
||||
std::abort();
|
||||
}
|
||||
|
@ -202,10 +202,9 @@ inline vtable::Layout drop_in_place(ComponentRef component)
|
|||
// so we have a relocation to a function that returns the address we seek. That
|
||||
// relocation will be resolved to the locally linked stub library, the implementation of
|
||||
// which will be patched.
|
||||
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) \
|
||||
sixtyfps::private_api::sixtyfps_get_##VTableName()
|
||||
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) slint::private_api::sixtyfps_get_##VTableName()
|
||||
# else
|
||||
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) (&sixtyfps::private_api::VTableName)
|
||||
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) (&slint::private_api::VTableName)
|
||||
# endif
|
||||
#endif // !defined(DOXYGEN)
|
||||
|
||||
|
@ -336,7 +335,7 @@ struct Timer
|
|||
/// the destructor of the timer is called.
|
||||
///
|
||||
/// This is a convenience function and equivalent to calling
|
||||
/// `start(sixtyfps::TimerMode::Repeated, interval, callback);` on a default constructed Timer.
|
||||
/// `start(slint::TimerMode::Repeated, interval, callback);` on a default constructed Timer.
|
||||
template<typename F>
|
||||
Timer(std::chrono::milliseconds interval, F callback)
|
||||
: id(cbindgen_private::slint_timer_start(
|
||||
|
@ -867,7 +866,7 @@ inline void run_event_loop()
|
|||
/// Schedules the main event loop for termination. This function is meant
|
||||
/// to be called from callbacks triggered by the UI. After calling the function,
|
||||
/// it will return immediately and once control is passed back to the event loop,
|
||||
/// the initial call to sixtyfps::run_event_loop() will return.
|
||||
/// the initial call to slint::run_event_loop() will return.
|
||||
inline void quit_event_loop()
|
||||
{
|
||||
cbindgen_private::slint_quit_event_loop();
|
||||
|
@ -894,10 +893,10 @@ inline void quit_event_loop()
|
|||
/// auto ui = NetworkStatusUI::create();
|
||||
/// ui->set_status_label("Pending");
|
||||
///
|
||||
/// sixtyfps::ComponentWeakHandle<NetworkStatusUI> weak_ui_handle(ui);
|
||||
/// slint::ComponentWeakHandle<NetworkStatusUI> weak_ui_handle(ui);
|
||||
/// std::thread network_thread([=]{
|
||||
/// std::string message = read_message_blocking_from_network();
|
||||
/// sixtyfps::invoke_from_event_loop([&]() {
|
||||
/// slint::invoke_from_event_loop([&]() {
|
||||
/// if (auto ui = weak_ui_handle.lock()) {
|
||||
/// ui->set_status_label(message);
|
||||
/// }
|
||||
|
@ -941,7 +940,7 @@ void invoke_from_event_loop(Functor f)
|
|||
///
|
||||
/// std::thread worker_thread([ui]{
|
||||
/// while (...) {
|
||||
/// auto message = sixtyfps::blocking_invoke_from_event_loop([ui]() {
|
||||
/// auto message = slint::blocking_invoke_from_event_loop([ui]() {
|
||||
/// return ui->get_message();
|
||||
/// }
|
||||
/// do_something(message);
|
||||
|
@ -1020,4 +1019,4 @@ inline std::optional<SharedString> register_font_from_data(const uint8_t *data,
|
|||
|
||||
}
|
||||
|
||||
} // namespace sixtyfps
|
||||
} // namespace slint
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "sixtyfps_brush_internal.h"
|
||||
#include "sixtyfps_string.h"
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace slint {
|
||||
|
||||
namespace private_api {
|
||||
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
private:
|
||||
cbindgen_private::types::LinearGradientBrush inner;
|
||||
|
||||
friend class sixtyfps::Brush;
|
||||
friend class slint::Brush;
|
||||
|
||||
static SharedVector<private_api::GradientStop>
|
||||
make_linear_gradient(float angle, const GradientStop *firstStop, int stopCount)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <tuple>
|
||||
#include "sixtyfps_properties_internal.h"
|
||||
|
||||
namespace sixtyfps::private_api {
|
||||
namespace slint::private_api {
|
||||
|
||||
/// A Callback stores a function pointer with no parameters and no return value.
|
||||
/// It's possible to set that pointer via set_handler() and it can be invoked via call(). This is
|
||||
|
@ -109,4 +109,4 @@ struct CallbackSignatureHelper<void, R>
|
|||
template<typename A, typename R = void>
|
||||
using CallbackHelper = Callback<typename CallbackSignatureHelper<A, R>::Result>;
|
||||
|
||||
} // namespace sixtyfps
|
||||
} // namespace slint
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace slint {
|
||||
|
||||
namespace private_api {
|
||||
class LinearGradientBrush;
|
||||
|
@ -229,4 +229,4 @@ Property<Color>::set_animated_value(const Color &new_value,
|
|||
|
||||
} // namespace private_api
|
||||
|
||||
} // namespace sixtyfps
|
||||
} // namespace slint
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
|
||||
#if !defined(DOXYGEN)
|
||||
# if defined(_MSC_VER)
|
||||
# define SIXTYFPS_DLL_IMPORT __declspec(dllimport)
|
||||
# define SLINT_DLL_IMPORT __declspec(dllimport)
|
||||
# elif defined(__GNUC__)
|
||||
# if defined(_WIN32) || defined(_WIN64)
|
||||
# define SIXTYFPS_DLL_IMPORT __declspec(dllimport)
|
||||
# define SLINT_DLL_IMPORT __declspec(dllimport)
|
||||
# else
|
||||
# define SIXTYFPS_DLL_IMPORT __attribute__((visibility("default")))
|
||||
# define SLINT_DLL_IMPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# else
|
||||
# define SIXTYFPS_DLL_IMPORT
|
||||
# define SLINT_DLL_IMPORT
|
||||
# endif
|
||||
#endif // !defined(DOXYGEN)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "sixtyfps_string.h"
|
||||
#include "sixtyfps_sharedvector.h"
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace slint {
|
||||
|
||||
/// An image type that can be displayed by the Image element
|
||||
struct Image
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
IntSize size() const { return cbindgen_private::types::slint_image_size(&data); }
|
||||
|
||||
/// Returns the path of the image on disk, if it was constructed via Image::load_from_path().
|
||||
std::optional<sixtyfps::SharedString> path() const
|
||||
std::optional<slint::SharedString> path() const
|
||||
{
|
||||
if (auto *str = cbindgen_private::types::slint_image_path(&data)) {
|
||||
return *str;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
class QWidget;
|
||||
#endif
|
||||
|
||||
namespace sixtyfps::cbindgen_private {
|
||||
namespace slint::cbindgen_private {
|
||||
// This has to stay opaque, but VRc don't compile if it is just forward declared
|
||||
struct ErasedComponentBox : vtable::Dyn
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ struct ErasedComponentBox : vtable::Dyn
|
|||
/// use to create \ref ComponentDefinition instances with the
|
||||
/// \ref ComponentCompiler::build_from_source() or \ref ComponentCompiler::build_from_path()
|
||||
/// functions.
|
||||
namespace sixtyfps::interpreter {
|
||||
namespace slint::interpreter {
|
||||
|
||||
class Value;
|
||||
|
||||
|
@ -216,13 +216,13 @@ public:
|
|||
inline void set_field(std::string_view name, const Value &value);
|
||||
|
||||
/// \private
|
||||
Struct(const sixtyfps::cbindgen_private::StructOpaque &other)
|
||||
Struct(const slint::cbindgen_private::StructOpaque &other)
|
||||
{
|
||||
cbindgen_private::slint_interpreter_struct_clone(&other, &inner);
|
||||
}
|
||||
|
||||
private:
|
||||
using StructOpaque = sixtyfps::cbindgen_private::StructOpaque;
|
||||
using StructOpaque = slint::cbindgen_private::StructOpaque;
|
||||
StructOpaque inner;
|
||||
friend class Value;
|
||||
};
|
||||
|
@ -235,7 +235,7 @@ private:
|
|||
/// It is also possible to query the type the value holds by calling the Value::type()
|
||||
/// function.
|
||||
///
|
||||
/// Note that models are only represented in one direction: You can create a sixtyfps::Model<Value>
|
||||
/// Note that models are only represented in one direction: You can create a slint::Model<Value>
|
||||
/// in C++, store it in a std::shared_ptr and construct Value from it. Then you can set it on a
|
||||
/// property in your .slint code that was declared to be either an array (`property <[sometype]>
|
||||
/// foo;`) or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are
|
||||
|
@ -246,7 +246,7 @@ private:
|
|||
///
|
||||
/// Value some_value = ...;
|
||||
/// // Check if the value has a string
|
||||
/// if (std::optional<sixtyfps::SharedString> string_value = some_value.to_string())
|
||||
/// if (std::optional<slint::SharedString> string_value = some_value.to_string())
|
||||
/// do_something(*string_value); // Extract the string by de-referencing
|
||||
/// ```
|
||||
class Value
|
||||
|
@ -303,7 +303,7 @@ public:
|
|||
|
||||
/// Returns a std::optional that contains a string if the type of this Value is
|
||||
/// Type::String, otherwise an empty optional is returned.
|
||||
std::optional<sixtyfps::SharedString> to_string() const
|
||||
std::optional<slint::SharedString> to_string() const
|
||||
{
|
||||
if (auto *str = cbindgen_private::slint_interpreter_value_to_string(&inner)) {
|
||||
return *str;
|
||||
|
@ -327,11 +327,11 @@ public:
|
|||
/// Type::Model, otherwise an empty optional is returned.
|
||||
///
|
||||
/// The vector will be constructed by serializing all the elements of the model.
|
||||
inline std::optional<sixtyfps::SharedVector<Value>> to_array() const;
|
||||
inline std::optional<slint::SharedVector<Value>> to_array() const;
|
||||
|
||||
/// Returns a std::optional that contains a brush if the type of this Value is
|
||||
/// Type::Brush, otherwise an empty optional is returned.
|
||||
std::optional<sixtyfps::Brush> to_brush() const
|
||||
std::optional<slint::Brush> to_brush() const
|
||||
{
|
||||
if (auto *brush = cbindgen_private::slint_interpreter_value_to_brush(&inner)) {
|
||||
return *brush;
|
||||
|
@ -376,9 +376,9 @@ public:
|
|||
/// Constructs a new Value that holds the value vector \a v as a model.
|
||||
inline Value(const SharedVector<Value> &v);
|
||||
/// Constructs a new Value that holds the value model \a m.
|
||||
Value(const std::shared_ptr<sixtyfps::Model<Value>> &m);
|
||||
Value(const std::shared_ptr<slint::Model<Value>> &m);
|
||||
/// Constructs a new Value that holds the brush \a b.
|
||||
Value(const sixtyfps::Brush &brush)
|
||||
Value(const slint::Brush &brush)
|
||||
{
|
||||
cbindgen_private::slint_interpreter_value_new_brush(&brush, &inner);
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ public:
|
|||
|
||||
private:
|
||||
inline Value(const void *) = delete; // Avoid that for example Value("foo") turns to Value(bool)
|
||||
using ValueOpaque = sixtyfps::cbindgen_private::ValueOpaque;
|
||||
using ValueOpaque = slint::cbindgen_private::ValueOpaque;
|
||||
ValueOpaque inner;
|
||||
friend struct Struct;
|
||||
friend class ComponentInstance;
|
||||
|
@ -410,29 +410,29 @@ private:
|
|||
explicit Value(ValueOpaque &inner) : inner(inner) { }
|
||||
};
|
||||
|
||||
inline Value::Value(const sixtyfps::SharedVector<Value> &array)
|
||||
inline Value::Value(const slint::SharedVector<Value> &array)
|
||||
{
|
||||
cbindgen_private::slint_interpreter_value_new_array_model(
|
||||
&reinterpret_cast<const sixtyfps::SharedVector<ValueOpaque> &>(array), &inner);
|
||||
&reinterpret_cast<const slint::SharedVector<ValueOpaque> &>(array), &inner);
|
||||
}
|
||||
|
||||
inline std::optional<sixtyfps::SharedVector<Value>> Value::to_array() const
|
||||
inline std::optional<slint::SharedVector<Value>> Value::to_array() const
|
||||
{
|
||||
sixtyfps::SharedVector<Value> array;
|
||||
slint::SharedVector<Value> array;
|
||||
if (cbindgen_private::slint_interpreter_value_to_array(
|
||||
&inner, &reinterpret_cast<sixtyfps::SharedVector<ValueOpaque> &>(array))) {
|
||||
&inner, &reinterpret_cast<slint::SharedVector<ValueOpaque> &>(array))) {
|
||||
return array;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
|
||||
inline Value::Value(const std::shared_ptr<slint::Model<Value>> &model)
|
||||
{
|
||||
using cbindgen_private::ModelAdaptorVTable;
|
||||
using vtable::VRef;
|
||||
struct ModelWrapper : private_api::AbstractRepeaterView
|
||||
{
|
||||
std::shared_ptr<sixtyfps::Model<Value>> model;
|
||||
std::shared_ptr<slint::Model<Value>> model;
|
||||
cbindgen_private::ModelNotifyOpaque notify;
|
||||
// This kind of mean that the rust code has ownership of "this" until the drop function is
|
||||
// called
|
||||
|
@ -533,7 +533,7 @@ class ComponentInstance : vtable::Dyn
|
|||
// ComponentHandle<ComponentInstance> is in fact a VRc<ComponentVTable, ErasedComponentBox>
|
||||
const cbindgen_private::ErasedComponentBox *inner() const
|
||||
{
|
||||
sixtyfps::private_api::assert_main_thread();
|
||||
slint::private_api::assert_main_thread();
|
||||
return reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(this);
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ public:
|
|||
/// Marks the window of this component to be shown on the screen. This registers
|
||||
/// the window with the windowing system. In order to react to events from the windowing system,
|
||||
/// such as draw requests or mouse/touch input, it is still necessary to spin the event loop,
|
||||
/// using sixtyfps::run_event_loop().
|
||||
/// using slint::run_event_loop().
|
||||
void show() const
|
||||
{
|
||||
cbindgen_private::slint_interpreter_component_instance_show(inner(), true);
|
||||
|
@ -555,14 +555,14 @@ public:
|
|||
/// Returns the Window associated with this component. The window API can be used
|
||||
/// to control different aspects of the integration into the windowing system,
|
||||
/// such as the position on the screen.
|
||||
const sixtyfps::Window &window()
|
||||
const slint::Window &window()
|
||||
{
|
||||
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
|
||||
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
|
||||
return *reinterpret_cast<const sixtyfps::Window *>(win_ptr);
|
||||
return *reinterpret_cast<const slint::Window *>(win_ptr);
|
||||
}
|
||||
/// This is a convenience function that first calls show(), followed by
|
||||
/// sixtyfps::run_event_loop() and hide().
|
||||
/// slint::run_event_loop() and hide().
|
||||
void run() const
|
||||
{
|
||||
show();
|
||||
|
@ -588,7 +588,7 @@ public:
|
|||
/// For example, if the component has a `property <string> hello;`,
|
||||
/// we can set this property
|
||||
/// ```
|
||||
/// instance->set_property("hello", sixtyfps::SharedString("world"));
|
||||
/// instance->set_property("hello", slint::SharedString("world"));
|
||||
/// ```
|
||||
///
|
||||
/// Returns true if the property was correctly set. Returns false if the property
|
||||
|
@ -598,7 +598,7 @@ public:
|
|||
{
|
||||
using namespace cbindgen_private;
|
||||
return slint_interpreter_component_instance_set_property(
|
||||
inner(), sixtyfps::private_api::string_to_slice(name), &value.inner);
|
||||
inner(), slint::private_api::string_to_slice(name), &value.inner);
|
||||
}
|
||||
/// Returns the value behind a property declared in .slint.
|
||||
std::optional<Value> get_property(std::string_view name) const
|
||||
|
@ -606,7 +606,7 @@ public:
|
|||
using namespace cbindgen_private;
|
||||
ValueOpaque out;
|
||||
if (slint_interpreter_component_instance_get_property(
|
||||
inner(), sixtyfps::private_api::string_to_slice(name), &out)) {
|
||||
inner(), slint::private_api::string_to_slice(name), &out)) {
|
||||
return Value(out);
|
||||
} else {
|
||||
return {};
|
||||
|
@ -620,7 +620,7 @@ public:
|
|||
/// ```
|
||||
/// Then one can call it with this function
|
||||
/// ```
|
||||
/// sixtyfps::Value args[] = { SharedString("Hello"), 42. };
|
||||
/// slint::Value args[] = { SharedString("Hello"), 42. };
|
||||
/// instance->invoke_callback("foo", { args, 2 });
|
||||
/// ```
|
||||
///
|
||||
|
@ -635,7 +635,7 @@ public:
|
|||
args.size() };
|
||||
ValueOpaque out;
|
||||
if (slint_interpreter_component_instance_invoke_callback(
|
||||
inner(), sixtyfps::private_api::string_to_slice(name), args_view, &out)) {
|
||||
inner(), slint::private_api::string_to_slice(name), args_view, &out)) {
|
||||
return Value(out);
|
||||
} else {
|
||||
return {};
|
||||
|
@ -674,7 +674,7 @@ public:
|
|||
new (ret) Value(std::move(r));
|
||||
};
|
||||
return cbindgen_private::slint_interpreter_component_instance_set_callback(
|
||||
inner(), sixtyfps::private_api::string_to_slice(name), actual_cb,
|
||||
inner(), slint::private_api::string_to_slice(name), actual_cb,
|
||||
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
|
||||
}
|
||||
|
||||
|
@ -694,8 +694,8 @@ public:
|
|||
{
|
||||
using namespace cbindgen_private;
|
||||
return slint_interpreter_component_instance_set_global_property(
|
||||
inner(), sixtyfps::private_api::string_to_slice(global),
|
||||
sixtyfps::private_api::string_to_slice(prop_name), &value.inner);
|
||||
inner(), slint::private_api::string_to_slice(global),
|
||||
slint::private_api::string_to_slice(prop_name), &value.inner);
|
||||
}
|
||||
/// Returns the value behind a property in an exported global singleton.
|
||||
std::optional<Value> get_global_property(std::string_view global,
|
||||
|
@ -704,8 +704,8 @@ public:
|
|||
using namespace cbindgen_private;
|
||||
ValueOpaque out;
|
||||
if (slint_interpreter_component_instance_get_global_property(
|
||||
inner(), sixtyfps::private_api::string_to_slice(global),
|
||||
sixtyfps::private_api::string_to_slice(prop_name), &out)) {
|
||||
inner(), slint::private_api::string_to_slice(global),
|
||||
slint::private_api::string_to_slice(prop_name), &out)) {
|
||||
return Value(out);
|
||||
} else {
|
||||
return {};
|
||||
|
@ -739,8 +739,8 @@ public:
|
|||
new (ret) Value(std::move(r));
|
||||
};
|
||||
return cbindgen_private::slint_interpreter_component_instance_set_global_callback(
|
||||
inner(), sixtyfps::private_api::string_to_slice(global),
|
||||
sixtyfps::private_api::string_to_slice(name), actual_cb, new F(std::move(callback)),
|
||||
inner(), slint::private_api::string_to_slice(global),
|
||||
slint::private_api::string_to_slice(name), actual_cb, new F(std::move(callback)),
|
||||
[](void *data) { delete reinterpret_cast<F *>(data); });
|
||||
}
|
||||
|
||||
|
@ -755,8 +755,8 @@ public:
|
|||
args.size() };
|
||||
ValueOpaque out;
|
||||
if (slint_interpreter_component_instance_invoke_global_callback(
|
||||
inner(), sixtyfps::private_api::string_to_slice(global),
|
||||
sixtyfps::private_api::string_to_slice(callback_name), args_view, &out)) {
|
||||
inner(), slint::private_api::string_to_slice(global),
|
||||
slint::private_api::string_to_slice(callback_name), args_view, &out)) {
|
||||
return Value(out);
|
||||
} else {
|
||||
return {};
|
||||
|
@ -776,7 +776,7 @@ class ComponentDefinition
|
|||
{
|
||||
friend class ComponentCompiler;
|
||||
|
||||
using ComponentDefinitionOpaque = sixtyfps::cbindgen_private::ComponentDefinitionOpaque;
|
||||
using ComponentDefinitionOpaque = slint::cbindgen_private::ComponentDefinitionOpaque;
|
||||
ComponentDefinitionOpaque inner;
|
||||
|
||||
ComponentDefinition() = delete;
|
||||
|
@ -792,7 +792,7 @@ public:
|
|||
/// Assigns \a other to this ComponentDefinition.
|
||||
ComponentDefinition &operator=(const ComponentDefinition &other)
|
||||
{
|
||||
using namespace sixtyfps::cbindgen_private;
|
||||
using namespace slint::cbindgen_private;
|
||||
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
@ -820,34 +820,34 @@ public:
|
|||
/// Returns a vector of that contains PropertyDescriptor instances that describe the list of
|
||||
/// public properties that can be read and written using ComponentInstance::set_property and
|
||||
/// ComponentInstance::get_property.
|
||||
sixtyfps::SharedVector<PropertyDescriptor> properties() const
|
||||
slint::SharedVector<PropertyDescriptor> properties() const
|
||||
{
|
||||
sixtyfps::SharedVector<PropertyDescriptor> props;
|
||||
slint::SharedVector<PropertyDescriptor> props;
|
||||
cbindgen_private::slint_interpreter_component_definition_properties(&inner, &props);
|
||||
return props;
|
||||
}
|
||||
|
||||
/// Returns a vector of strings that describe the list of public callbacks that can be invoked
|
||||
/// using ComponentInstance::invoke_callback and set using ComponentInstance::set_callback.
|
||||
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks() const
|
||||
slint::SharedVector<slint::SharedString> callbacks() const
|
||||
{
|
||||
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks;
|
||||
slint::SharedVector<slint::SharedString> callbacks;
|
||||
cbindgen_private::slint_interpreter_component_definition_callbacks(&inner, &callbacks);
|
||||
return callbacks;
|
||||
}
|
||||
|
||||
/// Returns the name of this Component as written in the .slint file
|
||||
sixtyfps::SharedString name() const
|
||||
slint::SharedString name() const
|
||||
{
|
||||
sixtyfps::SharedString name;
|
||||
slint::SharedString name;
|
||||
cbindgen_private::slint_interpreter_component_definition_name(&inner, &name);
|
||||
return name;
|
||||
}
|
||||
|
||||
/// Returns a vector of strings with the names of all exported global singletons.
|
||||
sixtyfps::SharedVector<sixtyfps::SharedString> globals() const
|
||||
slint::SharedVector<slint::SharedString> globals() const
|
||||
{
|
||||
sixtyfps::SharedVector<sixtyfps::SharedString> names;
|
||||
slint::SharedVector<slint::SharedString> names;
|
||||
cbindgen_private::slint_interpreter_component_definition_globals(&inner, &names);
|
||||
return names;
|
||||
}
|
||||
|
@ -855,12 +855,12 @@ public:
|
|||
/// Returns a vector of the property descriptors of the properties of the specified
|
||||
/// publicly exported global singleton. An empty optional is returned if there exists no
|
||||
/// exported global singleton under the specified name.
|
||||
std::optional<sixtyfps::SharedVector<PropertyDescriptor>>
|
||||
std::optional<slint::SharedVector<PropertyDescriptor>>
|
||||
global_properties(std::string_view global_name) const
|
||||
{
|
||||
sixtyfps::SharedVector<PropertyDescriptor> properties;
|
||||
slint::SharedVector<PropertyDescriptor> properties;
|
||||
if (cbindgen_private::slint_interpreter_component_definition_global_properties(
|
||||
&inner, sixtyfps::private_api::string_to_slice(global_name), &properties)) {
|
||||
&inner, slint::private_api::string_to_slice(global_name), &properties)) {
|
||||
return properties;
|
||||
}
|
||||
return {};
|
||||
|
@ -869,12 +869,12 @@ public:
|
|||
/// Returns a vector of the names of the callbacks of the specified publicly exported global
|
||||
/// singleton. An empty optional is returned if there exists no exported global singleton
|
||||
/// under the specified name.
|
||||
std::optional<sixtyfps::SharedVector<sixtyfps::SharedString>>
|
||||
std::optional<slint::SharedVector<slint::SharedString>>
|
||||
global_callbacks(std::string_view global_name) const
|
||||
{
|
||||
sixtyfps::SharedVector<sixtyfps::SharedString> names;
|
||||
slint::SharedVector<slint::SharedString> names;
|
||||
if (cbindgen_private::slint_interpreter_component_definition_global_callbacks(
|
||||
&inner, sixtyfps::private_api::string_to_slice(global_name), &names)) {
|
||||
&inner, slint::private_api::string_to_slice(global_name), &names)) {
|
||||
return names;
|
||||
}
|
||||
return {};
|
||||
|
@ -903,7 +903,7 @@ public:
|
|||
|
||||
/// Sets the include paths used for looking up `.slint` imports to the specified vector of
|
||||
/// paths.
|
||||
void set_include_paths(const sixtyfps::SharedVector<sixtyfps::SharedString> &paths)
|
||||
void set_include_paths(const slint::SharedVector<slint::SharedString> &paths)
|
||||
{
|
||||
cbindgen_private::slint_interpreter_component_compiler_set_include_paths(&inner, &paths);
|
||||
}
|
||||
|
@ -912,30 +912,30 @@ public:
|
|||
void set_style(std::string_view style)
|
||||
{
|
||||
cbindgen_private::slint_interpreter_component_compiler_set_style(
|
||||
&inner, sixtyfps::private_api::string_to_slice(style));
|
||||
&inner, slint::private_api::string_to_slice(style));
|
||||
}
|
||||
|
||||
/// Returns the widget style the compiler is currently using when compiling .slint files.
|
||||
sixtyfps::SharedString style() const
|
||||
slint::SharedString style() const
|
||||
{
|
||||
sixtyfps::SharedString s;
|
||||
slint::SharedString s;
|
||||
cbindgen_private::slint_interpreter_component_compiler_get_style(&inner, &s);
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Returns the include paths the component compiler is currently configured with.
|
||||
sixtyfps::SharedVector<sixtyfps::SharedString> include_paths() const
|
||||
slint::SharedVector<slint::SharedString> include_paths() const
|
||||
{
|
||||
sixtyfps::SharedVector<sixtyfps::SharedString> paths;
|
||||
slint::SharedVector<slint::SharedString> paths;
|
||||
cbindgen_private::slint_interpreter_component_compiler_get_include_paths(&inner, &paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
/// Returns the diagnostics that were produced in the last call to build_from_path() or
|
||||
/// build_from_source().
|
||||
sixtyfps::SharedVector<Diagnostic> diagnostics() const
|
||||
slint::SharedVector<Diagnostic> diagnostics() const
|
||||
{
|
||||
sixtyfps::SharedVector<Diagnostic> result;
|
||||
slint::SharedVector<Diagnostic> result;
|
||||
cbindgen_private::slint_interpreter_component_compiler_get_diagnostics(&inner, &result);
|
||||
return result;
|
||||
}
|
||||
|
@ -954,8 +954,8 @@ public:
|
|||
{
|
||||
cbindgen_private::ComponentDefinitionOpaque result;
|
||||
if (cbindgen_private::slint_interpreter_component_compiler_build_from_source(
|
||||
&inner, sixtyfps::private_api::string_to_slice(source_code),
|
||||
sixtyfps::private_api::string_to_slice(path), &result)) {
|
||||
&inner, slint::private_api::string_to_slice(source_code),
|
||||
slint::private_api::string_to_slice(path), &result)) {
|
||||
|
||||
return ComponentDefinition(result);
|
||||
} else {
|
||||
|
@ -977,7 +977,7 @@ public:
|
|||
{
|
||||
cbindgen_private::ComponentDefinitionOpaque result;
|
||||
if (cbindgen_private::slint_interpreter_component_compiler_build_from_path(
|
||||
&inner, sixtyfps::private_api::string_to_slice(path), &result)) {
|
||||
&inner, slint::private_api::string_to_slice(path), &result)) {
|
||||
|
||||
return ComponentDefinition(result);
|
||||
} else {
|
||||
|
@ -988,13 +988,13 @@ public:
|
|||
|
||||
}
|
||||
|
||||
namespace sixtyfps::testing {
|
||||
namespace slint::testing {
|
||||
|
||||
using cbindgen_private::KeyboardModifiers;
|
||||
|
||||
/// Send a key events to the given component instance
|
||||
inline void send_keyboard_string_sequence(const sixtyfps::interpreter::ComponentInstance *component,
|
||||
const sixtyfps::SharedString &str,
|
||||
inline void send_keyboard_string_sequence(const slint::interpreter::ComponentInstance *component,
|
||||
const slint::SharedString &str,
|
||||
KeyboardModifiers modifiers = {})
|
||||
{
|
||||
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
#include "sixtyfps_pathdata_internal.h"
|
||||
|
||||
// The C++ code generator assumes that enums are in the cbindgen_private namespace
|
||||
namespace sixtyfps::cbindgen_private {
|
||||
namespace slint::cbindgen_private {
|
||||
using cbindgen_private::types::PathEvent;
|
||||
}
|
||||
namespace sixtyfps::private_api {
|
||||
namespace slint::private_api {
|
||||
using cbindgen_private::types::PathArcTo;
|
||||
using cbindgen_private::types::PathCubicTo;
|
||||
using cbindgen_private::types::PathElement;
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
#include <string_view>
|
||||
#include <memory>
|
||||
|
||||
namespace sixtyfps::cbindgen_private {
|
||||
namespace slint::cbindgen_private {
|
||||
struct PropertyAnimation;
|
||||
}
|
||||
|
||||
#include "sixtyfps_properties_internal.h"
|
||||
|
||||
namespace sixtyfps::private_api {
|
||||
namespace slint::private_api {
|
||||
|
||||
using cbindgen_private::StateInfo;
|
||||
|
||||
|
@ -166,11 +166,11 @@ struct Property
|
|||
return true;
|
||||
};
|
||||
cbindgen_private::slint_property_set_binding(&p1->inner, call_fn,
|
||||
new TwoWayBinding { common_property },
|
||||
del_fn, intercept_fn, intercept_binding_fn);
|
||||
new TwoWayBinding { common_property }, del_fn,
|
||||
intercept_fn, intercept_binding_fn);
|
||||
cbindgen_private::slint_property_set_binding(&p2->inner, call_fn,
|
||||
new TwoWayBinding { common_property },
|
||||
del_fn, intercept_fn, intercept_binding_fn);
|
||||
new TwoWayBinding { common_property }, del_fn,
|
||||
intercept_fn, intercept_binding_fn);
|
||||
}
|
||||
|
||||
/// Internal (private) constructor used by link_two_way
|
||||
|
@ -292,4 +292,4 @@ private:
|
|||
cbindgen_private::PropertyTrackerOpaque inner;
|
||||
};
|
||||
|
||||
} // namespace sixtyfps::private_api
|
||||
} // namespace slint::private_api
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <algorithm>
|
||||
#include <initializer_list>
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace slint {
|
||||
|
||||
/// SharedVector is a vector template class similar to std::vector that's primarily used for passing
|
||||
/// data in and out of the SixtyFPS run-time library. It uses implicit-sharing to make creating
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <string_view>
|
||||
#include "sixtyfps_string_internal.h"
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace slint {
|
||||
|
||||
/// A string type used by the SixtyFPS run-time.
|
||||
///
|
||||
|
@ -36,14 +36,14 @@ struct SharedString
|
|||
#if defined(__cpp_char8_t) || __cplusplus >= 202002L
|
||||
/// Creates a new SharedString from the null-terminated string pointer \a s. The underlying
|
||||
/// string data is copied.
|
||||
SharedString(const char8_t *s) : SharedString(reinterpret_cast<const char*>(s)) { }
|
||||
SharedString(const char8_t *s) : SharedString(reinterpret_cast<const char *>(s)) { }
|
||||
#endif
|
||||
#ifdef __cpp_lib_char8_t
|
||||
/// Creates a new SharedString from the string view \a s. The underlying string data is copied.
|
||||
SharedString(std::u8string_view s)
|
||||
{
|
||||
cbindgen_private::slint_shared_string_from_bytes(
|
||||
this, reinterpret_cast<const char*>(s.data()), s.size());
|
||||
this, reinterpret_cast<const char *>(s.data()), s.size());
|
||||
}
|
||||
#endif
|
||||
/// Creates a new SharedString from \a other.
|
||||
|
@ -83,16 +83,10 @@ struct SharedString
|
|||
|
||||
/// Provides a view to the string data. The returned view is only valid as long as at
|
||||
/// least this SharedString exists.
|
||||
operator std::string_view() const
|
||||
{
|
||||
return cbindgen_private::slint_shared_string_bytes(this);
|
||||
}
|
||||
operator std::string_view() const { return cbindgen_private::slint_shared_string_bytes(this); }
|
||||
/// Provides a raw pointer to the string data. The returned pointer is only valid as long as at
|
||||
/// least this SharedString exists.
|
||||
auto data() const -> const char *
|
||||
{
|
||||
return cbindgen_private::slint_shared_string_bytes(this);
|
||||
}
|
||||
auto data() const -> const char * { return cbindgen_private::slint_shared_string_bytes(this); }
|
||||
|
||||
/// Returns a pointer to the first character. It is only safe to dereference the pointer if the
|
||||
/// string contains at least one character.
|
||||
|
@ -126,8 +120,8 @@ struct SharedString
|
|||
///
|
||||
/// For example:
|
||||
/// \code
|
||||
/// auto str = sixtyfps::SharedString::from_number(42); // creates "42"
|
||||
/// auto str2 = sixtyfps::SharedString::from_number(100.5) // creates "100.5"
|
||||
/// auto str = slint::SharedString::from_number(42); // creates "42"
|
||||
/// auto str2 = slint::SharedString::from_number(100.5) // creates "100.5"
|
||||
/// \endcode
|
||||
static SharedString from_number(double n) { return SharedString(n); }
|
||||
|
||||
|
@ -191,10 +185,7 @@ struct SharedString
|
|||
|
||||
private:
|
||||
/// Use SharedString::from_number
|
||||
explicit SharedString(double n)
|
||||
{
|
||||
cbindgen_private::slint_shared_string_from_number(this, n);
|
||||
}
|
||||
explicit SharedString(double n) { cbindgen_private::slint_shared_string_from_number(this, n); }
|
||||
void *inner; // opaque
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "sixtyfps.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace sixtyfps::testing {
|
||||
namespace slint::testing {
|
||||
|
||||
inline void init()
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ inline void send_mouse_click(const Component *component, float x, float y)
|
|||
|
||||
template<typename Component>
|
||||
inline void send_keyboard_string_sequence(const Component *component,
|
||||
const sixtyfps::SharedString &str,
|
||||
const slint::SharedString &str,
|
||||
cbindgen_private::KeyboardModifiers modifiers = {})
|
||||
{
|
||||
cbindgen_private::send_keyboard_string_sequence(&str, modifiers,
|
||||
|
@ -33,7 +33,7 @@ inline void send_keyboard_string_sequence(const Component *component,
|
|||
}
|
||||
|
||||
#define assert_eq(A, B) \
|
||||
sixtyfps::testing::private_api::assert_eq_impl(A, B, #A, #B, __FILE__, __LINE__)
|
||||
slint::testing::private_api::assert_eq_impl(A, B, #A, #B, __FILE__, __LINE__)
|
||||
|
||||
namespace private_api {
|
||||
template<typename A, typename B>
|
||||
|
@ -49,4 +49,4 @@ void assert_eq_impl(const A &a, const B &b, const char *a_str, const char *b_str
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace sixtyfps
|
||||
} // namespace slint
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
SCENARIO("SharedString API")
|
||||
{
|
||||
sixtyfps::SharedString str;
|
||||
slint::SharedString str;
|
||||
|
||||
REQUIRE(str.empty());
|
||||
REQUIRE(str == "");
|
||||
|
@ -35,7 +35,7 @@ SCENARIO("SharedString API")
|
|||
{
|
||||
str = "Hello";
|
||||
str += " ";
|
||||
str += sixtyfps::SharedString("🦊") + sixtyfps::SharedString("!");
|
||||
str += slint::SharedString("🦊") + slint::SharedString("!");
|
||||
REQUIRE(str == "Hello 🦊!");
|
||||
REQUIRE(std::string_view(str.data()) == "Hello 🦊!");
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ SCENARIO("SharedString API")
|
|||
|
||||
TEST_CASE("Basic SharedVector API", "[vector]")
|
||||
{
|
||||
sixtyfps::SharedVector<int> vec;
|
||||
slint::SharedVector<int> vec;
|
||||
REQUIRE(vec.empty());
|
||||
|
||||
SECTION("Initializer list")
|
||||
{
|
||||
sixtyfps::SharedVector<int> vec({ 1, 4, 10 });
|
||||
slint::SharedVector<int> vec({ 1, 4, 10 });
|
||||
REQUIRE(vec.size() == 3);
|
||||
REQUIRE(vec[0] == 1);
|
||||
REQUIRE(vec[1] == 4);
|
||||
|
@ -58,7 +58,7 @@ TEST_CASE("Basic SharedVector API", "[vector]")
|
|||
|
||||
TEST_CASE("Property Tracker")
|
||||
{
|
||||
using namespace sixtyfps::private_api;
|
||||
using namespace slint::private_api;
|
||||
PropertyTracker tracker1;
|
||||
PropertyTracker tracker2;
|
||||
Property<int> prop(42);
|
||||
|
@ -80,9 +80,9 @@ TEST_CASE("Property Tracker")
|
|||
|
||||
TEST_CASE("Model row changes")
|
||||
{
|
||||
using namespace sixtyfps::private_api;
|
||||
using namespace slint::private_api;
|
||||
|
||||
auto model = std::make_shared<sixtyfps::VectorModel<int>>();
|
||||
auto model = std::make_shared<slint::VectorModel<int>>();
|
||||
|
||||
PropertyTracker tracker;
|
||||
|
||||
|
@ -109,9 +109,9 @@ TEST_CASE("Model row changes")
|
|||
|
||||
TEST_CASE("Track model row data changes")
|
||||
{
|
||||
using namespace sixtyfps::private_api;
|
||||
using namespace slint::private_api;
|
||||
|
||||
auto model = std::make_shared<sixtyfps::VectorModel<int>>(std::vector<int> { 0, 1, 2, 3, 4 });
|
||||
auto model = std::make_shared<slint::VectorModel<int>>(std::vector<int> { 0, 1, 2, 3, 4 });
|
||||
|
||||
PropertyTracker tracker;
|
||||
|
||||
|
@ -149,7 +149,7 @@ TEST_CASE("Track model row data changes")
|
|||
|
||||
TEST_CASE("Image")
|
||||
{
|
||||
using namespace sixtyfps;
|
||||
using namespace slint;
|
||||
|
||||
// ensure a backend exists, using private api
|
||||
private_api::WindowRc wnd;
|
||||
|
@ -179,7 +179,7 @@ TEST_CASE("Image")
|
|||
|
||||
TEST_CASE("SharedVector")
|
||||
{
|
||||
using namespace sixtyfps;
|
||||
using namespace slint;
|
||||
|
||||
SharedVector<SharedString> vec;
|
||||
vec.clear();
|
||||
|
|
|
@ -9,35 +9,35 @@
|
|||
|
||||
TEST_CASE("C++ Singleshot Timers")
|
||||
{
|
||||
using namespace sixtyfps;
|
||||
using namespace slint;
|
||||
int called = 0;
|
||||
Timer testTimer(std::chrono::milliseconds(16), [&]() {
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::quit_event_loop();
|
||||
called += 10;
|
||||
});
|
||||
REQUIRE(called == 0);
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
REQUIRE(called == 10);
|
||||
}
|
||||
|
||||
TEST_CASE("C++ Repeated Timer")
|
||||
{
|
||||
int timer_triggered = 0;
|
||||
sixtyfps::Timer timer;
|
||||
slint::Timer timer;
|
||||
|
||||
timer.start(sixtyfps::TimerMode::Repeated, std::chrono::milliseconds(30),
|
||||
timer.start(slint::TimerMode::Repeated, std::chrono::milliseconds(30),
|
||||
[&]() { timer_triggered++; });
|
||||
|
||||
REQUIRE(timer_triggered == 0);
|
||||
|
||||
bool timer_was_running = false;
|
||||
|
||||
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
timer_was_running = timer.running();
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::quit_event_loop();
|
||||
});
|
||||
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
|
||||
REQUIRE(timer_triggered > 1);
|
||||
REQUIRE(timer_was_running);
|
||||
|
@ -46,32 +46,32 @@ TEST_CASE("C++ Repeated Timer")
|
|||
TEST_CASE("C++ Restart Singleshot Timer")
|
||||
{
|
||||
int timer_triggered = 0;
|
||||
sixtyfps::Timer timer;
|
||||
slint::Timer timer;
|
||||
|
||||
timer.start(sixtyfps::TimerMode::SingleShot, std::chrono::milliseconds(30),
|
||||
timer.start(slint::TimerMode::SingleShot, std::chrono::milliseconds(30),
|
||||
[&]() { timer_triggered++; });
|
||||
|
||||
REQUIRE(timer_triggered == 0);
|
||||
|
||||
bool timer_was_running = false;
|
||||
|
||||
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
timer_was_running = timer.running();
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::quit_event_loop();
|
||||
});
|
||||
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
|
||||
REQUIRE(timer_triggered == 1);
|
||||
REQUIRE(timer_was_running);
|
||||
timer_triggered = 0;
|
||||
timer.restart();
|
||||
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
timer_was_running = timer.running();
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::quit_event_loop();
|
||||
});
|
||||
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
|
||||
REQUIRE(timer_triggered == 1);
|
||||
REQUIRE(timer_was_running);
|
||||
|
@ -80,21 +80,21 @@ TEST_CASE("C++ Restart Singleshot Timer")
|
|||
TEST_CASE("C++ Restart Repeated Timer")
|
||||
{
|
||||
int timer_triggered = 0;
|
||||
sixtyfps::Timer timer;
|
||||
slint::Timer timer;
|
||||
|
||||
timer.start(sixtyfps::TimerMode::Repeated, std::chrono::milliseconds(30),
|
||||
timer.start(slint::TimerMode::Repeated, std::chrono::milliseconds(30),
|
||||
[&]() { timer_triggered++; });
|
||||
|
||||
REQUIRE(timer_triggered == 0);
|
||||
|
||||
bool timer_was_running = false;
|
||||
|
||||
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
timer_was_running = timer.running();
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::quit_event_loop();
|
||||
});
|
||||
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
|
||||
REQUIRE(timer_triggered > 1);
|
||||
REQUIRE(timer_was_running);
|
||||
|
@ -102,12 +102,12 @@ TEST_CASE("C++ Restart Repeated Timer")
|
|||
timer_was_running = false;
|
||||
timer_triggered = 0;
|
||||
timer.stop();
|
||||
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
timer_was_running = timer.running();
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::quit_event_loop();
|
||||
});
|
||||
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
|
||||
REQUIRE(timer_triggered == 0);
|
||||
REQUIRE(!timer_was_running);
|
||||
|
@ -117,12 +117,12 @@ TEST_CASE("C++ Restart Repeated Timer")
|
|||
|
||||
timer.restart();
|
||||
|
||||
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
|
||||
timer_was_running = timer.running();
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::quit_event_loop();
|
||||
});
|
||||
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
|
||||
REQUIRE(timer_triggered > 1);
|
||||
REQUIRE(timer_was_running);
|
||||
|
@ -131,12 +131,12 @@ TEST_CASE("C++ Restart Repeated Timer")
|
|||
TEST_CASE("Quit from event")
|
||||
{
|
||||
int called = 0;
|
||||
sixtyfps::invoke_from_event_loop([&] {
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::invoke_from_event_loop([&] {
|
||||
slint::quit_event_loop();
|
||||
called += 10;
|
||||
});
|
||||
REQUIRE(called == 0);
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
REQUIRE(called == 10);
|
||||
}
|
||||
|
||||
|
@ -145,13 +145,13 @@ TEST_CASE("Event from thread")
|
|||
std::atomic<int> called = 0;
|
||||
auto t = std::thread([&] {
|
||||
called += 10;
|
||||
sixtyfps::invoke_from_event_loop([&] {
|
||||
slint::invoke_from_event_loop([&] {
|
||||
called += 100;
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::quit_event_loop();
|
||||
});
|
||||
});
|
||||
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
REQUIRE(called == 110);
|
||||
t.join();
|
||||
}
|
||||
|
@ -161,18 +161,18 @@ TEST_CASE("Blocking Event from thread")
|
|||
std::atomic<int> called = 0;
|
||||
auto t = std::thread([&] {
|
||||
// test returning a, unique_ptr because it is movable-only
|
||||
std::unique_ptr foo = sixtyfps::blocking_invoke_from_event_loop(
|
||||
[&] { return std::make_unique<int>(42); });
|
||||
std::unique_ptr foo =
|
||||
slint::blocking_invoke_from_event_loop([&] { return std::make_unique<int>(42); });
|
||||
called = *foo;
|
||||
int xxx = 123;
|
||||
sixtyfps::blocking_invoke_from_event_loop([&] {
|
||||
sixtyfps::quit_event_loop();
|
||||
slint::blocking_invoke_from_event_loop([&] {
|
||||
slint::quit_event_loop();
|
||||
xxx = 888999;
|
||||
});
|
||||
REQUIRE(xxx == 888999);
|
||||
});
|
||||
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
REQUIRE(called == 42);
|
||||
t.join();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
SCENARIO("Value API")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace slint::interpreter;
|
||||
Value value;
|
||||
|
||||
REQUIRE(value.type() == Value::Type::Void);
|
||||
|
@ -17,7 +17,7 @@ SCENARIO("Value API")
|
|||
SECTION("Construct a string")
|
||||
{
|
||||
REQUIRE(!value.to_string().has_value());
|
||||
sixtyfps::SharedString cpp_str("Hello World");
|
||||
slint::SharedString cpp_str("Hello World");
|
||||
value = Value(cpp_str);
|
||||
REQUIRE(value.type() == Value::Type::String);
|
||||
|
||||
|
@ -52,7 +52,7 @@ SCENARIO("Value API")
|
|||
SECTION("Construct an array")
|
||||
{
|
||||
REQUIRE(!value.to_array().has_value());
|
||||
sixtyfps::SharedVector<Value> array { Value(42.0), Value(true) };
|
||||
slint::SharedVector<Value> array { Value(42.0), Value(true) };
|
||||
value = Value(array);
|
||||
REQUIRE(value.type() == Value::Type::Model);
|
||||
|
||||
|
@ -68,7 +68,7 @@ SCENARIO("Value API")
|
|||
SECTION("Construct a brush")
|
||||
{
|
||||
REQUIRE(!value.to_brush().has_value());
|
||||
sixtyfps::Brush brush(sixtyfps::Color::from_rgb_uint8(255, 0, 255));
|
||||
slint::Brush brush(slint::Color::from_rgb_uint8(255, 0, 255));
|
||||
value = Value(brush);
|
||||
REQUIRE(value.type() == Value::Type::Brush);
|
||||
|
||||
|
@ -80,7 +80,7 @@ SCENARIO("Value API")
|
|||
SECTION("Construct a struct")
|
||||
{
|
||||
REQUIRE(!value.to_struct().has_value());
|
||||
sixtyfps::interpreter::Struct struc;
|
||||
slint::interpreter::Struct struc;
|
||||
value = Value(struc);
|
||||
REQUIRE(value.type() == Value::Type::Struct);
|
||||
|
||||
|
@ -91,10 +91,10 @@ SCENARIO("Value API")
|
|||
SECTION("Construct an image")
|
||||
{
|
||||
// ensure a backend exists, using private api
|
||||
sixtyfps::private_api::WindowRc wnd;
|
||||
slint::private_api::WindowRc wnd;
|
||||
|
||||
REQUIRE(!value.to_image().has_value());
|
||||
sixtyfps::Image image = sixtyfps::Image::load_from_path(
|
||||
slint::Image image = slint::Image::load_from_path(
|
||||
SOURCE_DIR "/../../vscode_extension/extension-logo.png");
|
||||
REQUIRE(image.size().width == 128);
|
||||
value = Value(image);
|
||||
|
@ -109,7 +109,7 @@ SCENARIO("Value API")
|
|||
SECTION("Construct a model")
|
||||
{
|
||||
// And test that it is properly destroyed when the value is destroyed
|
||||
struct M : sixtyfps::VectorModel<Value>
|
||||
struct M : slint::VectorModel<Value>
|
||||
{
|
||||
bool *destroyed;
|
||||
explicit M(bool *destroyed) : destroyed(destroyed) { }
|
||||
|
@ -139,8 +139,8 @@ SCENARIO("Value API")
|
|||
|
||||
SECTION("Compare Values")
|
||||
{
|
||||
Value str1 { sixtyfps::SharedString("Hello1") };
|
||||
Value str2 { sixtyfps::SharedString("Hello2") };
|
||||
Value str1 { slint::SharedString("Hello1") };
|
||||
Value str2 { slint::SharedString("Hello2") };
|
||||
Value fl1 { 10. };
|
||||
Value fl2 { 12. };
|
||||
|
||||
|
@ -151,22 +151,22 @@ SCENARIO("Value API")
|
|||
REQUIRE(fl1 != fl2);
|
||||
REQUIRE(Value() == Value());
|
||||
REQUIRE(Value() != str1);
|
||||
REQUIRE(str1 == sixtyfps::SharedString("Hello1"));
|
||||
REQUIRE(str1 != sixtyfps::SharedString("Hello2"));
|
||||
REQUIRE(sixtyfps::SharedString("Hello2") == str2);
|
||||
REQUIRE(fl1 != sixtyfps::SharedString("Hello2"));
|
||||
REQUIRE(str1 == slint::SharedString("Hello1"));
|
||||
REQUIRE(str1 != slint::SharedString("Hello2"));
|
||||
REQUIRE(slint::SharedString("Hello2") == str2);
|
||||
REQUIRE(fl1 != slint::SharedString("Hello2"));
|
||||
REQUIRE(fl2 == 12.);
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("Struct API")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace slint::interpreter;
|
||||
Struct struc;
|
||||
|
||||
REQUIRE(!struc.get_field("not_there"));
|
||||
|
||||
struc.set_field("field_a", Value(sixtyfps::SharedString("Hallo")));
|
||||
struc.set_field("field_a", Value(slint::SharedString("Hallo")));
|
||||
|
||||
auto value_opt = struc.get_field("field_a");
|
||||
REQUIRE(value_opt.has_value());
|
||||
|
@ -182,20 +182,20 @@ SCENARIO("Struct API")
|
|||
REQUIRE(value.to_string().value() == "Hallo");
|
||||
}
|
||||
|
||||
struc.set_field("field_b", Value(sixtyfps::SharedString("World")));
|
||||
std::map<std::string, sixtyfps::SharedString> map;
|
||||
struc.set_field("field_b", Value(slint::SharedString("World")));
|
||||
std::map<std::string, slint::SharedString> map;
|
||||
for (auto [k, value] : struc)
|
||||
map[std::string(k)] = *value.to_string();
|
||||
|
||||
REQUIRE(map
|
||||
== std::map<std::string, sixtyfps::SharedString> {
|
||||
{ "field-a", sixtyfps::SharedString("Hallo") },
|
||||
{ "field-b", sixtyfps::SharedString("World") } });
|
||||
== std::map<std::string, slint::SharedString> {
|
||||
{ "field-a", slint::SharedString("Hallo") },
|
||||
{ "field-b", slint::SharedString("World") } });
|
||||
}
|
||||
|
||||
SCENARIO("Struct Iterator Constructor")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace slint::interpreter;
|
||||
|
||||
std::vector<std::pair<std::string_view, Value>> values = { { "field_a", Value(true) },
|
||||
{ "field_b", Value(42.0) } };
|
||||
|
@ -210,7 +210,7 @@ SCENARIO("Struct Iterator Constructor")
|
|||
|
||||
SCENARIO("Struct Initializer List Constructor")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace slint::interpreter;
|
||||
|
||||
Struct struc({ { "field_a", Value(true) }, { "field_b", Value(42.0) } });
|
||||
|
||||
|
@ -222,14 +222,14 @@ SCENARIO("Struct Initializer List Constructor")
|
|||
|
||||
SCENARIO("Struct empty field iteration")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace slint::interpreter;
|
||||
Struct struc;
|
||||
REQUIRE(struc.begin() == struc.end());
|
||||
}
|
||||
|
||||
SCENARIO("Struct field iteration")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace slint::interpreter;
|
||||
|
||||
Struct struc({ { "field_a", Value(true) }, { "field_b", Value(42.0) } });
|
||||
|
||||
|
@ -257,8 +257,8 @@ SCENARIO("Struct field iteration")
|
|||
|
||||
SCENARIO("Component Compiler")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
|
||||
|
@ -313,8 +313,8 @@ SCENARIO("Component Compiler")
|
|||
|
||||
SCENARIO("Component Definition Properties")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
auto comp_def = *compiler.build_from_source(
|
||||
|
@ -331,8 +331,8 @@ SCENARIO("Component Definition Properties")
|
|||
|
||||
SCENARIO("Component Definition Properties / Two-way bindings")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
auto comp_def = *compiler.build_from_source(
|
||||
|
@ -348,8 +348,8 @@ SCENARIO("Component Definition Properties / Two-way bindings")
|
|||
|
||||
SCENARIO("Invoke callback")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
|
||||
|
@ -387,8 +387,8 @@ SCENARIO("Invoke callback")
|
|||
|
||||
SCENARIO("Array between .slint and C++")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
|
||||
|
@ -404,12 +404,12 @@ SCENARIO("Array between .slint and C++")
|
|||
REQUIRE(maybe_array->type() == Value::Type::Model);
|
||||
|
||||
auto array = *maybe_array;
|
||||
REQUIRE(array.to_array() == sixtyfps::SharedVector<Value> { Value(1.), Value(2.), Value(3.) });
|
||||
REQUIRE(array.to_array() == slint::SharedVector<Value> { Value(1.), Value(2.), Value(3.) });
|
||||
}
|
||||
|
||||
SECTION("C++ to .slint")
|
||||
{
|
||||
sixtyfps::SharedVector<Value> cpp_array { Value(4.), Value(5.), Value(6.) };
|
||||
slint::SharedVector<Value> cpp_array { Value(4.), Value(5.), Value(6.) };
|
||||
|
||||
instance->set_property("array", Value(cpp_array));
|
||||
auto maybe_array = instance->get_property("array");
|
||||
|
@ -423,8 +423,8 @@ SCENARIO("Array between .slint and C++")
|
|||
|
||||
SCENARIO("Angle between .slint and C++")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
|
||||
|
@ -456,8 +456,8 @@ SCENARIO("Angle between .slint and C++")
|
|||
|
||||
SCENARIO("Component Definition Name")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
auto comp_def = *compiler.build_from_source("export IHaveAName := Rectangle { }", "");
|
||||
|
@ -466,8 +466,8 @@ SCENARIO("Component Definition Name")
|
|||
|
||||
SCENARIO("Send key events")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
auto comp_def = compiler.build_from_source(R"(
|
||||
|
@ -485,14 +485,14 @@ SCENARIO("Send key events")
|
|||
"");
|
||||
REQUIRE(comp_def.has_value());
|
||||
auto instance = comp_def->create();
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&*instance, "Hello keys!", {});
|
||||
slint::testing::send_keyboard_string_sequence(&*instance, "Hello keys!", {});
|
||||
REQUIRE(*instance->get_property("result")->to_string() == "Hello keys!");
|
||||
}
|
||||
|
||||
SCENARIO("Global properties")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
using namespace slint::interpreter;
|
||||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ int main()
|
|||
|
||||
// ANCHOR: game_logic
|
||||
|
||||
auto tiles_model = std::make_shared<sixtyfps::VectorModel<TileData>>(new_tiles);
|
||||
auto tiles_model = std::make_shared<slint::VectorModel<TileData>>(new_tiles);
|
||||
main_window->set_memory_tiles(tiles_model);
|
||||
|
||||
main_window->on_check_if_pair_solved(
|
||||
[main_window_weak = sixtyfps::ComponentWeakHandle(main_window)] {
|
||||
[main_window_weak = slint::ComponentWeakHandle(main_window)] {
|
||||
auto main_window = *main_window_weak.lock();
|
||||
auto tiles_model = main_window->get_memory_tiles();
|
||||
int first_visible_index = -1;
|
||||
|
@ -52,7 +52,7 @@ int main()
|
|||
}
|
||||
main_window->set_disable_tiles(true);
|
||||
|
||||
sixtyfps::Timer::single_shot(std::chrono::seconds(1),
|
||||
slint::Timer::single_shot(std::chrono::seconds(1),
|
||||
[=]() mutable {
|
||||
main_window->set_disable_tiles(false);
|
||||
first_visible_tile.image_visible = false;
|
||||
|
|
|
@ -21,7 +21,7 @@ int main()
|
|||
}
|
||||
std::default_random_engine rng {};
|
||||
std::shuffle(new_tiles.begin(), new_tiles.end(), rng);
|
||||
auto tiles_model = std::make_shared<sixtyfps::VectorModel<TileData>>(new_tiles);
|
||||
auto tiles_model = std::make_shared<slint::VectorModel<TileData>>(new_tiles);
|
||||
main_window->set_memory_tiles(tiles_model);
|
||||
|
||||
main_window->run();
|
||||
|
|
|
@ -5,21 +5,20 @@
|
|||
|
||||
#include <fmt/core.h>
|
||||
|
||||
void Widget::set_property(std::string_view name, const sixtyfps::interpreter::Value &value)
|
||||
void Widget::set_property(std::string_view name, const slint::interpreter::Value &value)
|
||||
{
|
||||
if (m_ui)
|
||||
(*m_ui)->set_property(qualified_property_name(name), value);
|
||||
}
|
||||
|
||||
std::optional<sixtyfps::interpreter::Value> Widget::property(std::string_view name) const
|
||||
std::optional<slint::interpreter::Value> Widget::property(std::string_view name) const
|
||||
{
|
||||
if (m_ui)
|
||||
return (*m_ui)->get_property(qualified_property_name(name));
|
||||
return {};
|
||||
}
|
||||
|
||||
void Widget::connect_ui(
|
||||
const sixtyfps::ComponentHandle<sixtyfps::interpreter::ComponentInstance> &ui,
|
||||
void Widget::connect_ui(const slint::ComponentHandle<slint::interpreter::ComponentInstance> &ui,
|
||||
std::string_view properties_prefix)
|
||||
{
|
||||
m_ui = ui;
|
||||
|
@ -73,8 +72,8 @@ int DashboardBuilder::register_widget(WidgetPtr widget)
|
|||
return widget_id;
|
||||
}
|
||||
|
||||
std::optional<sixtyfps::ComponentHandle<sixtyfps::interpreter::ComponentInstance>>
|
||||
DashboardBuilder::build(sixtyfps::interpreter::ComponentCompiler &compiler) const
|
||||
std::optional<slint::ComponentHandle<slint::interpreter::ComponentInstance>>
|
||||
DashboardBuilder::build(slint::interpreter::ComponentCompiler &compiler) const
|
||||
{
|
||||
std::string widget_imports;
|
||||
|
||||
|
@ -189,8 +188,7 @@ MainWindow := Window {{
|
|||
auto definition = compiler.build_from_source(source_code, SOURCE_DIR);
|
||||
|
||||
for (auto diagnostic : compiler.diagnostics()) {
|
||||
std::cerr << (diagnostic.level == sixtyfps::interpreter::DiagnosticLevel::Warning
|
||||
? "warning: "
|
||||
std::cerr << (diagnostic.level == slint::interpreter::DiagnosticLevel::Warning ? "warning: "
|
||||
: "error: ")
|
||||
<< diagnostic.message << std::endl;
|
||||
std::cerr << "location: " << diagnostic.source_file;
|
||||
|
|
|
@ -17,7 +17,7 @@ struct PropertyDeclaration
|
|||
};
|
||||
|
||||
/**
|
||||
The Widget base class is a wrapper around sixtyfps::interpreter::ComponentInstance that allows
|
||||
The Widget base class is a wrapper around slint::interpreter::ComponentInstance that allows
|
||||
conveniently reading and writing properties of an element of which the properties have been
|
||||
forwarded via two-way bindings.
|
||||
|
||||
|
@ -50,11 +50,11 @@ public:
|
|||
virtual std::string type_name() const = 0;
|
||||
virtual std::vector<PropertyDeclaration> properties() const = 0;
|
||||
|
||||
void set_property(std::string_view name, const sixtyfps::interpreter::Value &value);
|
||||
void set_property(std::string_view name, const slint::interpreter::Value &value);
|
||||
|
||||
std::optional<sixtyfps::interpreter::Value> property(std::string_view name) const;
|
||||
std::optional<slint::interpreter::Value> property(std::string_view name) const;
|
||||
|
||||
void connect_ui(const sixtyfps::ComponentHandle<sixtyfps::interpreter::ComponentInstance> &ui,
|
||||
void connect_ui(const slint::ComponentHandle<slint::interpreter::ComponentInstance> &ui,
|
||||
std::string_view properties_prefix);
|
||||
|
||||
std::pair<std::string, std::vector<PropertyDeclaration>>
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
private:
|
||||
std::string qualified_property_name(std::string_view name) const;
|
||||
|
||||
std::optional<sixtyfps::ComponentHandle<sixtyfps::interpreter::ComponentInstance>> m_ui;
|
||||
std::optional<slint::ComponentHandle<slint::interpreter::ComponentInstance>> m_ui;
|
||||
std::string m_properties_prefix;
|
||||
};
|
||||
|
||||
|
@ -89,8 +89,8 @@ struct DashboardBuilder
|
|||
void add_grid_widget(WidgetPtr widget, const WidgetLocation &location);
|
||||
void add_top_bar_widget(WidgetPtr widget);
|
||||
|
||||
std::optional<sixtyfps::ComponentHandle<sixtyfps::interpreter::ComponentInstance>>
|
||||
build(sixtyfps::interpreter::ComponentCompiler &compiler) const;
|
||||
std::optional<slint::ComponentHandle<slint::interpreter::ComponentInstance>>
|
||||
build(slint::interpreter::ComponentCompiler &compiler) const;
|
||||
|
||||
private:
|
||||
int register_widget(WidgetPtr widget);
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
private:
|
||||
void update_clock();
|
||||
|
||||
sixtyfps::Timer clock_update_timer;
|
||||
slint::Timer clock_update_timer;
|
||||
};
|
||||
|
||||
ClockWidget::ClockWidget() : clock_update_timer(std::chrono::seconds(1), [this] { update_clock(); })
|
||||
|
@ -45,7 +45,7 @@ ClockWidget::ClockWidget() : clock_update_timer(std::chrono::seconds(1), [this]
|
|||
void ClockWidget::update_clock()
|
||||
{
|
||||
std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr)));
|
||||
set_property("time", sixtyfps::SharedString(current_time));
|
||||
set_property("time", slint::SharedString(current_time));
|
||||
}
|
||||
|
||||
class HumidityWidget : public Widget
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
private:
|
||||
void update_fake_humidity();
|
||||
sixtyfps::Timer fake_humidity_update_timer;
|
||||
slint::Timer fake_humidity_update_timer;
|
||||
std::default_random_engine rng;
|
||||
};
|
||||
|
||||
|
@ -91,7 +91,7 @@ int main()
|
|||
builder.add_grid_widget(std::make_shared<PlaceholderWidget>("UsageDiagram"), { 2, 0, {}, 2 });
|
||||
builder.add_grid_widget(std::make_shared<PlaceholderWidget>("LightIntensity"), { 2, 2 });
|
||||
|
||||
sixtyfps::interpreter::ComponentCompiler compiler;
|
||||
slint::interpreter::ComponentCompiler compiler;
|
||||
compiler.set_include_paths({ SOURCE_DIR });
|
||||
auto dashboard = builder.build(compiler);
|
||||
|
||||
|
|
|
@ -14,12 +14,13 @@ int main()
|
|||
new_tiles.push_back(*old_tiles->row_data(i));
|
||||
new_tiles.push_back(*old_tiles->row_data(i));
|
||||
}
|
||||
std::default_random_engine rng{};
|
||||
std::default_random_engine rng {};
|
||||
std::shuffle(std::begin(new_tiles), std::end(new_tiles), rng);
|
||||
auto tiles_model = std::make_shared<sixtyfps::VectorModel<TileData>>(new_tiles);
|
||||
auto tiles_model = std::make_shared<slint::VectorModel<TileData>>(new_tiles);
|
||||
main_window->set_memory_tiles(tiles_model);
|
||||
|
||||
main_window->on_check_if_pair_solved([main_window_weak = sixtyfps::ComponentWeakHandle(main_window)] {
|
||||
main_window->on_check_if_pair_solved(
|
||||
[main_window_weak = slint::ComponentWeakHandle(main_window)] {
|
||||
auto main_window = *main_window_weak.lock();
|
||||
auto tiles_model = main_window->get_memory_tiles();
|
||||
int first_visible_index = -1;
|
||||
|
@ -43,7 +44,7 @@ int main()
|
|||
}
|
||||
main_window->set_disable_tiles(true);
|
||||
|
||||
sixtyfps::Timer::single_shot(std::chrono::seconds(1), [=]() mutable {
|
||||
slint::Timer::single_shot(std::chrono::seconds(1), [=]() mutable {
|
||||
main_window->set_disable_tiles(false);
|
||||
first_visible_tile.image_visible = false;
|
||||
tiles_model->set_row_data(first_visible_index, first_visible_tile);
|
||||
|
|
|
@ -5,19 +5,20 @@
|
|||
|
||||
#include <ctime>
|
||||
|
||||
struct InkLevelModel : sixtyfps::Model<InkLevel>
|
||||
struct InkLevelModel : slint::Model<InkLevel>
|
||||
{
|
||||
int row_count() const override { return m_data.size(); }
|
||||
std::optional<InkLevel> row_data(int i) const override {
|
||||
std::optional<InkLevel> row_data(int i) const override
|
||||
{
|
||||
if (i < row_count())
|
||||
return { m_data[i] };
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<InkLevel> m_data = { { sixtyfps::Color::from_rgb_uint8(255, 255, 0), 0.9 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(0, 255, 255), 0.5 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(255, 0, 255), 0.8 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(0, 0, 0), 0.1 } };
|
||||
std::vector<InkLevel> m_data = { { slint::Color::from_rgb_uint8(255, 255, 0), 0.9 },
|
||||
{ slint::Color::from_rgb_uint8(0, 255, 255), 0.5 },
|
||||
{ slint::Color::from_rgb_uint8(255, 0, 255), 0.8 },
|
||||
{ slint::Color::from_rgb_uint8(0, 0, 0), 0.1 } };
|
||||
};
|
||||
|
||||
int main()
|
||||
|
@ -26,15 +27,14 @@ int main()
|
|||
printer_demo->set_ink_levels(std::make_shared<InkLevelModel>());
|
||||
printer_demo->on_quit([] { std::exit(0); });
|
||||
|
||||
|
||||
auto printer_queue = std::make_shared<sixtyfps::VectorModel<PrinterQueueItem>>();
|
||||
auto printer_queue = std::make_shared<slint::VectorModel<PrinterQueueItem>>();
|
||||
auto default_queue = printer_demo->global<PrinterQueue>().get_printer_queue();
|
||||
for (int i = 0; i < default_queue->row_count(); ++i) {
|
||||
printer_queue->push_back(*default_queue->row_data(i));
|
||||
}
|
||||
printer_demo->global<PrinterQueue>().set_printer_queue(printer_queue);
|
||||
|
||||
printer_demo->global<PrinterQueue>().on_start_job([=](sixtyfps::SharedString name) {
|
||||
printer_demo->global<PrinterQueue>().on_start_job([=](slint::SharedString name) {
|
||||
std::time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||
char time_buf[100] = { 0 };
|
||||
std::strftime(time_buf, sizeof(time_buf), "%H:%M:%S %d/%m/%Y", std::localtime(&now));
|
||||
|
@ -52,7 +52,7 @@ int main()
|
|||
printer_demo->global<PrinterQueue>().on_cancel_job(
|
||||
[=](int index) { printer_queue->erase(int(index)); });
|
||||
|
||||
sixtyfps::Timer printer_queue_progress_timer(std::chrono::seconds(1), [=]() {
|
||||
slint::Timer printer_queue_progress_timer(std::chrono::seconds(1), [=]() {
|
||||
if (printer_queue->row_count() > 0) {
|
||||
auto top_item = *printer_queue->row_data(0);
|
||||
top_item.progress += 1;
|
||||
|
|
|
@ -5,42 +5,42 @@
|
|||
|
||||
#include <ctime>
|
||||
|
||||
using sixtyfps::interpreter::Value;
|
||||
using slint::interpreter::Value;
|
||||
|
||||
struct InkLevelModel : sixtyfps::Model<Value>
|
||||
struct InkLevelModel : slint::Model<Value>
|
||||
{
|
||||
int row_count() const override { return m_data.size(); }
|
||||
std::optional<Value> row_data(int i) const override {
|
||||
std::optional<Value> row_data(int i) const override
|
||||
{
|
||||
if (i < m_data.size())
|
||||
return { m_data[i] };
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
static Value make_inklevel_value(sixtyfps::Color color, float level)
|
||||
static Value make_inklevel_value(slint::Color color, float level)
|
||||
{
|
||||
sixtyfps::interpreter::Struct s;
|
||||
slint::interpreter::Struct s;
|
||||
s.set_field("color", Value(color));
|
||||
s.set_field("level", level);
|
||||
return s;
|
||||
}
|
||||
|
||||
std::vector<Value> m_data = {
|
||||
make_inklevel_value(sixtyfps::Color::from_rgb_uint8(255, 255, 0), 0.9),
|
||||
make_inklevel_value(sixtyfps::Color::from_rgb_uint8(255, 0, 255), 0.8),
|
||||
make_inklevel_value(sixtyfps::Color::from_rgb_uint8(0, 255, 255), 0.5),
|
||||
make_inklevel_value(sixtyfps::Color::from_rgb_uint8(0, 0, 0), 0.1),
|
||||
make_inklevel_value(slint::Color::from_rgb_uint8(255, 255, 0), 0.9),
|
||||
make_inklevel_value(slint::Color::from_rgb_uint8(255, 0, 255), 0.8),
|
||||
make_inklevel_value(slint::Color::from_rgb_uint8(0, 255, 255), 0.5),
|
||||
make_inklevel_value(slint::Color::from_rgb_uint8(0, 0, 0), 0.1),
|
||||
};
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
sixtyfps::interpreter::ComponentCompiler compiler;
|
||||
slint::interpreter::ComponentCompiler compiler;
|
||||
auto definition = compiler.build_from_path(SOURCE_DIR "/../ui/printerdemo.slint");
|
||||
|
||||
for (auto diagnostic : compiler.diagnostics()) {
|
||||
std::cerr << (diagnostic.level == sixtyfps::interpreter::DiagnosticLevel::Warning
|
||||
? "warning: "
|
||||
std::cerr << (diagnostic.level == slint::interpreter::DiagnosticLevel::Warning ? "warning: "
|
||||
: "error: ")
|
||||
<< diagnostic.message << std::endl;
|
||||
std::cerr << "location: " << diagnostic.source_file;
|
||||
|
@ -56,15 +56,15 @@ int main()
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
auto instance = definition->create();
|
||||
std::shared_ptr<sixtyfps::Model<Value>> ink_levels = std::make_shared<InkLevelModel>();
|
||||
std::shared_ptr<slint::Model<Value>> ink_levels = std::make_shared<InkLevelModel>();
|
||||
if (!instance->set_property("ink_levels", ink_levels)) {
|
||||
std::cerr << "Could not set property ink_levels" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
auto printer_queue = std::make_shared<sixtyfps::VectorModel<Value>>();
|
||||
auto printer_queue = std::make_shared<slint::VectorModel<Value>>();
|
||||
|
||||
sixtyfps::SharedVector<Value> default_queue =
|
||||
slint::SharedVector<Value> default_queue =
|
||||
*instance->get_global_property("PrinterQueue", "printer_queue")->to_array();
|
||||
for (const auto &default_item : default_queue)
|
||||
printer_queue->push_back(default_item);
|
||||
|
@ -76,15 +76,13 @@ int main()
|
|||
char time_buf[100] = { 0 };
|
||||
std::strftime(time_buf, sizeof(time_buf), "%H:%M:%S %d/%m/%Y", std::localtime(&now));
|
||||
|
||||
sixtyfps::interpreter::Struct item {
|
||||
{ "status", Value(sixtyfps::SharedString("WAITING...")) },
|
||||
slint::interpreter::Struct item { { "status", Value(slint::SharedString("WAITING...")) },
|
||||
{ "progress", Value(0.) },
|
||||
{ "title", args[0] },
|
||||
{ "owner", sixtyfps::SharedString("joe@example.com") },
|
||||
{ "owner", slint::SharedString("joe@example.com") },
|
||||
{ "pages", Value(1.) },
|
||||
{ "size", sixtyfps::SharedString("100kB") },
|
||||
{ "submission_date", sixtyfps::SharedString(time_buf) }
|
||||
};
|
||||
{ "size", slint::SharedString("100kB") },
|
||||
{ "submission_date", slint::SharedString(time_buf) } };
|
||||
printer_queue->push_back(item);
|
||||
return Value();
|
||||
});
|
||||
|
@ -95,12 +93,12 @@ int main()
|
|||
return Value();
|
||||
});
|
||||
|
||||
sixtyfps::Timer printer_queue_progress_timer(std::chrono::seconds(1), [=]() {
|
||||
slint::Timer printer_queue_progress_timer(std::chrono::seconds(1), [=]() {
|
||||
if (printer_queue->row_count() > 0) {
|
||||
auto top_item = *(*printer_queue->row_data(0)).to_struct();
|
||||
auto progress = *top_item.get_field("progress")->to_number() + 1.;
|
||||
top_item.set_field("progress", progress);
|
||||
top_item.set_field("status", sixtyfps::SharedString("PRINTING"));
|
||||
top_item.set_field("status", slint::SharedString("PRINTING"));
|
||||
if (progress > 100) {
|
||||
printer_queue->erase(0);
|
||||
} else {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "printerdemo.h"
|
||||
|
||||
struct InkLevelModel : sixtyfps::Model<InkLevel>
|
||||
struct InkLevelModel : slint::Model<InkLevel>
|
||||
{
|
||||
int row_count() const override { return m_data.size(); }
|
||||
std::optional<InkLevel> row_data(int i) const override
|
||||
|
@ -13,10 +13,10 @@ struct InkLevelModel : sixtyfps::Model<InkLevel>
|
|||
return {};
|
||||
}
|
||||
|
||||
std::vector<InkLevel> m_data = { { sixtyfps::Color::from_rgb_uint8(255, 255, 0), 0.9 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(0, 255, 255), 0.5 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(255, 0, 255), 0.8 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(0, 0, 0), 0.1 } };
|
||||
std::vector<InkLevel> m_data = { { slint::Color::from_rgb_uint8(255, 255, 0), 0.9 },
|
||||
{ slint::Color::from_rgb_uint8(0, 255, 255), 0.5 },
|
||||
{ slint::Color::from_rgb_uint8(255, 0, 255), 0.8 },
|
||||
{ slint::Color::from_rgb_uint8(0, 0, 0), 0.1 } };
|
||||
};
|
||||
|
||||
int main()
|
||||
|
@ -25,13 +25,13 @@ int main()
|
|||
printer_demo->set_ink_levels(std::make_shared<InkLevelModel>());
|
||||
printer_demo->on_quit([] { std::exit(0); });
|
||||
|
||||
printer_demo->on_fax_number_erase([printer_demo = sixtyfps::ComponentWeakHandle(printer_demo)] {
|
||||
printer_demo->on_fax_number_erase([printer_demo = slint::ComponentWeakHandle(printer_demo)] {
|
||||
std::string fax_number { (*printer_demo.lock())->get_fax_number() };
|
||||
fax_number.pop_back();
|
||||
(*printer_demo.lock())->set_fax_number(fax_number.data());
|
||||
});
|
||||
|
||||
printer_demo->on_fax_send([printer_demo = sixtyfps::ComponentWeakHandle(printer_demo)] {
|
||||
printer_demo->on_fax_send([printer_demo = slint::ComponentWeakHandle(printer_demo)] {
|
||||
std::cout << "Sending a fax to " << (*printer_demo.lock())->get_fax_number() << std::endl;
|
||||
(*printer_demo.lock())->set_fax_number({});
|
||||
});
|
||||
|
|
|
@ -6,22 +6,25 @@
|
|||
|
||||
#include "ui_interface.h"
|
||||
|
||||
|
||||
struct LoadedFile {
|
||||
sixtyfps::ComponentHandle<sixtyfps::interpreter::ComponentInstance> instance;
|
||||
struct LoadedFile
|
||||
{
|
||||
slint::ComponentHandle<slint::interpreter::ComponentInstance> instance;
|
||||
QWidget *widget;
|
||||
};
|
||||
|
||||
void show_diagnostics(QWidget *root, const sixtyfps::SharedVector< sixtyfps::interpreter::Diagnostic > &diags) {
|
||||
void show_diagnostics(QWidget *root,
|
||||
const slint::SharedVector<slint::interpreter::Diagnostic> &diags)
|
||||
{
|
||||
QString text;
|
||||
|
||||
for (auto diagnostic : diags) {
|
||||
text += (diagnostic.level == sixtyfps::interpreter::DiagnosticLevel::Warning
|
||||
text += (diagnostic.level == slint::interpreter::DiagnosticLevel::Warning
|
||||
? QApplication::translate("qt_viewer", "warning: %1\n")
|
||||
: QApplication::translate("qt_viewer", "error: %1\n")
|
||||
).arg(QString::fromUtf8(diagnostic.message.data()));
|
||||
: QApplication::translate("qt_viewer", "error: %1\n"))
|
||||
.arg(QString::fromUtf8(diagnostic.message.data()));
|
||||
|
||||
text += QApplication::translate("qt_viewer", "location: %1").arg(QString::fromUtf8(diagnostic.source_file.data()));
|
||||
text += QApplication::translate("qt_viewer", "location: %1")
|
||||
.arg(QString::fromUtf8(diagnostic.source_file.data()));
|
||||
if (diagnostic.line > 0)
|
||||
text += ":" + QString::number(diagnostic.line);
|
||||
if (diagnostic.column > 0)
|
||||
|
@ -29,10 +32,12 @@ void show_diagnostics(QWidget *root, const sixtyfps::SharedVector< sixtyfps::int
|
|||
text += "\n";
|
||||
}
|
||||
|
||||
QMessageBox::critical(root, QApplication::translate("qt_viewer", "Compilation error"), text, QMessageBox::StandardButton::Ok);
|
||||
QMessageBox::critical(root, QApplication::translate("qt_viewer", "Compilation error"), text,
|
||||
QMessageBox::StandardButton::Ok);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
std::unique_ptr<LoadedFile> loaded_file;
|
||||
|
||||
|
@ -41,11 +46,11 @@ int main(int argc, char **argv) {
|
|||
ui.setupUi(&main);
|
||||
QHBoxLayout layout(ui.my_content);
|
||||
|
||||
sixtyfps::interpreter::Value::Type currentType;
|
||||
slint::interpreter::Value::Type currentType;
|
||||
|
||||
auto load_file = [&](const QString &fileName) {
|
||||
loaded_file.reset();
|
||||
sixtyfps::interpreter::ComponentCompiler compiler;
|
||||
slint::interpreter::ComponentCompiler compiler;
|
||||
auto def = compiler.build_from_path(fileName.toUtf8().data());
|
||||
if (!def) {
|
||||
show_diagnostics(&main, compiler.diagnostics());
|
||||
|
@ -54,14 +59,16 @@ int main(int argc, char **argv) {
|
|||
auto instance = def->create();
|
||||
QWidget *wid = instance->qwidget();
|
||||
if (!wid) {
|
||||
QMessageBox::critical(&main, QApplication::translate("qt_viewer", "No Qt backend"),
|
||||
QApplication::translate("qt_viewer", "SixtyFPS is not running with the Qt backend."),
|
||||
QMessageBox::critical(
|
||||
&main, QApplication::translate("qt_viewer", "No Qt backend"),
|
||||
QApplication::translate("qt_viewer",
|
||||
"SixtyFPS is not running with the Qt backend."),
|
||||
QMessageBox::StandardButton::Ok);
|
||||
return;
|
||||
}
|
||||
wid->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
layout.addWidget(wid);
|
||||
loaded_file = std::make_unique<LoadedFile>(LoadedFile{ instance, wid });
|
||||
loaded_file = std::make_unique<LoadedFile>(LoadedFile { instance, wid });
|
||||
};
|
||||
|
||||
auto args = app.arguments();
|
||||
|
@ -79,15 +86,16 @@ int main(int argc, char **argv) {
|
|||
});
|
||||
|
||||
QObject::connect(ui.prop_name, &QLineEdit::textChanged, [&] {
|
||||
if (!loaded_file) return;
|
||||
if (!loaded_file)
|
||||
return;
|
||||
if (auto val = loaded_file->instance->get_property(ui.prop_name->text().toUtf8().data())) {
|
||||
currentType = val->type();
|
||||
switch (currentType) {
|
||||
case sixtyfps::interpreter::Value::Type::String:
|
||||
case slint::interpreter::Value::Type::String:
|
||||
ui.prop_value->setText(QString::fromUtf8(val->to_string()->data()));
|
||||
break;
|
||||
|
||||
case sixtyfps::interpreter::Value::Type::Number:
|
||||
case slint::interpreter::Value::Type::Number:
|
||||
ui.prop_value->setText(QString::number(val->to_number().value()));
|
||||
break;
|
||||
|
||||
|
@ -99,30 +107,36 @@ int main(int argc, char **argv) {
|
|||
});
|
||||
|
||||
QObject::connect(ui.set_button, &QPushButton::clicked, [&] {
|
||||
if (!loaded_file) return;
|
||||
sixtyfps::interpreter::Value val;
|
||||
if (!loaded_file)
|
||||
return;
|
||||
slint::interpreter::Value val;
|
||||
switch (currentType) {
|
||||
case sixtyfps::interpreter::Value::Type::String:
|
||||
val = sixtyfps::SharedString(ui.prop_value->text().toUtf8().data());
|
||||
case slint::interpreter::Value::Type::String:
|
||||
val = slint::SharedString(ui.prop_value->text().toUtf8().data());
|
||||
break;
|
||||
case sixtyfps::interpreter::Value::Type::Number: {
|
||||
case slint::interpreter::Value::Type::Number: {
|
||||
bool ok;
|
||||
val = ui.prop_value->text().toDouble(&ok);
|
||||
if (!ok) {
|
||||
QMessageBox::critical(&main, QApplication::translate("qt_viewer", "Set Property Error"),
|
||||
QApplication::translate("qt_viewer", "Invalid conversion to number"), QMessageBox::StandardButton::Ok);
|
||||
QMessageBox::critical(
|
||||
&main, QApplication::translate("qt_viewer", "Set Property Error"),
|
||||
QApplication::translate("qt_viewer", "Invalid conversion to number"),
|
||||
QMessageBox::StandardButton::Ok);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
QMessageBox::critical(&main, QApplication::translate("qt_viewer", "Set Property Error"),
|
||||
QApplication::translate("qt_viewer", "Cannot set properties of this type"), QMessageBox::StandardButton::Ok);
|
||||
QMessageBox::critical(
|
||||
&main, QApplication::translate("qt_viewer", "Set Property Error"),
|
||||
QApplication::translate("qt_viewer", "Cannot set properties of this type"),
|
||||
QMessageBox::StandardButton::Ok);
|
||||
return;
|
||||
}
|
||||
if (!loaded_file->instance->set_property(ui.prop_name->text().toUtf8().data(), val)) {
|
||||
QMessageBox::critical(&main, QApplication::translate("qt_viewer", "Set Property Error"),
|
||||
QApplication::translate("qt_viewer", "Could not set property"), QMessageBox::StandardButton::Ok);
|
||||
QApplication::translate("qt_viewer", "Could not set property"),
|
||||
QMessageBox::StandardButton::Ok);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -7,19 +7,15 @@ int main()
|
|||
{
|
||||
auto demo = MainWindow::create();
|
||||
|
||||
auto todo_model = std::make_shared<sixtyfps::VectorModel<TodoItem>>(std::vector {
|
||||
TodoItem { true, "Implement the .slint file" },
|
||||
TodoItem { false, "Do the Rust part" },
|
||||
auto todo_model = std::make_shared<slint::VectorModel<TodoItem>>(std::vector {
|
||||
TodoItem { true, "Implement the .slint file" }, TodoItem { false, "Do the Rust part" },
|
||||
TodoItem { true, "Make the C++ code" },
|
||||
TodoItem { false, "Write some JavaScript code" },
|
||||
TodoItem { false, "Test the application" },
|
||||
TodoItem { false, "Ship to customer" },
|
||||
TodoItem { false, "???" },
|
||||
TodoItem { false, "Profit" }
|
||||
});
|
||||
TodoItem { false, "Test the application" }, TodoItem { false, "Ship to customer" },
|
||||
TodoItem { false, "???" }, TodoItem { false, "Profit" } });
|
||||
demo->set_todo_model(todo_model);
|
||||
|
||||
demo->on_todo_added([todo_model](const sixtyfps::SharedString &s) {
|
||||
demo->on_todo_added([todo_model](const slint::SharedString &s) {
|
||||
todo_model->push_back(TodoItem { false, s });
|
||||
});
|
||||
|
||||
|
|
|
@ -306,5 +306,5 @@ impl ItemConsts for NativeButton {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeButtonVTable() -> NativeButtonVTable for NativeButton
|
||||
fn slint_get_NativeButtonVTable() -> NativeButtonVTable for NativeButton
|
||||
}
|
||||
|
|
|
@ -117,5 +117,5 @@ impl ItemConsts for NativeCheckBox {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeCheckBoxVTable() -> NativeCheckBoxVTable for NativeCheckBox
|
||||
fn slint_get_NativeCheckBoxVTable() -> NativeCheckBoxVTable for NativeCheckBox
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ impl ItemConsts for NativeComboBox {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeComboBoxVTable() -> NativeComboBoxVTable for NativeComboBox
|
||||
fn slint_get_NativeComboBoxVTable() -> NativeComboBoxVTable for NativeComboBox
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -229,5 +229,5 @@ impl ItemConsts for NativeComboBoxPopup {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeComboBoxPopupVTable() -> NativeComboBoxPopupVTable for NativeComboBoxPopup
|
||||
fn slint_get_NativeComboBoxPopupVTable() -> NativeComboBoxPopupVTable for NativeComboBoxPopup
|
||||
}
|
||||
|
|
|
@ -194,5 +194,5 @@ impl ItemConsts for NativeGroupBox {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeGroupBoxVTable() -> NativeGroupBoxVTable for NativeGroupBox
|
||||
fn slint_get_NativeGroupBoxVTable() -> NativeGroupBoxVTable for NativeGroupBox
|
||||
}
|
||||
|
|
|
@ -140,5 +140,5 @@ impl ItemConsts for NativeLineEdit {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeLineEditVTable() -> NativeLineEditVTable for NativeLineEdit
|
||||
fn slint_get_NativeLineEditVTable() -> NativeLineEditVTable for NativeLineEdit
|
||||
}
|
||||
|
|
|
@ -135,5 +135,5 @@ impl ItemConsts for NativeStandardListViewItem {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeStandardListViewItemVTable() -> NativeStandardListViewItemVTable for NativeStandardListViewItem
|
||||
fn slint_get_NativeStandardListViewItemVTable() -> NativeStandardListViewItemVTable for NativeStandardListViewItem
|
||||
}
|
||||
|
|
|
@ -411,5 +411,5 @@ impl ItemConsts for NativeScrollView {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeScrollViewVTable() -> NativeScrollViewVTable for NativeScrollView
|
||||
fn slint_get_NativeScrollViewVTable() -> NativeScrollViewVTable for NativeScrollView
|
||||
}
|
||||
|
|
|
@ -233,5 +233,5 @@ impl ItemConsts for NativeSlider {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeSliderVTable() -> NativeSliderVTable for NativeSlider
|
||||
fn slint_get_NativeSliderVTable() -> NativeSliderVTable for NativeSlider
|
||||
}
|
||||
|
|
|
@ -232,5 +232,5 @@ impl ItemConsts for NativeSpinBox {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeSpinBoxVTable() -> NativeSpinBoxVTable for NativeSpinBox
|
||||
fn slint_get_NativeSpinBoxVTable() -> NativeSpinBoxVTable for NativeSpinBox
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ impl ItemConsts for NativeTabWidget {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeTabWidgetVTable() -> NativeTabWidgetVTable for NativeTabWidget
|
||||
fn slint_get_NativeTabWidgetVTable() -> NativeTabWidgetVTable for NativeTabWidget
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -487,5 +487,5 @@ impl ItemConsts for NativeTab {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_NativeTabVTable() -> NativeTabVTable for NativeTab
|
||||
fn slint_get_NativeTabVTable() -> NativeTabVTable for NativeTab
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ export Text := _ {
|
|||
|
||||
|
||||
export struct PointerEvent := {
|
||||
//-name:sixtyfps::private_api::PointerEvent
|
||||
//-name:slint::private_api::PointerEvent
|
||||
button: PointerEventButton,
|
||||
kind: PointerEventKind,
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ export TouchArea := _ {
|
|||
}
|
||||
|
||||
export struct KeyboardModifiers := {
|
||||
//-name:sixtyfps::private_api::KeyboardModifiers
|
||||
//-name:slint::private_api::KeyboardModifiers
|
||||
alt: bool,
|
||||
control: bool,
|
||||
shift: bool,
|
||||
|
@ -124,7 +124,7 @@ export struct KeyboardModifiers := {
|
|||
}
|
||||
|
||||
export struct KeyEvent := {
|
||||
//-name:sixtyfps::private_api::KeyEvent
|
||||
//-name:slint::private_api::KeyEvent
|
||||
text: string,
|
||||
modifiers: KeyboardModifiers,
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ export BoxShadow := _ {
|
|||
}
|
||||
|
||||
export struct Point := {
|
||||
//-name:sixtyfps::private_api::Point
|
||||
//-name:slint::private_api::Point
|
||||
x: length,
|
||||
y: length,
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ MoveTo := _ {
|
|||
property <float> y;
|
||||
|
||||
//-rust_type_constructor:sixtyfps::re_exports::PathElement::MoveTo(PathMoveTo{{}})
|
||||
//-cpp_type:sixtyfps::private_api::PathMoveTo
|
||||
//-cpp_type:slint::private_api::PathMoveTo
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ LineTo := _ {
|
|||
property <float> y;
|
||||
|
||||
//-rust_type_constructor:sixtyfps::re_exports::PathElement::LineTo(PathLineTo{{}})
|
||||
//-cpp_type:sixtyfps::private_api::PathLineTo
|
||||
//-cpp_type:slint::private_api::PathLineTo
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ ArcTo := _ {
|
|||
property <bool> sweep;
|
||||
|
||||
//-rust_type_constructor:sixtyfps::re_exports::PathElement::ArcTo(PathArcTo{{}})
|
||||
//-cpp_type:sixtyfps::private_api::PathArcTo
|
||||
//-cpp_type:slint::private_api::PathArcTo
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ CubicTo := _ {
|
|||
property <float> y;
|
||||
|
||||
//-rust_type_constructor:sixtyfps::re_exports::PathElement::CubicTo(PathCubicTo{{}})
|
||||
//-cpp_type:sixtyfps::private_api::PathCubicTo
|
||||
//-cpp_type:slint::private_api::PathCubicTo
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
||||
|
@ -316,13 +316,13 @@ QuadraticTo := _ {
|
|||
property <float> y;
|
||||
|
||||
//-rust_type_constructor:sixtyfps::re_exports::PathElement::QuadraticTo(PathQuadraticTo{{}})
|
||||
//-cpp_type:sixtyfps::private_api::PathQuadraticTo
|
||||
//-cpp_type:slint::private_api::PathQuadraticTo
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
||||
Close := _ {
|
||||
//-rust_type_constructor:sixtyfps::re_exports::PathElement::Close
|
||||
//-cpp_type:sixtyfps::private_api::PathClose
|
||||
//-cpp_type:slint::private_api::PathClose
|
||||
//-is_non_item_type
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
@ -413,12 +413,12 @@ PropertyAnimation := _ {
|
|||
}
|
||||
|
||||
export struct StandardListViewItem := {
|
||||
//-name:sixtyfps::private_api::StandardListViewItem
|
||||
//-name:slint::private_api::StandardListViewItem
|
||||
text: string
|
||||
}
|
||||
|
||||
export struct StateInfo := {
|
||||
//-name:sixtyfps::private_api::StateInfo
|
||||
//-name:slint::private_api::StateInfo
|
||||
current_state: int,
|
||||
previous_state: int,
|
||||
//change_time: duration,
|
||||
|
|
|
@ -308,8 +308,8 @@ impl CppType for Type {
|
|||
Type::Void => Some("void".to_owned()),
|
||||
Type::Float32 => Some("float".to_owned()),
|
||||
Type::Int32 => Some("int".to_owned()),
|
||||
Type::String => Some("sixtyfps::SharedString".to_owned()),
|
||||
Type::Color => Some("sixtyfps::Color".to_owned()),
|
||||
Type::String => Some("slint::SharedString".to_owned()),
|
||||
Type::Color => Some("slint::Color".to_owned()),
|
||||
Type::Duration => Some("std::int64_t".to_owned()),
|
||||
Type::Angle => Some("float".to_owned()),
|
||||
Type::PhysicalLength => Some("float".to_owned()),
|
||||
|
@ -318,10 +318,10 @@ impl CppType for Type {
|
|||
Type::Bool => Some("bool".to_owned()),
|
||||
Type::Struct { name: Some(name), node: Some(_), .. } => Some(ident(name)),
|
||||
Type::Struct { name: Some(name), node: None, .. } => {
|
||||
Some(if name.starts_with("sixtyfps::") {
|
||||
Some(if name.starts_with("slint::") {
|
||||
name.clone()
|
||||
} else {
|
||||
format!("sixtyfps::cbindgen_private::{}", ident(name))
|
||||
format!("slint::cbindgen_private::{}", ident(name))
|
||||
})
|
||||
}
|
||||
Type::Struct { fields, .. } => {
|
||||
|
@ -330,14 +330,14 @@ impl CppType for Type {
|
|||
Some(format!("std::tuple<{}>", elem.join(", ")))
|
||||
}
|
||||
|
||||
Type::Array(i) => Some(format!("std::shared_ptr<sixtyfps::Model<{}>>", i.cpp_type()?)),
|
||||
Type::Image => Some("sixtyfps::Image".to_owned()),
|
||||
Type::Array(i) => Some(format!("std::shared_ptr<slint::Model<{}>>", i.cpp_type()?)),
|
||||
Type::Image => Some("slint::Image".to_owned()),
|
||||
Type::Builtin(elem) => elem.native_class.cpp_type.clone(),
|
||||
Type::Enumeration(enumeration) => {
|
||||
Some(format!("sixtyfps::cbindgen_private::{}", ident(&enumeration.name)))
|
||||
Some(format!("slint::cbindgen_private::{}", ident(&enumeration.name)))
|
||||
}
|
||||
Type::Brush => Some("sixtyfps::Brush".to_owned()),
|
||||
Type::LayoutCache => Some("sixtyfps::SharedVector<float>".into()),
|
||||
Type::Brush => Some("slint::Brush".to_owned()),
|
||||
Type::LayoutCache => Some("slint::SharedVector<float>".into()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -345,8 +345,8 @@ impl CppType for Type {
|
|||
|
||||
fn to_cpp_orientation(o: Orientation) -> &'static str {
|
||||
match o {
|
||||
Orientation::Horizontal => "sixtyfps::cbindgen_private::Orientation::Horizontal",
|
||||
Orientation::Vertical => "sixtyfps::cbindgen_private::Orientation::Vertical",
|
||||
Orientation::Horizontal => "slint::cbindgen_private::Orientation::Horizontal",
|
||||
Orientation::Vertical => "slint::cbindgen_private::Orientation::Vertical",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -438,7 +438,7 @@ fn handle_property_init(
|
|||
|
||||
let is_state_info = matches!(prop_type, Type::Struct { name: Some(name), .. } if name.ends_with("::StateInfo"));
|
||||
if is_state_info {
|
||||
format!("sixtyfps::private_api::set_state_binding({}, {});", prop_access, binding_code)
|
||||
format!("slint::private_api::set_state_binding({}, {});", prop_access, binding_code)
|
||||
} else {
|
||||
match &binding_expression.animation {
|
||||
Some(llr::Animation::Static(anim)) => {
|
||||
|
@ -451,7 +451,7 @@ fn handle_property_init(
|
|||
let anim = compile_expression(anim, ctx);
|
||||
format!(
|
||||
"{}.set_animated_binding_for_transition({},
|
||||
[this](uint64_t *start_time) -> sixtyfps::cbindgen_private::PropertyAnimation {{
|
||||
[this](uint64_t *start_time) -> slint::cbindgen_private::PropertyAnimation {{
|
||||
[[maybe_unused]] auto self = this;
|
||||
auto [anim, time] = {};
|
||||
*start_time = time;
|
||||
|
@ -552,12 +552,12 @@ pub fn generate(doc: &Document) -> impl std::fmt::Display {
|
|||
|
||||
file.definitions.push(Declaration::Var(Var{
|
||||
ty: format!(
|
||||
"[[maybe_unused]] constexpr sixtyfps::private_api::VersionCheckHelper<{}, {}, {}>",
|
||||
"[[maybe_unused]] constexpr slint::private_api::VersionCheckHelper<{}, {}, {}>",
|
||||
env!("CARGO_PKG_VERSION_MAJOR"),
|
||||
env!("CARGO_PKG_VERSION_MINOR"),
|
||||
env!("CARGO_PKG_VERSION_PATCH")),
|
||||
name: "THE_SAME_VERSION_MUST_BE_USED_FOR_THE_COMPILER_AND_THE_RUNTIME".into(),
|
||||
init: Some("sixtyfps::private_api::VersionCheckHelper<SLINT_VERSION_MAJOR, SLINT_VERSION_MINOR, SLINT_VERSION_PATCH>()".into()),
|
||||
init: Some("slint::private_api::VersionCheckHelper<SLINT_VERSION_MAJOR, SLINT_VERSION_MINOR, SLINT_VERSION_PATCH>()".into()),
|
||||
..Default::default()
|
||||
}));
|
||||
|
||||
|
@ -613,9 +613,9 @@ fn generate_public_component(file: &mut File, component: &llr::PublicComponent)
|
|||
// FIXME: many of the different component bindings need to access this
|
||||
Access::Public,
|
||||
Declaration::Var(Var {
|
||||
ty: "sixtyfps::Window".into(),
|
||||
ty: "slint::Window".into(),
|
||||
name: "m_window".into(),
|
||||
init: Some("sixtyfps::Window{sixtyfps::private_api::WindowRc()}".into()),
|
||||
init: Some("slint::Window{slint::private_api::WindowRc()}".into()),
|
||||
..Default::default()
|
||||
}),
|
||||
));
|
||||
|
@ -676,7 +676,7 @@ fn generate_public_component(file: &mut File, component: &llr::PublicComponent)
|
|||
Access::Public,
|
||||
Declaration::Function(Function {
|
||||
name: "window".into(),
|
||||
signature: "() const -> sixtyfps::Window&".into(),
|
||||
signature: "() const -> slint::Window&".into(),
|
||||
statements: Some(vec![format!(
|
||||
"return const_cast<{} *>(this)->m_window;",
|
||||
component_struct.name
|
||||
|
@ -692,14 +692,14 @@ fn generate_public_component(file: &mut File, component: &llr::PublicComponent)
|
|||
signature: "()".into(),
|
||||
statements: Some(vec![
|
||||
"show();".into(),
|
||||
"sixtyfps::run_event_loop();".into(),
|
||||
"slint::run_event_loop();".into(),
|
||||
"hide();".into(),
|
||||
]),
|
||||
..Default::default()
|
||||
}),
|
||||
));
|
||||
|
||||
component_struct.friends.push("sixtyfps::private_api::WindowRc".into());
|
||||
component_struct.friends.push("slint::private_api::WindowRc".into());
|
||||
|
||||
component_struct
|
||||
.friends
|
||||
|
@ -716,7 +716,7 @@ fn generate_public_component(file: &mut File, component: &llr::PublicComponent)
|
|||
|
||||
for glob in &component.globals {
|
||||
let ty = if glob.is_builtin {
|
||||
format!("sixtyfps::cbindgen_private::{}", glob.name)
|
||||
format!("slint::cbindgen_private::{}", glob.name)
|
||||
} else {
|
||||
ident(&glob.name)
|
||||
};
|
||||
|
@ -772,7 +772,7 @@ fn generate_item_tree(
|
|||
file: &mut File,
|
||||
) {
|
||||
target_struct.friends.push(format!(
|
||||
"vtable::VRc<sixtyfps::private_api::ComponentVTable, {}>",
|
||||
"vtable::VRc<slint::private_api::ComponentVTable, {}>",
|
||||
item_tree_class_name
|
||||
));
|
||||
|
||||
|
@ -801,7 +801,7 @@ fn generate_item_tree(
|
|||
sub_component = &sub_component.sub_components[*i].ty;
|
||||
}
|
||||
tree_array.push(format!(
|
||||
"sixtyfps::private_api::make_dyn_node({}, {})",
|
||||
"slint::private_api::make_dyn_node({}, {})",
|
||||
repeater_index, parent_index
|
||||
));
|
||||
} else {
|
||||
|
@ -822,14 +822,14 @@ fn generate_item_tree(
|
|||
let item = &sub_component.items[node.item_index];
|
||||
|
||||
if item.is_flickable_viewport {
|
||||
compo_offset += "offsetof(sixtyfps::cbindgen_private::Flickable, viewport) + ";
|
||||
compo_offset += "offsetof(slint::cbindgen_private::Flickable, viewport) + ";
|
||||
}
|
||||
|
||||
let children_count = node.children.len() as u32;
|
||||
let children_index = children_offset as u32;
|
||||
|
||||
tree_array.push(format!(
|
||||
"sixtyfps::private_api::make_item_node({} offsetof({}, {}), {}, {}, {}, {})",
|
||||
"slint::private_api::make_item_node({} offsetof({}, {}), {}, {}, {}, {})",
|
||||
compo_offset,
|
||||
&ident(&sub_component.name),
|
||||
ident(&item.name),
|
||||
|
@ -842,7 +842,7 @@ fn generate_item_tree(
|
|||
});
|
||||
|
||||
let mut visit_children_statements = vec![
|
||||
"static const auto dyn_visit = [] (const uint8_t *base, [[maybe_unused]] sixtyfps::private_api::TraversalOrder order, [[maybe_unused]] sixtyfps::private_api::ItemVisitorRefMut visitor, [[maybe_unused]] uintptr_t dyn_index) -> uint64_t {".to_owned(),
|
||||
"static const auto dyn_visit = [] (const uint8_t *base, [[maybe_unused]] slint::private_api::TraversalOrder order, [[maybe_unused]] slint::private_api::ItemVisitorRefMut visitor, [[maybe_unused]] uintptr_t dyn_index) -> uint64_t {".to_owned(),
|
||||
format!(" [[maybe_unused]] auto self = reinterpret_cast<const {}*>(base);", item_tree_class_name)];
|
||||
|
||||
if target_struct.members.iter().any(|(_, declaration)| {
|
||||
|
@ -857,14 +857,14 @@ fn generate_item_tree(
|
|||
visit_children_statements.extend([
|
||||
"};".into(),
|
||||
format!("auto self_rc = reinterpret_cast<const {}*>(component.instance)->self_weak.lock()->into_dyn();", item_tree_class_name),
|
||||
"return sixtyfps::cbindgen_private::slint_visit_item_tree(&self_rc, item_tree() , index, order, visitor, dyn_visit);".to_owned(),
|
||||
"return slint::cbindgen_private::slint_visit_item_tree(&self_rc, item_tree() , index, order, visitor, dyn_visit);".to_owned(),
|
||||
]);
|
||||
|
||||
target_struct.members.push((
|
||||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "visit_children".into(),
|
||||
signature: "(sixtyfps::private_api::ComponentRef component, intptr_t index, sixtyfps::private_api::TraversalOrder order, sixtyfps::private_api::ItemVisitorRefMut visitor) -> uint64_t".into(),
|
||||
signature: "(slint::private_api::ComponentRef component, intptr_t index, slint::private_api::TraversalOrder order, slint::private_api::ItemVisitorRefMut visitor) -> uint64_t".into(),
|
||||
is_static: true,
|
||||
statements: Some(visit_children_statements),
|
||||
..Default::default()
|
||||
|
@ -874,10 +874,10 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "get_item_ref".into(),
|
||||
signature: "(sixtyfps::private_api::ComponentRef component, uintptr_t index) -> sixtyfps::private_api::ItemRef".into(),
|
||||
signature: "(slint::private_api::ComponentRef component, uintptr_t index) -> slint::private_api::ItemRef".into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![
|
||||
"return sixtyfps::private_api::get_item_ref(component, item_tree(), index);".to_owned(),
|
||||
"return slint::private_api::get_item_ref(component, item_tree(), index);".to_owned(),
|
||||
]),
|
||||
..Default::default()
|
||||
}),
|
||||
|
@ -891,7 +891,7 @@ fn generate_item_tree(
|
|||
}) {
|
||||
format!(
|
||||
// that does not work when the parent is not a component with a ComponentVTable
|
||||
//" *result = sixtyfps::private_api::parent_item(self->parent->self_weak.into_dyn(), self->parent->item_tree(), {});",
|
||||
//" *result = slint::private_api::parent_item(self->parent->self_weak.into_dyn(), self->parent->item_tree(), {});",
|
||||
"self->parent->self_weak.vtable()->parent_item(self->parent->self_weak.lock()->borrow(), {}, result);",
|
||||
parent_index,
|
||||
)
|
||||
|
@ -902,7 +902,7 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "parent_item".into(),
|
||||
signature: "(sixtyfps::private_api::ComponentRef component, uintptr_t index, sixtyfps::private_api::ItemWeak *result) -> void".into(),
|
||||
signature: "(slint::private_api::ComponentRef component, uintptr_t index, slint::private_api::ItemWeak *result) -> void".into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![
|
||||
format!("auto self = reinterpret_cast<const {}*>(component.instance);", item_tree_class_name),
|
||||
|
@ -910,7 +910,7 @@ fn generate_item_tree(
|
|||
parent_item_from_parent_component,
|
||||
" return;".into(),
|
||||
"}".into(),
|
||||
"*result = sixtyfps::private_api::parent_item(self->self_weak.into_dyn(), item_tree(), index);".into(),
|
||||
"*result = slint::private_api::parent_item(self->self_weak.into_dyn(), item_tree(), index);".into(),
|
||||
]),
|
||||
..Default::default()
|
||||
}),
|
||||
|
@ -920,12 +920,12 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "item_tree".into(),
|
||||
signature: "() -> sixtyfps::cbindgen_private::Slice<sixtyfps::private_api::ItemTreeNode>".into(),
|
||||
signature: "() -> slint::cbindgen_private::Slice<slint::private_api::ItemTreeNode>".into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![
|
||||
"static const sixtyfps::private_api::ItemTreeNode children[] {".to_owned(),
|
||||
"static const slint::private_api::ItemTreeNode children[] {".to_owned(),
|
||||
format!(" {} }};", tree_array.join(", \n")),
|
||||
"return { const_cast<sixtyfps::private_api::ItemTreeNode*>(children), std::size(children) };"
|
||||
"return { const_cast<slint::private_api::ItemTreeNode*>(children), std::size(children) };"
|
||||
.to_owned(),
|
||||
]),
|
||||
..Default::default()
|
||||
|
@ -937,7 +937,7 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "layout_info".into(),
|
||||
signature:
|
||||
"([[maybe_unused]] sixtyfps::private_api::ComponentRef component, sixtyfps::cbindgen_private::Orientation o) -> sixtyfps::cbindgen_private::LayoutInfo"
|
||||
"([[maybe_unused]] slint::private_api::ComponentRef component, slint::cbindgen_private::Orientation o) -> slint::cbindgen_private::LayoutInfo"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![format!(
|
||||
|
@ -951,17 +951,17 @@ fn generate_item_tree(
|
|||
target_struct.members.push((
|
||||
Access::Public,
|
||||
Declaration::Var(Var {
|
||||
ty: "static const sixtyfps::private_api::ComponentVTable".to_owned(),
|
||||
ty: "static const slint::private_api::ComponentVTable".to_owned(),
|
||||
name: "static_vtable".to_owned(),
|
||||
..Default::default()
|
||||
}),
|
||||
));
|
||||
|
||||
file.definitions.push(Declaration::Var(Var {
|
||||
ty: "const sixtyfps::private_api::ComponentVTable".to_owned(),
|
||||
ty: "const slint::private_api::ComponentVTable".to_owned(),
|
||||
name: format!("{}::static_vtable", item_tree_class_name),
|
||||
init: Some(format!(
|
||||
"{{ visit_children, get_item_ref, parent_item, layout_info, sixtyfps::private_api::drop_in_place<{}>, sixtyfps::private_api::dealloc }}",
|
||||
"{{ visit_children, get_item_ref, parent_item, layout_info, slint::private_api::drop_in_place<{}>, slint::private_api::dealloc }}",
|
||||
item_tree_class_name)
|
||||
),
|
||||
..Default::default()
|
||||
|
@ -980,7 +980,7 @@ fn generate_item_tree(
|
|||
|
||||
let mut create_code = vec![
|
||||
format!(
|
||||
"auto self_rc = vtable::VRc<sixtyfps::private_api::ComponentVTable, {0}>::make();",
|
||||
"auto self_rc = vtable::VRc<slint::private_api::ComponentVTable, {0}>::make();",
|
||||
target_struct.name
|
||||
),
|
||||
format!("auto self = const_cast<{0} *>(&*self_rc);", target_struct.name),
|
||||
|
@ -997,7 +997,7 @@ fn generate_item_tree(
|
|||
create_code.extend([
|
||||
format!("{}->m_window.window_handle().init_items(self, item_tree());", root_access),
|
||||
format!("self->init({}, self->self_weak, 0, 1 {});", root_access, init_parent_parameters),
|
||||
format!("return sixtyfps::ComponentHandle<{0}>{{ self_rc }};", target_struct.name),
|
||||
format!("return slint::ComponentHandle<{0}>{{ self_rc }};", target_struct.name),
|
||||
]);
|
||||
|
||||
target_struct.members.push((
|
||||
|
@ -1005,7 +1005,7 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "create".into(),
|
||||
signature: format!(
|
||||
"({}) -> sixtyfps::ComponentHandle<{}>",
|
||||
"({}) -> slint::ComponentHandle<{}>",
|
||||
create_parameters.join(","),
|
||||
target_struct.name
|
||||
),
|
||||
|
@ -1046,7 +1046,7 @@ fn generate_sub_component(
|
|||
|
||||
let mut init_parameters = vec![
|
||||
format!("{} root", root_ptr_type),
|
||||
"sixtyfps::cbindgen_private::ComponentWeak enclosing_component".into(),
|
||||
"slint::cbindgen_private::ComponentWeak enclosing_component".into(),
|
||||
"uintptr_t tree_index".into(),
|
||||
"uintptr_t tree_index_of_first_child".into(),
|
||||
];
|
||||
|
@ -1057,7 +1057,7 @@ fn generate_sub_component(
|
|||
target_struct.members.push((
|
||||
Access::Public,
|
||||
Declaration::Var(Var {
|
||||
ty: "sixtyfps::cbindgen_private::ComponentWeak".into(),
|
||||
ty: "slint::cbindgen_private::ComponentWeak".into(),
|
||||
name: "self_weak".into(),
|
||||
..Default::default()
|
||||
}),
|
||||
|
@ -1135,9 +1135,9 @@ fn generate_sub_component(
|
|||
let param_types = args.iter().map(|t| t.cpp_type().unwrap()).collect::<Vec<_>>();
|
||||
let return_type =
|
||||
return_type.as_ref().map_or("void".to_owned(), |t| t.cpp_type().unwrap());
|
||||
format!("sixtyfps::private_api::Callback<{}({})>", return_type, param_types.join(", "))
|
||||
format!("slint::private_api::Callback<{}({})>", return_type, param_types.join(", "))
|
||||
} else {
|
||||
format!("sixtyfps::private_api::Property<{}>", property.ty.cpp_type().unwrap())
|
||||
format!("slint::private_api::Property<{}>", property.ty.cpp_type().unwrap())
|
||||
};
|
||||
|
||||
target_struct.members.push((
|
||||
|
@ -1203,7 +1203,7 @@ fn generate_sub_component(
|
|||
|
||||
for (prop1, prop2) in &component.two_way_bindings {
|
||||
init.push(format!(
|
||||
"sixtyfps::private_api::Property<{ty}>::link_two_way(&{p1}, &{p2});",
|
||||
"slint::private_api::Property<{ty}>::link_two_way(&{p1}, &{p2});",
|
||||
ty = ctx.property_ty(prop1).cpp_type().unwrap(),
|
||||
p1 = access_member(prop1, &ctx),
|
||||
p2 = access_member(prop2, &ctx),
|
||||
|
@ -1222,7 +1222,7 @@ fn generate_sub_component(
|
|||
target_struct.members.push((
|
||||
field_access,
|
||||
Declaration::Var(Var {
|
||||
ty: format!("sixtyfps::cbindgen_private::{}", ident(&item.ty.class_name)),
|
||||
ty: format!("slint::cbindgen_private::{}", ident(&item.ty.class_name)),
|
||||
name: ident(&item.name),
|
||||
init: Some("{}".to_owned()),
|
||||
..Default::default()
|
||||
|
@ -1251,7 +1251,7 @@ fn generate_sub_component(
|
|||
if repeated.model.ty(&ctx) == Type::Bool {
|
||||
// bool converts to int
|
||||
// FIXME: don't do a heap allocation here
|
||||
model = format!("std::make_shared<sixtyfps::private_api::IntModel>({})", model)
|
||||
model = format!("std::make_shared<slint::private_api::IntModel>({})", model)
|
||||
}
|
||||
|
||||
// FIXME: optimize if repeated.model.is_constant()
|
||||
|
@ -1290,7 +1290,7 @@ fn generate_sub_component(
|
|||
Access::Private,
|
||||
Declaration::Var(Var {
|
||||
ty: format!(
|
||||
"sixtyfps::private_api::Repeater<class {}, {}>",
|
||||
"slint::private_api::Repeater<class {}, {}>",
|
||||
ident(&repeated.sub_tree.root.name),
|
||||
data_type.cpp_type().unwrap(),
|
||||
),
|
||||
|
@ -1318,12 +1318,12 @@ fn generate_sub_component(
|
|||
field_access,
|
||||
Declaration::Function(Function {
|
||||
name: "layout_info".into(),
|
||||
signature: "(sixtyfps::cbindgen_private::Orientation o) const -> sixtyfps::cbindgen_private::LayoutInfo"
|
||||
signature: "(slint::cbindgen_private::Orientation o) const -> slint::cbindgen_private::LayoutInfo"
|
||||
.into(),
|
||||
statements: Some(vec![
|
||||
"[[maybe_unused]] auto self = this;".into(),
|
||||
format!(
|
||||
"return o == sixtyfps::cbindgen_private::Orientation::Horizontal ? {} : {};",
|
||||
"return o == slint::cbindgen_private::Orientation::Horizontal ? {} : {};",
|
||||
compile_expression(&component.layout_info_h, &ctx),
|
||||
compile_expression(&component.layout_info_v, &ctx)
|
||||
),
|
||||
|
@ -1337,7 +1337,7 @@ fn generate_sub_component(
|
|||
field_access,
|
||||
Declaration::Function(Function {
|
||||
name: "visit_dynamic_children".into(),
|
||||
signature: "(intptr_t dyn_index, [[maybe_unused]] sixtyfps::private_api::TraversalOrder order, [[maybe_unused]] sixtyfps::private_api::ItemVisitorRefMut visitor) const -> uint64_t".into(),
|
||||
signature: "(intptr_t dyn_index, [[maybe_unused]] slint::private_api::TraversalOrder order, [[maybe_unused]] slint::private_api::ItemVisitorRefMut visitor) const -> uint64_t".into(),
|
||||
statements: Some(vec![
|
||||
" auto self = this;".to_owned(),
|
||||
format!(" switch(dyn_index) {{ {} }};", children_visitor_cases.join("")),
|
||||
|
@ -1413,7 +1413,7 @@ fn generate_repeated_component(
|
|||
Declaration::Function(Function {
|
||||
name: "listview_layout".into(),
|
||||
signature:
|
||||
"(float *offset_y, const sixtyfps::private_api::Property<float> *viewport_width) const -> void"
|
||||
"(float *offset_y, const slint::private_api::Property<float> *viewport_width) const -> void"
|
||||
.to_owned(),
|
||||
statements: Some(vec![
|
||||
"[[maybe_unused]] auto self = this;".into(),
|
||||
|
@ -1433,7 +1433,7 @@ fn generate_repeated_component(
|
|||
Access::Public, // Because Repeater accesses it
|
||||
Declaration::Function(Function {
|
||||
name: "box_layout_data".into(),
|
||||
signature: "(sixtyfps::cbindgen_private::Orientation o) const -> sixtyfps::cbindgen_private::BoxLayoutCellData".to_owned(),
|
||||
signature: "(slint::cbindgen_private::Orientation o) const -> slint::cbindgen_private::BoxLayoutCellData".to_owned(),
|
||||
statements: Some(vec!["return { layout_info({&static_vtable, const_cast<void *>(static_cast<const void *>(this))}, o) };".into()]),
|
||||
|
||||
..Function::default()
|
||||
|
@ -1455,9 +1455,9 @@ fn generate_global(file: &mut File, global: &llr::GlobalComponent, root: &llr::P
|
|||
let param_types = args.iter().map(|t| t.cpp_type().unwrap()).collect::<Vec<_>>();
|
||||
let return_type =
|
||||
return_type.as_ref().map_or("void".to_owned(), |t| t.cpp_type().unwrap());
|
||||
format!("sixtyfps::private_api::Callback<{}({})>", return_type, param_types.join(", "))
|
||||
format!("slint::private_api::Callback<{}({})>", return_type, param_types.join(", "))
|
||||
} else {
|
||||
format!("sixtyfps::private_api::Property<{}>", property.ty.cpp_type().unwrap())
|
||||
format!("slint::private_api::Property<{}>", property.ty.cpp_type().unwrap())
|
||||
};
|
||||
|
||||
global_struct.members.push((
|
||||
|
@ -1715,7 +1715,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
use llr::Expression;
|
||||
match expr {
|
||||
Expression::StringLiteral(s) => {
|
||||
format!(r#"sixtyfps::SharedString(u8"{}")"#, escape_string(s.as_str()))
|
||||
format!(r#"slint::SharedString(u8"{}")"#, escape_string(s.as_str()))
|
||||
}
|
||||
Expression::NumberLiteral(num) => {
|
||||
if *num > 1_000_000_000. {
|
||||
|
@ -1740,7 +1740,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
}
|
||||
Expression::ExtraBuiltinFunctionCall { function, arguments, return_ty: _ } => {
|
||||
let mut a = arguments.iter().map(|a| compile_expression(a, ctx));
|
||||
format!("sixtyfps::private_api::{}({})", ident(function), a.join(","))
|
||||
format!("slint::private_api::{}({})", ident(function), a.join(","))
|
||||
}
|
||||
Expression::FunctionParameterReference { index, .. } => format!("arg_{}", index),
|
||||
Expression::StoreLocalVariable { name, value } => {
|
||||
|
@ -1762,7 +1762,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
},
|
||||
Expression::ArrayIndex { array, index } => {
|
||||
format!(
|
||||
"sixtyfps::private_api::access_array_index({}, {})",
|
||||
"slint::private_api::access_array_index({}, {})",
|
||||
compile_expression(array, ctx), compile_expression(index, ctx)
|
||||
)
|
||||
},
|
||||
|
@ -1770,17 +1770,17 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
let f = compile_expression(&*from, ctx);
|
||||
match (from.ty(ctx), to) {
|
||||
(from, Type::String) if from.as_unit_product().is_some() => {
|
||||
format!("sixtyfps::SharedString::from_number({})", f)
|
||||
format!("slint::SharedString::from_number({})", f)
|
||||
}
|
||||
(Type::Float32, Type::Model) | (Type::Int32, Type::Model) => {
|
||||
format!("std::make_shared<sixtyfps::private_api::IntModel>({})", f)
|
||||
format!("std::make_shared<slint::private_api::IntModel>({})", f)
|
||||
}
|
||||
(Type::Array(_), Type::Model) => f,
|
||||
(Type::Float32, Type::Color) => {
|
||||
format!("sixtyfps::Color::from_argb_encoded({})", f)
|
||||
format!("slint::Color::from_argb_encoded({})", f)
|
||||
}
|
||||
(Type::Color, Type::Brush) => {
|
||||
format!("sixtyfps::Brush({})", f)
|
||||
format!("slint::Brush({})", f)
|
||||
}
|
||||
(Type::Brush, Type::Color) => {
|
||||
format!("{}.color()", f)
|
||||
|
@ -1807,14 +1807,14 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
Type::Struct{ fields, name: Some(name), .. } => (fields.len(), name),
|
||||
_ => unreachable!()
|
||||
};
|
||||
// Turn sixtyfps::private_api::PathLineTo into `LineTo`
|
||||
// Turn slint::private_api::PathLineTo into `LineTo`
|
||||
let elem_type_name = qualified_elem_type_name.split("::").last().unwrap().strip_prefix("Path").unwrap();
|
||||
let elem_init = if field_count > 0 {
|
||||
compile_expression(path_elem_expr, ctx)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
format!("sixtyfps::private_api::PathElement::{}({})", elem_type_name, elem_init)
|
||||
format!("slint::private_api::PathElement::{}({})", elem_type_name, elem_init)
|
||||
}),
|
||||
_ => {
|
||||
unreachable!()
|
||||
|
@ -1822,10 +1822,10 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
}.collect::<Vec<_>>();
|
||||
format!(
|
||||
r#"[&](){{
|
||||
sixtyfps::private_api::PathElement elements[{}] = {{
|
||||
slint::private_api::PathElement elements[{}] = {{
|
||||
{}
|
||||
}};
|
||||
return sixtyfps::private_api::PathData(&elements[0], std::size(elements));
|
||||
return slint::private_api::PathData(&elements[0], std::size(elements));
|
||||
}}()"#,
|
||||
path_elements.len(),
|
||||
path_elements.join(",")
|
||||
|
@ -1848,7 +1848,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
};
|
||||
format!(
|
||||
r#"[&](auto events, auto points){{
|
||||
return sixtyfps::private_api::PathData(events.ptr, events.len, points.ptr, points.len);
|
||||
return slint::private_api::PathData(events.ptr, events.len, points.ptr, points.len);
|
||||
}}({}, {})"#,
|
||||
events, points
|
||||
)
|
||||
|
@ -1933,12 +1933,12 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
}
|
||||
Expression::ImageReference { resource_ref, .. } => {
|
||||
match resource_ref {
|
||||
crate::expression_tree::ImageReference::None => r#"sixtyfps::Image()"#.to_string(),
|
||||
crate::expression_tree::ImageReference::AbsolutePath(path) => format!(r#"sixtyfps::Image::load_from_path(sixtyfps::SharedString(u8"{}"))"#, escape_string(path.as_str())),
|
||||
crate::expression_tree::ImageReference::None => r#"slint::Image()"#.to_string(),
|
||||
crate::expression_tree::ImageReference::AbsolutePath(path) => format!(r#"slint::Image::load_from_path(slint::SharedString(u8"{}"))"#, escape_string(path.as_str())),
|
||||
crate::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => {
|
||||
let symbol = format!("sfps_embedded_resource_{}", resource_id);
|
||||
format!(
|
||||
r#"sixtyfps::Image(sixtyfps::cbindgen_private::types::ImageInner::EmbeddedData(sixtyfps::cbindgen_private::Slice<uint8_t>{{std::data({}), std::size({})}}, sixtyfps::cbindgen_private::Slice<uint8_t>{{const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(u8"{}")), {}}}))"#,
|
||||
r#"slint::Image(slint::cbindgen_private::types::ImageInner::EmbeddedData(slint::cbindgen_private::Slice<uint8_t>{{std::data({}), std::size({})}}, slint::cbindgen_private::Slice<uint8_t>{{const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(u8"{}")), {}}}))"#,
|
||||
symbol, symbol, escape_string(extension), extension.as_bytes().len()
|
||||
)
|
||||
}
|
||||
|
@ -1964,14 +1964,14 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
let mut val = values.iter().map(|e| format!("{ty} ( {expr} )", expr = compile_expression(e, ctx), ty = ty));
|
||||
if *as_model {
|
||||
format!(
|
||||
"std::make_shared<sixtyfps::private_api::ArrayModel<{count},{ty}>>({val})",
|
||||
"std::make_shared<slint::private_api::ArrayModel<{count},{ty}>>({val})",
|
||||
count = values.len(),
|
||||
ty = ty,
|
||||
val = val.join(", ")
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"sixtyfps::cbindgen_private::Slice<{ty}>{{ std::array<{ty}, {count}>{{ {val} }}.data(), {count} }}",
|
||||
"slint::cbindgen_private::Slice<{ty}>{{ std::array<{ty}, {count}>{{ {val} }}.data(), {count} }}",
|
||||
count = values.len(),
|
||||
ty = ty,
|
||||
val = val.join(", ")
|
||||
|
@ -1999,9 +1999,9 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
panic!("Expression::Object is not a Type::Object")
|
||||
}
|
||||
}
|
||||
Expression::EasingCurve(EasingCurve::Linear) => "sixtyfps::cbindgen_private::EasingCurve()".into(),
|
||||
Expression::EasingCurve(EasingCurve::Linear) => "slint::cbindgen_private::EasingCurve()".into(),
|
||||
Expression::EasingCurve(EasingCurve::CubicBezier(a, b, c, d)) => format!(
|
||||
"sixtyfps::cbindgen_private::EasingCurve(sixtyfps::cbindgen_private::EasingCurve::Tag::CubicBezier, {}, {}, {}, {})",
|
||||
"slint::cbindgen_private::EasingCurve(slint::cbindgen_private::EasingCurve::Tag::CubicBezier, {}, {}, {}, {})",
|
||||
a, b, c, d
|
||||
),
|
||||
Expression::LinearGradient{angle, stops} => {
|
||||
|
@ -2009,26 +2009,26 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
let mut stops_it = stops.iter().map(|(color, stop)| {
|
||||
let color = compile_expression(color, ctx);
|
||||
let position = compile_expression(stop, ctx);
|
||||
format!("sixtyfps::private_api::GradientStop{{ {}, {}, }}", color, position)
|
||||
format!("slint::private_api::GradientStop{{ {}, {}, }}", color, position)
|
||||
});
|
||||
format!(
|
||||
"[&] {{ const sixtyfps::private_api::GradientStop stops[] = {{ {} }}; return sixtyfps::Brush(sixtyfps::private_api::LinearGradientBrush({}, stops, {})); }}()",
|
||||
"[&] {{ const slint::private_api::GradientStop stops[] = {{ {} }}; return slint::Brush(slint::private_api::LinearGradientBrush({}, stops, {})); }}()",
|
||||
stops_it.join(", "), angle, stops.len()
|
||||
)
|
||||
}
|
||||
Expression::EnumerationValue(value) => {
|
||||
format!("sixtyfps::cbindgen_private::{}::{}", value.enumeration.name, ident(&value.to_string()))
|
||||
format!("slint::cbindgen_private::{}::{}", value.enumeration.name, ident(&value.to_string()))
|
||||
}
|
||||
Expression::ReturnStatement(Some(expr)) => format!(
|
||||
"throw sixtyfps::private_api::ReturnWrapper<{}>({})",
|
||||
"throw slint::private_api::ReturnWrapper<{}>({})",
|
||||
expr.ty(ctx).cpp_type().unwrap_or_default(),
|
||||
compile_expression(expr, ctx)
|
||||
),
|
||||
Expression::ReturnStatement(None) => "throw sixtyfps::private_api::ReturnWrapper<void>()".to_owned(),
|
||||
Expression::ReturnStatement(None) => "throw slint::private_api::ReturnWrapper<void>()".to_owned(),
|
||||
Expression::LayoutCacheAccess { layout_cache_prop, index, repeater_index } => {
|
||||
let cache = access_member(layout_cache_prop, ctx);
|
||||
if let Some(ri) = repeater_index {
|
||||
format!("sixtyfps::private_api::layout_cache_access({}.get(), {}, {})", cache, index, compile_expression(ri, ctx))
|
||||
format!("slint::private_api::layout_cache_access({}.get(), {}, {})", cache, index, compile_expression(ri, ctx))
|
||||
} else {
|
||||
format!("{}.get()[{}]", cache, index)
|
||||
}
|
||||
|
@ -2055,9 +2055,9 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
}
|
||||
_ => panic!("dialog layout unsorted cells not an array"),
|
||||
};
|
||||
format!("sixtyfps::cbindgen_private::GridLayoutCellData {cv}_array [] = {{ {c} }};\
|
||||
sixtyfps::cbindgen_private::slint_reorder_dialog_button_layout({cv}_array, {r});\
|
||||
sixtyfps::cbindgen_private::Slice<sixtyfps::cbindgen_private::GridLayoutCellData> {cv} {{ std::data({cv}_array), std::size({cv}_array) }}",
|
||||
format!("slint::cbindgen_private::GridLayoutCellData {cv}_array [] = {{ {c} }};\
|
||||
slint::cbindgen_private::slint_reorder_dialog_button_layout({cv}_array, {r});\
|
||||
slint::cbindgen_private::Slice<slint::cbindgen_private::GridLayoutCellData> {cv} {{ std::data({cv}_array), std::size({cv}_array) }}",
|
||||
r = compile_expression(roles, ctx),
|
||||
cv = cells_variable,
|
||||
c = cells.join(", "),
|
||||
|
@ -2142,7 +2142,7 @@ fn compile_builtin_function_call(
|
|||
format!("[](const auto &model){{ (*model).track_row_count_changes(); return (*model).row_count(); }}({})", a.next().unwrap())
|
||||
}
|
||||
BuiltinFunction::Rgb => {
|
||||
format!("sixtyfps::Color::from_argb_uint8(std::clamp(static_cast<float>({a}) * 255., 0., 255.), std::clamp(static_cast<int>({r}), 0, 255), std::clamp(static_cast<int>({g}), 0, 255), std::clamp(static_cast<int>({b}), 0, 255))",
|
||||
format!("slint::Color::from_argb_uint8(std::clamp(static_cast<float>({a}) * 255., 0., 255.), std::clamp(static_cast<int>({r}), 0, 255), std::clamp(static_cast<int>({g}), 0, 255), std::clamp(static_cast<int>({b}), 0, 255))",
|
||||
r = a.next().unwrap(),
|
||||
g = a.next().unwrap(),
|
||||
b = a.next().unwrap(),
|
||||
|
@ -2170,10 +2170,7 @@ fn compile_builtin_function_call(
|
|||
}
|
||||
BuiltinFunction::RegisterCustomFontByPath => {
|
||||
if let [llr::Expression::StringLiteral(path)] = arguments {
|
||||
format!(
|
||||
"sixtyfps::private_api::register_font_from_path(\"{}\");",
|
||||
escape_string(path)
|
||||
)
|
||||
format!("slint::private_api::register_font_from_path(\"{}\");", escape_string(path))
|
||||
} else {
|
||||
panic!(
|
||||
"internal error: argument to RegisterCustomFontByPath must be a string literal"
|
||||
|
@ -2185,7 +2182,7 @@ fn compile_builtin_function_call(
|
|||
let resource_id: usize = *resource_id as _;
|
||||
let symbol = format!("sfps_embedded_resource_{}", resource_id);
|
||||
format!(
|
||||
"sixtyfps::private_api::register_font_from_data({}, std::size({}));",
|
||||
"slint::private_api::register_font_from_data({}, std::size({}));",
|
||||
symbol, symbol
|
||||
)
|
||||
} else {
|
||||
|
@ -2196,7 +2193,7 @@ fn compile_builtin_function_call(
|
|||
if let [llr::Expression::PropertyReference(pr)] = arguments {
|
||||
let native = native_item(pr, ctx);
|
||||
format!(
|
||||
"{vt}->layout_info({{{vt}, const_cast<sixtyfps::cbindgen_private::{ty}*>(&{i})}}, {o}, &{window})",
|
||||
"{vt}->layout_info({{{vt}, const_cast<slint::cbindgen_private::{ty}*>(&{i})}}, {o}, &{window})",
|
||||
vt = native.cpp_vtable_getter,
|
||||
ty = native.class_name,
|
||||
o = to_cpp_orientation(orient),
|
||||
|
@ -2220,7 +2217,7 @@ fn box_layout_function(
|
|||
) -> String {
|
||||
let repeated_indices = repeated_indices.map(ident);
|
||||
let mut push_code =
|
||||
"std::vector<sixtyfps::cbindgen_private::BoxLayoutCellData> cells_vector;".to_owned();
|
||||
"std::vector<slint::cbindgen_private::BoxLayoutCellData> cells_vector;".to_owned();
|
||||
let mut repeater_idx = 0usize;
|
||||
|
||||
for item in elements {
|
||||
|
@ -2256,13 +2253,13 @@ fn box_layout_function(
|
|||
|
||||
let ri = repeated_indices.as_ref().map_or(String::new(), |ri| {
|
||||
push_code += &format!(
|
||||
"sixtyfps::cbindgen_private::Slice<int> {ri}{{ {ri}_array.data(), {ri}_array.size() }};",
|
||||
"slint::cbindgen_private::Slice<int> {ri}{{ {ri}_array.data(), {ri}_array.size() }};",
|
||||
ri = ri
|
||||
);
|
||||
format!("std::array<int, {}> {}_array;", 2 * repeater_idx, ri)
|
||||
});
|
||||
format!(
|
||||
"[&]{{ {} {} sixtyfps::cbindgen_private::Slice<sixtyfps::cbindgen_private::BoxLayoutCellData>{}{{cells_vector.data(), cells_vector.size()}}; return {}; }}()",
|
||||
"[&]{{ {} {} slint::cbindgen_private::Slice<slint::cbindgen_private::BoxLayoutCellData>{}{{cells_vector.data(), cells_vector.size()}}; return {}; }}()",
|
||||
ri,
|
||||
push_code,
|
||||
ident(cells_variable),
|
||||
|
@ -2282,13 +2279,13 @@ fn compile_expression_wrap_return(expr: &llr::Expression, ctx: &EvaluationContex
|
|||
if let Some(ty) = return_type {
|
||||
if ty == Type::Void || ty == Type::Invalid {
|
||||
format!(
|
||||
"[&]{{ try {{ {}; }} catch(const sixtyfps::private_api::ReturnWrapper<void> &w) {{ }} }}()",
|
||||
"[&]{{ try {{ {}; }} catch(const slint::private_api::ReturnWrapper<void> &w) {{ }} }}()",
|
||||
compile_expression(expr, ctx)
|
||||
)
|
||||
} else {
|
||||
let cpp_ty = ty.cpp_type().unwrap_or_default();
|
||||
format!(
|
||||
"[&]() -> {} {{ try {{ {}; }} catch(const sixtyfps::private_api::ReturnWrapper<{}> &w) {{ return w.value; }} }}()",
|
||||
"[&]() -> {} {{ try {{ {}; }} catch(const slint::private_api::ReturnWrapper<{}> &w) {{ return w.value; }} }}()",
|
||||
cpp_ty,
|
||||
return_compile_expression(expr, ctx, Some(&ty)),
|
||||
cpp_ty
|
||||
|
|
|
@ -1786,7 +1786,7 @@ fn compile_builtin_function_call(
|
|||
/// Return a TokenStream for a name (as in [`Type::Struct::name`])
|
||||
fn struct_name_to_tokens(name: &str) -> TokenStream {
|
||||
// the name match the C++ signature so we need to change that to the rust namespace
|
||||
let mut name = name.replace("::private_api::", "::re_exports::").replace('-', "_");
|
||||
let mut name = name.replace("slint::private_api::", "sixtyfps::re_exports::").replace('-', "_");
|
||||
if !name.contains("::") {
|
||||
name.insert_str(0, "r#")
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ impl ItemConsts for Rectangle {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_RectangleVTable() -> RectangleVTable for Rectangle
|
||||
fn slint_get_RectangleVTable() -> RectangleVTable for Rectangle
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -327,7 +327,7 @@ impl ItemConsts for BorderRectangle {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_BorderRectangleVTable() -> BorderRectangleVTable for BorderRectangle
|
||||
fn slint_get_BorderRectangleVTable() -> BorderRectangleVTable for BorderRectangle
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, strum::EnumString, strum::Display)]
|
||||
|
@ -532,7 +532,7 @@ impl ItemConsts for TouchArea {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_TouchAreaVTable() -> TouchAreaVTable for TouchArea
|
||||
fn slint_get_TouchAreaVTable() -> TouchAreaVTable for TouchArea
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, strum::EnumString, strum::Display)]
|
||||
|
@ -638,7 +638,7 @@ impl ItemConsts for FocusScope {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_FocusScopeVTable() -> FocusScopeVTable for FocusScope
|
||||
fn slint_get_FocusScopeVTable() -> FocusScopeVTable for FocusScope
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -716,7 +716,7 @@ impl ItemConsts for Clip {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_ClipVTable() -> ClipVTable for Clip
|
||||
fn slint_get_ClipVTable() -> ClipVTable for Clip
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -781,7 +781,7 @@ impl ItemConsts for Opacity {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_OpacityVTable() -> OpacityVTable for Opacity
|
||||
fn slint_get_OpacityVTable() -> OpacityVTable for Opacity
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -847,7 +847,7 @@ impl ItemConsts for Rotate {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_RotateVTable() -> RotateVTable for Rotate
|
||||
fn slint_get_RotateVTable() -> RotateVTable for Rotate
|
||||
}
|
||||
|
||||
/// The implementation of the `Flickable` element
|
||||
|
@ -933,7 +933,7 @@ impl ItemConsts for Flickable {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_FlickableVTable() -> FlickableVTable for Flickable
|
||||
fn slint_get_FlickableVTable() -> FlickableVTable for Flickable
|
||||
}
|
||||
|
||||
pub use crate::SharedVector;
|
||||
|
@ -1087,7 +1087,7 @@ impl ItemConsts for WindowItem {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_WindowItemVTable() -> WindowItemVTable for WindowItem
|
||||
fn slint_get_WindowItemVTable() -> WindowItemVTable for WindowItem
|
||||
}
|
||||
|
||||
/// The implementation of the `BoxShadow` element
|
||||
|
@ -1155,28 +1155,28 @@ impl ItemConsts for BoxShadow {
|
|||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_BoxShadowVTable() -> BoxShadowVTable for BoxShadow
|
||||
fn slint_get_BoxShadowVTable() -> BoxShadowVTable for BoxShadow
|
||||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_TextVTable() -> TextVTable for Text
|
||||
fn slint_get_TextVTable() -> TextVTable for Text
|
||||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_TextInputVTable() -> TextInputVTable for TextInput
|
||||
fn slint_get_TextInputVTable() -> TextInputVTable for TextInput
|
||||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_ImageItemVTable() -> ImageItemVTable for ImageItem
|
||||
fn slint_get_ImageItemVTable() -> ImageItemVTable for ImageItem
|
||||
}
|
||||
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_ClippedImageVTable() -> ClippedImageVTable for ClippedImage
|
||||
fn slint_get_ClippedImageVTable() -> ClippedImageVTable for ClippedImage
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
declare_item_vtable! {
|
||||
fn sixtyfps_get_PathVTable() -> PathVTable for Path
|
||||
fn slint_get_PathVTable() -> PathVTable for Path
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, strum::EnumString, strum::Display)]
|
||||
|
|
|
@ -38,9 +38,9 @@ assert_eq!(instance.get_sub_text(), sixtyfps::SharedString::from("EFG"));
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert_eq(instance.get_sub_text(), sixtyfps::SharedString("ABC"));
|
||||
instance.set_public_alias(sixtyfps::SharedString("EFG"));
|
||||
assert_eq(instance.get_sub_text(), sixtyfps::SharedString("EFG"));
|
||||
assert_eq(instance.get_sub_text(), slint::SharedString("ABC"));
|
||||
instance.set_public_alias(slint::SharedString("EFG"));
|
||||
assert_eq(instance.get_sub_text(), slint::SharedString("EFG"));
|
||||
```
|
||||
|
||||
```js
|
||||
|
|
|
@ -36,7 +36,7 @@ auto handle = TestCase::create();
|
|||
const TestCase &instance = *handle;
|
||||
assert_eq(instance.get_prop_a(), 1);
|
||||
assert_eq(instance.get_prop_b(), 2);
|
||||
assert_eq(instance.get_prop_text(), sixtyfps::SharedString("world"));
|
||||
assert_eq(instance.get_prop_text(), slint::SharedString("world"));
|
||||
```
|
||||
|
||||
```js
|
||||
|
|
|
@ -105,31 +105,31 @@ assert_eq!(instance.get_othercomp_some_value_alias2(), 1);
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert_eq(instance.get_text1(), sixtyfps::SharedString("Hello"));
|
||||
assert_eq(instance.get_text2(), sixtyfps::SharedString("Blah"));
|
||||
assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Hello"));
|
||||
assert_eq(instance.get_ti2_text(), sixtyfps::SharedString("Blah"));
|
||||
assert_eq(instance.get_text_item_text(), sixtyfps::SharedString("Blah"));
|
||||
assert_eq(instance.get_text1(), slint::SharedString("Hello"));
|
||||
assert_eq(instance.get_text2(), slint::SharedString("Blah"));
|
||||
assert_eq(instance.get_ti1_text(), slint::SharedString("Hello"));
|
||||
assert_eq(instance.get_ti2_text(), slint::SharedString("Blah"));
|
||||
assert_eq(instance.get_text_item_text(), slint::SharedString("Blah"));
|
||||
assert_eq(instance.get_othercomp_t(), instance.get_othercomp_get_text());
|
||||
assert_eq(instance.get_othercomp_t(), sixtyfps::SharedString("real value"));
|
||||
assert_eq(instance.get_othercomp_get_text(), sixtyfps::SharedString("real value"));
|
||||
assert_eq(instance.get_othercomp_t(), slint::SharedString("real value"));
|
||||
assert_eq(instance.get_othercomp_get_text(), slint::SharedString("real value"));
|
||||
|
||||
|
||||
instance.set_text1(sixtyfps::SharedString("Text1New"));
|
||||
instance.set_text2(sixtyfps::SharedString("Text2New"));
|
||||
assert_eq(instance.get_text1(), sixtyfps::SharedString("Text1New"));
|
||||
assert_eq(instance.get_text2(), sixtyfps::SharedString("Text2New"));
|
||||
assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Text1New"));
|
||||
assert_eq(instance.get_ti2_text(), sixtyfps::SharedString("Text2New"));
|
||||
assert_eq(instance.get_text_item_text(), sixtyfps::SharedString("Text2New"));
|
||||
instance.set_text1(slint::SharedString("Text1New"));
|
||||
instance.set_text2(slint::SharedString("Text2New"));
|
||||
assert_eq(instance.get_text1(), slint::SharedString("Text1New"));
|
||||
assert_eq(instance.get_text2(), slint::SharedString("Text2New"));
|
||||
assert_eq(instance.get_ti1_text(), slint::SharedString("Text1New"));
|
||||
assert_eq(instance.get_ti2_text(), slint::SharedString("Text2New"));
|
||||
assert_eq(instance.get_text_item_text(), slint::SharedString("Text2New"));
|
||||
|
||||
instance.invoke_set_ti1(sixtyfps::SharedString("Hallo"));
|
||||
instance.invoke_set_ti2(sixtyfps::SharedString("Bonjour"));
|
||||
assert_eq(instance.get_text1(), sixtyfps::SharedString("Hallo"));
|
||||
assert_eq(instance.get_text2(), sixtyfps::SharedString("Text2New"));
|
||||
assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Hallo"));
|
||||
assert_eq(instance.get_ti2_text(), sixtyfps::SharedString("Bonjour"));
|
||||
assert_eq(instance.get_text_item_text(), sixtyfps::SharedString("Bonjour"));
|
||||
instance.invoke_set_ti1(slint::SharedString("Hallo"));
|
||||
instance.invoke_set_ti2(slint::SharedString("Bonjour"));
|
||||
assert_eq(instance.get_text1(), slint::SharedString("Hallo"));
|
||||
assert_eq(instance.get_text2(), slint::SharedString("Text2New"));
|
||||
assert_eq(instance.get_ti1_text(), slint::SharedString("Hallo"));
|
||||
assert_eq(instance.get_ti2_text(), slint::SharedString("Bonjour"));
|
||||
assert_eq(instance.get_text_item_text(), slint::SharedString("Bonjour"));
|
||||
|
||||
assert_eq(instance.get_othercomp_some_value(), 42);
|
||||
assert_eq(instance.get_othercomp_some_value_alias(), 42);
|
||||
|
|
|
@ -108,31 +108,31 @@ assert_eq!(instance.get_othercomp_some_value_alias2(), 1);
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert_eq(instance.get_text1(), sixtyfps::SharedString("Hello"));
|
||||
assert_eq(instance.get_text2(), sixtyfps::SharedString("Blah"));
|
||||
assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Hello"));
|
||||
assert_eq(instance.get_ti2_text(), sixtyfps::SharedString("Blah"));
|
||||
assert_eq(instance.get_text_item_text(), sixtyfps::SharedString("Blah"));
|
||||
assert_eq(instance.get_text1(), slint::SharedString("Hello"));
|
||||
assert_eq(instance.get_text2(), slint::SharedString("Blah"));
|
||||
assert_eq(instance.get_ti1_text(), slint::SharedString("Hello"));
|
||||
assert_eq(instance.get_ti2_text(), slint::SharedString("Blah"));
|
||||
assert_eq(instance.get_text_item_text(), slint::SharedString("Blah"));
|
||||
assert_eq(instance.get_othercomp_t(), instance.get_othercomp_get_text());
|
||||
assert_eq(instance.get_othercomp_t(), sixtyfps::SharedString("real value"));
|
||||
assert_eq(instance.get_othercomp_get_text(), sixtyfps::SharedString("real value"));
|
||||
assert_eq(instance.get_othercomp_t(), slint::SharedString("real value"));
|
||||
assert_eq(instance.get_othercomp_get_text(), slint::SharedString("real value"));
|
||||
|
||||
|
||||
instance.set_text1(sixtyfps::SharedString("Text1New"));
|
||||
instance.set_text2(sixtyfps::SharedString("Text2New"));
|
||||
assert_eq(instance.get_text1(), sixtyfps::SharedString("Text1New"));
|
||||
assert_eq(instance.get_text2(), sixtyfps::SharedString("Text2New"));
|
||||
assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Text1New"));
|
||||
assert_eq(instance.get_ti2_text(), sixtyfps::SharedString("Text2New"));
|
||||
assert_eq(instance.get_text_item_text(), sixtyfps::SharedString("Text2New"));
|
||||
instance.set_text1(slint::SharedString("Text1New"));
|
||||
instance.set_text2(slint::SharedString("Text2New"));
|
||||
assert_eq(instance.get_text1(), slint::SharedString("Text1New"));
|
||||
assert_eq(instance.get_text2(), slint::SharedString("Text2New"));
|
||||
assert_eq(instance.get_ti1_text(), slint::SharedString("Text1New"));
|
||||
assert_eq(instance.get_ti2_text(), slint::SharedString("Text2New"));
|
||||
assert_eq(instance.get_text_item_text(), slint::SharedString("Text2New"));
|
||||
|
||||
instance.invoke_set_ti1(sixtyfps::SharedString("Hallo"));
|
||||
instance.invoke_set_ti2(sixtyfps::SharedString("Bonjour"));
|
||||
assert_eq(instance.get_text1(), sixtyfps::SharedString("Hallo"));
|
||||
assert_eq(instance.get_text2(), sixtyfps::SharedString("Text2New"));
|
||||
assert_eq(instance.get_ti1_text(), sixtyfps::SharedString("Hallo"));
|
||||
assert_eq(instance.get_ti2_text(), sixtyfps::SharedString("Bonjour"));
|
||||
assert_eq(instance.get_text_item_text(), sixtyfps::SharedString("Bonjour"));
|
||||
instance.invoke_set_ti1(slint::SharedString("Hallo"));
|
||||
instance.invoke_set_ti2(slint::SharedString("Bonjour"));
|
||||
assert_eq(instance.get_text1(), slint::SharedString("Hallo"));
|
||||
assert_eq(instance.get_text2(), slint::SharedString("Text2New"));
|
||||
assert_eq(instance.get_ti1_text(), slint::SharedString("Hallo"));
|
||||
assert_eq(instance.get_ti2_text(), slint::SharedString("Bonjour"));
|
||||
assert_eq(instance.get_text_item_text(), slint::SharedString("Bonjour"));
|
||||
|
||||
assert_eq(instance.get_othercomp_some_value(), 42);
|
||||
assert_eq(instance.get_othercomp_some_value_alias(), 42);
|
||||
|
|
|
@ -77,17 +77,17 @@ assert_eq(instance.get_hello(), 40);
|
|||
assert_eq(instance.get_binding_dep(), 100);
|
||||
|
||||
// Half the animation
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq(instance.get_hello(), 50);
|
||||
assert_eq(instance.get_binding_dep(), 125);
|
||||
|
||||
|
||||
// Remaining half
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq(instance.get_hello(), 60);
|
||||
assert_eq(instance.get_binding_dep(), 150);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(100);
|
||||
slint::testing::mock_elapsed_time(100);
|
||||
assert_eq(instance.get_hello(), 60);
|
||||
assert_eq(instance.get_binding_dep(), 150);
|
||||
|
||||
|
@ -95,7 +95,7 @@ assert_eq(instance.get_binding_dep(), 150);
|
|||
// querying the value (because te dirty event should cause the animation to start)
|
||||
instance.set_condition(true);
|
||||
instance.set_hello(30);
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq(instance.get_hello(), 45);
|
||||
assert_eq(instance.get_binding_dep(), 125);
|
||||
```
|
||||
|
|
|
@ -51,12 +51,12 @@ assert_eq!(instance.get_result(), 685);
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 70., 5.);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 85., 55.);
|
||||
slint::testing::send_mouse_click(&instance, 70., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 85., 55.);
|
||||
assert_eq(instance.get_result(), 345);
|
||||
instance.set_xx(0.);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 10.);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 60.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 10.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 60.);
|
||||
assert_eq(instance.get_result(), 685);
|
||||
```
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ TestCase := Rectangle {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_value(), 1);
|
||||
```
|
||||
|
||||
|
|
|
@ -35,16 +35,16 @@ assert_eq!(instance.invoke_test_func2("xxx".into(), 1), sixtyfps::SharedString::
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
instance.on_test_func([weak = sixtyfps::ComponentWeakHandle(handle)](int a) {
|
||||
instance.on_test_func([weak = slint::ComponentWeakHandle(handle)](int a) {
|
||||
return (*weak.lock())->get_some_value() * a;
|
||||
});
|
||||
assert_eq(instance.get_test_prop(), 4 + 16);
|
||||
assert_eq(instance.get_test_prop2(), sixtyfps::SharedString("hello=50"));
|
||||
assert_eq(instance.get_test_prop2(), slint::SharedString("hello=50"));
|
||||
instance.set_some_value(2);
|
||||
assert_eq(instance.get_test_prop(), 4 + 4);
|
||||
assert_eq(instance.get_test_prop2(), sixtyfps::SharedString("hello=44"));
|
||||
assert_eq(instance.get_test_prop2(), slint::SharedString("hello=44"));
|
||||
|
||||
assert_eq(instance.invoke_test_func2("xxx", 1), sixtyfps::SharedString("xxx=3"));
|
||||
assert_eq(instance.invoke_test_func2("xxx", 1), slint::SharedString("xxx=3"));
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -86,12 +86,12 @@ TestCase := Rectangle {
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 38, 5.);
|
||||
slint::testing::send_mouse_click(&instance, 38, 5.);
|
||||
assert_eq(instance.get_touch1(), 0);
|
||||
assert_eq(instance.get_value(), 10);
|
||||
assert_eq(instance.get_touch_error(), 0);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 95, 5.);
|
||||
slint::testing::send_mouse_click(&instance, 95, 5.);
|
||||
assert_eq(instance.get_touch1(), 1);
|
||||
assert_eq(instance.get_value(), 10);
|
||||
assert_eq(instance.get_touch_error(), 0);
|
||||
|
|
|
@ -25,7 +25,7 @@ export TestCase := Window {
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert(!instance.get_combo_has_focus());
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert(instance.get_combo_has_focus());
|
||||
```
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ export TestCase := Window {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
auto vec_model = std::make_shared<sixtyfps::VectorModel<int>>(std::vector<int>{1, 2});
|
||||
auto vec_model = std::make_shared<slint::VectorModel<int>>(std::vector<int>{1, 2});
|
||||
instance.set_model(vec_model);
|
||||
instance.on_clicked([vec_model] { vec_model->erase(vec_model->row_count()-1); });
|
||||
sixtyfps::testing::send_mouse_click(&instance, 95., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 95., 5.);
|
||||
assert_eq(instance.get_model()->row_count(), 1);
|
||||
assert(instance.get_hover());
|
||||
sixtyfps::testing::send_mouse_click(&instance, 95., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 95., 5.);
|
||||
assert_eq(instance.get_model()->row_count(), 0);
|
||||
assert(!instance.get_hover());
|
||||
```
|
||||
|
|
|
@ -12,7 +12,7 @@ export TestCase := Window {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
```
|
||||
|
||||
```rust
|
||||
|
|
|
@ -30,7 +30,7 @@ export TestCase := Window {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 295., 295.);
|
||||
slint::testing::send_mouse_click(&instance, 295., 295.);
|
||||
assert_eq(instance.get_result(), 99);
|
||||
```
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ TestCase := Window {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
|
||||
assert(instance.get_all_ok());
|
||||
```
|
||||
|
|
|
@ -38,7 +38,7 @@ TestCase := Window {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 205.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 205.);
|
||||
assert_eq(instance.get_value(), "Green");
|
||||
```
|
||||
|
||||
|
|
|
@ -63,25 +63,25 @@ auto handle = TestCase::create();
|
|||
const TestCase &instance = *handle;
|
||||
|
||||
// does not click on anything
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_touch1(), 0);
|
||||
assert_eq(instance.get_touch2(), 0);
|
||||
assert_eq(instance.get_touch3(), 0);
|
||||
|
||||
// click on second one
|
||||
sixtyfps::testing::send_mouse_click(&instance, 101., 101.);
|
||||
slint::testing::send_mouse_click(&instance, 101., 101.);
|
||||
assert_eq(instance.get_touch1(), 0);
|
||||
assert_eq(instance.get_touch2(), 1);
|
||||
assert_eq(instance.get_touch3(), 0);
|
||||
|
||||
// click on first one only
|
||||
sixtyfps::testing::send_mouse_click(&instance, 108., 108.);
|
||||
slint::testing::send_mouse_click(&instance, 108., 108.);
|
||||
assert_eq(instance.get_touch1(), 1);
|
||||
assert_eq(instance.get_touch2(), 1);
|
||||
assert_eq(instance.get_touch3(), 0);
|
||||
|
||||
// click on the third
|
||||
sixtyfps::testing::send_mouse_click(&instance, 106., 103.);
|
||||
slint::testing::send_mouse_click(&instance, 106., 103.);
|
||||
assert_eq(instance.get_touch1(), 1);
|
||||
assert_eq(instance.get_touch2(), 1);
|
||||
assert_eq(instance.get_touch3(), 1);
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert_eq(instance.get_s1(), sixtyfps::SharedString("hello1212"));
|
||||
assert_eq(instance.get_s2(), sixtyfps::SharedString("10hello5.1"));
|
||||
assert_eq(instance.get_s1(), slint::SharedString("hello1212"));
|
||||
assert_eq(instance.get_s2(), slint::SharedString("10hello5.1"));
|
||||
instance.set_a(42);
|
||||
assert_eq(instance.get_s1(), sixtyfps::SharedString("hello4242"));
|
||||
assert_eq(instance.get_s1(), slint::SharedString("hello4242"));
|
||||
instance.invoke_foo();
|
||||
assert_eq(instance.get_s3(), sixtyfps::SharedString("x42x42"));
|
||||
assert_eq(instance.get_s4(), sixtyfps::SharedString("ayoxxx"));
|
||||
assert_eq(instance.get_s3(), slint::SharedString("x42x42"));
|
||||
assert_eq(instance.get_s4(), slint::SharedString("ayoxxx"));
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert_eq(instance.get_s1(), sixtyfps::SharedString("hello1212"));
|
||||
assert_eq(instance.get_s2(), sixtyfps::SharedString("10hello5.1"));
|
||||
assert_eq(instance.get_s1(), slint::SharedString("hello1212"));
|
||||
assert_eq(instance.get_s2(), slint::SharedString("10hello5.1"));
|
||||
instance.set_a(42);
|
||||
assert_eq(instance.get_s1(), sixtyfps::SharedString("hello4242"));
|
||||
assert_eq(instance.get_s1(), slint::SharedString("hello4242"));
|
||||
instance.invoke_foo();
|
||||
assert_eq(instance.get_s3(), sixtyfps::SharedString("x42x42"));
|
||||
assert_eq(instance.get_s4(), sixtyfps::SharedString("ayoxxx"));
|
||||
assert_eq(instance.get_s3(), slint::SharedString("x42x42"));
|
||||
assert_eq(instance.get_s4(), slint::SharedString("ayoxxx"));
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ assert_eq!(instance.get_recieved(), "ß");
|
|||
```
|
||||
|
||||
```cpp
|
||||
sixtyfps::cbindgen_private::KeyboardModifiers ctrl_modifier{};
|
||||
slint::cbindgen_private::KeyboardModifiers ctrl_modifier{};
|
||||
ctrl_modifier.control = true;
|
||||
|
||||
auto handle = TestCase::create();
|
||||
|
@ -72,12 +72,12 @@ const TestCase &instance = *handle;
|
|||
assert(!instance.get_input1_focused());
|
||||
assert(instance.get_input2_focused());
|
||||
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&instance, "Hello");
|
||||
slint::testing::send_keyboard_string_sequence(&instance, "Hello");
|
||||
assert_eq(instance.get_input2_text(), "Hello");
|
||||
assert_eq(instance.get_input1_text(), "");
|
||||
assert_eq(instance.get_recieved(), "");
|
||||
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&instance, "ß", ctrl_modifier);
|
||||
slint::testing::send_keyboard_string_sequence(&instance, "ß", ctrl_modifier);
|
||||
assert_eq(instance.get_input2_text(), "Hello");
|
||||
assert_eq(instance.get_input1_text(), "");
|
||||
assert_eq(instance.get_recieved(), "ß");
|
||||
|
|
|
@ -67,8 +67,8 @@ assert_eq!(instance.get_r5(), "__abcdefghij__");
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 50., 50.);
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&instance, "__abcdefghij__");
|
||||
slint::testing::send_mouse_click(&instance, 50., 50.);
|
||||
slint::testing::send_keyboard_string_sequence(&instance, "__abcdefghij__");
|
||||
assert_eq(instance.get_r1(), "__afghij__");
|
||||
assert_eq(instance.get_r2(), "__abfghij__");
|
||||
assert_eq(instance.get_r3(), "__abcfghij__");
|
||||
|
|
|
@ -51,19 +51,19 @@ const TestCase &instance = *handle;
|
|||
assert(!instance.get_input1_focused());
|
||||
assert(!instance.get_input2_focused());
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 150., 100.);
|
||||
slint::testing::send_mouse_click(&instance, 150., 100.);
|
||||
assert(instance.get_input1_focused());
|
||||
assert(!instance.get_input2_focused());
|
||||
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&instance, "Only for field 1");
|
||||
slint::testing::send_keyboard_string_sequence(&instance, "Only for field 1");
|
||||
assert_eq(instance.get_input1_text(), "Only for field 1");
|
||||
assert_eq(instance.get_input2_text(), "");
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 150., 300.);
|
||||
slint::testing::send_mouse_click(&instance, 150., 300.);
|
||||
assert(!instance.get_input1_focused());
|
||||
assert(instance.get_input2_focused());
|
||||
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&instance, "Only for field 2");
|
||||
slint::testing::send_keyboard_string_sequence(&instance, "Only for field 2");
|
||||
assert_eq(instance.get_input1_text(), "Only for field 1");
|
||||
assert_eq(instance.get_input2_text(), "Only for field 2");
|
||||
```
|
||||
|
|
|
@ -47,15 +47,15 @@ const TestCase &instance = *handle;
|
|||
assert(instance.get_input1_focused());
|
||||
assert(!instance.get_input2_focused());
|
||||
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&instance, "Only for field 1");
|
||||
slint::testing::send_keyboard_string_sequence(&instance, "Only for field 1");
|
||||
assert_eq(instance.get_input1_text(), "Only for field 1");
|
||||
assert_eq(instance.get_input2_text(), "");
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 150., 100.);
|
||||
slint::testing::send_mouse_click(&instance, 150., 100.);
|
||||
assert(instance.get_input1_focused());
|
||||
assert(!instance.get_input2_focused());
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 150., 300.);
|
||||
slint::testing::send_mouse_click(&instance, 150., 300.);
|
||||
assert(!instance.get_input1_focused());
|
||||
assert(instance.get_input2_focused());
|
||||
```
|
||||
|
|
|
@ -54,29 +54,29 @@ assert_eq(instance.get_test(), true);
|
|||
assert_eq(instance.get_el1clip(), false);
|
||||
|
||||
// clip, outside
|
||||
sixtyfps::testing::send_mouse_click(&instance, 37., 27.);
|
||||
slint::testing::send_mouse_click(&instance, 37., 27.);
|
||||
assert_eq(instance.get_touch1(), 0);
|
||||
assert_eq(instance.get_touch2(), 0);
|
||||
|
||||
// clip, inside
|
||||
sixtyfps::testing::send_mouse_click(&instance, 37., 33.);
|
||||
slint::testing::send_mouse_click(&instance, 37., 33.);
|
||||
assert_eq(instance.get_touch1(), 0);
|
||||
assert_eq(instance.get_touch2(), 1);
|
||||
|
||||
|
||||
// no-clip, outside
|
||||
sixtyfps::testing::send_mouse_click(&instance, 17., 7.);
|
||||
slint::testing::send_mouse_click(&instance, 17., 7.);
|
||||
assert_eq(instance.get_touch1(), 1);
|
||||
assert_eq(instance.get_touch2(), 1);
|
||||
|
||||
// no-clip, inside
|
||||
sixtyfps::testing::send_mouse_click(&instance, 17., 13.);
|
||||
slint::testing::send_mouse_click(&instance, 17., 13.);
|
||||
assert_eq(instance.get_touch1(), 2);
|
||||
assert_eq(instance.get_touch2(), 1);
|
||||
|
||||
// now clip also el1
|
||||
instance.set_el1clip(true);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 17., 7.);
|
||||
slint::testing::send_mouse_click(&instance, 17., 7.);
|
||||
assert_eq(instance.get_touch1(), 2);
|
||||
assert_eq(instance.get_touch2(), 1);
|
||||
|
||||
|
|
|
@ -50,29 +50,29 @@ assert_eq(instance.get_test(), true);
|
|||
assert_eq(instance.get_el1visible(), true);
|
||||
|
||||
// el2 !visible, outside
|
||||
sixtyfps::testing::send_mouse_click(&instance, 37., 27.);
|
||||
slint::testing::send_mouse_click(&instance, 37., 27.);
|
||||
assert_eq(instance.get_touch1(), 0);
|
||||
assert_eq(instance.get_touch2(), 0);
|
||||
|
||||
// el2 !visible, inside
|
||||
sixtyfps::testing::send_mouse_click(&instance, 37., 33.);
|
||||
slint::testing::send_mouse_click(&instance, 37., 33.);
|
||||
assert_eq(instance.get_touch1(), 0);
|
||||
assert_eq(instance.get_touch2(), 0);
|
||||
|
||||
|
||||
// el1 visible, outside
|
||||
sixtyfps::testing::send_mouse_click(&instance, 17., 7.);
|
||||
slint::testing::send_mouse_click(&instance, 17., 7.);
|
||||
assert_eq(instance.get_touch1(), 1);
|
||||
assert_eq(instance.get_touch2(), 0);
|
||||
|
||||
// el1 visible, inside
|
||||
sixtyfps::testing::send_mouse_click(&instance, 17., 13.);
|
||||
slint::testing::send_mouse_click(&instance, 17., 13.);
|
||||
assert_eq(instance.get_touch1(), 2);
|
||||
assert_eq(instance.get_touch2(), 0);
|
||||
|
||||
// now makes el invisible
|
||||
instance.set_el1visible(false);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 17., 7.);
|
||||
slint::testing::send_mouse_click(&instance, 17., 7.);
|
||||
assert_eq(instance.get_touch1(), 2);
|
||||
assert_eq(instance.get_touch2(), 0);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ TestCase := Rectangle {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 95.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 95.);
|
||||
assert(instance.get_rect1_pos_ok());
|
||||
assert(instance.get_rect2_pos_ok());
|
||||
assert(instance.get_rect3_pos_ok());
|
||||
|
|
|
@ -59,7 +59,7 @@ TestCase := Rectangle {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 95.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 95.);
|
||||
assert(instance.get_rect1_pos_ok());
|
||||
assert(instance.get_rect2_pos_ok());
|
||||
assert(instance.get_rect3_pos_ok());
|
||||
|
|
|
@ -33,12 +33,12 @@ TestCase := Rectangle {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
|
||||
slint::testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 190., 190.);
|
||||
slint::testing::send_mouse_click(&instance, 190., 190.);
|
||||
assert_eq(instance.get_value(), 1+1);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 290.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 290.);
|
||||
assert_eq(instance.get_value(), 1+1+2);
|
||||
```
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@ export TestCase := Rectangle {
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_value(), -10);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 25., 25.);
|
||||
slint::testing::send_mouse_click(&instance, 25., 25.);
|
||||
assert_eq(instance.get_value(), 8);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 45., 15.);
|
||||
slint::testing::send_mouse_click(&instance, 45., 15.);
|
||||
assert_eq(instance.get_value(), 9);
|
||||
```
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ HelloWorld := Window {
|
|||
```cpp
|
||||
auto handle = HelloWorld::create();
|
||||
const HelloWorld &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ TestCase := Window {
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 455.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 455.);
|
||||
assert_eq(instance.get_last_clicked(), 0);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 305.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 305.);
|
||||
assert_eq(instance.get_last_clicked(), 11);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 295.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 295.);
|
||||
assert_eq(instance.get_last_clicked(), 3);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 95.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 95.);
|
||||
assert_eq(instance.get_last_clicked(), 1);
|
||||
```
|
||||
|
||||
|
|
|
@ -44,16 +44,16 @@ auto handle = TestCase::create();
|
|||
const TestCase &instance = *handle;
|
||||
|
||||
// aim at the padding
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 100.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 100.);
|
||||
assert_eq(instance.get_last_clicked(), 0);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 455.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 455.);
|
||||
assert_eq(instance.get_last_clicked(), 0);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 305.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 305.);
|
||||
assert_eq(instance.get_last_clicked(), 11);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 295.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 295.);
|
||||
assert_eq(instance.get_last_clicked(), 3);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 95.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 95.);
|
||||
assert_eq(instance.get_last_clicked(), 1);
|
||||
```
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ TestCase := Window {
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 95.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 95.);
|
||||
assert_eq(instance.get_last_clicked(), 11);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 105., 205.);
|
||||
slint::testing::send_mouse_click(&instance, 105., 205.);
|
||||
assert_eq(instance.get_last_clicked(), 23);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 95., 195.);
|
||||
slint::testing::send_mouse_click(&instance, 95., 195.);
|
||||
assert_eq(instance.get_last_clicked(), 12);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 295., 56.);
|
||||
slint::testing::send_mouse_click(&instance, 295., 56.);
|
||||
assert_eq(instance.get_last_clicked(), 31);
|
||||
```
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ export TestCase := Window {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 1., 1.);
|
||||
slint::testing::send_mouse_click(&instance, 1., 1.);
|
||||
assert(instance.get_check_ok());
|
||||
|
||||
```
|
||||
|
|
|
@ -24,9 +24,9 @@ TestCase := Window {
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert_eq(instance.get_last_clicked(), 0);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 145.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 145.);
|
||||
assert_eq(instance.get_last_clicked(), 1);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 155.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 155.);
|
||||
assert_eq(instance.get_last_clicked(), 2);
|
||||
```
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ TestCase := Rectangle {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_materialized_max_height(), 300);
|
||||
assert_eq(instance.get_materialized_min_width(), 50);
|
||||
assert_eq(instance.get_materialized_min_height(), 25);
|
||||
|
|
|
@ -64,28 +64,28 @@ export TestCase := Window {
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_value(), 0);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 52.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 52.);
|
||||
assert_eq(instance.get_value(), 2);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 30.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 30.);
|
||||
assert_eq(instance.get_value(), 1);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 80.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 80.);
|
||||
assert_eq(instance.get_value(), 4);
|
||||
|
||||
instance.set_cond(false);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 35.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 35.);
|
||||
assert_eq(instance.get_value(), 1);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 30.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 30.);
|
||||
assert_eq(instance.get_value(), 0);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 67.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 67.);
|
||||
assert_eq(instance.get_value(), 4);
|
||||
|
||||
instance.set_cond(true);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 70.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 70.);
|
||||
assert_eq(instance.get_value(), 2);
|
||||
|
||||
```
|
||||
|
|
|
@ -21,7 +21,7 @@ assert_eq(instance.get_num_ints(), 5);
|
|||
assert_eq(instance.get_n(), 4);
|
||||
assert_eq(instance.get_third_int(), 3);
|
||||
|
||||
auto model = std::make_shared<sixtyfps::VectorModel<int>>(std::vector<int>{1, 2, 3, 4, 5, 6, 7});
|
||||
auto model = std::make_shared<slint::VectorModel<int>>(std::vector<int>{1, 2, 3, 4, 5, 6, 7});
|
||||
instance.set_ints(model);
|
||||
assert_eq(instance.get_num_ints(), 7);
|
||||
assert_eq(instance.get_third_int(), 3);
|
||||
|
|
|
@ -91,13 +91,13 @@ export TestCase := Rectangle {
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_value(), 1010);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 15.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 15.);
|
||||
assert_eq(instance.get_value(), 2013);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 15.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 15.);
|
||||
assert_eq(instance.get_value(), 3000+13+42);
|
||||
```
|
||||
|
||||
|
|
|
@ -34,15 +34,15 @@ auto handle = TestCase::create();
|
|||
const TestCase &instance = *handle;
|
||||
|
||||
// condition is false
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_top_level(), 42);
|
||||
|
||||
instance.set_cond1(true);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_top_level(), 92);
|
||||
|
||||
instance.set_cond1(false);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_top_level(), 92);
|
||||
```
|
||||
|
||||
|
|
|
@ -34,15 +34,15 @@ auto handle = TestCase::create();
|
|||
const TestCase &instance = *handle;
|
||||
|
||||
// condition is false
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_top_level(), 42);
|
||||
|
||||
instance.set_cond1(true);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_top_level(), 92);
|
||||
|
||||
instance.set_cond1(false);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_top_level(), 92);
|
||||
```
|
||||
|
||||
|
|
|
@ -41,14 +41,14 @@ const TestCase &instance = *handle;
|
|||
|
||||
// Send an initial click to traverse the item tree and force a listview
|
||||
// layout.
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_viewport_height(), 100.);
|
||||
|
||||
// Trigger the mouse area to change the model
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 55.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 55.);
|
||||
|
||||
// Send a second click to force an item tree traversal and listview update
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_viewport_height(), 200.);
|
||||
```
|
||||
|
||||
|
|
|
@ -102,47 +102,47 @@ auto handle = TestCase::create();
|
|||
const TestCase &instance = *handle;
|
||||
|
||||
// there should be nothing there
|
||||
sixtyfps::testing::send_mouse_click(&instance, 25., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 25., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 0);
|
||||
assert_eq(instance.get_clicked_internal_state(), 0);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 789000);
|
||||
assert_eq(instance.get_clicked_internal_state(), 1);
|
||||
|
||||
using ModelData = std::tuple<sixtyfps::SharedString, sixtyfps::SharedString, float>;
|
||||
using ModelData = std::tuple<slint::SharedString, slint::SharedString, float>;
|
||||
std::vector<ModelData> array;
|
||||
array.push_back(ModelData{"a1", "hello", 111.});
|
||||
array.push_back(ModelData{"a2", "cruel", 222.});
|
||||
array.push_back(ModelData{"a3", "world", 333.});
|
||||
auto another_model = std::make_shared<sixtyfps::VectorModel<ModelData>>(std::move(array));
|
||||
auto another_model = std::make_shared<slint::VectorModel<ModelData>>(std::move(array));
|
||||
instance.set_model(another_model);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 25., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 25., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 333000);
|
||||
assert_eq(instance.get_clicked_internal_state(), 1);
|
||||
assert_eq(instance.get_clicked_index(), 2);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 222000);
|
||||
assert_eq(instance.get_clicked_name(), "cruel");
|
||||
assert_eq(instance.get_clicked_internal_state(), 1);
|
||||
|
||||
another_model->push_back({"a4", "!", 444.});
|
||||
sixtyfps::testing::send_mouse_click(&instance, 35., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 35., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 444000);
|
||||
assert_eq(instance.get_clicked_name(), "!");
|
||||
assert_eq(instance.get_clicked_internal_state(), 1);
|
||||
|
||||
another_model->set_row_data(1, {"a2", "idyllic", 555.});
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 555000);
|
||||
assert_eq(instance.get_clicked_name(), "idyllic");
|
||||
assert_eq(instance.get_clicked_internal_state(), 2);
|
||||
assert_eq(instance.get_clicked_index(), 1);
|
||||
|
||||
another_model->erase(1);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 333000);
|
||||
assert_eq(instance.get_clicked_name(), "world");
|
||||
assert_eq(instance.get_clicked_internal_state(), 2);
|
||||
|
|
|
@ -80,27 +80,27 @@ assert_eq!(another_model.row_count(), 3);
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 792);
|
||||
|
||||
assert_eq(std::get<2>(*instance.get_model()->row_data(1)), 792.);
|
||||
instance.invoke_manual_score_update(1, 100);
|
||||
assert_eq(std::get<2>(*instance.get_model()->row_data(1)), 892.);
|
||||
|
||||
using ModelData = std::tuple<sixtyfps::SharedString, sixtyfps::SharedString, float>;
|
||||
using ModelData = std::tuple<slint::SharedString, slint::SharedString, float>;
|
||||
std::vector<ModelData> array;
|
||||
array.push_back(ModelData{"a1", "hello", 111.});
|
||||
array.push_back(ModelData{"a2", "cruel", 222.});
|
||||
array.push_back(ModelData{"a3", "world", 333.});
|
||||
auto another_model = std::make_shared<sixtyfps::VectorModel<ModelData>>(std::move(array));
|
||||
auto another_model = std::make_shared<slint::VectorModel<ModelData>>(std::move(array));
|
||||
instance.set_model(another_model);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 25., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 25., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 336);
|
||||
assert_eq(std::get<2>(*another_model->row_data(2)), 336.);
|
||||
|
||||
instance.invoke_manual_score_update(2, 100);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 25., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 25., 5.);
|
||||
assert_eq(instance.get_clicked_score(), 439);
|
||||
assert_eq(std::get<2>(*another_model->row_data(2)), 439.);
|
||||
assert_eq(std::get<1>(*another_model->row_data(2)), "world");
|
||||
|
|
|
@ -73,26 +73,26 @@ const TestCase &instance = *handle;
|
|||
assert_eq(instance.get_hello(), 40);
|
||||
assert_eq(instance.get_binding_dep(), 100);
|
||||
assert_eq(instance.get_unset_property(), 0);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
// no time has ellapsed yet
|
||||
assert_eq(instance.get_hello(), 40);
|
||||
assert_eq(instance.get_binding_dep(), 100);
|
||||
assert_eq(instance.get_unset_property(), 0);
|
||||
|
||||
// Half the animation
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq(instance.get_hello(), 50);
|
||||
assert_eq(instance.get_binding_dep(), 125);
|
||||
assert_eq(instance.get_unset_property(), 50);
|
||||
|
||||
|
||||
// Remaining half
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq(instance.get_hello(), 60);
|
||||
assert_eq(instance.get_binding_dep(), 150);
|
||||
assert_eq(instance.get_unset_property(), 100);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(100);
|
||||
slint::testing::mock_elapsed_time(100);
|
||||
assert_eq(instance.get_hello(), 60);
|
||||
assert_eq(instance.get_binding_dep(), 150);
|
||||
assert_eq(instance.get_unset_property(), 100);
|
||||
|
|
|
@ -124,45 +124,45 @@ assert_eq(instance.get_text1_foo(), 11);
|
|||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 5000);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(50); // In delay
|
||||
slint::testing::mock_elapsed_time(50); // In delay
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 5000);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(50); // some: in delay, other: end of delay
|
||||
slint::testing::mock_elapsed_time(50); // some: in delay, other: end of delay
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 5000);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(50); // some: in delay, other: in play for 50ms [150ms]
|
||||
slint::testing::mock_elapsed_time(50); // some: in delay, other: in play for 50ms [150ms]
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert(instance.get_other_prop() < 4760); // should be 4750
|
||||
assert(instance.get_other_prop() > 4740);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(800); // some: in delay, other: in play for 850ms [950ms]
|
||||
slint::testing::mock_elapsed_time(800); // some: in delay, other: in play for 850ms [950ms]
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert(instance.get_other_prop() < 760); // should be 750
|
||||
assert(instance.get_other_prop() > 740);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(160); // some: in delay, other: ended [111ßms]
|
||||
slint::testing::mock_elapsed_time(160); // some: in delay, other: ended [111ßms]
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 0);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(3840); // some: in delay, other: ended [4950ms]
|
||||
slint::testing::mock_elapsed_time(3840); // some: in delay, other: ended [4950ms]
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 0);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(60); // some: in play for 10ms, other: ended [5010ms]
|
||||
slint::testing::mock_elapsed_time(60); // some: in play for 10ms, other: ended [5010ms]
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert(instance.get_some_prop() > 202); // should be 204,5
|
||||
assert(instance.get_some_prop() < 207);
|
||||
assert_eq(instance.get_other_prop(), 0);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(100); // some: ended, other: ended [5110ms]
|
||||
slint::testing::mock_elapsed_time(100); // some: ended, other: ended [5110ms]
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert_eq(instance.get_some_prop(), 2000);
|
||||
assert_eq(instance.get_other_prop(), 0);
|
||||
|
@ -172,18 +172,18 @@ assert_eq(instance.get_text1_foo(), 11);
|
|||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 5000);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(50); // In delay
|
||||
slint::testing::mock_elapsed_time(50); // In delay
|
||||
assert_eq(instance.get_text1_foo(), 11);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 5000);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(440);
|
||||
slint::testing::mock_elapsed_time(440);
|
||||
assert(instance.get_text1_foo() > 70);
|
||||
assert(instance.get_text1_foo() < 87);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 5000);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(30);
|
||||
slint::testing::mock_elapsed_time(30);
|
||||
assert_eq(instance.get_text1_foo(), 85 + 4);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_other_prop(), 5000);
|
||||
|
|
|
@ -72,17 +72,17 @@ assert_eq(instance.get_hello(), 40);
|
|||
assert_eq(instance.get_binding_dep(), 100);
|
||||
|
||||
// Half the animation
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq(instance.get_hello(), 50);
|
||||
assert_eq(instance.get_binding_dep(), 125);
|
||||
|
||||
|
||||
// Remaining half
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq(instance.get_hello(), 60);
|
||||
assert_eq(instance.get_binding_dep(), 150);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(100);
|
||||
slint::testing::mock_elapsed_time(100);
|
||||
assert_eq(instance.get_hello(), 60);
|
||||
assert_eq(instance.get_binding_dep(), 150);
|
||||
|
||||
|
@ -90,7 +90,7 @@ assert_eq(instance.get_binding_dep(), 150);
|
|||
// querying the value (because te dirty event should cause the animation to start)
|
||||
instance.set_condition(true);
|
||||
instance.set_hello(30);
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq(instance.get_hello(), 45);
|
||||
assert_eq(instance.get_binding_dep(), 125);
|
||||
```
|
||||
|
|
|
@ -62,13 +62,13 @@ assert_eq(instance.get_some_prop(), 5);
|
|||
instance.set_active_index(1);
|
||||
assert_eq(instance.get_text1_foo(), 0);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
sixtyfps::testing::mock_elapsed_time(75); // 75% the animation
|
||||
slint::testing::mock_elapsed_time(75); // 75% the animation
|
||||
assert(instance.get_some_prop() > 1500);
|
||||
assert(instance.get_some_prop() < 1999);
|
||||
assert(instance.get_text1_foo() > 2000);
|
||||
assert(instance.get_text1_foo() < 2999);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(30); // more than 100% the animation
|
||||
slint::testing::mock_elapsed_time(30); // more than 100% the animation
|
||||
assert_eq(instance.get_text1_foo(), 3000);
|
||||
assert_eq(instance.get_some_prop(), 2000);
|
||||
|
||||
|
@ -76,7 +76,7 @@ instance.set_active_index(2);
|
|||
assert_eq(instance.get_text1_foo(), 3000);
|
||||
assert_eq(instance.get_some_prop(), 2000);
|
||||
|
||||
sixtyfps::testing::mock_elapsed_time(100);
|
||||
slint::testing::mock_elapsed_time(100);
|
||||
assert_eq(instance.get_text1_foo(), 0);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
```
|
||||
|
|
|
@ -64,19 +64,19 @@ assert_eq(instance.get_some_prop(), 5);
|
|||
instance.set_active_index(1);
|
||||
assert_eq(instance.get_text1_foo(), 3 + 2 * 4);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
sixtyfps::testing::mock_elapsed_time(75); // 75% the animation
|
||||
slint::testing::mock_elapsed_time(75); // 75% the animation
|
||||
assert(instance.get_some_prop() > 1500);
|
||||
assert(instance.get_some_prop() < 1999);
|
||||
sixtyfps::testing::mock_elapsed_time(30); // more than 100% the animation
|
||||
slint::testing::mock_elapsed_time(30); // more than 100% the animation
|
||||
assert_eq(instance.get_some_prop(), 2000);
|
||||
|
||||
instance.set_active_index(2);
|
||||
assert_eq(instance.get_some_prop(), 5);
|
||||
assert_eq(instance.get_text1_foo(), 3 + 2 * 4);
|
||||
sixtyfps::testing::mock_elapsed_time(290);
|
||||
slint::testing::mock_elapsed_time(290);
|
||||
assert(instance.get_text1_foo() > 70);
|
||||
assert(instance.get_text1_foo() < 87);
|
||||
sixtyfps::testing::mock_elapsed_time(30);
|
||||
slint::testing::mock_elapsed_time(30);
|
||||
assert_eq(instance.get_text1_foo(), 85 + 4);
|
||||
```
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ assert!(!instance.get_clicked());
|
|||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert(!instance.get_clicked());
|
||||
sixtyfps::testing::send_mouse_click(&instance, 20., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 20., 5.);
|
||||
assert(!instance.get_clicked());
|
||||
```
|
||||
|
||||
|
|
|
@ -36,11 +36,11 @@ TestCase := Rectangle {
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
instance.set_binding_to_default_text_color(sixtyfps::Color::from_rgb_uint8(0, 0, 255));
|
||||
assert_eq(instance.get_default_text_color(), sixtyfps::Color::from_rgb_uint8(0, 0, 255));
|
||||
assert_eq(instance.get_color_of_initialized_text(), sixtyfps::Color::from_rgb_uint8(255, 255, 0));
|
||||
assert_eq(instance.get_color_of_sub_element_text(), sixtyfps::Color::from_rgb_uint8(255, 0, 0));
|
||||
assert_eq(instance.get_color_in_state(), sixtyfps::Color::from_rgb_uint8(0, 0, 255));
|
||||
instance.set_binding_to_default_text_color(slint::Color::from_rgb_uint8(0, 0, 255));
|
||||
assert_eq(instance.get_default_text_color(), slint::Color::from_rgb_uint8(0, 0, 255));
|
||||
assert_eq(instance.get_color_of_initialized_text(), slint::Color::from_rgb_uint8(255, 255, 0));
|
||||
assert_eq(instance.get_color_of_sub_element_text(), slint::Color::from_rgb_uint8(255, 0, 0));
|
||||
assert_eq(instance.get_color_in_state(), slint::Color::from_rgb_uint8(0, 0, 255));
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ Test := Rectangle {
|
|||
```cpp
|
||||
auto handle = Test::create();
|
||||
const Test &t = *handle;
|
||||
assert_eq(t.get_color_brush().color(), sixtyfps::Color::from_rgb_uint8(0, 0, 0xff));
|
||||
assert_eq(t.get_color_brush().color(), slint::Color::from_rgb_uint8(0, 0, 0xff));
|
||||
|
||||
auto green = sixtyfps::Color::from_rgb_uint8(0, 0xff, 0);
|
||||
auto green = slint::Color::from_rgb_uint8(0, 0xff, 0);
|
||||
t.set_color_brush(green);
|
||||
assert_eq(t.get_color_brush().color(), green);
|
||||
```
|
||||
|
|
|
@ -42,13 +42,13 @@ assert_eq(t.get_b1(), t.get_b5());
|
|||
assert(t.get_b1() != t.get_r5());
|
||||
assert_eq(t.get_y1(), t.get_y2());
|
||||
|
||||
auto red = sixtyfps::Color::from_argb_float(1, 1, 0, 0);
|
||||
auto blue = sixtyfps::Color::from_rgb_float(0, 0, 1);
|
||||
auto g = sixtyfps::Color::from_rgb_uint8(0x99, 0x99, 0x99);
|
||||
auto red = slint::Color::from_argb_float(1, 1, 0, 0);
|
||||
auto blue = slint::Color::from_rgb_float(0, 0, 1);
|
||||
auto g = slint::Color::from_rgb_uint8(0x99, 0x99, 0x99);
|
||||
assert_eq(t.get_r1(), red);
|
||||
assert_eq(t.get_b1(), blue);
|
||||
assert_eq(t.get_g1(), g);
|
||||
assert_eq(t.get_y1(), sixtyfps::Color::from_argb_encoded(0xffffff00));
|
||||
assert_eq(t.get_y1(), slint::Color::from_argb_encoded(0xffffff00));
|
||||
|
||||
t.set_g1(blue);
|
||||
assert_eq(t.get_g1(), t.get_b1());
|
||||
|
|
|
@ -47,18 +47,18 @@ assert_eq!(instance.get_foo_b(), 33);
|
|||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
assert_eq(instance.get_foo_a(), sixtyfps::SharedString("444"));
|
||||
assert_eq(instance.get_foo_a(), slint::SharedString("444"));
|
||||
assert_eq(instance.get_foo_b(), 12);
|
||||
instance.invoke_change_foo();
|
||||
assert_eq(instance.get_foo_a(), sixtyfps::SharedString("hello"));
|
||||
assert_eq(instance.get_foo_a(), slint::SharedString("hello"));
|
||||
assert_eq(instance.get_foo_b(), 20);
|
||||
assert_eq(instance.get_obj_cond_merge_b(), 0);
|
||||
assert_eq(instance.get_obj_binop_merge(), true);
|
||||
assert(instance.get_test());
|
||||
|
||||
// This API to set with a tuple should maybe not be accessible?
|
||||
instance.set_foo(std::make_tuple(sixtyfps::SharedString("yo"), 33));
|
||||
assert_eq(instance.get_foo_a(), sixtyfps::SharedString("yo"));
|
||||
instance.set_foo(std::make_tuple(slint::SharedString("yo"), 33));
|
||||
assert_eq(instance.get_foo_a(), slint::SharedString("yo"));
|
||||
assert_eq(instance.get_foo_b(), 33);
|
||||
```
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>>
|
|||
generated_cpp.write_all(
|
||||
b"#ifdef NDEBUG\n#undef NDEBUG\n#endif\n#include <assert.h>\n#include <cmath>\n#include <iostream>\n#include <sixtyfps_testing.h>\n",
|
||||
)?;
|
||||
generated_cpp.write_all(b"int main() {\n sixtyfps::testing::init();\n")?;
|
||||
generated_cpp.write_all(b"int main() {\n slint::testing::init();\n")?;
|
||||
for x in test_driver_lib::extract_test_functions(&source).filter(|x| x.language_id == "cpp") {
|
||||
write!(generated_cpp, " {{\n {}\n }}\n", x.source.replace("\n", "\n "))?;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue