mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
Rename internal crates and add a README.md to them
The README.md contains the warning that used to be in lib.rs. Add README.md files to all internal crates ... pointing to the official public crate to use instead. Rename internal crates fixup: README files fixup rename
This commit is contained in:
parent
c245c0f941
commit
de4e195280
124 changed files with 867 additions and 996 deletions
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
@ -81,7 +81,7 @@ jobs:
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --verbose --all-features --workspace --exclude slint-backend-mcu-internal # mcu backend requires nightly
|
args: --verbose --all-features --workspace --exclude i-slint-backend-mcu # mcu backend requires nightly
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -30,7 +30,7 @@ members = [
|
||||||
'internal/backends/testing',
|
'internal/backends/testing',
|
||||||
'internal/common',
|
'internal/common',
|
||||||
'internal/compiler',
|
'internal/compiler',
|
||||||
'internal/compiler/parser_test_macro',
|
'internal/compiler/parser-test-macro',
|
||||||
'internal/core',
|
'internal/core',
|
||||||
'internal/core-macros',
|
'internal/core-macros',
|
||||||
'internal/interpreter',
|
'internal/interpreter',
|
||||||
|
|
|
@ -22,20 +22,20 @@ crate-type = ["lib", "cdylib"]
|
||||||
# Note, these features need to be kept in sync (along with their defaults) in
|
# Note, these features need to be kept in sync (along with their defaults) in
|
||||||
# the C++ crate's CMakeLists.txt
|
# the C++ crate's CMakeLists.txt
|
||||||
[features]
|
[features]
|
||||||
backend-gl = ["slint-backend-selector-internal/slint-backend-gl-internal"]
|
backend-gl = ["i-slint-backend-selector/i-slint-backend-gl"]
|
||||||
backend-qt = ["slint-backend-selector-internal/slint-backend-qt-internal"]
|
backend-qt = ["i-slint-backend-selector/i-slint-backend-qt"]
|
||||||
interpreter = ["slint-interpreter"]
|
interpreter = ["slint-interpreter"]
|
||||||
testing = ["slint-backend-testing-internal"] # Enable some function used by the integration tests
|
testing = ["i-slint-backend-testing"] # Enable some function used by the integration tests
|
||||||
wayland = ["slint-backend-selector-internal/wayland"]
|
wayland = ["i-slint-backend-selector/wayland"]
|
||||||
x11 = ["slint-backend-selector-internal/x11"]
|
x11 = ["i-slint-backend-selector/x11"]
|
||||||
|
|
||||||
default = ["backend-gl", "x11", "backend-qt"]
|
default = ["backend-gl", "x11", "backend-qt"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-core-internal = { version = "=0.2.0", path="../../internal/core", features = ["ffi"] }
|
i-slint-backend-selector = { version = "=0.2.0", path="../../internal/backends/selector" }
|
||||||
|
i-slint-backend-testing = { version = "=0.2.0", path="../../internal/backends/testing", optional = true }
|
||||||
|
i-slint-core = { version = "=0.2.0", path="../../internal/core", features = ["ffi"] }
|
||||||
slint-interpreter = { version = "=0.2.0", path="../../internal/interpreter", default-features = false, features = ["ffi", "compat-0-2-0"], optional = true }
|
slint-interpreter = { version = "=0.2.0", path="../../internal/interpreter", default-features = false, features = ["ffi", "compat-0-2-0"], optional = true }
|
||||||
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
|
||||||
slint-backend-testing-internal = { version = "=0.2.0", path="../../internal/backends/testing", optional = true }
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
/*! This crate just expose the function used by the C++ integration */
|
/*! This crate just expose the function used by the C++ integration */
|
||||||
|
|
||||||
use core::ffi::c_void;
|
use core::ffi::c_void;
|
||||||
use slint_backend_selector_internal::backend;
|
use i_slint_backend_selector::backend;
|
||||||
use slint_core_internal::window::ffi::WindowRcOpaque;
|
use i_slint_core::window::ffi::WindowRcOpaque;
|
||||||
use slint_core_internal::window::WindowRc;
|
use i_slint_core::window::WindowRc;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[cold]
|
#[cold]
|
||||||
pub fn use_modules() -> usize {
|
pub fn use_modules() -> usize {
|
||||||
#[cfg(feature = "slint-interpreter")]
|
#[cfg(feature = "slint-interpreter")]
|
||||||
slint_interpreter::use_modules();
|
slint_interpreter::use_modules();
|
||||||
slint_backend_selector_internal::use_modules();
|
i_slint_backend_selector::use_modules();
|
||||||
slint_core_internal::use_modules()
|
i_slint_core::use_modules()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -25,9 +25,8 @@ pub unsafe extern "C" fn slint_windowrc_init(out: *mut WindowRcOpaque) {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn slint_run_event_loop() {
|
pub unsafe extern "C" fn slint_run_event_loop() {
|
||||||
crate::backend().run_event_loop(
|
crate::backend()
|
||||||
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed,
|
.run_event_loop(i_slint_core::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Will execute the given functor in the main thread
|
/// Will execute the given functor in the main thread
|
||||||
|
@ -64,8 +63,8 @@ pub unsafe extern "C" fn slint_quit_event_loop() {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn slint_register_font_from_path(
|
pub unsafe extern "C" fn slint_register_font_from_path(
|
||||||
path: &slint_core_internal::SharedString,
|
path: &i_slint_core::SharedString,
|
||||||
error_str: *mut slint_core_internal::SharedString,
|
error_str: *mut i_slint_core::SharedString,
|
||||||
) {
|
) {
|
||||||
core::ptr::write(
|
core::ptr::write(
|
||||||
error_str,
|
error_str,
|
||||||
|
@ -78,8 +77,8 @@ pub unsafe extern "C" fn slint_register_font_from_path(
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn slint_register_font_from_data(
|
pub unsafe extern "C" fn slint_register_font_from_data(
|
||||||
data: slint_core_internal::slice::Slice<'static, u8>,
|
data: i_slint_core::slice::Slice<'static, u8>,
|
||||||
error_str: *mut slint_core_internal::SharedString,
|
error_str: *mut i_slint_core::SharedString,
|
||||||
) {
|
) {
|
||||||
core::ptr::write(
|
core::ptr::write(
|
||||||
error_str,
|
error_str,
|
||||||
|
@ -93,5 +92,5 @@ pub unsafe extern "C" fn slint_register_font_from_data(
|
||||||
#[cfg(feature = "testing")]
|
#[cfg(feature = "testing")]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn slint_testing_init_backend() {
|
pub unsafe extern "C" fn slint_testing_init_backend() {
|
||||||
slint_backend_testing_internal::init();
|
i_slint_backend_testing::init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ crate-type = ["cdylib"]
|
||||||
name = "slint_node_native"
|
name = "slint_node_native"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-compiler-internal = { version = "=0.2.0", path="../../../internal/compiler" }
|
i-slint-compiler = { version = "=0.2.0", path="../../../internal/compiler" }
|
||||||
slint-core-internal = { version = "=0.2.0", path="../../../internal/core" }
|
i-slint-core = { version = "=0.2.0", path="../../../internal/core" }
|
||||||
slint-interpreter = { version = "=0.2.0", path="../../../internal/interpreter", features = ["display-diagnostics"] }
|
slint-interpreter = { version = "=0.2.0", path="../../../internal/interpreter", features = ["display-diagnostics"] }
|
||||||
|
|
||||||
vtable = { version = "0.1.1", path="../../../helper_crates/vtable" }
|
vtable = { version = "0.1.1", path="../../../helper_crates/vtable" }
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
|
use i_slint_compiler::langtype::Type;
|
||||||
|
use i_slint_core::model::Model;
|
||||||
use neon::prelude::*;
|
use neon::prelude::*;
|
||||||
use slint_compiler_internal::langtype::Type;
|
|
||||||
use slint_core_internal::model::Model;
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
|
|
||||||
/// Model coming from JS
|
/// Model coming from JS
|
||||||
pub struct JsModel {
|
pub struct JsModel {
|
||||||
notify: slint_core_internal::model::ModelNotify,
|
notify: i_slint_core::model::ModelNotify,
|
||||||
/// The index of the value in the PersistentContext
|
/// The index of the value in the PersistentContext
|
||||||
value_index: u32,
|
value_index: u32,
|
||||||
data_type: Type,
|
data_type: Type,
|
||||||
|
@ -87,7 +87,7 @@ impl Model for JsModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn model_tracker(&self) -> &dyn slint_core_internal::model::ModelTracker {
|
fn model_tracker(&self) -> &dyn i_slint_core::model::ModelTracker {
|
||||||
&self.notify
|
&self.notify
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
use i_slint_compiler::langtype::Type;
|
||||||
|
use i_slint_core::model::{Model, ModelRc};
|
||||||
|
use i_slint_core::window::WindowHandleAccess;
|
||||||
|
use i_slint_core::{ImageInner, SharedVector};
|
||||||
use neon::prelude::*;
|
use neon::prelude::*;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use slint_compiler_internal::langtype::Type;
|
|
||||||
use slint_core_internal::model::{Model, ModelRc};
|
|
||||||
use slint_core_internal::window::WindowHandleAccess;
|
|
||||||
use slint_core_internal::{ImageInner, SharedVector};
|
|
||||||
use slint_interpreter::ComponentHandle;
|
use slint_interpreter::ComponentHandle;
|
||||||
|
|
||||||
mod js_model;
|
mod js_model;
|
||||||
|
@ -15,7 +15,7 @@ mod persistent_context;
|
||||||
|
|
||||||
struct WrappedComponentType(Option<slint_interpreter::ComponentDefinition>);
|
struct WrappedComponentType(Option<slint_interpreter::ComponentDefinition>);
|
||||||
struct WrappedComponentRc(Option<slint_interpreter::ComponentInstance>);
|
struct WrappedComponentRc(Option<slint_interpreter::ComponentInstance>);
|
||||||
struct WrappedWindow(Option<slint_core_internal::window::WindowRc>);
|
struct WrappedWindow(Option<i_slint_core::window::WindowRc>);
|
||||||
|
|
||||||
/// We need to do some gymnastic with closures to pass the ExecuteContext with the right lifetime
|
/// We need to do some gymnastic with closures to pass the ExecuteContext with the right lifetime
|
||||||
type GlobalContextCallback<'c> =
|
type GlobalContextCallback<'c> =
|
||||||
|
@ -154,7 +154,7 @@ fn create<'cx>(
|
||||||
|
|
||||||
fn to_eval_value<'cx>(
|
fn to_eval_value<'cx>(
|
||||||
val: Handle<'cx, JsValue>,
|
val: Handle<'cx, JsValue>,
|
||||||
ty: slint_compiler_internal::langtype::Type,
|
ty: i_slint_compiler::langtype::Type,
|
||||||
cx: &mut impl Context<'cx>,
|
cx: &mut impl Context<'cx>,
|
||||||
persistent_context: &persistent_context::PersistentContext<'cx>,
|
persistent_context: &persistent_context::PersistentContext<'cx>,
|
||||||
) -> NeonResult<slint_interpreter::Value> {
|
) -> NeonResult<slint_interpreter::Value> {
|
||||||
|
@ -177,12 +177,12 @@ fn to_eval_value<'cx>(
|
||||||
.value()
|
.value()
|
||||||
.parse::<css_color_parser2::Color>()
|
.parse::<css_color_parser2::Color>()
|
||||||
.or_else(|e| cx.throw_error(&e.to_string()))?;
|
.or_else(|e| cx.throw_error(&e.to_string()))?;
|
||||||
Ok((slint_core_internal::Color::from_argb_u8((c.a * 255.) as u8, c.r, c.g, c.b)).into())
|
Ok((i_slint_core::Color::from_argb_u8((c.a * 255.) as u8, c.r, c.g, c.b)).into())
|
||||||
}
|
}
|
||||||
Type::Array(a) => match val.downcast::<JsArray>() {
|
Type::Array(a) => match val.downcast::<JsArray>() {
|
||||||
Ok(arr) => {
|
Ok(arr) => {
|
||||||
let vec = arr.to_vec(cx)?;
|
let vec = arr.to_vec(cx)?;
|
||||||
Ok(Value::Model(ModelRc::new(slint_core_internal::model::SharedVectorModel::from(
|
Ok(Value::Model(ModelRc::new(i_slint_core::model::SharedVectorModel::from(
|
||||||
vec.into_iter()
|
vec.into_iter()
|
||||||
.map(|i| to_eval_value(i, (*a).clone(), cx, persistent_context))
|
.map(|i| to_eval_value(i, (*a).clone(), cx, persistent_context))
|
||||||
.collect::<Result<SharedVector<_>, _>>()?,
|
.collect::<Result<SharedVector<_>, _>>()?,
|
||||||
|
@ -199,7 +199,7 @@ fn to_eval_value<'cx>(
|
||||||
Type::Image => {
|
Type::Image => {
|
||||||
let path = val.to_string(cx)?.value();
|
let path = val.to_string(cx)?.value();
|
||||||
Ok(Value::Image(
|
Ok(Value::Image(
|
||||||
slint_core_internal::graphics::Image::load_from_path(std::path::Path::new(&path))
|
i_slint_core::graphics::Image::load_from_path(std::path::Path::new(&path))
|
||||||
.or_else(|_| cx.throw_error(format!("cannot load image {:?}", path)))?,
|
.or_else(|_| cx.throw_error(format!("cannot load image {:?}", path)))?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ fn to_js_value<'cx>(
|
||||||
}
|
}
|
||||||
js_object.as_value(cx)
|
js_object.as_value(cx)
|
||||||
}
|
}
|
||||||
Value::Brush(slint_core_internal::Brush::SolidColor(c)) => JsString::new(
|
Value::Brush(i_slint_core::Brush::SolidColor(c)) => JsString::new(
|
||||||
cx,
|
cx,
|
||||||
&format!("#{:02x}{:02x}{:02x}{:02x}", c.red(), c.green(), c.blue(), c.alpha()),
|
&format!("#{:02x}{:02x}{:02x}{:02x}", c.red(), c.green(), c.blue(), c.alpha()),
|
||||||
)
|
)
|
||||||
|
@ -546,7 +546,7 @@ fn singleshot_timer(mut cx: FunctionContext) -> JsResult<JsValue> {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
slint_core_internal::timers::Timer::single_shot(
|
i_slint_core::timers::Timer::single_shot(
|
||||||
std::time::Duration::from_millis(duration_in_msecs),
|
std::time::Duration::from_millis(duration_in_msecs),
|
||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
|
@ -564,6 +564,6 @@ register_module!(mut m, {
|
||||||
/// let some time elapse for testing purposes
|
/// let some time elapse for testing purposes
|
||||||
fn mock_elapsed_time(mut cx: FunctionContext) -> JsResult<JsValue> {
|
fn mock_elapsed_time(mut cx: FunctionContext) -> JsResult<JsValue> {
|
||||||
let ms = cx.argument::<JsNumber>(0)?.value();
|
let ms = cx.argument::<JsNumber>(0)?.value();
|
||||||
slint_core_internal::tests::slint_mock_elapsed_time(ms as _);
|
i_slint_core::tests::slint_mock_elapsed_time(ms as _);
|
||||||
Ok(JsUndefined::new().as_value(&mut cx))
|
Ok(JsUndefined::new().as_value(&mut cx))
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ path = "lib.rs"
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-compiler-internal = { version = "=0.2.0", path = "../../../internal/compiler", features = ["rust", "display-diagnostics"] }
|
i-slint-compiler = { version = "=0.2.0", path = "../../../internal/compiler", features = ["rust", "display-diagnostics"] }
|
||||||
|
|
||||||
spin_on = "0.1"
|
spin_on = "0.1"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
This crate serves as a companion crate for the slint crate.
|
This crate serves as a companion crate of the slint crate.
|
||||||
It is meant to allow you to compile the `.slint` files from your `build.rs` script.
|
It is meant to allow you to compile the `.slint` files from your `build.rs` script.
|
||||||
|
|
||||||
The main entry point of this crate is the [`compile()`] function
|
The main entry point of this crate is the [`compile()`] function
|
||||||
|
@ -54,18 +54,18 @@ use std::env;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use slint_compiler_internal::diagnostics::BuildDiagnostics;
|
use i_slint_compiler::diagnostics::BuildDiagnostics;
|
||||||
|
|
||||||
/// The structure for configuring aspects of the compilation of `.slint` markup files to Rust.
|
/// The structure for configuring aspects of the compilation of `.slint` markup files to Rust.
|
||||||
pub struct CompilerConfiguration {
|
pub struct CompilerConfiguration {
|
||||||
config: slint_compiler_internal::CompilerConfiguration,
|
config: i_slint_compiler::CompilerConfiguration,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CompilerConfiguration {
|
impl Default for CompilerConfiguration {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
config: slint_compiler_internal::CompilerConfiguration::new(
|
config: i_slint_compiler::CompilerConfiguration::new(
|
||||||
slint_compiler_internal::generator::OutputFormat::Rust,
|
i_slint_compiler::generator::OutputFormat::Rust,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ pub fn compile_with_config(
|
||||||
.join(path.as_ref());
|
.join(path.as_ref());
|
||||||
|
|
||||||
let mut diag = BuildDiagnostics::default();
|
let mut diag = BuildDiagnostics::default();
|
||||||
let syntax_node = slint_compiler_internal::parser::parse_file(&path, &mut diag);
|
let syntax_node = i_slint_compiler::parser::parse_file(&path, &mut diag);
|
||||||
|
|
||||||
if diag.has_error() {
|
if diag.has_error() {
|
||||||
let vec = diag.to_string_vec();
|
let vec = diag.to_string_vec();
|
||||||
|
@ -208,9 +208,9 @@ pub fn compile_with_config(
|
||||||
|
|
||||||
if std::env::var_os("SLINT_STYLE").is_none() && compiler_config.style.is_none() {
|
if std::env::var_os("SLINT_STYLE").is_none() && compiler_config.style.is_none() {
|
||||||
compiler_config.style = std::env::var_os("OUT_DIR").and_then(|path| {
|
compiler_config.style = std::env::var_os("OUT_DIR").and_then(|path| {
|
||||||
// Same logic as in slint-backend-selector-internal's build script to get the path
|
// Same logic as in i-slint-backend-selector's build script to get the path
|
||||||
let path = Path::new(&path).parent()?.parent()?.join("SLINT_DEFAULT_STYLE.txt");
|
let path = Path::new(&path).parent()?.parent()?.join("SLINT_DEFAULT_STYLE.txt");
|
||||||
// unfortunately, if for some reason the file is changed by the slint-backend-selector-internal's build script,
|
// unfortunately, if for some reason the file is changed by the i-slint-backend-selector's build script,
|
||||||
// it is changed after cargo decide to re-run this build script or not. So that means one will need two build
|
// it is changed after cargo decide to re-run this build script or not. So that means one will need two build
|
||||||
// to settle the right thing.
|
// to settle the right thing.
|
||||||
rerun_if_changed = format!("cargo:rerun-if-changed={}", path.display());
|
rerun_if_changed = format!("cargo:rerun-if-changed={}", path.display());
|
||||||
|
@ -222,11 +222,8 @@ pub fn compile_with_config(
|
||||||
let syntax_node = syntax_node.expect("diags contained no compilation errors");
|
let syntax_node = syntax_node.expect("diags contained no compilation errors");
|
||||||
|
|
||||||
// 'spin_on' is ok here because the compiler in single threaded and does not block if there is no blocking future
|
// 'spin_on' is ok here because the compiler in single threaded and does not block if there is no blocking future
|
||||||
let (doc, diag) = spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
|
let (doc, diag) =
|
||||||
syntax_node,
|
spin_on::spin_on(i_slint_compiler::compile_syntax_node(syntax_node, diag, compiler_config));
|
||||||
diag,
|
|
||||||
compiler_config,
|
|
||||||
));
|
|
||||||
|
|
||||||
if diag.has_error() {
|
if diag.has_error() {
|
||||||
let vec = diag.to_string_vec();
|
let vec = diag.to_string_vec();
|
||||||
|
@ -244,7 +241,7 @@ pub fn compile_with_config(
|
||||||
|
|
||||||
let file = std::fs::File::create(&output_file_path).map_err(CompileError::SaveError)?;
|
let file = std::fs::File::create(&output_file_path).map_err(CompileError::SaveError)?;
|
||||||
let mut code_formatter = CodeFormatter { indentation: 0, in_string: false, sink: file };
|
let mut code_formatter = CodeFormatter { indentation: 0, in_string: false, sink: file };
|
||||||
let generated = slint_compiler_internal::generator::rust::generate(&doc);
|
let generated = i_slint_compiler::generator::rust::generate(&doc);
|
||||||
|
|
||||||
for x in &diag.all_loaded_files {
|
for x in &diag.all_loaded_files {
|
||||||
if x.is_absolute() {
|
if x.is_absolute() {
|
||||||
|
|
|
@ -17,7 +17,7 @@ proc-macro = true
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-compiler-internal = { version = "=0.2.0", path = "../../../internal/compiler", features = ["proc_macro_span", "rust", "display-diagnostics"] }
|
i-slint-compiler = { version = "=0.2.0", path = "../../../internal/compiler", features = ["proc_macro_span", "rust", "display-diagnostics"] }
|
||||||
|
|
||||||
proc-macro2 = "1.0.17"
|
proc-macro2 = "1.0.17"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
|
|
6
api/rs/macros/README.md
Normal file
6
api/rs/macros/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -1,29 +1,19 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// cSpell:ignore punct
|
// cSpell:ignore punct
|
||||||
|
|
||||||
|
#![doc = include_str!("README.md")]
|
||||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
use i_slint_compiler::diagnostics::BuildDiagnostics;
|
||||||
|
use i_slint_compiler::parser::SyntaxKind;
|
||||||
|
use i_slint_compiler::*;
|
||||||
use proc_macro::{Spacing, TokenStream, TokenTree};
|
use proc_macro::{Spacing, TokenStream, TokenTree};
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use slint_compiler_internal::diagnostics::BuildDiagnostics;
|
|
||||||
use slint_compiler_internal::parser::SyntaxKind;
|
|
||||||
use slint_compiler_internal::*;
|
|
||||||
|
|
||||||
/// Returns true if the two token are touching. For example the two token `foo`and `-` are touching if
|
/// Returns true if the two token are touching. For example the two token `foo`and `-` are touching if
|
||||||
/// it was written like so in the source code: `foo-` but not when written like so `foo -`
|
/// it was written like so in the source code: `foo-` but not when written like so `foo -`
|
||||||
|
@ -337,10 +327,10 @@ pub fn slint(stream: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
//println!("{:#?}", syntax_node);
|
//println!("{:#?}", syntax_node);
|
||||||
let mut compiler_config =
|
let mut compiler_config =
|
||||||
CompilerConfiguration::new(slint_compiler_internal::generator::OutputFormat::Rust);
|
CompilerConfiguration::new(i_slint_compiler::generator::OutputFormat::Rust);
|
||||||
|
|
||||||
if std::env::var_os("SLINT_STYLE").is_none() {
|
if std::env::var_os("SLINT_STYLE").is_none() {
|
||||||
// This file is written by the slint-backend-selector-internal's built script.
|
// This file is written by the i-slint-backend-selector's built script.
|
||||||
// It is in the target/xxx/build directory
|
// It is in the target/xxx/build directory
|
||||||
let target_path = match std::env::var_os("OUT_DIR") {
|
let target_path = match std::env::var_os("OUT_DIR") {
|
||||||
Some(out_dir) => Some(
|
Some(out_dir) => Some(
|
||||||
|
|
|
@ -27,7 +27,7 @@ default = ["std", "backend-gl", "x11", "backend-qt", "compat-0-2-0"]
|
||||||
compat-0-2-0 = []
|
compat-0-2-0 = []
|
||||||
|
|
||||||
## Enable use of the Rust standard library.
|
## Enable use of the Rust standard library.
|
||||||
std = ["slint-core-internal/std"]
|
std = ["i-slint-core/std"]
|
||||||
|
|
||||||
#! ### Backends
|
#! ### Backends
|
||||||
|
|
||||||
|
@ -35,22 +35,22 @@ std = ["slint-core-internal/std"]
|
||||||
## This backend is required to use the `native` style.
|
## This backend is required to use the `native` style.
|
||||||
## It requires Qt 5.15 or later to be installed. If Qt is not installed, the
|
## It requires Qt 5.15 or later to be installed. If Qt is not installed, the
|
||||||
## backend will not be operational
|
## backend will not be operational
|
||||||
backend-qt = ["slint-backend-selector-internal/slint-backend-qt-internal", "std"]
|
backend-qt = ["i-slint-backend-selector/i-slint-backend-qt", "std"]
|
||||||
|
|
||||||
## The GL backend uses the `winit` crate for the windowing system integration,
|
## The GL backend uses the `winit` crate for the windowing system integration,
|
||||||
## and the `femtovg` crate for the rendering.
|
## and the `femtovg` crate for the rendering.
|
||||||
## On unix, at least one of `x11` or `wayland` features must be enabled.
|
## On unix, at least one of `x11` or `wayland` features must be enabled.
|
||||||
backend-gl = ["slint-backend-selector-internal/slint-backend-gl-internal", "std"]
|
backend-gl = ["i-slint-backend-selector/i-slint-backend-gl", "std"]
|
||||||
## Same as the GL backend, with the `x11` feature of `winit` enabled
|
## Same as the GL backend, with the `x11` feature of `winit` enabled
|
||||||
x11 = ["slint-backend-selector-internal/x11", "backend-gl"]
|
x11 = ["i-slint-backend-selector/x11", "backend-gl"]
|
||||||
## Same as the GL backend, with the `wayland` feature of `winit` enabled
|
## Same as the GL backend, with the `wayland` feature of `winit` enabled
|
||||||
wayland = ["slint-backend-selector-internal/wayland", "backend-gl"]
|
wayland = ["i-slint-backend-selector/wayland", "backend-gl"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-core-internal = { version = "=0.2.0", path="../../../internal/core", default-features = false }
|
i-slint-core = { version = "=0.2.0", path="../../../internal/core", default-features = false }
|
||||||
slint-macros = { version = "=0.2.0", path = "../macros" }
|
slint-macros = { version = "=0.2.0", path = "../macros" }
|
||||||
slint-backend-selector-internal = { version = "=0.2.0", path="../../../internal/backends/selector" }
|
i-slint-backend-selector = { version = "=0.2.0", path="../../../internal/backends/selector" }
|
||||||
|
|
||||||
const-field-offset = { version = "0.1.2", path = "../../../helper_crates/const-field-offset" }
|
const-field-offset = { version = "0.1.2", path = "../../../helper_crates/const-field-offset" }
|
||||||
document-features = "0.1.0"
|
document-features = "0.1.0"
|
||||||
|
|
|
@ -237,16 +237,16 @@ compile_error!(
|
||||||
|
|
||||||
pub use slint_macros::slint;
|
pub use slint_macros::slint;
|
||||||
|
|
||||||
pub use slint_core_internal::api::*;
|
pub use i_slint_core::api::*;
|
||||||
pub use slint_core_internal::graphics::{
|
pub use i_slint_core::graphics::{
|
||||||
Brush, Color, Image, LoadImageError, Rgb8Pixel, Rgba8Pixel, RgbaColor, SharedPixelBuffer,
|
Brush, Color, Image, LoadImageError, Rgb8Pixel, Rgba8Pixel, RgbaColor, SharedPixelBuffer,
|
||||||
};
|
};
|
||||||
pub use slint_core_internal::model::{
|
pub use i_slint_core::model::{
|
||||||
Model, ModelNotify, ModelPeer, ModelRc, ModelTracker, StandardListViewItem, VecModel,
|
Model, ModelNotify, ModelPeer, ModelRc, ModelTracker, StandardListViewItem, VecModel,
|
||||||
};
|
};
|
||||||
pub use slint_core_internal::sharedvector::SharedVector;
|
pub use i_slint_core::sharedvector::SharedVector;
|
||||||
pub use slint_core_internal::string::SharedString;
|
pub use i_slint_core::string::SharedString;
|
||||||
pub use slint_core_internal::timers::{Timer, TimerMode};
|
pub use i_slint_core::timers::{Timer, TimerMode};
|
||||||
|
|
||||||
/// This function can be used to register a custom TrueType font with Slint,
|
/// This function can be used to register a custom TrueType font with Slint,
|
||||||
/// for use with the `font-family` property. The provided slice must be a valid TrueType
|
/// for use with the `font-family` property. The provided slice must be a valid TrueType
|
||||||
|
@ -254,7 +254,7 @@ pub use slint_core_internal::timers::{Timer, TimerMode};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub fn register_font_from_memory(data: &'static [u8]) -> Result<(), Box<dyn std::error::Error>> {
|
pub fn register_font_from_memory(data: &'static [u8]) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
slint_backend_selector_internal::backend().register_font_from_memory(data)
|
i_slint_backend_selector::backend().register_font_from_memory(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function can be used to register a custom TrueType font with Slint,
|
/// This function can be used to register a custom TrueType font with Slint,
|
||||||
|
@ -265,7 +265,7 @@ pub fn register_font_from_memory(data: &'static [u8]) -> Result<(), Box<dyn std:
|
||||||
pub fn register_font_from_path<P: AsRef<std::path::Path>>(
|
pub fn register_font_from_path<P: AsRef<std::path::Path>>(
|
||||||
path: P,
|
path: P,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
slint_backend_selector_internal::backend().register_font_from_path(path.as_ref())
|
i_slint_backend_selector::backend().register_font_from_path(path.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// internal re_exports used by the macro generated
|
/// internal re_exports used by the macro generated
|
||||||
|
@ -278,36 +278,34 @@ pub mod re_exports {
|
||||||
pub use alloc::{vec, vec::Vec};
|
pub use alloc::{vec, vec::Vec};
|
||||||
pub use const_field_offset::{self, FieldOffsets, PinnedDrop};
|
pub use const_field_offset::{self, FieldOffsets, PinnedDrop};
|
||||||
pub use core::iter::FromIterator;
|
pub use core::iter::FromIterator;
|
||||||
pub use once_cell::race::OnceBox;
|
pub use i_slint_backend_selector::native_widgets::*;
|
||||||
pub use once_cell::unsync::OnceCell;
|
pub use i_slint_core::animations::EasingCurve;
|
||||||
pub use pin_weak::rc::PinWeak;
|
pub use i_slint_core::callbacks::Callback;
|
||||||
pub use slint_backend_selector_internal::native_widgets::*;
|
pub use i_slint_core::component::{
|
||||||
pub use slint_core_internal::animations::EasingCurve;
|
|
||||||
pub use slint_core_internal::callbacks::Callback;
|
|
||||||
pub use slint_core_internal::component::{
|
|
||||||
free_component_item_graphics_resources, init_component_items, Component, ComponentRefPin,
|
free_component_item_graphics_resources, init_component_items, Component, ComponentRefPin,
|
||||||
ComponentVTable,
|
ComponentVTable,
|
||||||
};
|
};
|
||||||
pub use slint_core_internal::graphics::*;
|
pub use i_slint_core::graphics::*;
|
||||||
pub use slint_core_internal::input::{
|
pub use i_slint_core::input::{
|
||||||
FocusEvent, InputEventResult, KeyEvent, KeyEventResult, KeyboardModifiers, MouseEvent,
|
FocusEvent, InputEventResult, KeyEvent, KeyEventResult, KeyboardModifiers, MouseEvent,
|
||||||
};
|
};
|
||||||
pub use slint_core_internal::item_tree::{
|
pub use i_slint_core::item_tree::{
|
||||||
visit_item_tree, ItemTreeNode, ItemVisitorRefMut, ItemVisitorVTable, TraversalOrder,
|
visit_item_tree, ItemTreeNode, ItemVisitorRefMut, ItemVisitorVTable, TraversalOrder,
|
||||||
VisitChildrenResult,
|
VisitChildrenResult,
|
||||||
};
|
};
|
||||||
pub use slint_core_internal::items::*;
|
pub use i_slint_core::items::*;
|
||||||
pub use slint_core_internal::layout::*;
|
pub use i_slint_core::layout::*;
|
||||||
pub use slint_core_internal::model::*;
|
pub use i_slint_core::model::*;
|
||||||
pub use slint_core_internal::properties::{
|
pub use i_slint_core::properties::{set_state_binding, Property, PropertyTracker, StateInfo};
|
||||||
set_state_binding, Property, PropertyTracker, StateInfo,
|
pub use i_slint_core::slice::Slice;
|
||||||
};
|
pub use i_slint_core::window::{Window, WindowHandleAccess, WindowRc};
|
||||||
pub use slint_core_internal::slice::Slice;
|
pub use i_slint_core::Color;
|
||||||
pub use slint_core_internal::window::{Window, WindowHandleAccess, WindowRc};
|
pub use i_slint_core::ComponentVTable_static;
|
||||||
pub use slint_core_internal::Color;
|
pub use i_slint_core::SharedString;
|
||||||
pub use slint_core_internal::ComponentVTable_static;
|
pub use i_slint_core::SharedVector;
|
||||||
pub use slint_core_internal::SharedString;
|
pub use once_cell::race::OnceBox;
|
||||||
pub use slint_core_internal::SharedVector;
|
pub use once_cell::unsync::OnceCell;
|
||||||
|
pub use pin_weak::rc::PinWeak;
|
||||||
pub use vtable::{self, *};
|
pub use vtable::{self, *};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +367,7 @@ pub mod internal {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_animated_property_binding<
|
pub fn set_animated_property_binding<
|
||||||
T: Clone + slint_core_internal::properties::InterpolatedPropertyValue + 'static,
|
T: Clone + i_slint_core::properties::InterpolatedPropertyValue + 'static,
|
||||||
StrongRef: StrongComponentRef + 'static,
|
StrongRef: StrongComponentRef + 'static,
|
||||||
>(
|
>(
|
||||||
property: Pin<&Property<T>>,
|
property: Pin<&Property<T>>,
|
||||||
|
@ -385,7 +383,7 @@ pub mod internal {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_animated_property_binding_for_transition<
|
pub fn set_animated_property_binding_for_transition<
|
||||||
T: Clone + slint_core_internal::properties::InterpolatedPropertyValue + 'static,
|
T: Clone + i_slint_core::properties::InterpolatedPropertyValue + 'static,
|
||||||
StrongRef: StrongComponentRef + 'static,
|
StrongRef: StrongComponentRef + 'static,
|
||||||
>(
|
>(
|
||||||
property: Pin<&Property<T>>,
|
property: Pin<&Property<T>>,
|
||||||
|
@ -393,10 +391,8 @@ pub mod internal {
|
||||||
binding: fn(StrongRef) -> T,
|
binding: fn(StrongRef) -> T,
|
||||||
compute_animation_details: fn(
|
compute_animation_details: fn(
|
||||||
StrongRef,
|
StrongRef,
|
||||||
) -> (
|
)
|
||||||
PropertyAnimation,
|
-> (PropertyAnimation, i_slint_core::animations::Instant),
|
||||||
slint_core_internal::animations::Instant,
|
|
||||||
),
|
|
||||||
) {
|
) {
|
||||||
let weak_1 = component_strong.to_weak();
|
let weak_1 = component_strong.to_weak();
|
||||||
let weak_2 = weak_1.clone();
|
let weak_2 = weak_1.clone();
|
||||||
|
@ -440,23 +436,22 @@ pub mod internal {
|
||||||
/// Creates a new window to render components in.
|
/// Creates a new window to render components in.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn create_window() -> re_exports::WindowRc {
|
pub fn create_window() -> re_exports::WindowRc {
|
||||||
slint_backend_selector_internal::backend().create_window()
|
i_slint_backend_selector::backend().create_window()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enters the main event loop. This is necessary in order to receive
|
/// Enters the main event loop. This is necessary in order to receive
|
||||||
/// events from the windowing system in order to render to the screen
|
/// events from the windowing system in order to render to the screen
|
||||||
/// and react to user input.
|
/// and react to user input.
|
||||||
pub fn run_event_loop() {
|
pub fn run_event_loop() {
|
||||||
slint_backend_selector_internal::backend().run_event_loop(
|
i_slint_backend_selector::backend()
|
||||||
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed,
|
.run_event_loop(i_slint_core::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
/// Schedules the main event loop for termination. This function is meant
|
/// Schedules the main event loop for termination. This function is meant
|
||||||
/// to be called from callbacks triggered by the UI. After calling the function,
|
/// 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,
|
/// it will return immediately and once control is passed back to the event loop,
|
||||||
/// the initial call to [`run_event_loop()`] will return.
|
/// the initial call to [`run_event_loop()`] will return.
|
||||||
pub fn quit_event_loop() {
|
pub fn quit_event_loop() {
|
||||||
slint_backend_selector_internal::backend().quit_event_loop();
|
i_slint_backend_selector::backend().quit_event_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This module contains functions useful for unit tests
|
/// This module contains functions useful for unit tests
|
||||||
|
@ -467,14 +462,14 @@ pub mod testing {
|
||||||
|
|
||||||
use super::ComponentHandle;
|
use super::ComponentHandle;
|
||||||
|
|
||||||
pub use slint_core_internal::tests::slint_mock_elapsed_time as mock_elapsed_time;
|
pub use i_slint_core::tests::slint_mock_elapsed_time as mock_elapsed_time;
|
||||||
|
|
||||||
/// Simulate a mouse click
|
/// Simulate a mouse click
|
||||||
pub fn send_mouse_click<
|
pub fn send_mouse_click<
|
||||||
X: vtable::HasStaticVTable<slint_core_internal::component::ComponentVTable>
|
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>
|
||||||
+ crate::re_exports::WindowHandleAccess
|
+ crate::re_exports::WindowHandleAccess
|
||||||
+ 'static,
|
+ 'static,
|
||||||
Component: Into<vtable::VRc<slint_core_internal::component::ComponentVTable, X>> + ComponentHandle,
|
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||||
>(
|
>(
|
||||||
component: &Component,
|
component: &Component,
|
||||||
x: f32,
|
x: f32,
|
||||||
|
@ -482,19 +477,14 @@ pub mod testing {
|
||||||
) {
|
) {
|
||||||
let rc = component.clone_strong().into();
|
let rc = component.clone_strong().into();
|
||||||
let dyn_rc = vtable::VRc::into_dyn(rc.clone());
|
let dyn_rc = vtable::VRc::into_dyn(rc.clone());
|
||||||
slint_core_internal::tests::slint_send_mouse_click(
|
i_slint_core::tests::slint_send_mouse_click(&dyn_rc, x, y, &rc.window_handle().clone());
|
||||||
&dyn_rc,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
&rc.window_handle().clone(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Simulate a change in keyboard modifiers being pressed
|
/// Simulate a change in keyboard modifiers being pressed
|
||||||
pub fn set_current_keyboard_modifiers<
|
pub fn set_current_keyboard_modifiers<
|
||||||
X: vtable::HasStaticVTable<slint_core_internal::component::ComponentVTable>
|
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>
|
||||||
+ crate::re_exports::WindowHandleAccess,
|
+ crate::re_exports::WindowHandleAccess,
|
||||||
Component: Into<vtable::VRc<slint_core_internal::component::ComponentVTable, X>> + ComponentHandle,
|
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||||
>(
|
>(
|
||||||
_component: &Component,
|
_component: &Component,
|
||||||
modifiers: crate::re_exports::KeyboardModifiers,
|
modifiers: crate::re_exports::KeyboardModifiers,
|
||||||
|
@ -504,15 +494,15 @@ pub mod testing {
|
||||||
|
|
||||||
/// Simulate entering a sequence of ascii characters key by key.
|
/// Simulate entering a sequence of ascii characters key by key.
|
||||||
pub fn send_keyboard_string_sequence<
|
pub fn send_keyboard_string_sequence<
|
||||||
X: vtable::HasStaticVTable<slint_core_internal::component::ComponentVTable>
|
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>
|
||||||
+ crate::re_exports::WindowHandleAccess,
|
+ crate::re_exports::WindowHandleAccess,
|
||||||
Component: Into<vtable::VRc<slint_core_internal::component::ComponentVTable, X>> + ComponentHandle,
|
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||||
>(
|
>(
|
||||||
component: &Component,
|
component: &Component,
|
||||||
sequence: &str,
|
sequence: &str,
|
||||||
) {
|
) {
|
||||||
let component = component.clone_strong().into();
|
let component = component.clone_strong().into();
|
||||||
slint_core_internal::tests::send_keyboard_string_sequence(
|
i_slint_core::tests::send_keyboard_string_sequence(
|
||||||
&super::SharedString::from(sequence),
|
&super::SharedString::from(sequence),
|
||||||
KEYBOARD_MODIFIERS.with(|x| x.get()),
|
KEYBOARD_MODIFIERS.with(|x| x.get()),
|
||||||
&component.window_handle().clone(),
|
&component.window_handle().clone(),
|
||||||
|
@ -522,9 +512,9 @@ pub mod testing {
|
||||||
/// Applies the specified scale factor to the window that's associated with the given component.
|
/// Applies the specified scale factor to the window that's associated with the given component.
|
||||||
/// This overrides the value provided by the windowing system.
|
/// This overrides the value provided by the windowing system.
|
||||||
pub fn set_window_scale_factor<
|
pub fn set_window_scale_factor<
|
||||||
X: vtable::HasStaticVTable<slint_core_internal::component::ComponentVTable>
|
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>
|
||||||
+ crate::re_exports::WindowHandleAccess,
|
+ crate::re_exports::WindowHandleAccess,
|
||||||
Component: Into<vtable::VRc<slint_core_internal::component::ComponentVTable, X>> + ComponentHandle,
|
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||||
>(
|
>(
|
||||||
component: &Component,
|
component: &Component,
|
||||||
factor: f32,
|
factor: f32,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-backend-gl-internal"
|
name = "i-slint-backend-gl"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
@ -24,8 +24,8 @@ x11 = ["winit/x11", "glutin/x11", "copypasta/x11"]
|
||||||
default = ["svg"]
|
default = ["svg"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-core-internal = { version = "=0.2.0", path = "../../../internal/core" }
|
i-slint-core = { version = "=0.2.0", path = "../../../internal/core" }
|
||||||
slint-common-internal = { version = "=0.2.0", path = "../../../internal/common" }
|
i-slint-common = { version = "=0.2.0", path = "../../../internal/common" }
|
||||||
|
|
||||||
const-field-offset = { version = "0.1", path = "../../../helper_crates/const-field-offset" }
|
const-field-offset = { version = "0.1", path = "../../../helper_crates/const-field-offset" }
|
||||||
vtable = { version = "0.1", path = "../../../helper_crates/vtable" }
|
vtable = { version = "0.1", path = "../../../helper_crates/vtable" }
|
||||||
|
|
6
internal/backends/gl/README.md
Normal file
6
internal/backends/gl/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -10,7 +10,7 @@
|
||||||
use corelib::component::ComponentRc;
|
use corelib::component::ComponentRc;
|
||||||
use corelib::items::PointerEventButton;
|
use corelib::items::PointerEventButton;
|
||||||
use corelib::layout::Orientation;
|
use corelib::layout::Orientation;
|
||||||
use slint_core_internal as corelib;
|
use i_slint_core as corelib;
|
||||||
|
|
||||||
use corelib::graphics::Point;
|
use corelib::graphics::Point;
|
||||||
use corelib::input::{KeyEvent, KeyEventType, KeyboardModifiers, MouseEvent};
|
use corelib::input::{KeyEvent, KeyEventType, KeyboardModifiers, MouseEvent};
|
||||||
|
@ -99,7 +99,7 @@ pub trait WinitWindow: PlatformWindow {
|
||||||
|
|
||||||
fn apply_window_properties(
|
fn apply_window_properties(
|
||||||
&self,
|
&self,
|
||||||
window_item: core::pin::Pin<&slint_core_internal::items::WindowItem>,
|
window_item: core::pin::Pin<&i_slint_core::items::WindowItem>,
|
||||||
) {
|
) {
|
||||||
let background = window_item.background();
|
let background = window_item.background();
|
||||||
let title = window_item.title();
|
let title = window_item.title();
|
||||||
|
@ -330,23 +330,23 @@ fn redraw_all_windows() {
|
||||||
mod key_codes {
|
mod key_codes {
|
||||||
macro_rules! winit_key_to_string_fn {
|
macro_rules! winit_key_to_string_fn {
|
||||||
($($char:literal # $name:ident # $($_qt:ident)|* # $($winit:ident)|* ;)*) => {
|
($($char:literal # $name:ident # $($_qt:ident)|* # $($winit:ident)|* ;)*) => {
|
||||||
pub fn winit_key_to_string(virtual_keycode: winit::event::VirtualKeyCode) -> Option<slint_core_internal::SharedString> {
|
pub fn winit_key_to_string(virtual_keycode: winit::event::VirtualKeyCode) -> Option<i_slint_core::SharedString> {
|
||||||
let char = match(virtual_keycode) {
|
let char = match(virtual_keycode) {
|
||||||
$($(winit::event::VirtualKeyCode::$winit => $char,)*)*
|
$($(winit::event::VirtualKeyCode::$winit => $char,)*)*
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
let mut buffer = [0; 6];
|
let mut buffer = [0; 6];
|
||||||
Some(slint_core_internal::SharedString::from(char.encode_utf8(&mut buffer) as &str))
|
Some(i_slint_core::SharedString::from(char.encode_utf8(&mut buffer) as &str))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
slint_common_internal::for_each_special_keys!(winit_key_to_string_fn);
|
i_slint_common::for_each_special_keys!(winit_key_to_string_fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_window_event(
|
fn process_window_event(
|
||||||
window: Rc<dyn WinitWindow>,
|
window: Rc<dyn WinitWindow>,
|
||||||
event: WindowEvent,
|
event: WindowEvent,
|
||||||
quit_behavior: slint_core_internal::backend::EventLoopQuitBehavior,
|
quit_behavior: i_slint_core::backend::EventLoopQuitBehavior,
|
||||||
control_flow: &mut winit::event_loop::ControlFlow,
|
control_flow: &mut winit::event_loop::ControlFlow,
|
||||||
cursor_pos: &mut Point,
|
cursor_pos: &mut Point,
|
||||||
pressed: &mut bool,
|
pressed: &mut bool,
|
||||||
|
@ -523,7 +523,7 @@ fn process_window_event(
|
||||||
/// Runs the event loop and renders the items in the provided `component` in its
|
/// Runs the event loop and renders the items in the provided `component` in its
|
||||||
/// own window.
|
/// own window.
|
||||||
#[allow(unused_mut)] // mut need changes for wasm
|
#[allow(unused_mut)] // mut need changes for wasm
|
||||||
pub fn run(quit_behavior: slint_core_internal::backend::EventLoopQuitBehavior) {
|
pub fn run(quit_behavior: i_slint_core::backend::EventLoopQuitBehavior) {
|
||||||
use winit::event::Event;
|
use winit::event::Event;
|
||||||
use winit::event_loop::{ControlFlow, EventLoopWindowTarget};
|
use winit::event_loop::{ControlFlow, EventLoopWindowTarget};
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
use femtovg::TextContext;
|
use femtovg::TextContext;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use font_kit::loader::Loader;
|
use font_kit::loader::Loader;
|
||||||
use slint_core_internal::graphics::{FontRequest, Point, Size};
|
use i_slint_core::graphics::{FontRequest, Point, Size};
|
||||||
use slint_core_internal::items::{
|
use i_slint_core::items::{TextHorizontalAlignment, TextOverflow, TextVerticalAlignment, TextWrap};
|
||||||
TextHorizontalAlignment, TextOverflow, TextVerticalAlignment, TextWrap,
|
use i_slint_core::{SharedString, SharedVector};
|
||||||
};
|
|
||||||
use slint_core_internal::{SharedString, SharedVector};
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
|
@ -119,7 +117,7 @@ impl Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn text_size(
|
pub(crate) fn text_size(
|
||||||
font_request: &slint_core_internal::graphics::FontRequest,
|
font_request: &i_slint_core::graphics::FontRequest,
|
||||||
scale_factor: f32,
|
scale_factor: f32,
|
||||||
text: &str,
|
text: &str,
|
||||||
max_width: Option<f32>,
|
max_width: Option<f32>,
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl OpenGLContext {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
match &self.0.borrow().as_ref().unwrap() {
|
match &self.0.borrow().as_ref().unwrap() {
|
||||||
OpenGLContextState::NotCurrent(_) => {
|
OpenGLContextState::NotCurrent(_) => {
|
||||||
slint_core_internal::debug_log!("internal error: cannot call OpenGLContext::ensure_resized without context being current!")
|
i_slint_core::debug_log!("internal error: cannot call OpenGLContext::ensure_resized without context being current!")
|
||||||
}
|
}
|
||||||
OpenGLContextState::Current(_current) => {
|
OpenGLContextState::Current(_current) => {
|
||||||
_current.resize(_current.window().inner_size());
|
_current.resize(_current.window().inner_size());
|
||||||
|
|
|
@ -21,7 +21,7 @@ use corelib::items::{ItemRef, MouseCursor};
|
||||||
use corelib::layout::Orientation;
|
use corelib::layout::Orientation;
|
||||||
use corelib::window::{PlatformWindow, PopupWindow, PopupWindowLocation};
|
use corelib::window::{PlatformWindow, PopupWindow, PopupWindowLocation};
|
||||||
use corelib::Property;
|
use corelib::Property;
|
||||||
use slint_core_internal as corelib;
|
use i_slint_core as corelib;
|
||||||
use winit::dpi::LogicalSize;
|
use winit::dpi::LogicalSize;
|
||||||
|
|
||||||
use crate::CanvasRc;
|
use crate::CanvasRc;
|
||||||
|
@ -360,7 +360,7 @@ impl PlatformWindow for GLWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_window_properties(&self, window_item: Pin<&slint_core_internal::items::WindowItem>) {
|
fn apply_window_properties(&self, window_item: Pin<&i_slint_core::items::WindowItem>) {
|
||||||
// Make the unwrap() calls on self.borrow_mapped_window*() safe
|
// Make the unwrap() calls on self.borrow_mapped_window*() safe
|
||||||
if !self.is_mapped() {
|
if !self.is_mapped() {
|
||||||
return;
|
return;
|
||||||
|
@ -574,7 +574,7 @@ impl PlatformWindow for GLWindow {
|
||||||
|
|
||||||
fn text_input_byte_offset_for_position(
|
fn text_input_byte_offset_for_position(
|
||||||
&self,
|
&self,
|
||||||
text_input: Pin<&slint_core_internal::items::TextInput>,
|
text_input: Pin<&i_slint_core::items::TextInput>,
|
||||||
pos: Point,
|
pos: Point,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
let scale_factor = self.self_weak.upgrade().unwrap().scale_factor();
|
let scale_factor = self.self_weak.upgrade().unwrap().scale_factor();
|
||||||
|
@ -607,7 +607,7 @@ impl PlatformWindow for GLWindow {
|
||||||
Size::new(width, height),
|
Size::new(width, height),
|
||||||
(text_input.horizontal_alignment(), text_input.vertical_alignment()),
|
(text_input.horizontal_alignment(), text_input.vertical_alignment()),
|
||||||
text_input.wrap(),
|
text_input.wrap(),
|
||||||
slint_core_internal::items::TextOverflow::clip,
|
i_slint_core::items::TextOverflow::clip,
|
||||||
text_input.single_line(),
|
text_input.single_line(),
|
||||||
paint,
|
paint,
|
||||||
|line_text, line_pos, start, metrics| {
|
|line_text, line_pos, start, metrics| {
|
||||||
|
@ -659,7 +659,7 @@ impl PlatformWindow for GLWindow {
|
||||||
Size::new(width, height),
|
Size::new(width, height),
|
||||||
(text_input.horizontal_alignment(), text_input.vertical_alignment()),
|
(text_input.horizontal_alignment(), text_input.vertical_alignment()),
|
||||||
text_input.wrap(),
|
text_input.wrap(),
|
||||||
slint_core_internal::items::TextOverflow::clip,
|
i_slint_core::items::TextOverflow::clip,
|
||||||
text_input.single_line(),
|
text_input.single_line(),
|
||||||
paint,
|
paint,
|
||||||
|line_text, line_pos, start, metrics| {
|
|line_text, line_pos, start, metrics| {
|
||||||
|
|
|
@ -5,10 +5,10 @@ use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use slint_core_internal::graphics::{IntSize, SharedImageBuffer};
|
use i_slint_core::graphics::{IntSize, SharedImageBuffer};
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use slint_core_internal::Property;
|
use i_slint_core::Property;
|
||||||
use slint_core_internal::{items::ImageRendering, slice::Slice, ImageInner, SharedString};
|
use i_slint_core::{items::ImageRendering, slice::Slice, ImageInner, SharedString};
|
||||||
|
|
||||||
use super::{CanvasRc, GLItemRenderer};
|
use super::{CanvasRc, GLItemRenderer};
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -19,13 +10,13 @@ use std::rc::Rc;
|
||||||
|
|
||||||
use euclid::approxeq::ApproxEq;
|
use euclid::approxeq::ApproxEq;
|
||||||
use event_loop::WinitWindow;
|
use event_loop::WinitWindow;
|
||||||
use slint_core_internal::graphics::{
|
use i_slint_core::graphics::{
|
||||||
Brush, Color, Image, ImageInner, IntRect, IntSize, Point, Rect, RenderingCache, Size,
|
Brush, Color, Image, ImageInner, IntRect, IntSize, Point, Rect, RenderingCache, Size,
|
||||||
};
|
};
|
||||||
use slint_core_internal::item_rendering::{CachedRenderingData, ItemRenderer};
|
use i_slint_core::item_rendering::{CachedRenderingData, ItemRenderer};
|
||||||
use slint_core_internal::items::{FillRule, ImageFit, ImageRendering};
|
use i_slint_core::items::{FillRule, ImageFit, ImageRendering};
|
||||||
use slint_core_internal::properties::Property;
|
use i_slint_core::properties::Property;
|
||||||
use slint_core_internal::window::{Window, WindowRc};
|
use i_slint_core::window::{Window, WindowRc};
|
||||||
|
|
||||||
mod glwindow;
|
mod glwindow;
|
||||||
use glwindow::*;
|
use glwindow::*;
|
||||||
|
@ -125,13 +116,13 @@ fn adjust_rect_and_border_for_inner_drawing(rect: &mut Rect, border_width: &mut
|
||||||
rect.size.height -= *border_width;
|
rect.size.height -= *border_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_rect<Item: slint_core_internal::items::Item>(item: Pin<&Item>, scale_factor: f32) -> Rect {
|
fn item_rect<Item: i_slint_core::items::Item>(item: Pin<&Item>, scale_factor: f32) -> Rect {
|
||||||
let geometry = item.geometry();
|
let geometry = item.geometry();
|
||||||
euclid::rect(0., 0., geometry.width() * scale_factor, geometry.height() * scale_factor)
|
euclid::rect(0., 0., geometry.width() * scale_factor, geometry.height() * scale_factor)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemRenderer for GLItemRenderer {
|
impl ItemRenderer for GLItemRenderer {
|
||||||
fn draw_rectangle(&mut self, rect: std::pin::Pin<&slint_core_internal::items::Rectangle>) {
|
fn draw_rectangle(&mut self, rect: std::pin::Pin<&i_slint_core::items::Rectangle>) {
|
||||||
let geometry = item_rect(rect, self.scale_factor);
|
let geometry = item_rect(rect, self.scale_factor);
|
||||||
if geometry.is_empty() {
|
if geometry.is_empty() {
|
||||||
return;
|
return;
|
||||||
|
@ -147,7 +138,7 @@ impl ItemRenderer for GLItemRenderer {
|
||||||
|
|
||||||
fn draw_border_rectangle(
|
fn draw_border_rectangle(
|
||||||
&mut self,
|
&mut self,
|
||||||
rect: std::pin::Pin<&slint_core_internal::items::BorderRectangle>,
|
rect: std::pin::Pin<&i_slint_core::items::BorderRectangle>,
|
||||||
) {
|
) {
|
||||||
let mut geometry = item_rect(rect, self.scale_factor);
|
let mut geometry = item_rect(rect, self.scale_factor);
|
||||||
if geometry.is_empty() {
|
if geometry.is_empty() {
|
||||||
|
@ -179,13 +170,13 @@ impl ItemRenderer for GLItemRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_image(&mut self, image: std::pin::Pin<&slint_core_internal::items::ImageItem>) {
|
fn draw_image(&mut self, image: std::pin::Pin<&i_slint_core::items::ImageItem>) {
|
||||||
self.draw_image_impl(
|
self.draw_image_impl(
|
||||||
&image.cached_rendering_data,
|
&image.cached_rendering_data,
|
||||||
slint_core_internal::items::ImageItem::FIELD_OFFSETS.source.apply_pin(image),
|
i_slint_core::items::ImageItem::FIELD_OFFSETS.source.apply_pin(image),
|
||||||
IntRect::default(),
|
IntRect::default(),
|
||||||
slint_core_internal::items::ImageItem::FIELD_OFFSETS.width.apply_pin(image),
|
i_slint_core::items::ImageItem::FIELD_OFFSETS.width.apply_pin(image),
|
||||||
slint_core_internal::items::ImageItem::FIELD_OFFSETS.height.apply_pin(image),
|
i_slint_core::items::ImageItem::FIELD_OFFSETS.height.apply_pin(image),
|
||||||
image.image_fit(),
|
image.image_fit(),
|
||||||
None,
|
None,
|
||||||
image.image_rendering(),
|
image.image_rendering(),
|
||||||
|
@ -194,7 +185,7 @@ impl ItemRenderer for GLItemRenderer {
|
||||||
|
|
||||||
fn draw_clipped_image(
|
fn draw_clipped_image(
|
||||||
&mut self,
|
&mut self,
|
||||||
clipped_image: std::pin::Pin<&slint_core_internal::items::ClippedImage>,
|
clipped_image: std::pin::Pin<&i_slint_core::items::ClippedImage>,
|
||||||
) {
|
) {
|
||||||
let source_clip_rect = IntRect::new(
|
let source_clip_rect = IntRect::new(
|
||||||
[clipped_image.source_clip_x(), clipped_image.source_clip_y()].into(),
|
[clipped_image.source_clip_x(), clipped_image.source_clip_y()].into(),
|
||||||
|
@ -203,21 +194,19 @@ impl ItemRenderer for GLItemRenderer {
|
||||||
|
|
||||||
self.draw_image_impl(
|
self.draw_image_impl(
|
||||||
&clipped_image.cached_rendering_data,
|
&clipped_image.cached_rendering_data,
|
||||||
slint_core_internal::items::ClippedImage::FIELD_OFFSETS.source.apply_pin(clipped_image),
|
i_slint_core::items::ClippedImage::FIELD_OFFSETS.source.apply_pin(clipped_image),
|
||||||
source_clip_rect,
|
source_clip_rect,
|
||||||
slint_core_internal::items::ClippedImage::FIELD_OFFSETS.width.apply_pin(clipped_image),
|
i_slint_core::items::ClippedImage::FIELD_OFFSETS.width.apply_pin(clipped_image),
|
||||||
slint_core_internal::items::ClippedImage::FIELD_OFFSETS.height.apply_pin(clipped_image),
|
i_slint_core::items::ClippedImage::FIELD_OFFSETS.height.apply_pin(clipped_image),
|
||||||
clipped_image.image_fit(),
|
clipped_image.image_fit(),
|
||||||
Some(
|
Some(
|
||||||
slint_core_internal::items::ClippedImage::FIELD_OFFSETS
|
i_slint_core::items::ClippedImage::FIELD_OFFSETS.colorize.apply_pin(clipped_image),
|
||||||
.colorize
|
|
||||||
.apply_pin(clipped_image),
|
|
||||||
),
|
),
|
||||||
clipped_image.image_rendering(),
|
clipped_image.image_rendering(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text(&mut self, text: std::pin::Pin<&slint_core_internal::items::Text>) {
|
fn draw_text(&mut self, text: std::pin::Pin<&i_slint_core::items::Text>) {
|
||||||
let max_width = text.width() * self.scale_factor;
|
let max_width = text.width() * self.scale_factor;
|
||||||
let max_height = text.height() * self.scale_factor;
|
let max_height = text.height() * self.scale_factor;
|
||||||
|
|
||||||
|
@ -259,10 +248,7 @@ impl ItemRenderer for GLItemRenderer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text_input(
|
fn draw_text_input(&mut self, text_input: std::pin::Pin<&i_slint_core::items::TextInput>) {
|
||||||
&mut self,
|
|
||||||
text_input: std::pin::Pin<&slint_core_internal::items::TextInput>,
|
|
||||||
) {
|
|
||||||
let width = text_input.width() * self.scale_factor;
|
let width = text_input.width() * self.scale_factor;
|
||||||
let height = text_input.height() * self.scale_factor;
|
let height = text_input.height() * self.scale_factor;
|
||||||
if width <= 0. || height <= 0. {
|
if width <= 0. || height <= 0. {
|
||||||
|
@ -302,7 +288,7 @@ impl ItemRenderer for GLItemRenderer {
|
||||||
Size::new(width, height),
|
Size::new(width, height),
|
||||||
(text_input.horizontal_alignment(), text_input.vertical_alignment()),
|
(text_input.horizontal_alignment(), text_input.vertical_alignment()),
|
||||||
text_input.wrap(),
|
text_input.wrap(),
|
||||||
slint_core_internal::items::TextOverflow::clip,
|
i_slint_core::items::TextOverflow::clip,
|
||||||
text_input.single_line(),
|
text_input.single_line(),
|
||||||
paint,
|
paint,
|
||||||
|to_draw, pos, start, metrics| {
|
|to_draw, pos, start, metrics| {
|
||||||
|
@ -414,9 +400,9 @@ impl ItemRenderer for GLItemRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_path(&mut self, path: std::pin::Pin<&slint_core_internal::items::Path>) {
|
fn draw_path(&mut self, path: std::pin::Pin<&i_slint_core::items::Path>) {
|
||||||
let elements = path.elements();
|
let elements = path.elements();
|
||||||
if matches!(elements, slint_core_internal::PathData::None) {
|
if matches!(elements, i_slint_core::PathData::None) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,10 +514,7 @@ impl ItemRenderer for GLItemRenderer {
|
||||||
/// * Blur the image
|
/// * Blur the image
|
||||||
/// * Fill the image with the shadow color and SourceIn as composition mode
|
/// * Fill the image with the shadow color and SourceIn as composition mode
|
||||||
/// * Draw the shadow image
|
/// * Draw the shadow image
|
||||||
fn draw_box_shadow(
|
fn draw_box_shadow(&mut self, box_shadow: std::pin::Pin<&i_slint_core::items::BoxShadow>) {
|
||||||
&mut self,
|
|
||||||
box_shadow: std::pin::Pin<&slint_core_internal::items::BoxShadow>,
|
|
||||||
) {
|
|
||||||
if box_shadow.color().alpha() == 0
|
if box_shadow.color().alpha() == 0
|
||||||
|| (box_shadow.blur() == 0.0
|
|| (box_shadow.blur() == 0.0
|
||||||
&& box_shadow.offset_x() == 0.
|
&& box_shadow.offset_x() == 0.
|
||||||
|
@ -1080,7 +1063,7 @@ impl GLItemRenderer {
|
||||||
let transform = euclid::Transform2D::scale(path_width, path_height)
|
let transform = euclid::Transform2D::scale(path_width, path_height)
|
||||||
.then_translate(euclid::Vector2D::new(path_bounds.minx, path_bounds.miny));
|
.then_translate(euclid::Vector2D::new(path_bounds.minx, path_bounds.miny));
|
||||||
|
|
||||||
let (start, end) = slint_core_internal::graphics::line_for_angle(gradient.angle());
|
let (start, end) = i_slint_core::graphics::line_for_angle(gradient.angle());
|
||||||
|
|
||||||
let start: Point = transform.transform_point(start);
|
let start: Point = transform.transform_point(start);
|
||||||
let end: Point = transform.transform_point(end);
|
let end: Point = transform.transform_point(end);
|
||||||
|
@ -1160,7 +1143,7 @@ fn to_femtovg_color(col: &Color) -> femtovg::Color {
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
pub fn create_gl_window_with_canvas_id(canvas_id: String) -> Rc<Window> {
|
pub fn create_gl_window_with_canvas_id(canvas_id: String) -> Rc<Window> {
|
||||||
slint_core_internal::window::Window::new(|window| GLWindow::new(window, canvas_id))
|
i_slint_core::window::Window::new(|window| GLWindow::new(window, canvas_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -1198,9 +1181,9 @@ thread_local!(pub(crate) static CLIPBOARD : RefCell<ClipboardBackend> = std::cel
|
||||||
thread_local!(pub(crate) static IMAGE_CACHE: RefCell<images::ImageCache> = Default::default());
|
thread_local!(pub(crate) static IMAGE_CACHE: RefCell<images::ImageCache> = Default::default());
|
||||||
|
|
||||||
pub struct Backend;
|
pub struct Backend;
|
||||||
impl slint_core_internal::backend::Backend for Backend {
|
impl i_slint_core::backend::Backend for Backend {
|
||||||
fn create_window(&'static self) -> Rc<Window> {
|
fn create_window(&'static self) -> Rc<Window> {
|
||||||
slint_core_internal::window::Window::new(|window| {
|
i_slint_core::window::Window::new(|window| {
|
||||||
GLWindow::new(
|
GLWindow::new(
|
||||||
window,
|
window,
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
@ -1209,10 +1192,7 @@ impl slint_core_internal::backend::Backend for Backend {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_event_loop(
|
fn run_event_loop(&'static self, behavior: i_slint_core::backend::EventLoopQuitBehavior) {
|
||||||
&'static self,
|
|
||||||
behavior: slint_core_internal::backend::EventLoopQuitBehavior,
|
|
||||||
) {
|
|
||||||
crate::event_loop::run(behavior);
|
crate::event_loop::run(behavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-backend-mcu-internal"
|
name = "i-slint-backend-mcu"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
@ -18,18 +18,18 @@ path = "lib.rs"
|
||||||
[features]
|
[features]
|
||||||
simulator = ["winit", "glutin", "femtovg", "embedded-graphics-simulator", "std", "imgref", "scoped-tls-hkt"]
|
simulator = ["winit", "glutin", "femtovg", "embedded-graphics-simulator", "std", "imgref", "scoped-tls-hkt"]
|
||||||
|
|
||||||
pico-st7789 = ["unsafe_single_core", "rp-pico", "embedded-hal", "cortex-m-rt", "alloc-cortex-m", "embedded-time", "cortex-m", "display-interface-spi", "st7789", "defmt", "defmt-rtt", "slint-core-internal/defmt", "shared-bus" ]
|
pico-st7789 = ["unsafe_single_core", "rp-pico", "embedded-hal", "cortex-m-rt", "alloc-cortex-m", "embedded-time", "cortex-m", "display-interface-spi", "st7789", "defmt", "defmt-rtt", "i-slint-core/defmt", "shared-bus" ]
|
||||||
|
|
||||||
unsafe_single_core = ["slint-core-internal/unsafe_single_core"]
|
unsafe_single_core = ["i-slint-core/unsafe_single_core"]
|
||||||
|
|
||||||
snapshot_renderer = []
|
snapshot_renderer = []
|
||||||
std = ["slint-core-internal/std"]
|
std = ["i-slint-core/std"]
|
||||||
|
|
||||||
default = ["simulator"]
|
default = ["simulator"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-common-internal = { version = "=0.2.0", path = "../../../internal/common", default-features = false }
|
i-slint-common = { version = "=0.2.0", path = "../../../internal/common", default-features = false }
|
||||||
slint-core-internal = { version = "=0.2.0", path = "../../../internal/core", default-features = false }
|
i-slint-core = { version = "=0.2.0", path = "../../../internal/core", default-features = false }
|
||||||
|
|
||||||
const-field-offset = { version = "0.1", path = "../../../helper_crates/const-field-offset" }
|
const-field-offset = { version = "0.1", path = "../../../helper_crates/const-field-offset" }
|
||||||
vtable = { version = "0.1", path = "../../../helper_crates/vtable" }
|
vtable = { version = "0.1", path = "../../../helper_crates/vtable" }
|
||||||
|
|
6
internal/backends/mcu/README.md
Normal file
6
internal/backends/mcu/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -1,16 +1,7 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
#![cfg_attr(not(feature = "simulator"), no_std)]
|
#![cfg_attr(not(feature = "simulator"), no_std)]
|
||||||
#![cfg_attr(feature = "pico-st7789", feature(alloc_error_handler))]
|
#![cfg_attr(feature = "pico-st7789", feature(alloc_error_handler))]
|
||||||
|
@ -21,13 +12,13 @@ use alloc::boxed::Box;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use embedded_graphics::pixelcolor::Rgb888;
|
use embedded_graphics::pixelcolor::Rgb888;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
use slint_core_internal::graphics::{IntRect, IntSize};
|
use i_slint_core::graphics::{IntRect, IntSize};
|
||||||
|
|
||||||
#[cfg(all(not(feature = "std"), feature = "unsafe_single_core"))]
|
#[cfg(all(not(feature = "std"), feature = "unsafe_single_core"))]
|
||||||
use slint_core_internal::unsafe_single_core;
|
use i_slint_core::unsafe_single_core;
|
||||||
|
|
||||||
#[cfg(all(not(feature = "std"), feature = "unsafe_single_core"))]
|
#[cfg(all(not(feature = "std"), feature = "unsafe_single_core"))]
|
||||||
use slint_core_internal::thread_local_ as thread_local;
|
use i_slint_core::thread_local_ as thread_local;
|
||||||
|
|
||||||
#[cfg(feature = "simulator")]
|
#[cfg(feature = "simulator")]
|
||||||
mod simulator;
|
mod simulator;
|
||||||
|
@ -40,7 +31,7 @@ mod renderer;
|
||||||
pub trait Devices {
|
pub trait Devices {
|
||||||
fn screen_size(&self) -> IntSize;
|
fn screen_size(&self) -> IntSize;
|
||||||
fn fill_region(&mut self, region: IntRect, pixels: &[Rgb888]);
|
fn fill_region(&mut self, region: IntRect, pixels: &[Rgb888]);
|
||||||
fn read_touch_event(&mut self) -> Option<slint_core_internal::input::MouseEvent> {
|
fn read_touch_event(&mut self) -> Option<i_slint_core::input::MouseEvent> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
fn debug(&mut self, _: &str);
|
fn debug(&mut self, _: &str);
|
||||||
|
@ -54,12 +45,12 @@ where
|
||||||
T::Error: core::fmt::Debug,
|
T::Error: core::fmt::Debug,
|
||||||
T::Color: core::convert::From<embedded_graphics::pixelcolor::Rgb888>,
|
T::Color: core::convert::From<embedded_graphics::pixelcolor::Rgb888>,
|
||||||
{
|
{
|
||||||
fn screen_size(&self) -> slint_core_internal::graphics::IntSize {
|
fn screen_size(&self) -> i_slint_core::graphics::IntSize {
|
||||||
let s = self.bounding_box().size;
|
let s = self.bounding_box().size;
|
||||||
slint_core_internal::graphics::IntSize::new(s.width, s.height)
|
i_slint_core::graphics::IntSize::new(s.width, s.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_region(&mut self, region: slint_core_internal::graphics::IntRect, pixels: &[Rgb888]) {
|
fn fill_region(&mut self, region: i_slint_core::graphics::IntRect, pixels: &[Rgb888]) {
|
||||||
self.color_converted()
|
self.color_converted()
|
||||||
.fill_contiguous(
|
.fill_contiguous(
|
||||||
&embedded_graphics::primitives::Rectangle::new(
|
&embedded_graphics::primitives::Rectangle::new(
|
||||||
|
@ -91,11 +82,11 @@ mod the_backend {
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use core::cell::{Cell, RefCell};
|
use core::cell::{Cell, RefCell};
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use slint_core_internal::component::ComponentRc;
|
use i_slint_core::component::ComponentRc;
|
||||||
use slint_core_internal::graphics::{Color, Point, Size};
|
use i_slint_core::graphics::{Color, Point, Size};
|
||||||
use slint_core_internal::window::PlatformWindow;
|
use i_slint_core::window::PlatformWindow;
|
||||||
use slint_core_internal::window::Window;
|
use i_slint_core::window::Window;
|
||||||
use slint_core_internal::ImageInner;
|
use i_slint_core::ImageInner;
|
||||||
|
|
||||||
thread_local! { static WINDOWS: RefCell<Option<Rc<McuWindow>>> = RefCell::new(None) }
|
thread_local! { static WINDOWS: RefCell<Option<Rc<McuWindow>>> = RefCell::new(None) }
|
||||||
|
|
||||||
|
@ -120,34 +111,27 @@ mod the_backend {
|
||||||
}
|
}
|
||||||
fn free_graphics_resources<'a>(
|
fn free_graphics_resources<'a>(
|
||||||
&self,
|
&self,
|
||||||
_items: &mut dyn Iterator<Item = Pin<slint_core_internal::items::ItemRef<'a>>>,
|
_items: &mut dyn Iterator<Item = Pin<i_slint_core::items::ItemRef<'a>>>,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_popup(
|
fn show_popup(&self, _popup: &ComponentRc, _position: i_slint_core::graphics::Point) {
|
||||||
&self,
|
|
||||||
_popup: &ComponentRc,
|
|
||||||
_position: slint_core_internal::graphics::Point,
|
|
||||||
) {
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
fn request_window_properties_update(&self) {}
|
fn request_window_properties_update(&self) {}
|
||||||
fn apply_window_properties(
|
fn apply_window_properties(&self, window_item: Pin<&i_slint_core::items::WindowItem>) {
|
||||||
&self,
|
|
||||||
window_item: Pin<&slint_core_internal::items::WindowItem>,
|
|
||||||
) {
|
|
||||||
self.background_color.set(window_item.background());
|
self.background_color.set(window_item.background());
|
||||||
}
|
}
|
||||||
fn apply_geometry_constraint(
|
fn apply_geometry_constraint(
|
||||||
&self,
|
&self,
|
||||||
_constraints_horizontal: slint_core_internal::layout::LayoutInfo,
|
_constraints_horizontal: i_slint_core::layout::LayoutInfo,
|
||||||
_constraints_vertical: slint_core_internal::layout::LayoutInfo,
|
_constraints_vertical: i_slint_core::layout::LayoutInfo,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
fn set_mouse_cursor(&self, _cursor: slint_core_internal::items::MouseCursor) {}
|
fn set_mouse_cursor(&self, _cursor: i_slint_core::items::MouseCursor) {}
|
||||||
fn text_size(
|
fn text_size(
|
||||||
&self,
|
&self,
|
||||||
_font_request: slint_core_internal::graphics::FontRequest,
|
_font_request: i_slint_core::graphics::FontRequest,
|
||||||
text: &str,
|
text: &str,
|
||||||
_max_width: Option<f32>,
|
_max_width: Option<f32>,
|
||||||
) -> Size {
|
) -> Size {
|
||||||
|
@ -156,14 +140,14 @@ mod the_backend {
|
||||||
|
|
||||||
fn text_input_byte_offset_for_position(
|
fn text_input_byte_offset_for_position(
|
||||||
&self,
|
&self,
|
||||||
_text_input: Pin<&slint_core_internal::items::TextInput>,
|
_text_input: Pin<&i_slint_core::items::TextInput>,
|
||||||
_pos: Point,
|
_pos: Point,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
fn text_input_position_for_byte_offset(
|
fn text_input_position_for_byte_offset(
|
||||||
&self,
|
&self,
|
||||||
_text_input: Pin<&slint_core_internal::items::TextInput>,
|
_text_input: Pin<&i_slint_core::items::TextInput>,
|
||||||
_byte_offset: usize,
|
_byte_offset: usize,
|
||||||
) -> Point {
|
) -> Point {
|
||||||
Default::default()
|
Default::default()
|
||||||
|
@ -231,9 +215,9 @@ mod the_backend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl slint_core_internal::backend::Backend for MCUBackend {
|
impl i_slint_core::backend::Backend for MCUBackend {
|
||||||
fn create_window(&'static self) -> Rc<slint_core_internal::window::Window> {
|
fn create_window(&'static self) -> Rc<i_slint_core::window::Window> {
|
||||||
slint_core_internal::window::Window::new(|window| {
|
i_slint_core::window::Window::new(|window| {
|
||||||
Rc::new(McuWindow {
|
Rc::new(McuWindow {
|
||||||
backend: self,
|
backend: self,
|
||||||
self_weak: window.clone(),
|
self_weak: window.clone(),
|
||||||
|
@ -242,12 +226,9 @@ mod the_backend {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_event_loop(
|
fn run_event_loop(&'static self, behavior: i_slint_core::backend::EventLoopQuitBehavior) {
|
||||||
&'static self,
|
|
||||||
behavior: slint_core_internal::backend::EventLoopQuitBehavior,
|
|
||||||
) {
|
|
||||||
loop {
|
loop {
|
||||||
slint_core_internal::animations::update_animations();
|
i_slint_core::animations::update_animations();
|
||||||
match self.with_inner(|inner| inner.event_queue.pop_front()) {
|
match self.with_inner(|inner| inner.event_queue.pop_front()) {
|
||||||
Some(McuEvent::Quit) => break,
|
Some(McuEvent::Quit) => break,
|
||||||
Some(McuEvent::Custom(e)) => e(),
|
Some(McuEvent::Custom(e)) => e(),
|
||||||
|
@ -274,12 +255,12 @@ mod the_backend {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
match behavior {
|
match behavior {
|
||||||
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed => {
|
i_slint_core::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed => {
|
||||||
if WINDOWS.with(|x| x.borrow().is_none()) {
|
if WINDOWS.with(|x| x.borrow().is_none()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnlyExplicitly => (),
|
i_slint_core::backend::EventLoopQuitBehavior::QuitOnlyExplicitly => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,8 +284,8 @@ mod the_backend {
|
||||||
|
|
||||||
fn image_size(
|
fn image_size(
|
||||||
&'static self,
|
&'static self,
|
||||||
image: &slint_core_internal::graphics::Image,
|
image: &i_slint_core::graphics::Image,
|
||||||
) -> slint_core_internal::graphics::IntSize {
|
) -> i_slint_core::graphics::IntSize {
|
||||||
let inner: &ImageInner = image.into();
|
let inner: &ImageInner = image.into();
|
||||||
match inner {
|
match inner {
|
||||||
ImageInner::None => Default::default(),
|
ImageInner::None => Default::default(),
|
||||||
|
@ -345,14 +326,12 @@ pub const IS_AVAILABLE: bool = true;
|
||||||
|
|
||||||
#[cfg(feature = "simulator")]
|
#[cfg(feature = "simulator")]
|
||||||
pub fn init_simulator() {
|
pub fn init_simulator() {
|
||||||
slint_core_internal::backend::instance_or_init(|| {
|
i_slint_core::backend::instance_or_init(|| alloc::boxed::Box::new(simulator::SimulatorBackend));
|
||||||
alloc::boxed::Box::new(simulator::SimulatorBackend)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_with_display<Display: Devices + 'static>(display: Display) {
|
pub fn init_with_display<Display: Devices + 'static>(display: Display) {
|
||||||
DEVICES.with(|d| *d.borrow_mut() = Some(Box::new(display)));
|
DEVICES.with(|d| *d.borrow_mut() = Some(Box::new(display)));
|
||||||
slint_core_internal::backend::instance_or_init(|| {
|
i_slint_core::backend::instance_or_init(|| {
|
||||||
alloc::boxed::Box::new(the_backend::MCUBackend::default())
|
alloc::boxed::Box::new(the_backend::MCUBackend::default())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,20 +106,20 @@ pub fn init_board() {
|
||||||
struct PicoDevices<Display, Touch> {
|
struct PicoDevices<Display, Touch> {
|
||||||
display: Display,
|
display: Display,
|
||||||
touch: Touch,
|
touch: Touch,
|
||||||
last_touch: Option<slint_core_internal::graphics::Point>,
|
last_touch: Option<i_slint_core::graphics::Point>,
|
||||||
timer: Timer,
|
timer: Timer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Display: Devices, IRQ: InputPin, CS: OutputPin<Error = IRQ::Error>, SPI: Transfer<u8>> Devices
|
impl<Display: Devices, IRQ: InputPin, CS: OutputPin<Error = IRQ::Error>, SPI: Transfer<u8>> Devices
|
||||||
for PicoDevices<Display, xpt2046::XPT2046<IRQ, CS, SPI>>
|
for PicoDevices<Display, xpt2046::XPT2046<IRQ, CS, SPI>>
|
||||||
{
|
{
|
||||||
fn screen_size(&self) -> slint_core_internal::graphics::IntSize {
|
fn screen_size(&self) -> i_slint_core::graphics::IntSize {
|
||||||
self.display.screen_size()
|
self.display.screen_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_region(
|
fn fill_region(
|
||||||
&mut self,
|
&mut self,
|
||||||
region: slint_core_internal::graphics::IntRect,
|
region: i_slint_core::graphics::IntRect,
|
||||||
pixels: &[embedded_graphics::pixelcolor::Rgb888],
|
pixels: &[embedded_graphics::pixelcolor::Rgb888],
|
||||||
) {
|
) {
|
||||||
self.display.fill_region(region, pixels)
|
self.display.fill_region(region, pixels)
|
||||||
|
@ -129,8 +129,8 @@ impl<Display: Devices, IRQ: InputPin, CS: OutputPin<Error = IRQ::Error>, SPI: Tr
|
||||||
self.display.debug(text)
|
self.display.debug(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_touch_event(&mut self) -> Option<slint_core_internal::input::MouseEvent> {
|
fn read_touch_event(&mut self) -> Option<i_slint_core::input::MouseEvent> {
|
||||||
let button = slint_core_internal::items::PointerEventButton::left;
|
let button = i_slint_core::items::PointerEventButton::left;
|
||||||
self.touch
|
self.touch
|
||||||
.read()
|
.read()
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
|
@ -140,14 +140,14 @@ impl<Display: Devices, IRQ: InputPin, CS: OutputPin<Error = IRQ::Error>, SPI: Tr
|
||||||
let size = self.display.screen_size().to_f32();
|
let size = self.display.screen_size().to_f32();
|
||||||
let pos = euclid::point2(point.x * size.width, point.y * size.height);
|
let pos = euclid::point2(point.x * size.width, point.y * size.height);
|
||||||
match self.last_touch.replace(pos) {
|
match self.last_touch.replace(pos) {
|
||||||
Some(_) => slint_core_internal::input::MouseEvent::MouseMoved { pos },
|
Some(_) => i_slint_core::input::MouseEvent::MouseMoved { pos },
|
||||||
None => slint_core_internal::input::MouseEvent::MousePressed { pos, button },
|
None => i_slint_core::input::MouseEvent::MousePressed { pos, button },
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
self.last_touch.take().map(|pos| {
|
self.last_touch
|
||||||
slint_core_internal::input::MouseEvent::MouseReleased { pos, button }
|
.take()
|
||||||
})
|
.map(|pos| i_slint_core::input::MouseEvent::MouseReleased { pos, button })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,16 +8,14 @@ use core::pin::Pin;
|
||||||
|
|
||||||
use embedded_graphics::pixelcolor::Rgb888;
|
use embedded_graphics::pixelcolor::Rgb888;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
use slint_core_internal::graphics::{
|
use i_slint_core::graphics::{IntRect, PixelFormat, Point as PointF, Rect as RectF, Size as SizeF};
|
||||||
IntRect, PixelFormat, Point as PointF, Rect as RectF, Size as SizeF,
|
use i_slint_core::items::Item;
|
||||||
};
|
use i_slint_core::{Color, ImageInner};
|
||||||
use slint_core_internal::items::Item;
|
|
||||||
use slint_core_internal::{Color, ImageInner};
|
|
||||||
|
|
||||||
use crate::Devices;
|
use crate::Devices;
|
||||||
|
|
||||||
pub fn render_window_frame(
|
pub fn render_window_frame(
|
||||||
runtime_window: Rc<slint_core_internal::window::Window>,
|
runtime_window: Rc<i_slint_core::window::Window>,
|
||||||
background: Rgb888,
|
background: Rgb888,
|
||||||
devices: &mut dyn Devices,
|
devices: &mut dyn Devices,
|
||||||
) {
|
) {
|
||||||
|
@ -271,11 +269,11 @@ enum SceneCommand {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_scene(runtime_window: Rc<slint_core_internal::window::Window>, size: SizeF) -> Scene {
|
fn prepare_scene(runtime_window: Rc<i_slint_core::window::Window>, size: SizeF) -> Scene {
|
||||||
let mut prepare_scene = PrepareScene::new(size, ScaleFactor(runtime_window.scale_factor()));
|
let mut prepare_scene = PrepareScene::new(size, ScaleFactor(runtime_window.scale_factor()));
|
||||||
runtime_window.draw_contents(|components| {
|
runtime_window.draw_contents(|components| {
|
||||||
for (component, origin) in components {
|
for (component, origin) in components {
|
||||||
slint_core_internal::item_rendering::render_component_items(
|
i_slint_core::item_rendering::render_component_items(
|
||||||
component,
|
component,
|
||||||
&mut prepare_scene,
|
&mut prepare_scene,
|
||||||
origin.clone(),
|
origin.clone(),
|
||||||
|
@ -327,7 +325,7 @@ impl PrepareScene {
|
||||||
fn draw_image_impl(
|
fn draw_image_impl(
|
||||||
&mut self,
|
&mut self,
|
||||||
geom: RectF,
|
geom: RectF,
|
||||||
source: &slint_core_internal::graphics::Image,
|
source: &i_slint_core::graphics::Image,
|
||||||
source_clip: IntRect,
|
source_clip: IntRect,
|
||||||
colorize: Color,
|
colorize: Color,
|
||||||
) {
|
) {
|
||||||
|
@ -377,8 +375,8 @@ struct RenderState {
|
||||||
clip: RectF,
|
clip: RectF,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl slint_core_internal::item_rendering::ItemRenderer for PrepareScene {
|
impl i_slint_core::item_rendering::ItemRenderer for PrepareScene {
|
||||||
fn draw_rectangle(&mut self, rect: Pin<&slint_core_internal::items::Rectangle>) {
|
fn draw_rectangle(&mut self, rect: Pin<&i_slint_core::items::Rectangle>) {
|
||||||
let geom = RectF::new(PointF::default(), rect.geometry().size);
|
let geom = RectF::new(PointF::default(), rect.geometry().size);
|
||||||
if self.should_draw(&geom) {
|
if self.should_draw(&geom) {
|
||||||
let geom = match geom.intersection(&self.current_state.clip) {
|
let geom = match geom.intersection(&self.current_state.clip) {
|
||||||
|
@ -395,7 +393,7 @@ impl slint_core_internal::item_rendering::ItemRenderer for PrepareScene {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_border_rectangle(&mut self, rect: Pin<&slint_core_internal::items::BorderRectangle>) {
|
fn draw_border_rectangle(&mut self, rect: Pin<&i_slint_core::items::BorderRectangle>) {
|
||||||
let geom = RectF::new(PointF::default(), rect.geometry().size);
|
let geom = RectF::new(PointF::default(), rect.geometry().size);
|
||||||
if self.should_draw(&geom) {
|
if self.should_draw(&geom) {
|
||||||
let border = rect.border_width();
|
let border = rect.border_width();
|
||||||
|
@ -432,7 +430,7 @@ impl slint_core_internal::item_rendering::ItemRenderer for PrepareScene {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_image(&mut self, image: Pin<&slint_core_internal::items::ImageItem>) {
|
fn draw_image(&mut self, image: Pin<&i_slint_core::items::ImageItem>) {
|
||||||
let geom = RectF::new(PointF::default(), image.geometry().size);
|
let geom = RectF::new(PointF::default(), image.geometry().size);
|
||||||
if self.should_draw(&geom) {
|
if self.should_draw(&geom) {
|
||||||
self.draw_image_impl(
|
self.draw_image_impl(
|
||||||
|
@ -444,7 +442,7 @@ impl slint_core_internal::item_rendering::ItemRenderer for PrepareScene {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_clipped_image(&mut self, image: Pin<&slint_core_internal::items::ClippedImage>) {
|
fn draw_clipped_image(&mut self, image: Pin<&i_slint_core::items::ClippedImage>) {
|
||||||
// when the source_clip size is empty, make it full
|
// when the source_clip size is empty, make it full
|
||||||
let a = |v| if v == 0 { i32::MAX } else { v };
|
let a = |v| if v == 0 { i32::MAX } else { v };
|
||||||
|
|
||||||
|
@ -464,20 +462,20 @@ impl slint_core_internal::item_rendering::ItemRenderer for PrepareScene {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text(&mut self, _text: Pin<&slint_core_internal::items::Text>) {
|
fn draw_text(&mut self, _text: Pin<&i_slint_core::items::Text>) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text_input(&mut self, _text_input: Pin<&slint_core_internal::items::TextInput>) {
|
fn draw_text_input(&mut self, _text_input: Pin<&i_slint_core::items::TextInput>) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "simulator")]
|
#[cfg(feature = "simulator")]
|
||||||
fn draw_path(&mut self, _path: Pin<&slint_core_internal::items::Path>) {
|
fn draw_path(&mut self, _path: Pin<&i_slint_core::items::Path>) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_box_shadow(&mut self, _box_shadow: Pin<&slint_core_internal::items::BoxShadow>) {
|
fn draw_box_shadow(&mut self, _box_shadow: Pin<&i_slint_core::items::BoxShadow>) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +491,7 @@ impl slint_core_internal::item_rendering::ItemRenderer for PrepareScene {
|
||||||
// TODO: handle radius and border
|
// TODO: handle radius and border
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_current_clip(&self) -> slint_core_internal::graphics::Rect {
|
fn get_current_clip(&self) -> i_slint_core::graphics::Rect {
|
||||||
self.current_state.clip
|
self.current_state.clip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +523,7 @@ impl slint_core_internal::item_rendering::ItemRenderer for PrepareScene {
|
||||||
|
|
||||||
fn draw_cached_pixmap(
|
fn draw_cached_pixmap(
|
||||||
&mut self,
|
&mut self,
|
||||||
_item_cache: &slint_core_internal::item_rendering::CachedRenderingData,
|
_item_cache: &i_slint_core::item_rendering::CachedRenderingData,
|
||||||
_update_fn: &dyn Fn(&mut dyn FnMut(u32, u32, &[u8])),
|
_update_fn: &dyn Fn(&mut dyn FnMut(u32, u32, &[u8])),
|
||||||
) {
|
) {
|
||||||
todo!()
|
todo!()
|
||||||
|
@ -535,7 +533,7 @@ impl slint_core_internal::item_rendering::ItemRenderer for PrepareScene {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window(&self) -> slint_core_internal::window::WindowRc {
|
fn window(&self) -> i_slint_core::window::WindowRc {
|
||||||
unreachable!("this backend don't query the window")
|
unreachable!("this backend don't query the window")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,14 @@ use std::rc::{Rc, Weak};
|
||||||
use embedded_graphics::pixelcolor::Rgb888;
|
use embedded_graphics::pixelcolor::Rgb888;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
use embedded_graphics_simulator::SimulatorDisplay;
|
use embedded_graphics_simulator::SimulatorDisplay;
|
||||||
|
use i_slint_core::component::ComponentRc;
|
||||||
|
use i_slint_core::graphics::{Image, ImageInner};
|
||||||
|
use i_slint_core::input::KeyboardModifiers;
|
||||||
|
use i_slint_core::items::ItemRef;
|
||||||
|
use i_slint_core::layout::Orientation;
|
||||||
|
use i_slint_core::window::{PlatformWindow, Window};
|
||||||
|
use i_slint_core::Color;
|
||||||
use rgb::FromSlice;
|
use rgb::FromSlice;
|
||||||
use slint_core_internal::component::ComponentRc;
|
|
||||||
use slint_core_internal::graphics::{Image, ImageInner};
|
|
||||||
use slint_core_internal::input::KeyboardModifiers;
|
|
||||||
use slint_core_internal::items::ItemRef;
|
|
||||||
use slint_core_internal::layout::Orientation;
|
|
||||||
use slint_core_internal::window::{PlatformWindow, Window};
|
|
||||||
use slint_core_internal::Color;
|
|
||||||
|
|
||||||
use self::event_loop::WinitWindow;
|
use self::event_loop::WinitWindow;
|
||||||
|
|
||||||
|
@ -26,19 +26,18 @@ mod glcontext;
|
||||||
use glcontext::*;
|
use glcontext::*;
|
||||||
|
|
||||||
pub struct SimulatorWindow {
|
pub struct SimulatorWindow {
|
||||||
self_weak: Weak<slint_core_internal::window::Window>,
|
self_weak: Weak<i_slint_core::window::Window>,
|
||||||
keyboard_modifiers: std::cell::Cell<KeyboardModifiers>,
|
keyboard_modifiers: std::cell::Cell<KeyboardModifiers>,
|
||||||
currently_pressed_key_code: std::cell::Cell<Option<winit::event::VirtualKeyCode>>,
|
currently_pressed_key_code: std::cell::Cell<Option<winit::event::VirtualKeyCode>>,
|
||||||
canvas: CanvasRc,
|
canvas: CanvasRc,
|
||||||
opengl_context: OpenGLContext,
|
opengl_context: OpenGLContext,
|
||||||
constraints:
|
constraints: Cell<(i_slint_core::layout::LayoutInfo, i_slint_core::layout::LayoutInfo)>,
|
||||||
Cell<(slint_core_internal::layout::LayoutInfo, slint_core_internal::layout::LayoutInfo)>,
|
|
||||||
visible: Cell<bool>,
|
visible: Cell<bool>,
|
||||||
background_color: Cell<Color>,
|
background_color: Cell<Color>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SimulatorWindow {
|
impl SimulatorWindow {
|
||||||
pub(crate) fn new(window_weak: &Weak<slint_core_internal::window::Window>) -> Rc<Self> {
|
pub(crate) fn new(window_weak: &Weak<i_slint_core::window::Window>) -> Rc<Self> {
|
||||||
let window_builder = winit::window::WindowBuilder::new().with_visible(false);
|
let window_builder = winit::window::WindowBuilder::new().with_visible(false);
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
@ -93,7 +92,7 @@ impl PlatformWindow for SimulatorWindow {
|
||||||
let platform_window = self.opengl_context.window();
|
let platform_window = self.opengl_context.window();
|
||||||
|
|
||||||
if let Some(window_item) =
|
if let Some(window_item) =
|
||||||
ItemRef::downcast_pin::<slint_core_internal::items::WindowItem>(root_item)
|
ItemRef::downcast_pin::<i_slint_core::items::WindowItem>(root_item)
|
||||||
{
|
{
|
||||||
platform_window.set_title(&window_item.title());
|
platform_window.set_title(&window_item.title());
|
||||||
platform_window.set_decorations(!window_item.no_frame());
|
platform_window.set_decorations(!window_item.no_frame());
|
||||||
|
@ -136,15 +135,15 @@ impl PlatformWindow for SimulatorWindow {
|
||||||
|
|
||||||
fn free_graphics_resources<'a>(
|
fn free_graphics_resources<'a>(
|
||||||
&self,
|
&self,
|
||||||
_items: &mut dyn Iterator<Item = std::pin::Pin<slint_core_internal::items::ItemRef<'a>>>,
|
_items: &mut dyn Iterator<Item = std::pin::Pin<i_slint_core::items::ItemRef<'a>>>,
|
||||||
) {
|
) {
|
||||||
// Nothing to do until we start caching stuff that needs freeing
|
// Nothing to do until we start caching stuff that needs freeing
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_popup(
|
fn show_popup(
|
||||||
&self,
|
&self,
|
||||||
_popup: &slint_core_internal::component::ComponentRc,
|
_popup: &i_slint_core::component::ComponentRc,
|
||||||
_position: slint_core_internal::graphics::Point,
|
_position: i_slint_core::graphics::Point,
|
||||||
) {
|
) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
@ -161,44 +160,44 @@ impl PlatformWindow for SimulatorWindow {
|
||||||
|
|
||||||
fn apply_window_properties(
|
fn apply_window_properties(
|
||||||
&self,
|
&self,
|
||||||
window_item: std::pin::Pin<&slint_core_internal::items::WindowItem>,
|
window_item: std::pin::Pin<&i_slint_core::items::WindowItem>,
|
||||||
) {
|
) {
|
||||||
WinitWindow::apply_window_properties(self as &dyn WinitWindow, window_item);
|
WinitWindow::apply_window_properties(self as &dyn WinitWindow, window_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_geometry_constraint(
|
fn apply_geometry_constraint(
|
||||||
&self,
|
&self,
|
||||||
constraints_horizontal: slint_core_internal::layout::LayoutInfo,
|
constraints_horizontal: i_slint_core::layout::LayoutInfo,
|
||||||
constraints_vertical: slint_core_internal::layout::LayoutInfo,
|
constraints_vertical: i_slint_core::layout::LayoutInfo,
|
||||||
) {
|
) {
|
||||||
self.apply_constraints(constraints_horizontal, constraints_vertical)
|
self.apply_constraints(constraints_horizontal, constraints_vertical)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_mouse_cursor(&self, _cursor: slint_core_internal::items::MouseCursor) {}
|
fn set_mouse_cursor(&self, _cursor: i_slint_core::items::MouseCursor) {}
|
||||||
|
|
||||||
fn text_size(
|
fn text_size(
|
||||||
&self,
|
&self,
|
||||||
_font_request: slint_core_internal::graphics::FontRequest,
|
_font_request: i_slint_core::graphics::FontRequest,
|
||||||
_text: &str,
|
_text: &str,
|
||||||
_max_width: Option<f32>,
|
_max_width: Option<f32>,
|
||||||
) -> slint_core_internal::graphics::Size {
|
) -> i_slint_core::graphics::Size {
|
||||||
// TODO
|
// TODO
|
||||||
Default::default()
|
Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn text_input_byte_offset_for_position(
|
fn text_input_byte_offset_for_position(
|
||||||
&self,
|
&self,
|
||||||
_text_input: std::pin::Pin<&slint_core_internal::items::TextInput>,
|
_text_input: std::pin::Pin<&i_slint_core::items::TextInput>,
|
||||||
_pos: slint_core_internal::graphics::Point,
|
_pos: i_slint_core::graphics::Point,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn text_input_position_for_byte_offset(
|
fn text_input_position_for_byte_offset(
|
||||||
&self,
|
&self,
|
||||||
_text_input: std::pin::Pin<&slint_core_internal::items::TextInput>,
|
_text_input: std::pin::Pin<&i_slint_core::items::TextInput>,
|
||||||
_byte_offset: usize,
|
_byte_offset: usize,
|
||||||
) -> slint_core_internal::graphics::Point {
|
) -> i_slint_core::graphics::Point {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +207,7 @@ impl PlatformWindow for SimulatorWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WinitWindow for SimulatorWindow {
|
impl WinitWindow for SimulatorWindow {
|
||||||
fn runtime_window(&self) -> Rc<slint_core_internal::window::Window> {
|
fn runtime_window(&self) -> Rc<i_slint_core::window::Window> {
|
||||||
self.self_weak.upgrade().unwrap()
|
self.self_weak.upgrade().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,17 +302,12 @@ impl WinitWindow for SimulatorWindow {
|
||||||
callback(&*self.opengl_context.window())
|
callback(&*self.opengl_context.window())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn constraints(
|
fn constraints(&self) -> (i_slint_core::layout::LayoutInfo, i_slint_core::layout::LayoutInfo) {
|
||||||
&self,
|
|
||||||
) -> (slint_core_internal::layout::LayoutInfo, slint_core_internal::layout::LayoutInfo) {
|
|
||||||
self.constraints.get()
|
self.constraints.get()
|
||||||
}
|
}
|
||||||
fn set_constraints(
|
fn set_constraints(
|
||||||
&self,
|
&self,
|
||||||
constraints: (
|
constraints: (i_slint_core::layout::LayoutInfo, i_slint_core::layout::LayoutInfo),
|
||||||
slint_core_internal::layout::LayoutInfo,
|
|
||||||
slint_core_internal::layout::LayoutInfo,
|
|
||||||
),
|
|
||||||
) {
|
) {
|
||||||
self.constraints.set(constraints)
|
self.constraints.set(constraints)
|
||||||
}
|
}
|
||||||
|
@ -321,20 +315,17 @@ impl WinitWindow for SimulatorWindow {
|
||||||
fn set_background_color(&self, color: Color) {
|
fn set_background_color(&self, color: Color) {
|
||||||
self.background_color.set(color);
|
self.background_color.set(color);
|
||||||
}
|
}
|
||||||
fn set_icon(&self, _icon: slint_core_internal::graphics::Image) {}
|
fn set_icon(&self, _icon: i_slint_core::graphics::Image) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SimulatorBackend;
|
pub struct SimulatorBackend;
|
||||||
|
|
||||||
impl slint_core_internal::backend::Backend for SimulatorBackend {
|
impl i_slint_core::backend::Backend for SimulatorBackend {
|
||||||
fn create_window(&'static self) -> Rc<Window> {
|
fn create_window(&'static self) -> Rc<Window> {
|
||||||
slint_core_internal::window::Window::new(|window| SimulatorWindow::new(window))
|
i_slint_core::window::Window::new(|window| SimulatorWindow::new(window))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_event_loop(
|
fn run_event_loop(&'static self, behavior: i_slint_core::backend::EventLoopQuitBehavior) {
|
||||||
&'static self,
|
|
||||||
behavior: slint_core_internal::backend::EventLoopQuitBehavior,
|
|
||||||
) {
|
|
||||||
event_loop::run(behavior);
|
event_loop::run(behavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +366,7 @@ impl slint_core_internal::backend::Backend for SimulatorBackend {
|
||||||
.send_event(self::event_loop::CustomEvent::UserEvent(event));
|
.send_event(self::event_loop::CustomEvent::UserEvent(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn image_size(&'static self, image: &Image) -> slint_core_internal::graphics::IntSize {
|
fn image_size(&'static self, image: &Image) -> i_slint_core::graphics::IntSize {
|
||||||
let inner: &ImageInner = image.into();
|
let inner: &ImageInner = image.into();
|
||||||
match inner {
|
match inner {
|
||||||
ImageInner::None => Default::default(),
|
ImageInner::None => Default::default(),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-backend-qt-internal"
|
name = "i-slint-backend-qt"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
@ -10,19 +10,19 @@ license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
|
||||||
description = "Qt rendering backend for Slint"
|
description = "Qt rendering backend for Slint"
|
||||||
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
||||||
homepage = "https://sixtyfps.io"
|
homepage = "https://sixtyfps.io"
|
||||||
links = "slint_backend_qt_internal" # just so we can pass metadata to the dependee's build script
|
links = "i_slint_backend_qt" # just so we can pass metadata to the dependee's build script
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
rtti = ["slint-core-internal/rtti"]
|
rtti = ["i-slint-core/rtti"]
|
||||||
default = ["rtti"]
|
default = ["rtti"]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-common-internal = { version = "=0.2.0", path = "../../../internal/common" }
|
i-slint-common = { version = "=0.2.0", path = "../../../internal/common" }
|
||||||
slint-core-macros-internal = { version = "=0.2.0", path = "../../../internal/core-macros" }
|
i-slint-core-macros = { version = "=0.2.0", path = "../../../internal/core-macros" }
|
||||||
slint-core-internal = { version = "=0.2.0", path = "../../../internal/core" }
|
i-slint-core = { version = "=0.2.0", path = "../../../internal/core" }
|
||||||
|
|
||||||
const-field-offset = { version = "0.1", path = "../../../helper_crates/const-field-offset" }
|
const-field-offset = { version = "0.1", path = "../../../helper_crates/const-field-offset" }
|
||||||
vtable = { version = "0.1", path = "../../../helper_crates/vtable" }
|
vtable = { version = "0.1", path = "../../../helper_crates/vtable" }
|
||||||
|
|
6
internal/backends/qt/README.md
Normal file
6
internal/backends/qt/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -1,27 +1,18 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
#![recursion_limit = "1024"]
|
#![recursion_limit = "1024"]
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use slint_core_internal::graphics::{Image, IntSize};
|
use i_slint_core::graphics::{Image, IntSize};
|
||||||
#[cfg(not(no_qt))]
|
#[cfg(not(no_qt))]
|
||||||
use slint_core_internal::items::ImageFit;
|
use i_slint_core::items::ImageFit;
|
||||||
use slint_core_internal::window::Window;
|
use i_slint_core::window::Window;
|
||||||
#[cfg(not(no_qt))]
|
#[cfg(not(no_qt))]
|
||||||
use slint_core_internal::ImageInner;
|
use i_slint_core::ImageInner;
|
||||||
|
|
||||||
#[cfg(not(no_qt))]
|
#[cfg(not(no_qt))]
|
||||||
mod qt_widgets;
|
mod qt_widgets;
|
||||||
|
@ -49,7 +40,7 @@ pub fn use_modules() -> usize {
|
||||||
mod ffi {
|
mod ffi {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn slint_qt_get_widget(
|
pub extern "C" fn slint_qt_get_widget(
|
||||||
_: &slint_core_internal::window::WindowRc,
|
_: &i_slint_core::window::WindowRc,
|
||||||
) -> *mut std::ffi::c_void {
|
) -> *mut std::ffi::c_void {
|
||||||
std::ptr::null_mut()
|
std::ptr::null_mut()
|
||||||
}
|
}
|
||||||
|
@ -67,13 +58,13 @@ mod ffi {
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// impl DoSomething for () {}
|
/// impl DoSomething for () {}
|
||||||
/// impl<T: slint_core_internal::rtti::BuiltinItem, Next: DoSomething> DoSomething for (T, Next) {
|
/// impl<T: i_slint_core::rtti::BuiltinItem, Next: DoSomething> DoSomething for (T, Next) {
|
||||||
/// fn do_something(/*...*/) {
|
/// fn do_something(/*...*/) {
|
||||||
/// /*...*/
|
/// /*...*/
|
||||||
/// Next::do_something(/*...*/);
|
/// Next::do_something(/*...*/);
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// slint_backend_qt_internal::NativeWidgets::do_something(/*...*/)
|
/// i_slint_backend_qt::NativeWidgets::do_something(/*...*/)
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(no_qt))]
|
#[cfg(not(no_qt))]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
@ -113,25 +104,22 @@ pub const HAS_NATIVE_STYLE: bool = cfg!(not(no_qt));
|
||||||
pub const IS_AVAILABLE: bool = cfg!(not(no_qt));
|
pub const IS_AVAILABLE: bool = cfg!(not(no_qt));
|
||||||
|
|
||||||
pub struct Backend;
|
pub struct Backend;
|
||||||
impl slint_core_internal::backend::Backend for Backend {
|
impl i_slint_core::backend::Backend for Backend {
|
||||||
fn create_window(&'static self) -> std::rc::Rc<Window> {
|
fn create_window(&'static self) -> std::rc::Rc<Window> {
|
||||||
#[cfg(no_qt)]
|
#[cfg(no_qt)]
|
||||||
panic!("The Qt backend needs Qt");
|
panic!("The Qt backend needs Qt");
|
||||||
#[cfg(not(no_qt))]
|
#[cfg(not(no_qt))]
|
||||||
{
|
{
|
||||||
slint_core_internal::window::Window::new(|window| qt_window::QtWindow::new(window))
|
i_slint_core::window::Window::new(|window| qt_window::QtWindow::new(window))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_event_loop(
|
fn run_event_loop(&'static self, _behavior: i_slint_core::backend::EventLoopQuitBehavior) {
|
||||||
&'static self,
|
|
||||||
_behavior: slint_core_internal::backend::EventLoopQuitBehavior,
|
|
||||||
) {
|
|
||||||
#[cfg(not(no_qt))]
|
#[cfg(not(no_qt))]
|
||||||
{
|
{
|
||||||
let quit_on_last_window_closed = match _behavior {
|
let quit_on_last_window_closed = match _behavior {
|
||||||
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed => true,
|
i_slint_core::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed => true,
|
||||||
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnlyExplicitly => false,
|
i_slint_core::backend::EventLoopQuitBehavior::QuitOnlyExplicitly => false,
|
||||||
};
|
};
|
||||||
// Schedule any timers with Qt that were set up before this event loop start.
|
// Schedule any timers with Qt that were set up before this event loop start.
|
||||||
crate::qt_window::timer_event();
|
crate::qt_window::timer_event();
|
||||||
|
@ -275,8 +263,8 @@ impl slint_core_internal::backend::Backend for Backend {
|
||||||
{
|
{
|
||||||
let inner: &ImageInner = _image.into();
|
let inner: &ImageInner = _image.into();
|
||||||
match inner {
|
match inner {
|
||||||
slint_core_internal::ImageInner::None => Default::default(),
|
i_slint_core::ImageInner::None => Default::default(),
|
||||||
slint_core_internal::ImageInner::EmbeddedImage(buffer) => buffer.size(),
|
i_slint_core::ImageInner::EmbeddedImage(buffer) => buffer.size(),
|
||||||
_ => qt_window::load_image_from_resource(inner, None, ImageFit::fill)
|
_ => qt_window::load_image_from_resource(inner, None, ImageFit::fill)
|
||||||
.map(|img| {
|
.map(|img| {
|
||||||
let qsize = img.size();
|
let qsize = img.size();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
This module contains all the native Qt widget implementation that forwards to QStyle.
|
This module contains all the native Qt widget implementation that forwards to QStyle.
|
||||||
|
|
||||||
Same as in slint_core_internal::items, when When adding an item or a property,
|
Same as in i_slint_core::items, when When adding an item or a property,
|
||||||
it needs to be kept in sync with different place.
|
it needs to be kept in sync with different place.
|
||||||
|
|
||||||
- It needs to be changed in this module
|
- It needs to be changed in this module
|
||||||
|
@ -20,19 +20,19 @@ it needs to be kept in sync with different place.
|
||||||
use const_field_offset::FieldOffsets;
|
use const_field_offset::FieldOffsets;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use cpp::cpp;
|
use cpp::cpp;
|
||||||
use slint_core_internal::graphics::{Color, Rect};
|
use i_slint_core::graphics::{Color, Rect};
|
||||||
use slint_core_internal::input::{
|
use i_slint_core::input::{
|
||||||
FocusEvent, InputEventFilterResult, InputEventResult, KeyEvent, KeyEventResult, MouseEvent,
|
FocusEvent, InputEventFilterResult, InputEventResult, KeyEvent, KeyEventResult, MouseEvent,
|
||||||
};
|
};
|
||||||
use slint_core_internal::item_rendering::{CachedRenderingData, ItemRenderer};
|
use i_slint_core::item_rendering::{CachedRenderingData, ItemRenderer};
|
||||||
use slint_core_internal::items::{Item, ItemConsts, ItemRc, ItemVTable, VoidArg};
|
use i_slint_core::items::{Item, ItemConsts, ItemRc, ItemVTable, VoidArg};
|
||||||
use slint_core_internal::layout::{LayoutInfo, Orientation};
|
use i_slint_core::layout::{LayoutInfo, Orientation};
|
||||||
use slint_core_internal::rtti::*;
|
use i_slint_core::rtti::*;
|
||||||
use slint_core_internal::window::WindowRc;
|
use i_slint_core::window::WindowRc;
|
||||||
use slint_core_internal::{
|
use i_slint_core::{
|
||||||
declare_item_vtable, Callback, ItemVTable_static, Property, SharedString, SharedVector,
|
declare_item_vtable, Callback, ItemVTable_static, Property, SharedString, SharedVector,
|
||||||
};
|
};
|
||||||
use slint_core_macros_internal::*;
|
use i_slint_core_macros::*;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
type ItemRendererRef<'a> = &'a mut dyn ItemRenderer;
|
type ItemRendererRef<'a> = &'a mut dyn ItemRenderer;
|
||||||
|
|
|
@ -90,7 +90,7 @@ mod standard_button {
|
||||||
pub type QStyle_StandardPixmap = ::std::os::raw::c_uint;
|
pub type QStyle_StandardPixmap = ::std::os::raw::c_uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
use slint_core_internal::items::StandardButtonKind;
|
use i_slint_core::items::StandardButtonKind;
|
||||||
use standard_button::*;
|
use standard_button::*;
|
||||||
|
|
||||||
type ActualStandardButtonKind = Option<StandardButtonKind>;
|
type ActualStandardButtonKind = Option<StandardButtonKind>;
|
||||||
|
@ -104,7 +104,7 @@ pub struct NativeButton {
|
||||||
pub width: Property<f32>,
|
pub width: Property<f32>,
|
||||||
pub height: Property<f32>,
|
pub height: Property<f32>,
|
||||||
pub text: Property<SharedString>,
|
pub text: Property<SharedString>,
|
||||||
pub icon: Property<slint_core_internal::graphics::Image>,
|
pub icon: Property<i_slint_core::graphics::Image>,
|
||||||
pub enabled: Property<bool>,
|
pub enabled: Property<bool>,
|
||||||
pub pressed: Property<bool>,
|
pub pressed: Property<bool>,
|
||||||
pub clicked: Callback<VoidArg>,
|
pub clicked: Callback<VoidArg>,
|
||||||
|
@ -226,7 +226,7 @@ impl Item for NativeButton {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
let enabled = self.enabled();
|
let enabled = self.enabled();
|
||||||
if !enabled {
|
if !enabled {
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl Item for NativeCheckBox {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
if !self.enabled() {
|
if !self.enabled() {
|
||||||
return InputEventResult::EventIgnored;
|
return InputEventResult::EventIgnored;
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl Item for NativeComboBox {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
let enabled = self.enabled();
|
let enabled = self.enabled();
|
||||||
if !enabled {
|
if !enabled {
|
||||||
|
@ -178,7 +178,7 @@ impl Item for NativeComboBoxPopup {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
_: MouseEvent,
|
_: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
InputEventResult::EventIgnored
|
InputEventResult::EventIgnored
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ impl Item for NativeGroupBox {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
_: MouseEvent,
|
_: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
InputEventResult::EventIgnored
|
InputEventResult::EventIgnored
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl Item for NativeLineEdit {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
_: MouseEvent,
|
_: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
InputEventResult::EventIgnored
|
InputEventResult::EventIgnored
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub struct NativeStandardListViewItem {
|
||||||
pub y: Property<f32>,
|
pub y: Property<f32>,
|
||||||
pub width: Property<f32>,
|
pub width: Property<f32>,
|
||||||
pub height: Property<f32>,
|
pub height: Property<f32>,
|
||||||
pub item: Property<slint_core_internal::model::StandardListViewItem>,
|
pub item: Property<i_slint_core::model::StandardListViewItem>,
|
||||||
pub index: Property<i32>,
|
pub index: Property<i32>,
|
||||||
pub is_selected: Property<bool>,
|
pub is_selected: Property<bool>,
|
||||||
pub cached_rendering_data: CachedRenderingData,
|
pub cached_rendering_data: CachedRenderingData,
|
||||||
|
@ -68,7 +68,7 @@ impl Item for NativeStandardListViewItem {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
_event: MouseEvent,
|
_event: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
InputEventResult::EventIgnored
|
InputEventResult::EventIgnored
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ impl Item for NativeScrollView {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
let size: qttypes::QSize = get_size!(self);
|
let size: qttypes::QSize = get_size!(self);
|
||||||
let mut data = self.data();
|
let mut data = self.data();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
use slint_core_internal::items::PointerEventButton;
|
use i_slint_core::items::PointerEventButton;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ impl Item for NativeSlider {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
let size: qttypes::QSize = get_size!(self);
|
let size: qttypes::QSize = get_size!(self);
|
||||||
let enabled = self.enabled();
|
let enabled = self.enabled();
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl Item for NativeSpinBox {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
let size: qttypes::QSize = get_size!(self);
|
let size: qttypes::QSize = get_size!(self);
|
||||||
let enabled = self.enabled();
|
let enabled = self.enabled();
|
||||||
|
|
|
@ -131,7 +131,7 @@ impl NativeStyleMetrics {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "rtti")]
|
#[cfg(feature = "rtti")]
|
||||||
impl slint_core_internal::rtti::BuiltinGlobal for NativeStyleMetrics {
|
impl i_slint_core::rtti::BuiltinGlobal for NativeStyleMetrics {
|
||||||
fn new() -> Pin<Rc<Self>> {
|
fn new() -> Pin<Rc<Self>> {
|
||||||
NativeStyleMetrics::new()
|
NativeStyleMetrics::new()
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl Item for NativeTabWidget {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
_: MouseEvent,
|
_: MouseEvent,
|
||||||
_window: &WindowRc,
|
_window: &WindowRc,
|
||||||
_self_rc: &slint_core_internal::items::ItemRc,
|
_self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
InputEventResult::EventIgnored
|
InputEventResult::EventIgnored
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ pub struct NativeTab {
|
||||||
pub width: Property<f32>,
|
pub width: Property<f32>,
|
||||||
pub height: Property<f32>,
|
pub height: Property<f32>,
|
||||||
pub title: Property<SharedString>,
|
pub title: Property<SharedString>,
|
||||||
pub icon: Property<slint_core_internal::graphics::Image>,
|
pub icon: Property<i_slint_core::graphics::Image>,
|
||||||
pub enabled: Property<bool>,
|
pub enabled: Property<bool>,
|
||||||
pub pressed: Property<bool>,
|
pub pressed: Property<bool>,
|
||||||
pub current: Property<i32>,
|
pub current: Property<i32>,
|
||||||
|
@ -383,7 +383,7 @@ impl Item for NativeTab {
|
||||||
self: Pin<&Self>,
|
self: Pin<&Self>,
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
window: &WindowRc,
|
window: &WindowRc,
|
||||||
self_rc: &slint_core_internal::items::ItemRc,
|
self_rc: &i_slint_core::items::ItemRc,
|
||||||
) -> InputEventResult {
|
) -> InputEventResult {
|
||||||
let enabled = self.enabled();
|
let enabled = self.enabled();
|
||||||
if !enabled {
|
if !enabled {
|
||||||
|
|
|
@ -5,22 +5,22 @@
|
||||||
|
|
||||||
use cpp::*;
|
use cpp::*;
|
||||||
use euclid::approxeq::ApproxEq;
|
use euclid::approxeq::ApproxEq;
|
||||||
use items::{ImageFit, TextHorizontalAlignment, TextVerticalAlignment};
|
use i_slint_core::graphics::{
|
||||||
use qttypes::QPainter;
|
|
||||||
use slint_core_internal::graphics::{
|
|
||||||
Brush, Color, FPSCounter, FontRequest, Image, Point, Rect, RenderingCache, SharedImageBuffer,
|
Brush, Color, FPSCounter, FontRequest, Image, Point, Rect, RenderingCache, SharedImageBuffer,
|
||||||
Size,
|
Size,
|
||||||
};
|
};
|
||||||
use slint_core_internal::input::{KeyEvent, KeyEventType, MouseEvent};
|
use i_slint_core::input::{KeyEvent, KeyEventType, MouseEvent};
|
||||||
use slint_core_internal::item_rendering::{CachedRenderingData, ItemRenderer};
|
use i_slint_core::item_rendering::{CachedRenderingData, ItemRenderer};
|
||||||
use slint_core_internal::items::{
|
use i_slint_core::items::{
|
||||||
self, FillRule, ImageRendering, ItemRef, MouseCursor, PointerEventButton, TextOverflow,
|
self, FillRule, ImageRendering, ItemRef, MouseCursor, PointerEventButton, TextOverflow,
|
||||||
TextWrap,
|
TextWrap,
|
||||||
};
|
};
|
||||||
use slint_core_internal::layout::Orientation;
|
use i_slint_core::layout::Orientation;
|
||||||
use slint_core_internal::window::{PlatformWindow, PopupWindow, PopupWindowLocation, WindowRc};
|
use i_slint_core::window::{PlatformWindow, PopupWindow, PopupWindowLocation, WindowRc};
|
||||||
use slint_core_internal::{component::ComponentRc, SharedString};
|
use i_slint_core::{component::ComponentRc, SharedString};
|
||||||
use slint_core_internal::{ImageInner, PathData, Property};
|
use i_slint_core::{ImageInner, PathData, Property};
|
||||||
|
use items::{ImageFit, TextHorizontalAlignment, TextVerticalAlignment};
|
||||||
|
use qttypes::QPainter;
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
@ -280,16 +280,16 @@ impl QPainterPath {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn into_qbrush(brush: slint_core_internal::Brush) -> qttypes::QBrush {
|
fn into_qbrush(brush: i_slint_core::Brush) -> qttypes::QBrush {
|
||||||
match brush {
|
match brush {
|
||||||
slint_core_internal::Brush::SolidColor(color) => {
|
i_slint_core::Brush::SolidColor(color) => {
|
||||||
let color: u32 = color.as_argb_encoded();
|
let color: u32 = color.as_argb_encoded();
|
||||||
cpp!(unsafe [color as "QRgb"] -> qttypes::QBrush as "QBrush" {
|
cpp!(unsafe [color as "QRgb"] -> qttypes::QBrush as "QBrush" {
|
||||||
return QBrush(QColor::fromRgba(color));
|
return QBrush(QColor::fromRgba(color));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
slint_core_internal::Brush::LinearGradient(g) => {
|
i_slint_core::Brush::LinearGradient(g) => {
|
||||||
let (start, end) = slint_core_internal::graphics::line_for_angle(g.angle());
|
let (start, end) = i_slint_core::graphics::line_for_angle(g.angle());
|
||||||
let p1 = qttypes::QPointF { x: start.x as _, y: start.y as _ };
|
let p1 = qttypes::QPointF { x: start.x as _, y: start.y as _ };
|
||||||
let p2 = qttypes::QPointF { x: end.x as _, y: end.y as _ };
|
let p2 = qttypes::QPointF { x: end.x as _, y: end.y as _ };
|
||||||
cpp_class!(unsafe struct QLinearGradient as "QLinearGradient");
|
cpp_class!(unsafe struct QLinearGradient as "QLinearGradient");
|
||||||
|
@ -795,7 +795,7 @@ impl ItemRenderer for QtItemRenderer<'_> {
|
||||||
|
|
||||||
fn draw_cached_pixmap(
|
fn draw_cached_pixmap(
|
||||||
&mut self,
|
&mut self,
|
||||||
_item_cache: &slint_core_internal::item_rendering::CachedRenderingData,
|
_item_cache: &i_slint_core::item_rendering::CachedRenderingData,
|
||||||
update_fn: &dyn Fn(&mut dyn FnMut(u32, u32, &[u8])),
|
update_fn: &dyn Fn(&mut dyn FnMut(u32, u32, &[u8])),
|
||||||
) {
|
) {
|
||||||
update_fn(&mut |width: u32, height: u32, data: &[u8]| {
|
update_fn(&mut |width: u32, height: u32, data: &[u8]| {
|
||||||
|
@ -942,8 +942,8 @@ fn adjust_to_image_fit(
|
||||||
dest_rect: &mut qttypes::QRectF,
|
dest_rect: &mut qttypes::QRectF,
|
||||||
) {
|
) {
|
||||||
match image_fit {
|
match image_fit {
|
||||||
slint_core_internal::items::ImageFit::fill => (),
|
i_slint_core::items::ImageFit::fill => (),
|
||||||
slint_core_internal::items::ImageFit::cover => {
|
i_slint_core::items::ImageFit::cover => {
|
||||||
let ratio = qttypes::qreal::max(
|
let ratio = qttypes::qreal::max(
|
||||||
dest_rect.width / source_rect.width,
|
dest_rect.width / source_rect.width,
|
||||||
dest_rect.height / source_rect.height,
|
dest_rect.height / source_rect.height,
|
||||||
|
@ -957,7 +957,7 @@ fn adjust_to_image_fit(
|
||||||
source_rect.height = dest_rect.height / ratio;
|
source_rect.height = dest_rect.height / ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slint_core_internal::items::ImageFit::contain => {
|
i_slint_core::items::ImageFit::contain => {
|
||||||
let ratio = qttypes::qreal::min(
|
let ratio = qttypes::qreal::min(
|
||||||
dest_rect.width / source_rect.width,
|
dest_rect.width / source_rect.width,
|
||||||
dest_rect.height / source_rect.height,
|
dest_rect.height / source_rect.height,
|
||||||
|
@ -1094,7 +1094,7 @@ cpp_class!(unsafe struct QWidgetPtr as "std::unique_ptr<QWidget>");
|
||||||
|
|
||||||
pub struct QtWindow {
|
pub struct QtWindow {
|
||||||
widget_ptr: QWidgetPtr,
|
widget_ptr: QWidgetPtr,
|
||||||
pub(crate) self_weak: Weak<slint_core_internal::window::Window>,
|
pub(crate) self_weak: Weak<i_slint_core::window::Window>,
|
||||||
|
|
||||||
fps_counter: Option<Rc<FPSCounter>>,
|
fps_counter: Option<Rc<FPSCounter>>,
|
||||||
|
|
||||||
|
@ -1102,7 +1102,7 @@ pub struct QtWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QtWindow {
|
impl QtWindow {
|
||||||
pub fn new(window_weak: &Weak<slint_core_internal::window::Window>) -> Rc<Self> {
|
pub fn new(window_weak: &Weak<i_slint_core::window::Window>) -> Rc<Self> {
|
||||||
let widget_ptr = cpp! {unsafe [] -> QWidgetPtr as "std::unique_ptr<QWidget>" {
|
let widget_ptr = cpp! {unsafe [] -> QWidgetPtr as "std::unique_ptr<QWidget>" {
|
||||||
ensure_initialized(true);
|
ensure_initialized(true);
|
||||||
return std::make_unique<SlintWidget>();
|
return std::make_unique<SlintWidget>();
|
||||||
|
@ -1131,7 +1131,7 @@ impl QtWindow {
|
||||||
fn paint_event(&self, painter: &mut QPainter) {
|
fn paint_event(&self, painter: &mut QPainter) {
|
||||||
let runtime_window = self.self_weak.upgrade().unwrap();
|
let runtime_window = self.self_weak.upgrade().unwrap();
|
||||||
runtime_window.clone().draw_contents(|components| {
|
runtime_window.clone().draw_contents(|components| {
|
||||||
slint_core_internal::animations::update_animations();
|
i_slint_core::animations::update_animations();
|
||||||
let cache = self.cache.clone();
|
let cache = self.cache.clone();
|
||||||
let mut renderer = QtItemRenderer {
|
let mut renderer = QtItemRenderer {
|
||||||
painter,
|
painter,
|
||||||
|
@ -1141,7 +1141,7 @@ impl QtWindow {
|
||||||
};
|
};
|
||||||
|
|
||||||
for (component, origin) in components {
|
for (component, origin) in components {
|
||||||
slint_core_internal::item_rendering::render_component_items(
|
i_slint_core::item_rendering::render_component_items(
|
||||||
component,
|
component,
|
||||||
&mut renderer,
|
&mut renderer,
|
||||||
*origin,
|
*origin,
|
||||||
|
@ -1152,7 +1152,7 @@ impl QtWindow {
|
||||||
fps_counter.measure_frame_rendered(&mut renderer);
|
fps_counter.measure_frame_rendered(&mut renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
slint_core_internal::animations::CURRENT_ANIMATION_DRIVER.with(|driver| {
|
i_slint_core::animations::CURRENT_ANIMATION_DRIVER.with(|driver| {
|
||||||
if !driver.has_active_animations() {
|
if !driver.has_active_animations() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1182,9 +1182,9 @@ impl QtWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn key_event(&self, key: i32, text: qttypes::QString, qt_modifiers: u32, released: bool) {
|
fn key_event(&self, key: i32, text: qttypes::QString, qt_modifiers: u32, released: bool) {
|
||||||
slint_core_internal::animations::update_animations();
|
i_slint_core::animations::update_animations();
|
||||||
let text: String = text.into();
|
let text: String = text.into();
|
||||||
let modifiers = slint_core_internal::input::KeyboardModifiers {
|
let modifiers = i_slint_core::input::KeyboardModifiers {
|
||||||
control: (qt_modifiers & key_generated::Qt_KeyboardModifier_ControlModifier) != 0,
|
control: (qt_modifiers & key_generated::Qt_KeyboardModifier_ControlModifier) != 0,
|
||||||
alt: (qt_modifiers & key_generated::Qt_KeyboardModifier_AltModifier) != 0,
|
alt: (qt_modifiers & key_generated::Qt_KeyboardModifier_AltModifier) != 0,
|
||||||
shift: (qt_modifiers & key_generated::Qt_KeyboardModifier_ShiftModifier) != 0,
|
shift: (qt_modifiers & key_generated::Qt_KeyboardModifier_ShiftModifier) != 0,
|
||||||
|
@ -1324,8 +1324,8 @@ impl PlatformWindow for QtWindow {
|
||||||
/// Set the min/max sizes on the QWidget
|
/// Set the min/max sizes on the QWidget
|
||||||
fn apply_geometry_constraint(
|
fn apply_geometry_constraint(
|
||||||
&self,
|
&self,
|
||||||
constraints_h: slint_core_internal::layout::LayoutInfo,
|
constraints_h: i_slint_core::layout::LayoutInfo,
|
||||||
constraints_v: slint_core_internal::layout::LayoutInfo,
|
constraints_v: i_slint_core::layout::LayoutInfo,
|
||||||
) {
|
) {
|
||||||
let widget_ptr = self.widget_ptr();
|
let widget_ptr = self.widget_ptr();
|
||||||
let min_width: f32 = constraints_h.min.min(constraints_h.max);
|
let min_width: f32 = constraints_h.min.min(constraints_h.max);
|
||||||
|
@ -1349,8 +1349,8 @@ impl PlatformWindow for QtWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_popup(&self, popup: &slint_core_internal::component::ComponentRc, position: Point) {
|
fn show_popup(&self, popup: &i_slint_core::component::ComponentRc, position: Point) {
|
||||||
let window = slint_core_internal::window::Window::new(|window| QtWindow::new(window));
|
let window = i_slint_core::window::Window::new(|window| QtWindow::new(window));
|
||||||
let popup_window: &QtWindow =
|
let popup_window: &QtWindow =
|
||||||
<dyn std::any::Any>::downcast_ref(window.as_ref().as_any()).unwrap();
|
<dyn std::any::Any>::downcast_ref(window.as_ref().as_any()).unwrap();
|
||||||
window.set_component(popup);
|
window.set_component(popup);
|
||||||
|
@ -1413,7 +1413,7 @@ impl PlatformWindow for QtWindow {
|
||||||
|
|
||||||
fn text_size(
|
fn text_size(
|
||||||
&self,
|
&self,
|
||||||
font_request: slint_core_internal::graphics::FontRequest,
|
font_request: i_slint_core::graphics::FontRequest,
|
||||||
text: &str,
|
text: &str,
|
||||||
max_width: Option<f32>,
|
max_width: Option<f32>,
|
||||||
) -> Size {
|
) -> Size {
|
||||||
|
@ -1422,7 +1422,7 @@ impl PlatformWindow for QtWindow {
|
||||||
|
|
||||||
fn text_input_byte_offset_for_position(
|
fn text_input_byte_offset_for_position(
|
||||||
&self,
|
&self,
|
||||||
text_input: Pin<&slint_core_internal::items::TextInput>,
|
text_input: Pin<&i_slint_core::items::TextInput>,
|
||||||
pos: Point,
|
pos: Point,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
|
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
|
||||||
|
@ -1469,7 +1469,7 @@ impl PlatformWindow for QtWindow {
|
||||||
|
|
||||||
fn text_input_position_for_byte_offset(
|
fn text_input_position_for_byte_offset(
|
||||||
&self,
|
&self,
|
||||||
text_input: Pin<&slint_core_internal::items::TextInput>,
|
text_input: Pin<&i_slint_core::items::TextInput>,
|
||||||
byte_offset: usize,
|
byte_offset: usize,
|
||||||
) -> Point {
|
) -> Point {
|
||||||
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
|
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
|
||||||
|
@ -1547,7 +1547,7 @@ fn get_font(request: FontRequest) -> QFont {
|
||||||
cpp_class! {pub unsafe struct QFont as "QFont"}
|
cpp_class! {pub unsafe struct QFont as "QFont"}
|
||||||
|
|
||||||
impl QFont {
|
impl QFont {
|
||||||
fn text_size(&self, text: &str, max_width: Option<f32>) -> slint_core_internal::graphics::Size {
|
fn text_size(&self, text: &str, max_width: Option<f32>) -> i_slint_core::graphics::Size {
|
||||||
let string = qttypes::QString::from(text);
|
let string = qttypes::QString::from(text);
|
||||||
let mut r = qttypes::QRectF::default();
|
let mut r = qttypes::QRectF::default();
|
||||||
if let Some(max) = max_width {
|
if let Some(max) = max_width {
|
||||||
|
@ -1558,7 +1558,7 @@ impl QFont {
|
||||||
-> qttypes::QSizeF as "QSizeF"{
|
-> qttypes::QSizeF as "QSizeF"{
|
||||||
return QFontMetricsF(*self).boundingRect(r, r.isEmpty() ? 0 : Qt::TextWordWrap , string).size();
|
return QFontMetricsF(*self).boundingRect(r, r.isEmpty() ? 0 : Qt::TextWordWrap , string).size();
|
||||||
}};
|
}};
|
||||||
slint_core_internal::graphics::Size::new(size.width as _, size.height as _)
|
i_slint_core::graphics::Size::new(size.width as _, size.height as _)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1569,10 +1569,10 @@ thread_local! {
|
||||||
|
|
||||||
/// Called by C++'s TimerHandler::timerEvent, or every time a timer might have been started
|
/// Called by C++'s TimerHandler::timerEvent, or every time a timer might have been started
|
||||||
pub(crate) fn timer_event() {
|
pub(crate) fn timer_event() {
|
||||||
slint_core_internal::animations::update_animations();
|
i_slint_core::animations::update_animations();
|
||||||
slint_core_internal::timers::TimerList::maybe_activate_timers();
|
i_slint_core::timers::TimerList::maybe_activate_timers();
|
||||||
|
|
||||||
slint_core_internal::animations::CURRENT_ANIMATION_DRIVER.with(|driver| {
|
i_slint_core::animations::CURRENT_ANIMATION_DRIVER.with(|driver| {
|
||||||
if !driver.has_active_animations() {
|
if !driver.has_active_animations() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1586,7 +1586,7 @@ pub(crate) fn timer_event() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut timeout = slint_core_internal::timers::TimerList::next_timeout().map(|instant| {
|
let mut timeout = i_slint_core::timers::TimerList::next_timeout().map(|instant| {
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
let instant: std::time::Instant = instant.into();
|
let instant: std::time::Instant = instant.into();
|
||||||
if instant > now {
|
if instant > now {
|
||||||
|
@ -1595,7 +1595,7 @@ pub(crate) fn timer_event() {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if slint_core_internal::animations::CURRENT_ANIMATION_DRIVER
|
if i_slint_core::animations::CURRENT_ANIMATION_DRIVER
|
||||||
.with(|driver| driver.has_active_animations())
|
.with(|driver| driver.has_active_animations())
|
||||||
{
|
{
|
||||||
timeout = timeout.map(|x| x.max(16)).or(Some(16));
|
timeout = timeout.map(|x| x.max(16)).or(Some(16));
|
||||||
|
@ -1612,19 +1612,19 @@ mod key_codes {
|
||||||
macro_rules! define_qt_key_to_string_fn {
|
macro_rules! define_qt_key_to_string_fn {
|
||||||
($($char:literal # $name:ident # $($qt:ident)|* # $($winit:ident)|* ;)*) => {
|
($($char:literal # $name:ident # $($qt:ident)|* # $($winit:ident)|* ;)*) => {
|
||||||
use crate::key_generated;
|
use crate::key_generated;
|
||||||
pub fn qt_key_to_string(key: key_generated::Qt_Key) -> Option<slint_core_internal::SharedString> {
|
pub fn qt_key_to_string(key: key_generated::Qt_Key) -> Option<i_slint_core::SharedString> {
|
||||||
|
|
||||||
let char = match(key) {
|
let char = match(key) {
|
||||||
$($(key_generated::$qt => $char,)*)*
|
$($(key_generated::$qt => $char,)*)*
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
let mut buffer = [0; 6];
|
let mut buffer = [0; 6];
|
||||||
Some(slint_core_internal::SharedString::from(char.encode_utf8(&mut buffer) as &str))
|
Some(i_slint_core::SharedString::from(char.encode_utf8(&mut buffer) as &str))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
slint_common_internal::for_each_special_keys!(define_qt_key_to_string_fn);
|
i_slint_common::for_each_special_keys!(define_qt_key_to_string_fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn qt_key_to_string(key: key_generated::Qt_Key, event_text: String) -> SharedString {
|
fn qt_key_to_string(key: key_generated::Qt_Key, event_text: String) -> SharedString {
|
||||||
|
@ -1725,9 +1725,7 @@ pub(crate) mod ffi {
|
||||||
use super::QtWindow;
|
use super::QtWindow;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn slint_qt_get_widget(
|
pub extern "C" fn slint_qt_get_widget(window: &i_slint_core::window::WindowRc) -> *mut c_void {
|
||||||
window: &slint_core_internal::window::WindowRc,
|
|
||||||
) -> *mut c_void {
|
|
||||||
<dyn std::any::Any>::downcast_ref(window.as_any())
|
<dyn std::any::Any>::downcast_ref(window.as_any())
|
||||||
.map_or(std::ptr::null_mut(), |win: &QtWindow| {
|
.map_or(std::ptr::null_mut(), |win: &QtWindow| {
|
||||||
win.widget_ptr().cast::<c_void>().as_ptr()
|
win.widget_ptr().cast::<c_void>().as_ptr()
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-backend-selector-internal"
|
name = "i-slint-backend-selector"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
@ -15,12 +15,12 @@ homepage = "https://sixtyfps.io"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
wayland = ["slint-backend-gl-internal/wayland"]
|
wayland = ["i-slint-backend-gl/wayland"]
|
||||||
x11 = ["slint-backend-gl-internal/x11"]
|
x11 = ["i-slint-backend-gl/x11"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-core-internal = { version = "=0.2.0", path = "../../../internal/core", default-features = false }
|
i-slint-core = { version = "=0.2.0", path = "../../../internal/core", default-features = false }
|
||||||
slint-backend-gl-internal = { version = "=0.2.0", path = "../gl", optional = true }
|
i-slint-backend-gl = { version = "=0.2.0", path = "../gl", optional = true }
|
||||||
slint-backend-qt-internal = { version = "=0.2.0", path = "../qt", optional = true }
|
i-slint-backend-qt = { version = "=0.2.0", path = "../qt", optional = true }
|
||||||
|
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
|
|
13
internal/backends/selector/README.md
Normal file
13
internal/backends/selector/README.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
||||||
|
|
||||||
|
|
||||||
|
The purpose of this crate is to select the default backend for [Slint](https://sixtyfps.io)
|
||||||
|
|
||||||
|
The backend can either be a runtime or a build time decision. The runtime decision is decided
|
||||||
|
by the `SLINT_BACKEND` environment variable. The built time default depends on the platform.
|
||||||
|
In order for the crate to be available at runtime, they need to be added as feature
|
|
@ -10,10 +10,10 @@ fn main() {
|
||||||
// The way this work is this
|
// The way this work is this
|
||||||
// 1. `qttypes`' crate's build script already detects Qt and set the DEP_QT_VERSION
|
// 1. `qttypes`' crate's build script already detects Qt and set the DEP_QT_VERSION
|
||||||
// 2. The qt rendering backend's build script will check if the qttype crates found Qt and
|
// 2. The qt rendering backend's build script will check if the qttype crates found Qt and
|
||||||
// look at the SLINT_NO_QT env variable, and sets the DEP_slint_backend_qt_internal_SUPPORTS_NATIVE_STYLE
|
// look at the SLINT_NO_QT env variable, and sets the DEP_i_slint_backend_qt_SUPPORTS_NATIVE_STYLE
|
||||||
// env variable so that the default rendering backend can know if Qt was there.
|
// env variable so that the default rendering backend can know if Qt was there.
|
||||||
// 3. here, in the default rendering backend, we know if we depends on the qt backend and if it
|
// 3. here, in the default rendering backend, we know if we depends on the qt backend and if it
|
||||||
// has set the DEP_slint_backend_qt_internal_SUPPORTS_NATIVE_STYLE env variable.
|
// has set the DEP_i_slint_backend_qt_SUPPORTS_NATIVE_STYLE env variable.
|
||||||
// We then write a file in the build directory with the default style that depends on the
|
// We then write a file in the build directory with the default style that depends on the
|
||||||
// Qt availability
|
// Qt availability
|
||||||
// 4a. When using the slint-build crate from a build script, it will be able to read this file
|
// 4a. When using the slint-build crate from a build script, it will be able to read this file
|
||||||
|
@ -26,7 +26,7 @@ fn main() {
|
||||||
|
|
||||||
let out_dir = std::env::var_os("OUT_DIR").unwrap();
|
let out_dir = std::env::var_os("OUT_DIR").unwrap();
|
||||||
// out_dir is something like
|
// out_dir is something like
|
||||||
// <target_dir>/build/slint-backend-selector-internal-1fe5c4ab61eb0584/out
|
// <target_dir>/build/i-slint-backend-selector-1fe5c4ab61eb0584/out
|
||||||
// and we want to write to a common directory, so write in the build/ dir
|
// and we want to write to a common directory, so write in the build/ dir
|
||||||
let target_path =
|
let target_path =
|
||||||
Path::new(&out_dir).parent().unwrap().parent().unwrap().join("SLINT_DEFAULT_STYLE.txt");
|
Path::new(&out_dir).parent().unwrap().parent().unwrap().join("SLINT_DEFAULT_STYLE.txt");
|
||||||
|
|
|
@ -1,67 +1,48 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
|
|
||||||
The purpose of this crate is to select the default backend for [Slint](https://sixtyfps.io)
|
|
||||||
|
|
||||||
The backend can either be a runtime or a build time decision. The runtime decision is decided
|
|
||||||
by the `SLINT_BACKEND` environment variable. The built time default depends on the platform.
|
|
||||||
In order for the crate to be available at runtime, they need to be added as feature
|
|
||||||
|
|
||||||
*/
|
|
||||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
#![cfg_attr(
|
#![cfg_attr(not(any(feature = "i-slint-backend-qt", feature = "i-slint-backend-gl")), no_std)]
|
||||||
not(any(feature = "slint-backend-qt-internal", feature = "slint-backend-gl-internal")),
|
|
||||||
no_std
|
|
||||||
)]
|
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(feature = "slint-backend-qt-internal")] {
|
if #[cfg(feature = "i-slint-backend-qt")] {
|
||||||
use slint_backend_qt_internal as default_backend;
|
use i_slint_backend_qt as default_backend;
|
||||||
} else if #[cfg(feature = "slint-backend-gl-internal")] {
|
} else if #[cfg(feature = "i-slint-backend-gl")] {
|
||||||
use slint_backend_gl_internal as default_backend;
|
use i_slint_backend_gl as default_backend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(any(
|
if #[cfg(any(
|
||||||
feature = "slint-backend-qt-internal",
|
feature = "i-slint-backend-qt",
|
||||||
feature = "slint-backend-gl-internal"
|
feature = "i-slint-backend-gl"
|
||||||
))] {
|
))] {
|
||||||
pub fn backend() -> &'static dyn slint_core_internal::backend::Backend {
|
pub fn backend() -> &'static dyn i_slint_core::backend::Backend {
|
||||||
slint_core_internal::backend::instance_or_init(|| {
|
i_slint_core::backend::instance_or_init(|| {
|
||||||
let backend_config = std::env::var("SLINT_BACKEND").unwrap_or_default();
|
let backend_config = std::env::var("SLINT_BACKEND").unwrap_or_default();
|
||||||
|
|
||||||
#[cfg(feature = "slint-backend-qt-internal")]
|
#[cfg(feature = "i-slint-backend-qt")]
|
||||||
if backend_config == "Qt" {
|
if backend_config == "Qt" {
|
||||||
return Box::new(slint_backend_qt_internal::Backend);
|
return Box::new(i_slint_backend_qt::Backend);
|
||||||
}
|
}
|
||||||
#[cfg(feature = "slint-backend-gl-internal")]
|
#[cfg(feature = "i-slint-backend-gl")]
|
||||||
if backend_config == "GL" {
|
if backend_config == "GL" {
|
||||||
return Box::new(slint_backend_gl_internal::Backend);
|
return Box::new(i_slint_backend_gl::Backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "slint-backend-qt-internal",
|
feature = "i-slint-backend-qt",
|
||||||
feature = "slint-backend-gl-internal"
|
feature = "i-slint-backend-gl"
|
||||||
))]
|
))]
|
||||||
if !backend_config.is_empty() {
|
if !backend_config.is_empty() {
|
||||||
eprintln!("Could not load rendering backend {}, fallback to default", backend_config)
|
eprintln!("Could not load rendering backend {}, fallback to default", backend_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "slint-backend-gl-internal")]
|
#[cfg(feature = "i-slint-backend-gl")]
|
||||||
if !default_backend::IS_AVAILABLE {
|
if !default_backend::IS_AVAILABLE {
|
||||||
// If Qt is not available always fallback to Gl
|
// If Qt is not available always fallback to Gl
|
||||||
return Box::new(slint_backend_gl_internal::Backend);
|
return Box::new(i_slint_backend_gl::Backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
Box::new(default_backend::Backend)
|
Box::new(default_backend::Backend)
|
||||||
|
@ -71,8 +52,8 @@ cfg_if::cfg_if! {
|
||||||
native_widgets, Backend, NativeGlobals, NativeWidgets, HAS_NATIVE_STYLE,
|
native_widgets, Backend, NativeGlobals, NativeWidgets, HAS_NATIVE_STYLE,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
pub fn backend() -> &'static dyn slint_core_internal::backend::Backend {
|
pub fn backend() -> &'static dyn i_slint_core::backend::Backend {
|
||||||
slint_core_internal::backend::instance().expect("no default backend configured, the backend must be initialized manually")
|
i_slint_core::backend::instance().expect("no default backend configured, the backend must be initialized manually")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type NativeWidgets = ();
|
pub type NativeWidgets = ();
|
||||||
|
@ -86,9 +67,9 @@ cfg_if::cfg_if! {
|
||||||
#[cold]
|
#[cold]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub fn use_modules() {
|
pub fn use_modules() {
|
||||||
slint_core_internal::use_modules();
|
i_slint_core::use_modules();
|
||||||
#[cfg(feature = "slint-backend-qt-internal")]
|
#[cfg(feature = "i-slint-backend-qt")]
|
||||||
slint_backend_qt_internal::use_modules();
|
i_slint_backend_qt::use_modules();
|
||||||
#[cfg(feature = "slint-backend-gl-internal")]
|
#[cfg(feature = "i-slint-backend-gl")]
|
||||||
slint_backend_gl_internal::use_modules();
|
i_slint_backend_gl::use_modules();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-backend-testing-internal"
|
name = "i-slint-backend-testing"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
@ -16,6 +16,6 @@ publish = false
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-core-internal = { version = "=0.2.0", path = "../../../internal/core" }
|
i-slint-core = { version = "=0.2.0", path = "../../../internal/core" }
|
||||||
|
|
||||||
image = { version = "0.24.0", default-features = false, features = ["png"] }
|
image = { version = "0.24.0", default-features = false, features = ["png"] }
|
||||||
|
|
6
internal/backends/testing/README.md
Normal file
6
internal/backends/testing/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -1,20 +1,14 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
|
|
||||||
*NOTE*: This library is an internal crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should not be used directly by application using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
|
|
||||||
|
use i_slint_core::component::ComponentRc;
|
||||||
|
use i_slint_core::graphics::{Image, IntSize, Point, Size};
|
||||||
|
use i_slint_core::window::{PlatformWindow, Window};
|
||||||
|
use i_slint_core::ImageInner;
|
||||||
use image::GenericImageView;
|
use image::GenericImageView;
|
||||||
use slint_core_internal::component::ComponentRc;
|
|
||||||
use slint_core_internal::graphics::{Image, IntSize, Point, Size};
|
|
||||||
use slint_core_internal::window::{PlatformWindow, Window};
|
|
||||||
use slint_core_internal::ImageInner;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -25,15 +19,12 @@ pub struct TestingBackend {
|
||||||
clipboard: Mutex<Option<String>>,
|
clipboard: Mutex<Option<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl slint_core_internal::backend::Backend for TestingBackend {
|
impl i_slint_core::backend::Backend for TestingBackend {
|
||||||
fn create_window(&'static self) -> Rc<Window> {
|
fn create_window(&'static self) -> Rc<Window> {
|
||||||
Window::new(|_| Rc::new(TestingWindow::default()))
|
Window::new(|_| Rc::new(TestingWindow::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_event_loop(
|
fn run_event_loop(&'static self, _behavior: i_slint_core::backend::EventLoopQuitBehavior) {
|
||||||
&'static self,
|
|
||||||
_behavior: slint_core_internal::backend::EventLoopQuitBehavior,
|
|
||||||
) {
|
|
||||||
unimplemented!("running an event loop with the testing backend");
|
unimplemented!("running an event loop with the testing backend");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,32 +90,32 @@ impl PlatformWindow for TestingWindow {
|
||||||
|
|
||||||
fn free_graphics_resources<'a>(
|
fn free_graphics_resources<'a>(
|
||||||
&self,
|
&self,
|
||||||
_items: &mut dyn Iterator<Item = Pin<slint_core_internal::items::ItemRef<'a>>>,
|
_items: &mut dyn Iterator<Item = Pin<i_slint_core::items::ItemRef<'a>>>,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_popup(&self, _popup: &ComponentRc, _position: slint_core_internal::graphics::Point) {
|
fn show_popup(&self, _popup: &ComponentRc, _position: i_slint_core::graphics::Point) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_window_properties_update(&self) {}
|
fn request_window_properties_update(&self) {}
|
||||||
|
|
||||||
fn apply_window_properties(&self, _window_item: Pin<&slint_core_internal::items::WindowItem>) {
|
fn apply_window_properties(&self, _window_item: Pin<&i_slint_core::items::WindowItem>) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_geometry_constraint(
|
fn apply_geometry_constraint(
|
||||||
&self,
|
&self,
|
||||||
_constraints_horizontal: slint_core_internal::layout::LayoutInfo,
|
_constraints_horizontal: i_slint_core::layout::LayoutInfo,
|
||||||
_constraints_vertical: slint_core_internal::layout::LayoutInfo,
|
_constraints_vertical: i_slint_core::layout::LayoutInfo,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_mouse_cursor(&self, _cursor: slint_core_internal::items::MouseCursor) {}
|
fn set_mouse_cursor(&self, _cursor: i_slint_core::items::MouseCursor) {}
|
||||||
|
|
||||||
fn text_size(
|
fn text_size(
|
||||||
&self,
|
&self,
|
||||||
_font_request: slint_core_internal::graphics::FontRequest,
|
_font_request: i_slint_core::graphics::FontRequest,
|
||||||
text: &str,
|
text: &str,
|
||||||
_max_width: Option<f32>,
|
_max_width: Option<f32>,
|
||||||
) -> Size {
|
) -> Size {
|
||||||
|
@ -133,7 +124,7 @@ impl PlatformWindow for TestingWindow {
|
||||||
|
|
||||||
fn text_input_byte_offset_for_position(
|
fn text_input_byte_offset_for_position(
|
||||||
&self,
|
&self,
|
||||||
_text_input: Pin<&slint_core_internal::items::TextInput>,
|
_text_input: Pin<&i_slint_core::items::TextInput>,
|
||||||
_pos: Point,
|
_pos: Point,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
0
|
0
|
||||||
|
@ -141,7 +132,7 @@ impl PlatformWindow for TestingWindow {
|
||||||
|
|
||||||
fn text_input_position_for_byte_offset(
|
fn text_input_position_for_byte_offset(
|
||||||
&self,
|
&self,
|
||||||
_text_input: Pin<&slint_core_internal::items::TextInput>,
|
_text_input: Pin<&i_slint_core::items::TextInput>,
|
||||||
_byte_offset: usize,
|
_byte_offset: usize,
|
||||||
) -> Point {
|
) -> Point {
|
||||||
Default::default()
|
Default::default()
|
||||||
|
@ -156,5 +147,5 @@ impl PlatformWindow for TestingWindow {
|
||||||
/// Must be called before any call that would otherwise initialize the rendering backend.
|
/// Must be called before any call that would otherwise initialize the rendering backend.
|
||||||
/// Calling it when the rendering backend is already initialized will have no effects
|
/// Calling it when the rendering backend is already initialized will have no effects
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
slint_core_internal::backend::instance_or_init(|| Box::new(TestingBackend::default()));
|
i_slint_core::backend::instance_or_init(|| Box::new(TestingBackend::default()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-common-internal"
|
name = "i-slint-common"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
|
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
|
||||||
description = "Helper crate for sharing code & data structures between slint-core-internal and slint-compiler"
|
description = "Helper crate for sharing code & data structures between i-slint-core and slint-compiler"
|
||||||
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
||||||
homepage = "https://sixtyfps.io"
|
homepage = "https://sixtyfps.io"
|
||||||
|
|
||||||
|
|
9
internal/common/README.md
Normal file
9
internal/common/README.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
This crate contains internal data structures and code that is shared between
|
||||||
|
the i-slint-core and the i-slint-compiler crates.
|
||||||
|
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -1,19 +1,8 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
This crate contains internal data structures and code that is shared between
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
the slint-core-internal and the slint-compiler-internal crates.
|
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
pub mod key_codes;
|
pub mod key_codes;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-compiler-internal"
|
name = "i-slint-compiler"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
@ -29,6 +29,8 @@ display-diagnostics = ["codemap", "codemap-diagnostic"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
i-slint-common = { version = "=0.2.0", path = "../common" }
|
||||||
|
|
||||||
num_enum = "0.5.1"
|
num_enum = "0.5.1"
|
||||||
rowan = "0.15.3"
|
rowan = "0.15.3"
|
||||||
smol_str = "0.1.17"
|
smol_str = "0.1.17"
|
||||||
|
@ -47,7 +49,6 @@ once_cell = "1"
|
||||||
url = "2.2.1"
|
url = "2.2.1"
|
||||||
dunce = "1.0.1"
|
dunce = "1.0.1"
|
||||||
linked_hash_set = "0.1.4"
|
linked_hash_set = "0.1.4"
|
||||||
slint-common-internal = { version = "=0.2.0", path = "../common" }
|
|
||||||
|
|
||||||
# for processing and embedding the rendered image (texture)
|
# for processing and embedding the rendered image (texture)
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
@ -57,6 +58,7 @@ resvg = "0.20"
|
||||||
usvg = "0.20"
|
usvg = "0.20"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
i-slint-parser-test-macro = { path = "./parser-test-macro" }
|
||||||
|
|
||||||
regex = "1.3.7"
|
regex = "1.3.7"
|
||||||
parser_test_macro = { path = "./parser_test_macro" }
|
|
||||||
spin_on = "0.1"
|
spin_on = "0.1"
|
||||||
|
|
8
internal/compiler/README.md
Normal file
8
internal/compiler/README.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# The Slint Compiler Library
|
||||||
|
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -208,7 +208,7 @@ impl LayoutConstraints {
|
||||||
|| self.vertical_stretch.is_some()
|
|| self.vertical_stretch.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over the constraint with a reference to a property, and the corresponding member in the slint_core_internal::layout::LayoutInfo struct
|
// Iterate over the constraint with a reference to a property, and the corresponding member in the i_slint_core::layout::LayoutInfo struct
|
||||||
pub fn for_each_restrictions<'a>(
|
pub fn for_each_restrictions<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
orientation: Orientation,
|
orientation: Orientation,
|
||||||
|
@ -420,7 +420,7 @@ pub struct GridLayout {
|
||||||
pub geometry: LayoutGeometry,
|
pub geometry: LayoutGeometry,
|
||||||
|
|
||||||
/// When this GridLyout is actually the layout of a Dialog, then the cells start with all the buttons,
|
/// When this GridLyout is actually the layout of a Dialog, then the cells start with all the buttons,
|
||||||
/// and this variable contains their roles. The string is actually one of the values from the slint_core_internal::layout::DialogButtonRole
|
/// and this variable contains their roles. The string is actually one of the values from the i_slint_core::layout::DialogButtonRole
|
||||||
pub dialog_button_roles: Option<Vec<String>>,
|
pub dialog_button_roles: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
# The Slint Compiler Library
|
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
// It would be nice to keep the compiler free of unsafe code
|
// It would be nice to keep the compiler free of unsafe code
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
|
|
|
@ -457,7 +457,7 @@ macro_rules! special_keys_lookup {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
slint_common_internal::for_each_special_keys!(special_keys_lookup);
|
i_slint_common::for_each_special_keys!(special_keys_lookup);
|
||||||
|
|
||||||
struct EasingSpecific;
|
struct EasingSpecific;
|
||||||
impl LookupObject for EasingSpecific {
|
impl LookupObject for EasingSpecific {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "parser_test_macro"
|
name = "i-slint-parser-test-macro"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
14
internal/compiler/parser-test-macro/README.md
Normal file
14
internal/compiler/parser-test-macro/README.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
parser_test: a proc macro attribute that generate tests for the parser functions
|
||||||
|
|
||||||
|
The parser_test macro will look at the documentation of a function for a
|
||||||
|
markdown block delimited by ` ```test` and will feeds each line to the parser
|
||||||
|
function, checking that no error are reported, and that everything was consumed
|
||||||
|
|
||||||
|
A parser function must have the signature `fn(&mut impl Parser)`
|
||||||
|
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -1,22 +1,8 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*! parser_test: a proc macro attribute that generate tests for the parser functions
|
#![doc = include_str!("README.md")]
|
||||||
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
The parser_test macro will look at the documentation of a function for a
|
|
||||||
markdown block delimited by ` ```test` and will feeds each line to the parser
|
|
||||||
function, checking that no error are reported, and that everything was consumed
|
|
||||||
|
|
||||||
A parser function must have the signature `fn(&mut impl Parser)`
|
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
use core::iter::IntoIterator;
|
use core::iter::IntoIterator;
|
|
@ -28,7 +28,7 @@ mod prelude {
|
||||||
pub use super::{syntax_nodes, SyntaxNode, SyntaxNodeVerify};
|
pub use super::{syntax_nodes, SyntaxNode, SyntaxNodeVerify};
|
||||||
pub use super::{DefaultParser, Parser, SyntaxKind};
|
pub use super::{DefaultParser, Parser, SyntaxKind};
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub use parser_test_macro::parser_test;
|
pub use i_slint_parser_test_macro::parser_test;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -59,7 +59,7 @@ fn process_file(path: &std::path::Path) -> std::io::Result<bool> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_diagnostics(
|
fn process_diagnostics(
|
||||||
compile_diagnostics: &slint_compiler_internal::diagnostics::BuildDiagnostics,
|
compile_diagnostics: &i_slint_compiler::diagnostics::BuildDiagnostics,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
source: &str,
|
source: &str,
|
||||||
silent: bool,
|
silent: bool,
|
||||||
|
@ -108,8 +108,8 @@ fn process_diagnostics(
|
||||||
} + column;
|
} + column;
|
||||||
|
|
||||||
let expected_diag_level = match warning_or_error {
|
let expected_diag_level = match warning_or_error {
|
||||||
"warning" => slint_compiler_internal::diagnostics::DiagnosticLevel::Warning,
|
"warning" => i_slint_compiler::diagnostics::DiagnosticLevel::Warning,
|
||||||
"error" => slint_compiler_internal::diagnostics::DiagnosticLevel::Error,
|
"error" => i_slint_compiler::diagnostics::DiagnosticLevel::Error,
|
||||||
_ => panic!("Unsupported diagnostic level {}", warning_or_error),
|
_ => panic!("Unsupported diagnostic level {}", warning_or_error),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ fn process_diagnostics(
|
||||||
|
|
||||||
#[cfg(feature = "display-diagnostics")]
|
#[cfg(feature = "display-diagnostics")]
|
||||||
if !silent {
|
if !silent {
|
||||||
let mut to_report = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
|
let mut to_report = i_slint_compiler::diagnostics::BuildDiagnostics::default();
|
||||||
for d in diags {
|
for d in diags {
|
||||||
to_report.push_compiler_error(d.clone());
|
to_report.push_compiler_error(d.clone());
|
||||||
}
|
}
|
||||||
|
@ -156,16 +156,16 @@ fn process_file_source(
|
||||||
source: String,
|
source: String,
|
||||||
silent: bool,
|
silent: bool,
|
||||||
) -> std::io::Result<bool> {
|
) -> std::io::Result<bool> {
|
||||||
let mut parse_diagnostics = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
|
let mut parse_diagnostics = i_slint_compiler::diagnostics::BuildDiagnostics::default();
|
||||||
let syntax_node =
|
let syntax_node =
|
||||||
slint_compiler_internal::parser::parse(source.clone(), Some(path), &mut parse_diagnostics);
|
i_slint_compiler::parser::parse(source.clone(), Some(path), &mut parse_diagnostics);
|
||||||
let has_parse_error = parse_diagnostics.has_error();
|
let has_parse_error = parse_diagnostics.has_error();
|
||||||
let mut compiler_config = slint_compiler_internal::CompilerConfiguration::new(
|
let mut compiler_config = i_slint_compiler::CompilerConfiguration::new(
|
||||||
slint_compiler_internal::generator::OutputFormat::Interpreter,
|
i_slint_compiler::generator::OutputFormat::Interpreter,
|
||||||
);
|
);
|
||||||
compiler_config.style = Some("fluent".into());
|
compiler_config.style = Some("fluent".into());
|
||||||
let compile_diagnostics = if !parse_diagnostics.has_error() {
|
let compile_diagnostics = if !parse_diagnostics.has_error() {
|
||||||
let (_, build_diags) = spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
|
let (_, build_diags) = spin_on::spin_on(i_slint_compiler::compile_syntax_node(
|
||||||
syntax_node.clone(),
|
syntax_node.clone(),
|
||||||
parse_diagnostics,
|
parse_diagnostics,
|
||||||
compiler_config.clone(),
|
compiler_config.clone(),
|
||||||
|
@ -190,7 +190,7 @@ fn process_file_source(
|
||||||
|
|
||||||
if has_parse_error {
|
if has_parse_error {
|
||||||
// Still try to compile to make sure it doesn't panic
|
// Still try to compile to make sure it doesn't panic
|
||||||
spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
|
spin_on::spin_on(i_slint_compiler::compile_syntax_node(
|
||||||
syntax_node,
|
syntax_node,
|
||||||
compile_diagnostics,
|
compile_diagnostics,
|
||||||
compiler_config,
|
compiler_config,
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-core-macros-internal"
|
name = "i-slint-core-macros"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
|
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
|
||||||
description = "Helper macro for slint-core-internal"
|
description = "Helper macro for i-slint-core"
|
||||||
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
||||||
homepage = "https://sixtyfps.io"
|
homepage = "https://sixtyfps.io"
|
||||||
|
|
||||||
|
|
8
internal/core-macros/README.md
Normal file
8
internal/core-macros/README.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
This crate contains the internal procedural macros used by the i-slint-core crate
|
||||||
|
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -1,18 +1,8 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
This crate contains the internal procedural macros
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
used by the slint-core-internal crate
|
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "slint-core-internal"
|
name = "i-slint-core"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["Slint Developers <info@slint-ui.com>"]
|
authors = ["Slint Developers <info@slint-ui.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
@ -31,8 +31,8 @@ unsafe_single_core = []
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-common-internal = { version = "=0.2.0", path = "../common" }
|
i-slint-common = { version = "=0.2.0", path = "../common" }
|
||||||
slint-core-macros-internal = { version = "=0.2.0", path = "../core-macros" }
|
i-slint-core-macros = { version = "=0.2.0", path = "../core-macros" }
|
||||||
|
|
||||||
const-field-offset = { version = "0.1", path = "../../helper_crates/const-field-offset" }
|
const-field-offset = { version = "0.1", path = "../../helper_crates/const-field-offset" }
|
||||||
vtable = { version="0.1.1", path = "../../helper_crates/vtable" }
|
vtable = { version="0.1.1", path = "../../helper_crates/vtable" }
|
||||||
|
@ -68,7 +68,7 @@ web_sys = { version = "0.3", package = "web-sys", features=["console", "CanvasRe
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
slint = { version = "=0.2.0", path = "../../api/rs/slint", default-features = false, features = ["std"] }
|
slint = { version = "=0.2.0", path = "../../api/rs/slint", default-features = false, features = ["std"] }
|
||||||
slint-backend-testing-internal = { path="../backends/testing" }
|
i-slint-backend-testing = { path="../backends/testing" }
|
||||||
|
|
||||||
image = { version = "0.24.0", default-features = false, features = [ "png" ] }
|
image = { version = "0.24.0", default-features = false, features = [ "png" ] }
|
||||||
pin-weak = "1"
|
pin-weak = "1"
|
||||||
|
|
8
internal/core/README.md
Normal file
8
internal/core/README.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Slint Runtime Library
|
||||||
|
|
||||||
|
**NOTE**: This library is an **internal** crate of the [Slint project](https://sixtyfps.io).
|
||||||
|
This crate should **not be used directly** by applications using Slint.
|
||||||
|
You should use the `slint` crate instead.
|
||||||
|
|
||||||
|
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||||
|
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
@ -147,7 +147,7 @@ impl crate::window::WindowHandleAccess for Window {
|
||||||
/// The following example of `.slint` markup defines a global singleton called `Palette`, exports
|
/// The following example of `.slint` markup defines a global singleton called `Palette`, exports
|
||||||
/// it and modifies it from Rust code:
|
/// it and modifies it from Rust code:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # slint_backend_testing_internal::init();
|
/// # i_slint_backend_testing::init();
|
||||||
/// slint::slint!{
|
/// slint::slint!{
|
||||||
/// export global Palette := {
|
/// export global Palette := {
|
||||||
/// property<color> foreground-color;
|
/// property<color> foreground-color;
|
||||||
|
@ -300,7 +300,7 @@ mod weak_handle {
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # slint_backend_testing_internal::init();
|
/// # i_slint_backend_testing::init();
|
||||||
/// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
|
/// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
|
||||||
/// let handle = MyApp::new();
|
/// let handle = MyApp::new();
|
||||||
/// let handle_weak = handle.as_weak();
|
/// let handle_weak = handle.as_weak();
|
||||||
|
@ -352,7 +352,7 @@ pub use weak_handle::*;
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
|
/// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
|
||||||
/// # slint_backend_testing_internal::init();
|
/// # i_slint_backend_testing::init();
|
||||||
/// let handle = MyApp::new();
|
/// let handle = MyApp::new();
|
||||||
/// let handle_weak = handle.as_weak();
|
/// let handle_weak = handle.as_weak();
|
||||||
/// let thread = std::thread::spawn(move || {
|
/// let thread = std::thread::spawn(move || {
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl Brush {
|
||||||
/// Returns true if this brush contains a fully transparent color (alpha value is zero)
|
/// Returns true if this brush contains a fully transparent color (alpha value is zero)
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use slint_core_internal::graphics::*;
|
/// # use i_slint_core::graphics::*;
|
||||||
/// assert!(Brush::default().is_transparent());
|
/// assert!(Brush::default().is_transparent());
|
||||||
/// assert!(Brush::SolidColor(Color::from_argb_u8(0, 255, 128, 140)).is_transparent());
|
/// assert!(Brush::SolidColor(Color::from_argb_u8(0, 255, 128, 140)).is_transparent());
|
||||||
/// assert!(!Brush::SolidColor(Color::from_argb_u8(25, 128, 140, 210)).is_transparent());
|
/// assert!(!Brush::SolidColor(Color::from_argb_u8(25, 128, 140, 210)).is_transparent());
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub struct RgbaColor<T> {
|
||||||
/// ```
|
/// ```
|
||||||
/// # fn do_something_with_red_and_green(_:f32, _:f32) {}
|
/// # fn do_something_with_red_and_green(_:f32, _:f32) {}
|
||||||
/// # fn do_something_with_red(_:u8) {}
|
/// # fn do_something_with_red(_:u8) {}
|
||||||
/// # use slint_core_internal::graphics::{Color, RgbaColor};
|
/// # use i_slint_core::graphics::{Color, RgbaColor};
|
||||||
/// # let some_color = Color::from_rgb_u8(0, 0, 0);
|
/// # let some_color = Color::from_rgb_u8(0, 0, 0);
|
||||||
/// let col = some_color.to_argb_f32();
|
/// let col = some_color.to_argb_f32();
|
||||||
/// do_something_with_red_and_green(col.red, col.green);
|
/// do_something_with_red_and_green(col.red, col.green);
|
||||||
|
|
|
@ -286,7 +286,7 @@ pub struct LoadImageError(());
|
||||||
/// low_level_render() function to draw a shape into it. Finally the result is
|
/// low_level_render() function to draw a shape into it. Finally the result is
|
||||||
/// stored in an Image with [`Self::from_rgb8()`]:
|
/// stored in an Image with [`Self::from_rgb8()`]:
|
||||||
/// ```
|
/// ```
|
||||||
/// # use slint_core_internal::graphics::{SharedPixelBuffer, Image, Rgb8Pixel};
|
/// # use i_slint_core::graphics::{SharedPixelBuffer, Image, Rgb8Pixel};
|
||||||
///
|
///
|
||||||
/// fn low_level_render(width: u32, height: u32, buffer: &mut [u8]) {
|
/// fn low_level_render(width: u32, height: u32, buffer: &mut [u8]) {
|
||||||
/// // render beautiful circle or other shapes here
|
/// // render beautiful circle or other shapes here
|
||||||
|
@ -307,7 +307,7 @@ pub struct LoadImageError(());
|
||||||
/// load a `.png` file from disk, apply brightening filter on it and then import
|
/// load a `.png` file from disk, apply brightening filter on it and then import
|
||||||
/// it into an [`Image`]:
|
/// it into an [`Image`]:
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # use slint_core_internal::graphics::{SharedPixelBuffer, Image, Rgba8Pixel};
|
/// # use i_slint_core::graphics::{SharedPixelBuffer, Image, Rgba8Pixel};
|
||||||
/// let mut cat_image = image::open("cat.png").expect("Error loading cat image").into_rgba8();
|
/// let mut cat_image = image::open("cat.png").expect("Error loading cat image").into_rgba8();
|
||||||
///
|
///
|
||||||
/// image::imageops::colorops::brighten_in_place(&mut cat_image, 20);
|
/// image::imageops::colorops::brighten_in_place(&mut cat_image, 20);
|
||||||
|
@ -323,7 +323,7 @@ pub struct LoadImageError(());
|
||||||
/// A popular software (CPU) rendering library in Rust is tiny-skia. The following example shows
|
/// A popular software (CPU) rendering library in Rust is tiny-skia. The following example shows
|
||||||
/// how to use tiny-skia to render into a [`SharedPixelBuffer`]:
|
/// how to use tiny-skia to render into a [`SharedPixelBuffer`]:
|
||||||
/// ```
|
/// ```
|
||||||
/// # use slint_core_internal::graphics::{SharedPixelBuffer, Image, Rgba8Pixel};
|
/// # use i_slint_core::graphics::{SharedPixelBuffer, Image, Rgba8Pixel};
|
||||||
/// let mut pixel_buffer = SharedPixelBuffer::<Rgba8Pixel>::new(640, 480);
|
/// let mut pixel_buffer = SharedPixelBuffer::<Rgba8Pixel>::new(640, 480);
|
||||||
/// let width = pixel_buffer.width();
|
/// let width = pixel_buffer.width();
|
||||||
/// let height = pixel_buffer.height();
|
/// let height = pixel_buffer.height();
|
||||||
|
@ -404,7 +404,7 @@ impl Image {
|
||||||
/// For example:
|
/// For example:
|
||||||
/// ```
|
/// ```
|
||||||
/// # use std::path::Path;
|
/// # use std::path::Path;
|
||||||
/// # use slint_core_internal::graphics::*;
|
/// # use i_slint_core::graphics::*;
|
||||||
/// let path_buf = Path::new(env!("CARGO_MANIFEST_DIR"))
|
/// let path_buf = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
/// .join("../../examples/printerdemo/ui/images/cat_preview_round.png");
|
/// .join("../../examples/printerdemo/ui/images/cat_preview_round.png");
|
||||||
/// let image = Image::load_from_path(&path_buf).unwrap();
|
/// let image = Image::load_from_path(&path_buf).unwrap();
|
||||||
|
|
|
@ -10,7 +10,7 @@ use super::{Point, Rect, Size};
|
||||||
use crate::rtti::*;
|
use crate::rtti::*;
|
||||||
use auto_enums::auto_enum;
|
use auto_enums::auto_enum;
|
||||||
use const_field_offset::FieldOffsets;
|
use const_field_offset::FieldOffsets;
|
||||||
use slint_core_macros_internal::*;
|
use i_slint_core_macros::*;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(FieldOffsets, Default, SlintElement, Clone, Debug, PartialEq)]
|
#[derive(FieldOffsets, Default, SlintElement, Clone, Debug, PartialEq)]
|
||||||
|
|
|
@ -120,7 +120,7 @@ pub mod key_codes {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
slint_common_internal::for_each_special_keys!(declare_consts_for_special_keys);
|
i_slint_common::for_each_special_keys!(declare_consts_for_special_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// KeyboardModifier provides booleans to indicate possible modifier keys
|
/// KeyboardModifier provides booleans to indicate possible modifier keys
|
||||||
|
|
|
@ -34,7 +34,7 @@ use alloc::boxed::Box;
|
||||||
use const_field_offset::FieldOffsets;
|
use const_field_offset::FieldOffsets;
|
||||||
use core::cell::Cell;
|
use core::cell::Cell;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use slint_core_macros_internal::*;
|
use i_slint_core_macros::*;
|
||||||
use vtable::*;
|
use vtable::*;
|
||||||
|
|
||||||
mod text;
|
mod text;
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::window::WindowRc;
|
||||||
use crate::{Brush, Property};
|
use crate::{Brush, Property};
|
||||||
use const_field_offset::FieldOffsets;
|
use const_field_offset::FieldOffsets;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use slint_core_macros_internal::*;
|
use i_slint_core_macros::*;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, strum::EnumString, strum::Display)]
|
#[derive(Copy, Clone, Debug, PartialEq, strum::EnumString, strum::Display)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::window::WindowRc;
|
||||||
use crate::Property;
|
use crate::Property;
|
||||||
use const_field_offset::FieldOffsets;
|
use const_field_offset::FieldOffsets;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use slint_core_macros_internal::*;
|
use i_slint_core_macros::*;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, strum::EnumString, strum::Display)]
|
#[derive(Copy, Clone, Debug, PartialEq, strum::EnumString, strum::Display)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::{Callback, Property, SharedString};
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use const_field_offset::FieldOffsets;
|
use const_field_offset::FieldOffsets;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use slint_core_macros_internal::*;
|
use i_slint_core_macros::*;
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
use num_traits::float::Float;
|
use num_traits::float::Float;
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
#![doc = include_str!("README.md")]
|
||||||
|
|
||||||
# Slint Runtime Library
|
|
||||||
|
|
||||||
**NOTE**: This library is an **internal** crate for the [Slint project](https://sixtyfps.io).
|
|
||||||
This crate should **not be used directly** by applications using Slint.
|
|
||||||
You should use the `slint` crate instead.
|
|
||||||
|
|
||||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
|
||||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl ModelTracker for ModelNotify {
|
||||||
/// As an example, let's see the implementation of [`VecModel`].
|
/// As an example, let's see the implementation of [`VecModel`].
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use slint_core_internal::model::{Model, ModelNotify, ModelPeer, ModelTracker};
|
/// # use i_slint_core::model::{Model, ModelNotify, ModelPeer, ModelTracker};
|
||||||
/// pub struct VecModel<T> {
|
/// pub struct VecModel<T> {
|
||||||
/// // the backing data, stored in a `RefCell` as this model can be modified
|
/// // the backing data, stored in a `RefCell` as this model can be modified
|
||||||
/// array: std::cell::RefCell<Vec<T>>,
|
/// array: std::cell::RefCell<Vec<T>>,
|
||||||
|
@ -244,7 +244,7 @@ pub trait Model {
|
||||||
/// in a component.
|
/// in a component.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use slint_core_internal::model::*;
|
/// # use i_slint_core::model::*;
|
||||||
/// # use std::rc::Rc;
|
/// # use std::rc::Rc;
|
||||||
/// let handle = ModelRc::new(VecModel::from(vec![1i32, 2, 3]));
|
/// let handle = ModelRc::new(VecModel::from(vec![1i32, 2, 3]));
|
||||||
/// // later:
|
/// // later:
|
||||||
|
|
|
@ -731,7 +731,7 @@ impl<T: Clone> Property<T> {
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::rc::Rc;
|
/// use std::rc::Rc;
|
||||||
/// use slint_core_internal::Property;
|
/// use i_slint_core::Property;
|
||||||
/// let prop1 = Rc::pin(Property::new(100));
|
/// let prop1 = Rc::pin(Property::new(100));
|
||||||
/// let prop2 = Rc::pin(Property::<i32>::default());
|
/// let prop2 = Rc::pin(Property::<i32>::default());
|
||||||
/// prop2.as_ref().set_binding({
|
/// prop2.as_ref().set_binding({
|
||||||
|
@ -800,7 +800,7 @@ impl<T: Clone> Property<T> {
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::rc::Rc;
|
/// use std::rc::Rc;
|
||||||
/// use slint_core_internal::Property;
|
/// use i_slint_core::Property;
|
||||||
/// let prop1 = Rc::pin(Property::new(100));
|
/// let prop1 = Rc::pin(Property::new(100));
|
||||||
/// let prop2 = Rc::pin(Property::<i32>::default());
|
/// let prop2 = Rc::pin(Property::<i32>::default());
|
||||||
/// prop2.as_ref().set_binding({
|
/// prop2.as_ref().set_binding({
|
||||||
|
|
|
@ -216,7 +216,7 @@ impl<T: Clone> SharedVector<T> {
|
||||||
/// If the array was bigger, extra elements will be discarded
|
/// If the array was bigger, extra elements will be discarded
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use slint_core_internal::SharedVector;
|
/// use i_slint_core::SharedVector;
|
||||||
/// let mut shared_vector = SharedVector::<u32>::from_slice(&[1, 2, 3]);
|
/// let mut shared_vector = SharedVector::<u32>::from_slice(&[1, 2, 3]);
|
||||||
/// shared_vector.resize(5, 8);
|
/// shared_vector.resize(5, 8);
|
||||||
/// assert_eq!(shared_vector.as_slice(), &[1, 2, 3, 8, 8]);
|
/// assert_eq!(shared_vector.as_slice(), &[1, 2, 3, 8, 8]);
|
||||||
|
|
|
@ -13,7 +13,7 @@ use core::{cmp::PartialEq, fmt::Debug, marker::PhantomData, ptr::NonNull};
|
||||||
/// Can be constructed from a slice using the from trait.
|
/// Can be constructed from a slice using the from trait.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use slint_core_internal::slice::Slice;
|
/// use i_slint_core::slice::Slice;
|
||||||
/// let x = Slice::from_slice(&[1, 2, 3]);
|
/// let x = Slice::from_slice(&[1, 2, 3]);
|
||||||
/// assert_eq!(x.len(), 3);
|
/// assert_eq!(x.len(), 3);
|
||||||
/// assert_eq!(x[1], 2);
|
/// assert_eq!(x[1], 2);
|
||||||
|
@ -22,7 +22,7 @@ use core::{cmp::PartialEq, fmt::Debug, marker::PhantomData, ptr::NonNull};
|
||||||
///
|
///
|
||||||
/// Comparing two Slice compare their pointer, not the content.
|
/// Comparing two Slice compare their pointer, not the content.
|
||||||
/// ```
|
/// ```
|
||||||
/// use slint_core_internal::slice::Slice;
|
/// use i_slint_core::slice::Slice;
|
||||||
/// let a = Slice::from_slice(&[1, 2, 3]);
|
/// let a = Slice::from_slice(&[1, 2, 3]);
|
||||||
/// let slice = [1, 2, 3, 4];
|
/// let slice = [1, 2, 3, 4];
|
||||||
/// let b = Slice::from(&slice[..3]);
|
/// let b = Slice::from(&slice[..3]);
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl SharedString {
|
||||||
/// Append a string to this string
|
/// Append a string to this string
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use slint_core_internal::SharedString;
|
/// # use i_slint_core::SharedString;
|
||||||
/// let mut hello = SharedString::from("Hello");
|
/// let mut hello = SharedString::from("Hello");
|
||||||
/// hello.push_str(", ");
|
/// hello.push_str(", ");
|
||||||
/// hello.push_str("World");
|
/// hello.push_str("World");
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub enum TimerMode {
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # slint_backend_testing_internal::init();
|
/// # i_slint_backend_testing::init();
|
||||||
/// use slint::{Timer, TimerMode};
|
/// use slint::{Timer, TimerMode};
|
||||||
/// let timer = Timer::default();
|
/// let timer = Timer::default();
|
||||||
/// timer.start(TimerMode::Repeated, std::time::Duration::from_millis(200), move || {
|
/// timer.start(TimerMode::Repeated, std::time::Duration::from_millis(200), move || {
|
||||||
|
@ -92,7 +92,7 @@ impl Timer {
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # slint_backend_testing_internal::init();
|
/// # i_slint_backend_testing::init();
|
||||||
/// use slint::Timer;
|
/// use slint::Timer;
|
||||||
/// Timer::single_shot(std::time::Duration::from_millis(200), move || {
|
/// Timer::single_shot(std::time::Duration::from_millis(200), move || {
|
||||||
/// println!("This will be printed after 200ms.");
|
/// println!("This will be printed after 200ms.");
|
||||||
|
|
|
@ -194,15 +194,12 @@ impl Window {
|
||||||
|
|
||||||
#[cfg(slint_debug_property)]
|
#[cfg(slint_debug_property)]
|
||||||
{
|
{
|
||||||
window
|
window.scale_factor.debug_name.replace("i_slint_core::Window::scale_factor".into());
|
||||||
.scale_factor
|
window.active.debug_name.replace("i_slint_core::Window::active".into());
|
||||||
.debug_name
|
window.active.debug_name.replace("i_slint_core::Window::active".into());
|
||||||
.replace("slint_core_internal::Window::scale_factor".into());
|
|
||||||
window.active.debug_name.replace("slint_core_internal::Window::active".into());
|
|
||||||
window.active.debug_name.replace("slint_core_internal::Window::active".into());
|
|
||||||
window_properties_tracker
|
window_properties_tracker
|
||||||
.set_debug_name("slint_core_internal::Window::window_properties_tracker".into());
|
.set_debug_name("i_slint_core::Window::window_properties_tracker".into());
|
||||||
redraw_tracker.set_debug_name("slint_core_internal::Window::redraw_tracker".into());
|
redraw_tracker.set_debug_name("i_slint_core::Window::redraw_tracker".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
window.window_properties_tracker.set(Box::pin(window_properties_tracker)).ok().unwrap();
|
window.window_properties_tracker.set(Box::pin(window_properties_tracker)).ok().unwrap();
|
||||||
|
|
|
@ -27,13 +27,13 @@ default = ["std", "backend-gl", "x11", "backend-qt", "compat-0-2-0"]
|
||||||
compat-0-2-0 = []
|
compat-0-2-0 = []
|
||||||
|
|
||||||
## enable the [`print_diagnostics`] function to show diagnostic in the console output
|
## enable the [`print_diagnostics`] function to show diagnostic in the console output
|
||||||
display-diagnostics = ["slint-compiler-internal/display-diagnostics"]
|
display-diagnostics = ["i-slint-compiler/display-diagnostics"]
|
||||||
|
|
||||||
# (internal) export C++ FFI functions
|
# (internal) export C++ FFI functions
|
||||||
ffi = ["spin_on", "slint-core-internal/ffi"]
|
ffi = ["spin_on", "i-slint-core/ffi"]
|
||||||
|
|
||||||
## Enable use of the Rust standard library.
|
## Enable use of the Rust standard library.
|
||||||
std = ["slint-core-internal/std"]
|
std = ["i-slint-core/std"]
|
||||||
|
|
||||||
#! ### Backends
|
#! ### Backends
|
||||||
|
|
||||||
|
@ -41,21 +41,21 @@ std = ["slint-core-internal/std"]
|
||||||
## This backend is required to use the `native` style.
|
## This backend is required to use the `native` style.
|
||||||
## It requires Qt 5.15 or later to be installed. If Qt is not installed, the
|
## It requires Qt 5.15 or later to be installed. If Qt is not installed, the
|
||||||
## backend will not be operational
|
## backend will not be operational
|
||||||
backend-qt = ["slint-backend-selector-internal/slint-backend-qt-internal", "std"]
|
backend-qt = ["i-slint-backend-selector/i-slint-backend-qt", "std"]
|
||||||
|
|
||||||
## The GL backend uses the `winit` crate for the windowing system integration,
|
## The GL backend uses the `winit` crate for the windowing system integration,
|
||||||
## and the `femtovg` crate for the rendering.
|
## and the `femtovg` crate for the rendering.
|
||||||
## On unix, at least one of `x11` or `wayland` features must be enabled.
|
## On unix, at least one of `x11` or `wayland` features must be enabled.
|
||||||
backend-gl = ["slint-backend-selector-internal/slint-backend-gl-internal", "std"]
|
backend-gl = ["i-slint-backend-selector/i-slint-backend-gl", "std"]
|
||||||
## Same as the GL backend, with the `x11` feature of `winit` enabled
|
## Same as the GL backend, with the `x11` feature of `winit` enabled
|
||||||
x11 = ["slint-backend-selector-internal/x11", "backend-gl"]
|
x11 = ["i-slint-backend-selector/x11", "backend-gl"]
|
||||||
## Same as the GL backend, with the `wayland` feature of `winit` enabled
|
## Same as the GL backend, with the `wayland` feature of `winit` enabled
|
||||||
wayland = ["slint-backend-selector-internal/wayland", "backend-gl"]
|
wayland = ["i-slint-backend-selector/wayland", "backend-gl"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-compiler-internal = { version = "=0.2.0", path = "../compiler" }
|
i-slint-compiler = { version = "=0.2.0", path = "../compiler" }
|
||||||
slint-core-internal = { version = "=0.2.0", path = "../core", features = ["rtti"] }
|
i-slint-core = { version = "=0.2.0", path = "../core", features = ["rtti"] }
|
||||||
slint-backend-selector-internal = { version = "=0.2.0", path = "../../internal/backends/selector" }
|
i-slint-backend-selector = { version = "=0.2.0", path = "../../internal/backends/selector" }
|
||||||
|
|
||||||
vtable = { version = "0.1.1", path="../../helper_crates/vtable" }
|
vtable = { version = "0.1.1", path="../../helper_crates/vtable" }
|
||||||
|
|
||||||
|
@ -71,10 +71,10 @@ version = "0.1"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
slint-backend-gl-internal = { version = "=0.2.0", path = "../../internal/backends/gl" }
|
i-slint-backend-gl = { version = "=0.2.0", path = "../../internal/backends/gl" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
slint-backend-testing-internal = { path = "../../internal/backends/testing" }
|
i-slint-backend-testing = { path = "../../internal/backends/testing" }
|
||||||
|
|
||||||
spin_on = "0.1"
|
spin_on = "0.1"
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
use slint_compiler_internal::langtype::Type as LangType;
|
use i_slint_compiler::langtype::Type as LangType;
|
||||||
use slint_core_internal::graphics::Image;
|
use i_slint_core::graphics::Image;
|
||||||
use slint_core_internal::model::{Model, ModelRc};
|
use i_slint_core::model::{Model, ModelRc};
|
||||||
use slint_core_internal::{Brush, PathData, SharedString, SharedVector};
|
use i_slint_core::{Brush, PathData, SharedString, SharedVector};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
@ -13,9 +13,9 @@ use std::path::{Path, PathBuf};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use slint_compiler_internal::diagnostics::{Diagnostic, DiagnosticLevel};
|
pub use i_slint_compiler::diagnostics::{Diagnostic, DiagnosticLevel};
|
||||||
|
|
||||||
pub use slint_core_internal::api::*;
|
pub use i_slint_core::api::*;
|
||||||
|
|
||||||
use crate::dynamic_component::ErasedComponentBox;
|
use crate::dynamic_component::ErasedComponentBox;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ pub enum Value {
|
||||||
PathData(PathData),
|
PathData(PathData),
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// An easing curve
|
/// An easing curve
|
||||||
EasingCurve(slint_core_internal::animations::EasingCurve),
|
EasingCurve(i_slint_core::animations::EasingCurve),
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// An enumeration, like `TextHorizontalAlignment::align_center`, represented by `("TextHorizontalAlignment", "align_center")`.
|
/// An enumeration, like `TextHorizontalAlignment::align_center`, represented by `("TextHorizontalAlignment", "align_center")`.
|
||||||
/// FIXME: consider representing that with a number?
|
/// FIXME: consider representing that with a number?
|
||||||
|
@ -224,7 +224,7 @@ declare_value_conversion!(Image => [Image] );
|
||||||
declare_value_conversion!(Struct => [Struct] );
|
declare_value_conversion!(Struct => [Struct] );
|
||||||
declare_value_conversion!(Brush => [Brush] );
|
declare_value_conversion!(Brush => [Brush] );
|
||||||
declare_value_conversion!(PathData => [PathData]);
|
declare_value_conversion!(PathData => [PathData]);
|
||||||
declare_value_conversion!(EasingCurve => [slint_core_internal::animations::EasingCurve]);
|
declare_value_conversion!(EasingCurve => [i_slint_core::animations::EasingCurve]);
|
||||||
declare_value_conversion!(LayoutCache => [SharedVector<f32>] );
|
declare_value_conversion!(LayoutCache => [SharedVector<f32>] );
|
||||||
|
|
||||||
/// Implement From / TryInto for Value that convert a `struct` to/from `Value::Object`
|
/// Implement From / TryInto for Value that convert a `struct` to/from `Value::Object`
|
||||||
|
@ -255,13 +255,13 @@ macro_rules! declare_value_struct_conversion {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_value_struct_conversion!(struct slint_core_internal::model::StandardListViewItem { text });
|
declare_value_struct_conversion!(struct i_slint_core::model::StandardListViewItem { text });
|
||||||
declare_value_struct_conversion!(struct slint_core_internal::properties::StateInfo { current_state, previous_state, change_time });
|
declare_value_struct_conversion!(struct i_slint_core::properties::StateInfo { current_state, previous_state, change_time });
|
||||||
declare_value_struct_conversion!(struct slint_core_internal::input::KeyboardModifiers { control, alt, shift, meta });
|
declare_value_struct_conversion!(struct i_slint_core::input::KeyboardModifiers { control, alt, shift, meta });
|
||||||
declare_value_struct_conversion!(struct slint_core_internal::input::KeyEvent { event_type, text, modifiers });
|
declare_value_struct_conversion!(struct i_slint_core::input::KeyEvent { event_type, text, modifiers });
|
||||||
declare_value_struct_conversion!(struct slint_core_internal::layout::LayoutInfo { min, max, min_percent, max_percent, preferred, stretch });
|
declare_value_struct_conversion!(struct i_slint_core::layout::LayoutInfo { min, max, min_percent, max_percent, preferred, stretch });
|
||||||
declare_value_struct_conversion!(struct slint_core_internal::graphics::Point { x, y, ..Default::default()});
|
declare_value_struct_conversion!(struct i_slint_core::graphics::Point { x, y, ..Default::default()});
|
||||||
declare_value_struct_conversion!(struct slint_core_internal::items::PointerEvent { kind, button });
|
declare_value_struct_conversion!(struct i_slint_core::items::PointerEvent { kind, button });
|
||||||
|
|
||||||
/// Implement From / TryInto for Value that convert an `enum` to/from `Value::EnumerationValue`
|
/// Implement From / TryInto for Value that convert an `enum` to/from `Value::EnumerationValue`
|
||||||
///
|
///
|
||||||
|
@ -296,38 +296,35 @@ macro_rules! declare_value_enum_conversion {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_value_enum_conversion!(
|
declare_value_enum_conversion!(
|
||||||
slint_core_internal::items::TextHorizontalAlignment,
|
i_slint_core::items::TextHorizontalAlignment,
|
||||||
TextHorizontalAlignment
|
TextHorizontalAlignment
|
||||||
);
|
);
|
||||||
declare_value_enum_conversion!(
|
declare_value_enum_conversion!(i_slint_core::items::TextVerticalAlignment, TextVerticalAlignment);
|
||||||
slint_core_internal::items::TextVerticalAlignment,
|
declare_value_enum_conversion!(i_slint_core::items::TextOverflow, TextOverflow);
|
||||||
TextVerticalAlignment
|
declare_value_enum_conversion!(i_slint_core::items::TextWrap, TextWrap);
|
||||||
);
|
declare_value_enum_conversion!(i_slint_core::layout::LayoutAlignment, LayoutAlignment);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::TextOverflow, TextOverflow);
|
declare_value_enum_conversion!(i_slint_core::items::ImageFit, ImageFit);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::TextWrap, TextWrap);
|
declare_value_enum_conversion!(i_slint_core::items::ImageRendering, ImageRendering);
|
||||||
declare_value_enum_conversion!(slint_core_internal::layout::LayoutAlignment, LayoutAlignment);
|
declare_value_enum_conversion!(i_slint_core::input::KeyEventType, KeyEventType);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::ImageFit, ImageFit);
|
declare_value_enum_conversion!(i_slint_core::items::EventResult, EventResult);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::ImageRendering, ImageRendering);
|
declare_value_enum_conversion!(i_slint_core::items::FillRule, FillRule);
|
||||||
declare_value_enum_conversion!(slint_core_internal::input::KeyEventType, KeyEventType);
|
declare_value_enum_conversion!(i_slint_core::items::MouseCursor, MouseCursor);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::EventResult, EventResult);
|
declare_value_enum_conversion!(i_slint_core::items::StandardButtonKind, StandardButtonKind);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::FillRule, FillRule);
|
declare_value_enum_conversion!(i_slint_core::items::PointerEventKind, PointerEventKind);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::MouseCursor, MouseCursor);
|
declare_value_enum_conversion!(i_slint_core::items::PointerEventButton, PointerEventButton);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::StandardButtonKind, StandardButtonKind);
|
declare_value_enum_conversion!(i_slint_core::items::DialogButtonRole, DialogButtonRole);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::PointerEventKind, PointerEventKind);
|
declare_value_enum_conversion!(i_slint_core::graphics::PathEvent, PathEvent);
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::PointerEventButton, PointerEventButton);
|
|
||||||
declare_value_enum_conversion!(slint_core_internal::items::DialogButtonRole, DialogButtonRole);
|
|
||||||
declare_value_enum_conversion!(slint_core_internal::graphics::PathEvent, PathEvent);
|
|
||||||
|
|
||||||
impl From<slint_core_internal::animations::Instant> for Value {
|
impl From<i_slint_core::animations::Instant> for Value {
|
||||||
fn from(value: slint_core_internal::animations::Instant) -> Self {
|
fn from(value: i_slint_core::animations::Instant) -> Self {
|
||||||
Value::Number(value.0 as _)
|
Value::Number(value.0 as _)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl TryInto<slint_core_internal::animations::Instant> for Value {
|
impl TryInto<i_slint_core::animations::Instant> for Value {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
fn try_into(self) -> Result<slint_core_internal::animations::Instant, ()> {
|
fn try_into(self) -> Result<i_slint_core::animations::Instant, ()> {
|
||||||
match self {
|
match self {
|
||||||
Value::Number(x) => Ok(slint_core_internal::animations::Instant(x as _)),
|
Value::Number(x) => Ok(i_slint_core::animations::Instant(x as _)),
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,16 +344,16 @@ impl TryInto<()> for Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<slint_core_internal::Color> for Value {
|
impl From<i_slint_core::Color> for Value {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(c: slint_core_internal::Color) -> Self {
|
fn from(c: i_slint_core::Color) -> Self {
|
||||||
Value::Brush(Brush::SolidColor(c))
|
Value::Brush(Brush::SolidColor(c))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl TryInto<slint_core_internal::Color> for Value {
|
impl TryInto<i_slint_core::Color> for Value {
|
||||||
type Error = Value;
|
type Error = Value;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn try_into(self) -> Result<slint_core_internal::Color, Value> {
|
fn try_into(self) -> Result<i_slint_core::Color, Value> {
|
||||||
match self {
|
match self {
|
||||||
Value::Brush(Brush::SolidColor(c)) => Ok(c),
|
Value::Brush(Brush::SolidColor(c)) => Ok(c),
|
||||||
_ => Err(self),
|
_ => Err(self),
|
||||||
|
@ -429,15 +426,15 @@ impl FromIterator<(String, Value)> for Struct {
|
||||||
/// ComponentCompiler is the entry point to the Slint interpreter that can be used
|
/// ComponentCompiler is the entry point to the Slint interpreter that can be used
|
||||||
/// to load .slint files or compile them on-the-fly from a string.
|
/// to load .slint files or compile them on-the-fly from a string.
|
||||||
pub struct ComponentCompiler {
|
pub struct ComponentCompiler {
|
||||||
config: slint_compiler_internal::CompilerConfiguration,
|
config: i_slint_compiler::CompilerConfiguration,
|
||||||
diagnostics: Vec<Diagnostic>,
|
diagnostics: Vec<Diagnostic>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ComponentCompiler {
|
impl Default for ComponentCompiler {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
config: slint_compiler_internal::CompilerConfiguration::new(
|
config: i_slint_compiler::CompilerConfiguration::new(
|
||||||
slint_compiler_internal::generator::OutputFormat::Interpreter,
|
i_slint_compiler::generator::OutputFormat::Interpreter,
|
||||||
),
|
),
|
||||||
diagnostics: vec![],
|
diagnostics: vec![],
|
||||||
}
|
}
|
||||||
|
@ -516,7 +513,7 @@ impl ComponentCompiler {
|
||||||
path: P,
|
path: P,
|
||||||
) -> Option<ComponentDefinition> {
|
) -> Option<ComponentDefinition> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let source = match slint_compiler_internal::diagnostics::load_from_path(path) {
|
let source = match i_slint_compiler::diagnostics::load_from_path(path) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(d) => {
|
Err(d) => {
|
||||||
self.diagnostics = vec![d];
|
self.diagnostics = vec![d];
|
||||||
|
@ -595,7 +592,7 @@ impl ComponentDefinition {
|
||||||
/// This method is internal because the WindowRc is not a public type
|
/// This method is internal because the WindowRc is not a public type
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn create_with_existing_window(&self, window: &Window) -> ComponentInstance {
|
pub fn create_with_existing_window(&self, window: &Window) -> ComponentInstance {
|
||||||
use slint_core_internal::window::WindowHandleAccess;
|
use i_slint_core::window::WindowHandleAccess;
|
||||||
generativity::make_guard!(guard);
|
generativity::make_guard!(guard);
|
||||||
ComponentInstance {
|
ComponentInstance {
|
||||||
inner: self
|
inner: self
|
||||||
|
@ -612,7 +609,7 @@ impl ComponentDefinition {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn properties_and_callbacks(
|
pub fn properties_and_callbacks(
|
||||||
&self,
|
&self,
|
||||||
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_ {
|
) -> impl Iterator<Item = (String, i_slint_compiler::langtype::Type)> + '_ {
|
||||||
// We create here a 'static guard, because unfortunately the returned type would be restricted to the guard lifetime
|
// We create here a 'static guard, because unfortunately the returned type would be restricted to the guard lifetime
|
||||||
// which is not required, but this is safe because there is only one instance of the unerased type
|
// which is not required, but this is safe because there is only one instance of the unerased type
|
||||||
let guard = unsafe { generativity::Guard::new(generativity::Id::new()) };
|
let guard = unsafe { generativity::Guard::new(generativity::Id::new()) };
|
||||||
|
@ -706,7 +703,7 @@ impl ComponentDefinition {
|
||||||
/// This function is available when the `display-diagnostics` is enabled.
|
/// This function is available when the `display-diagnostics` is enabled.
|
||||||
#[cfg(feature = "display-diagnostics")]
|
#[cfg(feature = "display-diagnostics")]
|
||||||
pub fn print_diagnostics(diagnostics: &[Diagnostic]) {
|
pub fn print_diagnostics(diagnostics: &[Diagnostic]) {
|
||||||
let mut build_diagnostics = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
|
let mut build_diagnostics = i_slint_compiler::diagnostics::BuildDiagnostics::default();
|
||||||
for d in diagnostics {
|
for d in diagnostics {
|
||||||
build_diagnostics.push_compiler_error(d.clone())
|
build_diagnostics.push_compiler_error(d.clone())
|
||||||
}
|
}
|
||||||
|
@ -723,7 +720,7 @@ pub fn print_diagnostics(diagnostics: &[Diagnostic]) {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ComponentInstance {
|
pub struct ComponentInstance {
|
||||||
inner: vtable::VRc<
|
inner: vtable::VRc<
|
||||||
slint_core_internal::component::ComponentVTable,
|
i_slint_core::component::ComponentVTable,
|
||||||
crate::dynamic_component::ErasedComponentBox,
|
crate::dynamic_component::ErasedComponentBox,
|
||||||
>,
|
>,
|
||||||
}
|
}
|
||||||
|
@ -969,7 +966,7 @@ impl ComponentHandle for ComponentInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_inner(
|
fn from_inner(
|
||||||
inner: vtable::VRc<slint_core_internal::component::ComponentVTable, Self::Inner>,
|
inner: vtable::VRc<i_slint_core::component::ComponentVTable, Self::Inner>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { inner }
|
Self { inner }
|
||||||
}
|
}
|
||||||
|
@ -988,9 +985,8 @@ impl ComponentHandle for ComponentInstance {
|
||||||
|
|
||||||
fn run(&self) {
|
fn run(&self) {
|
||||||
self.show();
|
self.show();
|
||||||
slint_backend_selector_internal::backend().run_event_loop(
|
i_slint_backend_selector::backend()
|
||||||
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed,
|
.run_event_loop(i_slint_core::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed);
|
||||||
);
|
|
||||||
self.hide();
|
self.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,7 +1003,7 @@ impl ComponentHandle for ComponentInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ComponentInstance>
|
impl From<ComponentInstance>
|
||||||
for vtable::VRc<slint_core_internal::component::ComponentVTable, ErasedComponentBox>
|
for vtable::VRc<i_slint_core::component::ComponentVTable, ErasedComponentBox>
|
||||||
{
|
{
|
||||||
fn from(value: ComponentInstance) -> Self {
|
fn from(value: ComponentInstance) -> Self {
|
||||||
value.inner
|
value.inner
|
||||||
|
@ -1057,31 +1053,30 @@ pub enum InvokeCallbackError {
|
||||||
/// events from the windowing system in order to render to the screen
|
/// events from the windowing system in order to render to the screen
|
||||||
/// and react to user input.
|
/// and react to user input.
|
||||||
pub fn run_event_loop() {
|
pub fn run_event_loop() {
|
||||||
slint_backend_selector_internal::backend().run_event_loop(
|
i_slint_backend_selector::backend()
|
||||||
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed,
|
.run_event_loop(i_slint_core::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This module contains a few function use by tests
|
/// This module contains a few function use by tests
|
||||||
pub mod testing {
|
pub mod testing {
|
||||||
use super::ComponentHandle;
|
use super::ComponentHandle;
|
||||||
use slint_core_internal::window::WindowHandleAccess;
|
use i_slint_core::window::WindowHandleAccess;
|
||||||
|
|
||||||
/// Wrapper around [`slint_core_internal::tests::slint_send_mouse_click`]
|
/// Wrapper around [`i_slint_core::tests::slint_send_mouse_click`]
|
||||||
pub fn send_mouse_click(comp: &super::ComponentInstance, x: f32, y: f32) {
|
pub fn send_mouse_click(comp: &super::ComponentInstance, x: f32, y: f32) {
|
||||||
slint_core_internal::tests::slint_send_mouse_click(
|
i_slint_core::tests::slint_send_mouse_click(
|
||||||
&vtable::VRc::into_dyn(comp.inner.clone()),
|
&vtable::VRc::into_dyn(comp.inner.clone()),
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
comp.window().window_handle(),
|
comp.window().window_handle(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/// Wrapper around [`slint_core_internal::tests::send_keyboard_string_sequence`]
|
/// Wrapper around [`i_slint_core::tests::send_keyboard_string_sequence`]
|
||||||
pub fn send_keyboard_string_sequence(
|
pub fn send_keyboard_string_sequence(
|
||||||
comp: &super::ComponentInstance,
|
comp: &super::ComponentInstance,
|
||||||
string: slint_core_internal::SharedString,
|
string: i_slint_core::SharedString,
|
||||||
) {
|
) {
|
||||||
slint_core_internal::tests::send_keyboard_string_sequence(
|
i_slint_core::tests::send_keyboard_string_sequence(
|
||||||
&string,
|
&string,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
comp.window().window_handle(),
|
comp.window().window_handle(),
|
||||||
|
@ -1091,7 +1086,7 @@ pub mod testing {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn component_definition_properties() {
|
fn component_definition_properties() {
|
||||||
slint_backend_testing_internal::init();
|
i_slint_backend_testing::init();
|
||||||
let mut compiler = ComponentCompiler::default();
|
let mut compiler = ComponentCompiler::default();
|
||||||
compiler.set_style("fluent".into());
|
compiler.set_style("fluent".into());
|
||||||
let comp_def = spin_on::spin_on(
|
let comp_def = spin_on::spin_on(
|
||||||
|
@ -1139,7 +1134,7 @@ fn component_definition_properties() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn component_definition_properties2() {
|
fn component_definition_properties2() {
|
||||||
slint_backend_testing_internal::init();
|
i_slint_backend_testing::init();
|
||||||
let mut compiler = ComponentCompiler::default();
|
let mut compiler = ComponentCompiler::default();
|
||||||
compiler.set_style("fluent".into());
|
compiler.set_style("fluent".into());
|
||||||
let comp_def = spin_on::spin_on(
|
let comp_def = spin_on::spin_on(
|
||||||
|
@ -1169,7 +1164,7 @@ fn component_definition_properties2() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn globals() {
|
fn globals() {
|
||||||
slint_backend_testing_internal::init();
|
i_slint_backend_testing::init();
|
||||||
let mut compiler = ComponentCompiler::default();
|
let mut compiler = ComponentCompiler::default();
|
||||||
compiler.set_style("fluent".into());
|
compiler.set_style("fluent".into());
|
||||||
let definition = spin_on::spin_on(
|
let definition = spin_on::spin_on(
|
||||||
|
@ -1287,7 +1282,7 @@ fn globals() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn component_definition_struct_properties() {
|
fn component_definition_struct_properties() {
|
||||||
slint_backend_testing_internal::init();
|
i_slint_backend_testing::init();
|
||||||
let mut compiler = ComponentCompiler::default();
|
let mut compiler = ComponentCompiler::default();
|
||||||
compiler.set_style("fluent".into());
|
compiler.set_style("fluent".into());
|
||||||
let comp_def = spin_on::spin_on(
|
let comp_def = spin_on::spin_on(
|
||||||
|
@ -1337,8 +1332,8 @@ fn component_definition_struct_properties() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn component_definition_model_properties() {
|
fn component_definition_model_properties() {
|
||||||
use slint_core_internal::model::*;
|
use i_slint_core::model::*;
|
||||||
slint_backend_testing_internal::init();
|
i_slint_backend_testing::init();
|
||||||
let mut compiler = ComponentCompiler::default();
|
let mut compiler = ComponentCompiler::default();
|
||||||
compiler.set_style("fluent".into());
|
compiler.set_style("fluent".into());
|
||||||
let comp_def = spin_on::spin_on(compiler.build_from_source(
|
let comp_def = spin_on::spin_on(compiler.build_from_source(
|
||||||
|
|
|
@ -6,26 +6,24 @@ use crate::{api::Value, dynamic_type, eval};
|
||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
use core::ptr::NonNull;
|
use core::ptr::NonNull;
|
||||||
use dynamic_type::{Instance, InstanceBox};
|
use dynamic_type::{Instance, InstanceBox};
|
||||||
use slint_compiler_internal::expression_tree::{Expression, NamedReference};
|
use i_slint_compiler::expression_tree::{Expression, NamedReference};
|
||||||
use slint_compiler_internal::langtype::Type;
|
use i_slint_compiler::langtype::Type;
|
||||||
use slint_compiler_internal::object_tree::ElementRc;
|
use i_slint_compiler::object_tree::ElementRc;
|
||||||
use slint_compiler_internal::*;
|
use i_slint_compiler::*;
|
||||||
use slint_compiler_internal::{diagnostics::BuildDiagnostics, object_tree::PropertyDeclaration};
|
use i_slint_compiler::{diagnostics::BuildDiagnostics, object_tree::PropertyDeclaration};
|
||||||
use slint_core_internal::api::Window;
|
use i_slint_core::api::Window;
|
||||||
use slint_core_internal::component::{Component, ComponentRef, ComponentRefPin, ComponentVTable};
|
use i_slint_core::component::{Component, ComponentRef, ComponentRefPin, ComponentVTable};
|
||||||
use slint_core_internal::item_tree::{
|
use i_slint_core::item_tree::{
|
||||||
ItemTreeNode, ItemVisitorRefMut, ItemVisitorVTable, TraversalOrder, VisitChildrenResult,
|
ItemTreeNode, ItemVisitorRefMut, ItemVisitorVTable, TraversalOrder, VisitChildrenResult,
|
||||||
};
|
};
|
||||||
use slint_core_internal::items::{
|
use i_slint_core::items::{Flickable, ItemRc, ItemRef, ItemVTable, ItemWeak, PropertyAnimation};
|
||||||
Flickable, ItemRc, ItemRef, ItemVTable, ItemWeak, PropertyAnimation,
|
use i_slint_core::layout::{BoxLayoutCellData, LayoutInfo, Orientation};
|
||||||
};
|
use i_slint_core::model::RepeatedComponent;
|
||||||
use slint_core_internal::layout::{BoxLayoutCellData, LayoutInfo, Orientation};
|
use i_slint_core::model::Repeater;
|
||||||
use slint_core_internal::model::RepeatedComponent;
|
use i_slint_core::properties::InterpolatedPropertyValue;
|
||||||
use slint_core_internal::model::Repeater;
|
use i_slint_core::rtti::{self, AnimatedBindingKind, FieldOffset, PropertyInfo};
|
||||||
use slint_core_internal::properties::InterpolatedPropertyValue;
|
use i_slint_core::window::{WindowHandleAccess, WindowRc};
|
||||||
use slint_core_internal::rtti::{self, AnimatedBindingKind, FieldOffset, PropertyInfo};
|
use i_slint_core::{Brush, Color, Property, SharedString, SharedVector};
|
||||||
use slint_core_internal::window::{WindowHandleAccess, WindowRc};
|
|
||||||
use slint_core_internal::{Brush, Color, Property, SharedString, SharedVector};
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::{pin::Pin, rc::Rc};
|
use std::{pin::Pin, rc::Rc};
|
||||||
|
@ -64,7 +62,7 @@ impl<'id> Drop for ComponentBox<'id> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let instance_ref = self.borrow_instance();
|
let instance_ref = self.borrow_instance();
|
||||||
if let Some(window) = eval::window_ref(instance_ref) {
|
if let Some(window) = eval::window_ref(instance_ref) {
|
||||||
slint_core_internal::component::init_component_items(
|
i_slint_core::component::init_component_items(
|
||||||
instance_ref.instance,
|
instance_ref.instance,
|
||||||
instance_ref.component_type.item_tree.as_slice(),
|
instance_ref.component_type.item_tree.as_slice(),
|
||||||
window,
|
window,
|
||||||
|
@ -160,10 +158,7 @@ impl Component for ErasedComponentBox {
|
||||||
self.borrow().as_ref().visit_children_item(index, order, visitor)
|
self.borrow().as_ref().visit_children_item(index, order, visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout_info(
|
fn layout_info(self: Pin<&Self>, orientation: Orientation) -> i_slint_core::layout::LayoutInfo {
|
||||||
self: Pin<&Self>,
|
|
||||||
orientation: Orientation,
|
|
||||||
) -> slint_core_internal::layout::LayoutInfo {
|
|
||||||
self.borrow().as_ref().layout_info(orientation)
|
self.borrow().as_ref().layout_info(orientation)
|
||||||
}
|
}
|
||||||
fn get_item_ref(self: Pin<&Self>, index: usize) -> Pin<ItemRef> {
|
fn get_item_ref(self: Pin<&Self>, index: usize) -> Pin<ItemRef> {
|
||||||
|
@ -177,7 +172,7 @@ impl Component for ErasedComponentBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
slint_core_internal::ComponentVTable_static!(static COMPONENT_BOX_VT for ErasedComponentBox);
|
i_slint_core::ComponentVTable_static!(static COMPONENT_BOX_VT for ErasedComponentBox);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(crate) struct ComponentExtraData {
|
pub(crate) struct ComponentExtraData {
|
||||||
|
@ -225,7 +220,7 @@ impl<'id> ErasedRepeaterWithinComponent<'id> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Callback = slint_core_internal::Callback<[Value], Value>;
|
type Callback = i_slint_core::Callback<[Value], Value>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ErasedComponentDescription(Rc<ComponentDescription<'static>>);
|
pub struct ErasedComponentDescription(Rc<ComponentDescription<'static>>);
|
||||||
|
@ -293,7 +288,7 @@ pub struct ComponentDescription<'id> {
|
||||||
|
|
||||||
fn internal_properties_to_public<'a>(
|
fn internal_properties_to_public<'a>(
|
||||||
prop_iter: impl Iterator<Item = (&'a String, &'a PropertyDeclaration)> + 'a,
|
prop_iter: impl Iterator<Item = (&'a String, &'a PropertyDeclaration)> + 'a,
|
||||||
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + 'a {
|
) -> impl Iterator<Item = (String, i_slint_compiler::langtype::Type)> + 'a {
|
||||||
prop_iter.filter(|(_, v)| v.expose_in_public_api).map(|(s, v)| {
|
prop_iter.filter(|(_, v)| v.expose_in_public_api).map(|(s, v)| {
|
||||||
let name = v
|
let name = v
|
||||||
.node
|
.node
|
||||||
|
@ -320,7 +315,7 @@ impl<'id> ComponentDescription<'id> {
|
||||||
/// We try to preserve the dashes and underscore as written in the property declaration
|
/// We try to preserve the dashes and underscore as written in the property declaration
|
||||||
pub fn properties(
|
pub fn properties(
|
||||||
&self,
|
&self,
|
||||||
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_ {
|
) -> impl Iterator<Item = (String, i_slint_compiler::langtype::Type)> + '_ {
|
||||||
internal_properties_to_public(self.public_properties.iter())
|
internal_properties_to_public(self.public_properties.iter())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +330,7 @@ impl<'id> ComponentDescription<'id> {
|
||||||
pub fn global_properties(
|
pub fn global_properties(
|
||||||
&self,
|
&self,
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Option<impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_> {
|
) -> Option<impl Iterator<Item = (String, i_slint_compiler::langtype::Type)> + '_> {
|
||||||
self.exported_globals_by_name
|
self.exported_globals_by_name
|
||||||
.get(crate::normalize_identifier(name).as_ref())
|
.get(crate::normalize_identifier(name).as_ref())
|
||||||
.and_then(|global_idx| self.compiled_globals.get(*global_idx))
|
.and_then(|global_idx| self.compiled_globals.get(*global_idx))
|
||||||
|
@ -348,12 +343,12 @@ impl<'id> ComponentDescription<'id> {
|
||||||
#[cfg(target_arch = "wasm32")] canvas_id: String,
|
#[cfg(target_arch = "wasm32")] canvas_id: String,
|
||||||
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
|
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let window = slint_backend_selector_internal::backend().create_window();
|
let window = i_slint_backend_selector::backend().create_window();
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
let window = {
|
let window = {
|
||||||
// Ensure that the backend is initialized
|
// Ensure that the backend is initialized
|
||||||
slint_backend_selector_internal::backend();
|
i_slint_backend_selector::backend();
|
||||||
slint_backend_gl_internal::create_gl_window_with_canvas_id(canvas_id)
|
i_slint_backend_gl::create_gl_window_with_canvas_id(canvas_id)
|
||||||
};
|
};
|
||||||
self.create_with_existing_window(&window)
|
self.create_with_existing_window(&window)
|
||||||
}
|
}
|
||||||
|
@ -361,7 +356,7 @@ impl<'id> ComponentDescription<'id> {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn create_with_existing_window(
|
pub fn create_with_existing_window(
|
||||||
self: Rc<Self>,
|
self: Rc<Self>,
|
||||||
window: &slint_core_internal::window::WindowRc,
|
window: &i_slint_core::window::WindowRc,
|
||||||
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
|
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
|
||||||
let component_ref = instantiate(self, None, Some(window));
|
let component_ref = instantiate(self, None, Some(window));
|
||||||
component_ref
|
component_ref
|
||||||
|
@ -423,7 +418,7 @@ impl<'id> ComponentDescription<'id> {
|
||||||
.set_binding(
|
.set_binding(
|
||||||
Pin::new_unchecked(&*component.as_ptr().add(x.offset)),
|
Pin::new_unchecked(&*component.as_ptr().add(x.offset)),
|
||||||
binding,
|
binding,
|
||||||
slint_core_internal::rtti::AnimatedBindingKind::NotAnimated,
|
i_slint_core::rtti::AnimatedBindingKind::NotAnimated,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
@ -582,7 +577,7 @@ extern "C" fn visit_children_item(
|
||||||
generativity::make_guard!(guard);
|
generativity::make_guard!(guard);
|
||||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||||
let comp_rc = instance_ref.self_weak().get().unwrap().upgrade().unwrap();
|
let comp_rc = instance_ref.self_weak().get().unwrap().upgrade().unwrap();
|
||||||
slint_core_internal::item_tree::visit_item_tree(
|
i_slint_core::item_tree::visit_item_tree(
|
||||||
instance_ref.instance,
|
instance_ref.instance,
|
||||||
&vtable::VRc::into_dyn(comp_rc),
|
&vtable::VRc::into_dyn(comp_rc),
|
||||||
instance_ref.component_type.item_tree.as_slice(),
|
instance_ref.component_type.item_tree.as_slice(),
|
||||||
|
@ -684,13 +679,10 @@ pub async fn load(
|
||||||
path: std::path::PathBuf,
|
path: std::path::PathBuf,
|
||||||
mut compiler_config: CompilerConfiguration,
|
mut compiler_config: CompilerConfiguration,
|
||||||
guard: generativity::Guard<'_>,
|
guard: generativity::Guard<'_>,
|
||||||
) -> (
|
) -> (Result<Rc<ComponentDescription<'_>>, ()>, i_slint_compiler::diagnostics::BuildDiagnostics) {
|
||||||
Result<Rc<ComponentDescription<'_>>, ()>,
|
|
||||||
slint_compiler_internal::diagnostics::BuildDiagnostics,
|
|
||||||
) {
|
|
||||||
if compiler_config.style.is_none() && std::env::var("SLINT_STYLE").is_err() {
|
if compiler_config.style.is_none() && std::env::var("SLINT_STYLE").is_err() {
|
||||||
// Defaults to native if it exists:
|
// Defaults to native if it exists:
|
||||||
compiler_config.style = Some(if slint_backend_selector_internal::HAS_NATIVE_STYLE {
|
compiler_config.style = Some(if i_slint_backend_selector::HAS_NATIVE_STYLE {
|
||||||
"native".to_owned()
|
"native".to_owned()
|
||||||
} else {
|
} else {
|
||||||
"fluent".to_owned()
|
"fluent".to_owned()
|
||||||
|
@ -720,7 +712,7 @@ pub(crate) fn generate_component<'id>(
|
||||||
//dbg!(&*component.root_element.borrow());
|
//dbg!(&*component.root_element.borrow());
|
||||||
let mut rtti = HashMap::new();
|
let mut rtti = HashMap::new();
|
||||||
{
|
{
|
||||||
use slint_core_internal::items::*;
|
use i_slint_core::items::*;
|
||||||
rtti.extend(
|
rtti.extend(
|
||||||
[
|
[
|
||||||
rtti_for::<ImageItem>(),
|
rtti_for::<ImageItem>(),
|
||||||
|
@ -760,7 +752,7 @@ pub(crate) fn generate_component<'id>(
|
||||||
Next::push(rtti);
|
Next::push(rtti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slint_backend_selector_internal::NativeWidgets::push(&mut rtti);
|
i_slint_backend_selector::NativeWidgets::push(&mut rtti);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TreeBuilder<'id> {
|
struct TreeBuilder<'id> {
|
||||||
|
@ -913,7 +905,7 @@ pub(crate) fn generate_component<'id>(
|
||||||
Type::Angle => animated_property_info::<f32>(),
|
Type::Angle => animated_property_info::<f32>(),
|
||||||
Type::PhysicalLength => animated_property_info::<f32>(),
|
Type::PhysicalLength => animated_property_info::<f32>(),
|
||||||
Type::LogicalLength => animated_property_info::<f32>(),
|
Type::LogicalLength => animated_property_info::<f32>(),
|
||||||
Type::Image => property_info::<slint_core_internal::graphics::Image>(),
|
Type::Image => property_info::<i_slint_core::graphics::Image>(),
|
||||||
Type::Bool => property_info::<bool>(),
|
Type::Bool => property_info::<bool>(),
|
||||||
Type::Callback { .. } => {
|
Type::Callback { .. } => {
|
||||||
custom_callbacks
|
custom_callbacks
|
||||||
|
@ -921,38 +913,28 @@ pub(crate) fn generate_component<'id>(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Type::Struct { name: Some(name), .. } if name.ends_with("::StateInfo") => {
|
Type::Struct { name: Some(name), .. } if name.ends_with("::StateInfo") => {
|
||||||
property_info::<slint_core_internal::properties::StateInfo>()
|
property_info::<i_slint_core::properties::StateInfo>()
|
||||||
}
|
}
|
||||||
Type::Struct { .. } => property_info::<Value>(),
|
Type::Struct { .. } => property_info::<Value>(),
|
||||||
Type::Array(_) => property_info::<Value>(),
|
Type::Array(_) => property_info::<Value>(),
|
||||||
Type::Percent => property_info::<f32>(),
|
Type::Percent => property_info::<f32>(),
|
||||||
Type::Enumeration(e) => match e.name.as_ref() {
|
Type::Enumeration(e) => match e.name.as_ref() {
|
||||||
"LayoutAlignment" => {
|
"LayoutAlignment" => property_info::<i_slint_core::layout::LayoutAlignment>(),
|
||||||
property_info::<slint_core_internal::layout::LayoutAlignment>()
|
|
||||||
}
|
|
||||||
"TextHorizontalAlignment" => {
|
"TextHorizontalAlignment" => {
|
||||||
property_info::<slint_core_internal::items::TextHorizontalAlignment>()
|
property_info::<i_slint_core::items::TextHorizontalAlignment>()
|
||||||
}
|
}
|
||||||
"TextVerticalAlignment" => {
|
"TextVerticalAlignment" => {
|
||||||
property_info::<slint_core_internal::items::TextVerticalAlignment>()
|
property_info::<i_slint_core::items::TextVerticalAlignment>()
|
||||||
}
|
|
||||||
"TextWrap" => property_info::<slint_core_internal::items::TextWrap>(),
|
|
||||||
"TextOverflow" => property_info::<slint_core_internal::items::TextOverflow>(),
|
|
||||||
"ImageFit" => property_info::<slint_core_internal::items::ImageFit>(),
|
|
||||||
"FillRule" => property_info::<slint_core_internal::items::FillRule>(),
|
|
||||||
"MouseCursor" => property_info::<slint_core_internal::items::MouseCursor>(),
|
|
||||||
"StandardButtonKind" => {
|
|
||||||
property_info::<slint_core_internal::items::StandardButtonKind>()
|
|
||||||
}
|
|
||||||
"DialogButtonRole" => {
|
|
||||||
property_info::<slint_core_internal::items::DialogButtonRole>()
|
|
||||||
}
|
|
||||||
"PointerEventButton" => {
|
|
||||||
property_info::<slint_core_internal::items::PointerEventButton>()
|
|
||||||
}
|
|
||||||
"PointerEventKind" => {
|
|
||||||
property_info::<slint_core_internal::items::PointerEventKind>()
|
|
||||||
}
|
}
|
||||||
|
"TextWrap" => property_info::<i_slint_core::items::TextWrap>(),
|
||||||
|
"TextOverflow" => property_info::<i_slint_core::items::TextOverflow>(),
|
||||||
|
"ImageFit" => property_info::<i_slint_core::items::ImageFit>(),
|
||||||
|
"FillRule" => property_info::<i_slint_core::items::FillRule>(),
|
||||||
|
"MouseCursor" => property_info::<i_slint_core::items::MouseCursor>(),
|
||||||
|
"StandardButtonKind" => property_info::<i_slint_core::items::StandardButtonKind>(),
|
||||||
|
"DialogButtonRole" => property_info::<i_slint_core::items::DialogButtonRole>(),
|
||||||
|
"PointerEventButton" => property_info::<i_slint_core::items::PointerEventButton>(),
|
||||||
|
"PointerEventKind" => property_info::<i_slint_core::items::PointerEventKind>(),
|
||||||
_ => panic!("unknown enum"),
|
_ => panic!("unknown enum"),
|
||||||
},
|
},
|
||||||
Type::LayoutCache => property_info::<SharedVector<f32>>(),
|
Type::LayoutCache => property_info::<SharedVector<f32>>(),
|
||||||
|
@ -1055,16 +1037,16 @@ pub(crate) fn generate_component<'id>(
|
||||||
|
|
||||||
pub fn animation_for_property(
|
pub fn animation_for_property(
|
||||||
component: InstanceRef,
|
component: InstanceRef,
|
||||||
animation: &Option<slint_compiler_internal::object_tree::PropertyAnimation>,
|
animation: &Option<i_slint_compiler::object_tree::PropertyAnimation>,
|
||||||
) -> AnimatedBindingKind {
|
) -> AnimatedBindingKind {
|
||||||
match animation {
|
match animation {
|
||||||
Some(slint_compiler_internal::object_tree::PropertyAnimation::Static(anim_elem)) => {
|
Some(i_slint_compiler::object_tree::PropertyAnimation::Static(anim_elem)) => {
|
||||||
AnimatedBindingKind::Animation(eval::new_struct_with_bindings(
|
AnimatedBindingKind::Animation(eval::new_struct_with_bindings(
|
||||||
&anim_elem.borrow().bindings,
|
&anim_elem.borrow().bindings,
|
||||||
&mut eval::EvalLocalContext::from_component_instance(component),
|
&mut eval::EvalLocalContext::from_component_instance(component),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
Some(slint_compiler_internal::object_tree::PropertyAnimation::Transition {
|
Some(i_slint_compiler::object_tree::PropertyAnimation::Transition {
|
||||||
animations,
|
animations,
|
||||||
state_ref,
|
state_ref,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -1073,7 +1055,7 @@ pub fn animation_for_property(
|
||||||
let animations = animations.clone();
|
let animations = animations.clone();
|
||||||
let state_ref = state_ref.clone();
|
let state_ref = state_ref.clone();
|
||||||
AnimatedBindingKind::Transition(Box::new(
|
AnimatedBindingKind::Transition(Box::new(
|
||||||
move || -> (PropertyAnimation, slint_core_internal::animations::Instant) {
|
move || -> (PropertyAnimation, i_slint_core::animations::Instant) {
|
||||||
generativity::make_guard!(guard);
|
generativity::make_guard!(guard);
|
||||||
let component = unsafe {
|
let component = unsafe {
|
||||||
InstanceRef::from_pin_ref(
|
InstanceRef::from_pin_ref(
|
||||||
|
@ -1087,8 +1069,7 @@ pub fn animation_for_property(
|
||||||
|
|
||||||
let mut context = eval::EvalLocalContext::from_component_instance(component);
|
let mut context = eval::EvalLocalContext::from_component_instance(component);
|
||||||
let state = eval::eval_expression(&state_ref, &mut context);
|
let state = eval::eval_expression(&state_ref, &mut context);
|
||||||
let state_info: slint_core_internal::properties::StateInfo =
|
let state_info: i_slint_core::properties::StateInfo = state.try_into().unwrap();
|
||||||
state.try_into().unwrap();
|
|
||||||
for a in &animations {
|
for a in &animations {
|
||||||
if (a.is_out && a.state_id == state_info.previous_state)
|
if (a.is_out && a.state_id == state_info.previous_state)
|
||||||
|| (!a.is_out && a.state_id == state_info.current_state)
|
|| (!a.is_out && a.state_id == state_info.current_state)
|
||||||
|
@ -1113,7 +1094,7 @@ pub fn animation_for_property(
|
||||||
pub fn instantiate(
|
pub fn instantiate(
|
||||||
component_type: Rc<ComponentDescription>,
|
component_type: Rc<ComponentDescription>,
|
||||||
parent_ctx: Option<ComponentRefPin>,
|
parent_ctx: Option<ComponentRefPin>,
|
||||||
window: Option<&slint_core_internal::window::WindowRc>,
|
window: Option<&i_slint_core::window::WindowRc>,
|
||||||
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
|
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
|
||||||
let mut instance = component_type.dynamic_type.clone().create_instance();
|
let mut instance = component_type.dynamic_type.clone().create_instance();
|
||||||
|
|
||||||
|
@ -1149,7 +1130,7 @@ pub fn instantiate(
|
||||||
let instance_ref = component_box.borrow_instance();
|
let instance_ref = component_box.borrow_instance();
|
||||||
|
|
||||||
if !component_type.original.is_global() {
|
if !component_type.original.is_global() {
|
||||||
slint_core_internal::component::init_component_items(
|
i_slint_core::component::init_component_items(
|
||||||
instance_ref.instance,
|
instance_ref.instance,
|
||||||
instance_ref.component_type.item_tree.as_slice(),
|
instance_ref.component_type.item_tree.as_slice(),
|
||||||
eval::window_ref(instance_ref).unwrap(),
|
eval::window_ref(instance_ref).unwrap(),
|
||||||
|
@ -1238,10 +1219,10 @@ pub fn instantiate(
|
||||||
if is_state_info {
|
if is_state_info {
|
||||||
let prop = Pin::new_unchecked(
|
let prop = Pin::new_unchecked(
|
||||||
&*(instance_ref.as_ptr().add(*offset)
|
&*(instance_ref.as_ptr().add(*offset)
|
||||||
as *const Property<slint_core_internal::properties::StateInfo>),
|
as *const Property<i_slint_core::properties::StateInfo>),
|
||||||
);
|
);
|
||||||
let e = binding.expression.clone();
|
let e = binding.expression.clone();
|
||||||
slint_core_internal::properties::set_state_binding(prop, move || {
|
i_slint_core::properties::set_state_binding(prop, move || {
|
||||||
generativity::make_guard!(guard);
|
generativity::make_guard!(guard);
|
||||||
eval::eval_expression(
|
eval::eval_expression(
|
||||||
&e,
|
&e,
|
||||||
|
@ -1364,7 +1345,7 @@ pub fn instantiate(
|
||||||
InstanceRef::from_pin_ref(c, guard)
|
InstanceRef::from_pin_ref(c, guard)
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
slint_core_internal::model::ModelRc::new(crate::value_model::ValueModel::new(m))
|
i_slint_core::model::ModelRc::new(crate::value_model::ValueModel::new(m))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1461,8 +1442,8 @@ impl<'id> From<ComponentBox<'id>> for ErasedComponentBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl slint_core_internal::window::WindowHandleAccess for ErasedComponentBox {
|
impl i_slint_core::window::WindowHandleAccess for ErasedComponentBox {
|
||||||
fn window_handle(&self) -> &Rc<slint_core_internal::window::Window> {
|
fn window_handle(&self) -> &Rc<i_slint_core::window::Window> {
|
||||||
self.window().window_handle()
|
self.window().window_handle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1610,7 +1591,7 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
|
||||||
&extra_data.self_weak
|
&extra_data.self_weak
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window(&self) -> &slint_core_internal::api::Window {
|
pub fn window(&self) -> &i_slint_core::api::Window {
|
||||||
self.component_type.window_offset.apply(self.as_ref()).as_ref().as_ref().unwrap()
|
self.component_type.window_offset.apply(self.as_ref()).as_ref().as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1645,7 +1626,7 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
|
||||||
/// Show the popup at the given location
|
/// Show the popup at the given location
|
||||||
pub fn show_popup(
|
pub fn show_popup(
|
||||||
popup: &object_tree::PopupWindow,
|
popup: &object_tree::PopupWindow,
|
||||||
pos: slint_core_internal::graphics::Point,
|
pos: i_slint_core::graphics::Point,
|
||||||
parent_comp: ComponentRefPin,
|
parent_comp: ComponentRefPin,
|
||||||
parent_window: &WindowRc,
|
parent_window: &WindowRc,
|
||||||
parent_item: &ItemRc,
|
parent_item: &ItemRc,
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
use core::alloc::Layout;
|
use core::alloc::Layout;
|
||||||
use generativity::Id;
|
use generativity::Id;
|
||||||
use slint_core_internal::rtti::FieldOffset;
|
use i_slint_core::rtti::FieldOffset;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
unsafe fn construct_fn<T: Default>(ptr: *mut u8) {
|
unsafe fn construct_fn<T: Default>(ptr: *mut u8) {
|
||||||
|
|
|
@ -11,12 +11,12 @@ use corelib::model::{Model, ModelRc};
|
||||||
use corelib::rtti::AnimatedBindingKind;
|
use corelib::rtti::AnimatedBindingKind;
|
||||||
use corelib::window::{WindowHandleAccess, WindowRc};
|
use corelib::window::{WindowHandleAccess, WindowRc};
|
||||||
use corelib::{Brush, Color, PathData, SharedString, SharedVector};
|
use corelib::{Brush, Color, PathData, SharedString, SharedVector};
|
||||||
use slint_compiler_internal::expression_tree::{
|
use i_slint_compiler::expression_tree::{
|
||||||
BuiltinFunction, EasingCurve, Expression, Path as ExprPath, PathElement as ExprPathElement,
|
BuiltinFunction, EasingCurve, Expression, Path as ExprPath, PathElement as ExprPathElement,
|
||||||
};
|
};
|
||||||
use slint_compiler_internal::langtype::Type;
|
use i_slint_compiler::langtype::Type;
|
||||||
use slint_compiler_internal::object_tree::ElementRc;
|
use i_slint_compiler::object_tree::ElementRc;
|
||||||
use slint_core_internal as corelib;
|
use i_slint_core as corelib;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
|
||||||
|
|
||||||
crate::dynamic_component::show_popup(
|
crate::dynamic_component::show_popup(
|
||||||
popup,
|
popup,
|
||||||
slint_core_internal::graphics::Point::new(x.try_into().unwrap(), y.try_into().unwrap()),
|
i_slint_core::graphics::Point::new(x.try_into().unwrap(), y.try_into().unwrap()),
|
||||||
component.borrow(),
|
component.borrow(),
|
||||||
window_ref(component).unwrap(),
|
window_ref(component).unwrap(),
|
||||||
&parent_item);
|
&parent_item);
|
||||||
|
@ -519,13 +519,13 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
|
||||||
}
|
}
|
||||||
Expression::ImageReference{ resource_ref, .. } => {
|
Expression::ImageReference{ resource_ref, .. } => {
|
||||||
Value::Image(match resource_ref {
|
Value::Image(match resource_ref {
|
||||||
slint_compiler_internal::expression_tree::ImageReference::None => {
|
i_slint_compiler::expression_tree::ImageReference::None => {
|
||||||
Ok(Default::default())
|
Ok(Default::default())
|
||||||
}
|
}
|
||||||
slint_compiler_internal::expression_tree::ImageReference::AbsolutePath(path) => {
|
i_slint_compiler::expression_tree::ImageReference::AbsolutePath(path) => {
|
||||||
corelib::graphics::Image::load_from_path(std::path::Path::new(path))
|
corelib::graphics::Image::load_from_path(std::path::Path::new(path))
|
||||||
}
|
}
|
||||||
slint_compiler_internal::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => {
|
i_slint_compiler::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => {
|
||||||
let toplevel_instance = match local_context.component_instance {
|
let toplevel_instance = match local_context.component_instance {
|
||||||
ComponentInstance::InstanceRef(instance) => instance.toplevel_instance(),
|
ComponentInstance::InstanceRef(instance) => instance.toplevel_instance(),
|
||||||
ComponentInstance::GlobalComponent(_) => unimplemented!(),
|
ComponentInstance::GlobalComponent(_) => unimplemented!(),
|
||||||
|
@ -533,7 +533,7 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
|
||||||
let extra_data = toplevel_instance.component_type.extra_data_offset.apply(toplevel_instance.as_ref());
|
let extra_data = toplevel_instance.component_type.extra_data_offset.apply(toplevel_instance.as_ref());
|
||||||
let path = extra_data.embedded_file_resources.get(resource_id).expect("internal error: invalid resource id");
|
let path = extra_data.embedded_file_resources.get(resource_id).expect("internal error: invalid resource id");
|
||||||
|
|
||||||
let virtual_file = slint_compiler_internal::fileaccess::load_file(std::path::Path::new(path)).unwrap(); // embedding pass ensured that the file exists
|
let virtual_file = i_slint_compiler::fileaccess::load_file(std::path::Path::new(path)).unwrap(); // embedding pass ensured that the file exists
|
||||||
|
|
||||||
if let (std::borrow::Cow::Borrowed(static_path), Some(static_data)) = (virtual_file.path, virtual_file.builtin_contents) {
|
if let (std::borrow::Cow::Borrowed(static_path), Some(static_data)) = (virtual_file.path, virtual_file.builtin_contents) {
|
||||||
let virtual_file_extension = std::path::Path::new(static_path).extension().unwrap().to_str().unwrap();
|
let virtual_file_extension = std::path::Path::new(static_path).extension().unwrap().to_str().unwrap();
|
||||||
|
@ -550,7 +550,7 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slint_compiler_internal::expression_tree::ImageReference::EmbeddedTexture { .. } => {
|
i_slint_compiler::expression_tree::ImageReference::EmbeddedTexture { .. } => {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}.unwrap_or_else(|_| {
|
}.unwrap_or_else(|_| {
|
||||||
|
@ -1054,7 +1054,7 @@ pub(crate) fn enclosing_component_instance_for_element<'a, 'old_id, 'new_id>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_struct_with_bindings<ElementType: 'static + Default + corelib::rtti::BuiltinItem>(
|
pub fn new_struct_with_bindings<ElementType: 'static + Default + corelib::rtti::BuiltinItem>(
|
||||||
bindings: &slint_compiler_internal::object_tree::BindingsMap,
|
bindings: &i_slint_compiler::object_tree::BindingsMap,
|
||||||
local_context: &mut EvalLocalContext,
|
local_context: &mut EvalLocalContext,
|
||||||
) -> ElementType {
|
) -> ElementType {
|
||||||
let mut element = ElementType::default();
|
let mut element = ElementType::default();
|
||||||
|
@ -1068,8 +1068,8 @@ pub fn new_struct_with_bindings<ElementType: 'static + Default + corelib::rtti::
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_from_lyon_path<'a>(
|
fn convert_from_lyon_path<'a>(
|
||||||
events_it: impl IntoIterator<Item = &'a slint_compiler_internal::expression_tree::Expression>,
|
events_it: impl IntoIterator<Item = &'a i_slint_compiler::expression_tree::Expression>,
|
||||||
points_it: impl IntoIterator<Item = &'a slint_compiler_internal::expression_tree::Expression>,
|
points_it: impl IntoIterator<Item = &'a i_slint_compiler::expression_tree::Expression>,
|
||||||
local_context: &mut EvalLocalContext,
|
local_context: &mut EvalLocalContext,
|
||||||
) -> PathData {
|
) -> PathData {
|
||||||
let events = events_it
|
let events = events_it
|
||||||
|
@ -1082,7 +1082,7 @@ fn convert_from_lyon_path<'a>(
|
||||||
.map(|point_expr| {
|
.map(|point_expr| {
|
||||||
let point_value = eval_expression(point_expr, local_context);
|
let point_value = eval_expression(point_expr, local_context);
|
||||||
let point_struct: Struct = point_value.try_into().unwrap();
|
let point_struct: Struct = point_value.try_into().unwrap();
|
||||||
let mut point = slint_core_internal::graphics::Point::default();
|
let mut point = i_slint_core::graphics::Point::default();
|
||||||
let x: f64 = point_struct.get_field("x").unwrap().clone().try_into().unwrap();
|
let x: f64 = point_struct.get_field("x").unwrap().clone().try_into().unwrap();
|
||||||
let y: f64 = point_struct.get_field("y").unwrap().clone().try_into().unwrap();
|
let y: f64 = point_struct.get_field("y").unwrap().clone().try_into().unwrap();
|
||||||
point.x = x as _;
|
point.x = x as _;
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
use crate::dynamic_component::InstanceRef;
|
use crate::dynamic_component::InstanceRef;
|
||||||
use crate::eval::{self, ComponentInstance, EvalLocalContext};
|
use crate::eval::{self, ComponentInstance, EvalLocalContext};
|
||||||
use crate::Value;
|
use crate::Value;
|
||||||
use slint_compiler_internal::expression_tree::Expression;
|
use i_slint_compiler::expression_tree::Expression;
|
||||||
use slint_compiler_internal::langtype::Type;
|
use i_slint_compiler::langtype::Type;
|
||||||
use slint_compiler_internal::layout::{Layout, LayoutConstraints, LayoutGeometry, Orientation};
|
use i_slint_compiler::layout::{Layout, LayoutConstraints, LayoutGeometry, Orientation};
|
||||||
use slint_compiler_internal::namedreference::NamedReference;
|
use i_slint_compiler::namedreference::NamedReference;
|
||||||
use slint_compiler_internal::object_tree::ElementRc;
|
use i_slint_compiler::object_tree::ElementRc;
|
||||||
use slint_core_internal::items::DialogButtonRole;
|
use i_slint_core::items::DialogButtonRole;
|
||||||
use slint_core_internal::layout::{self as core_layout};
|
use i_slint_core::layout::{self as core_layout};
|
||||||
use slint_core_internal::model::RepeatedComponent;
|
use i_slint_core::model::RepeatedComponent;
|
||||||
use slint_core_internal::slice::Slice;
|
use i_slint_core::slice::Slice;
|
||||||
use slint_core_internal::window::WindowRc;
|
use i_slint_core::window::WindowRc;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ fn padding_and_spacing(
|
||||||
|
|
||||||
/// return the celldata, the padding, and the spacing of a grid layout
|
/// return the celldata, the padding, and the spacing of a grid layout
|
||||||
fn grid_layout_data(
|
fn grid_layout_data(
|
||||||
grid_layout: &slint_compiler_internal::layout::GridLayout,
|
grid_layout: &i_slint_compiler::layout::GridLayout,
|
||||||
orientation: Orientation,
|
orientation: Orientation,
|
||||||
component: InstanceRef,
|
component: InstanceRef,
|
||||||
expr_eval: &impl Fn(&NamedReference) -> f32,
|
expr_eval: &impl Fn(&NamedReference) -> f32,
|
||||||
|
@ -203,7 +203,7 @@ fn grid_layout_data(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn box_layout_data(
|
fn box_layout_data(
|
||||||
box_layout: &slint_compiler_internal::layout::BoxLayout,
|
box_layout: &i_slint_compiler::layout::BoxLayout,
|
||||||
orientation: Orientation,
|
orientation: Orientation,
|
||||||
component: InstanceRef,
|
component: InstanceRef,
|
||||||
expr_eval: &impl Fn(&NamedReference) -> f32,
|
expr_eval: &impl Fn(&NamedReference) -> f32,
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
use crate::dynamic_component::ErasedComponentBox;
|
use crate::dynamic_component::ErasedComponentBox;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use slint_core_internal::model::{Model, ModelNotify, SharedVectorModel};
|
use i_slint_core::model::{Model, ModelNotify, SharedVectorModel};
|
||||||
use slint_core_internal::slice::Slice;
|
use i_slint_core::slice::Slice;
|
||||||
use slint_core_internal::window::{WindowHandleAccess, WindowRc};
|
use i_slint_core::window::{WindowHandleAccess, WindowRc};
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
use vtable::VRef;
|
use vtable::VRef;
|
||||||
|
|
||||||
|
@ -552,11 +552,11 @@ pub extern "C" fn slint_interpreter_component_instance_show(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn slint_interpreter_component_instance_window(
|
pub unsafe extern "C" fn slint_interpreter_component_instance_window(
|
||||||
inst: &ErasedComponentBox,
|
inst: &ErasedComponentBox,
|
||||||
out: *mut *const slint_core_internal::window::ffi::WindowRcOpaque,
|
out: *mut *const i_slint_core::window::ffi::WindowRcOpaque,
|
||||||
) {
|
) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
core::mem::size_of::<WindowRc>(),
|
core::mem::size_of::<WindowRc>(),
|
||||||
core::mem::size_of::<slint_core_internal::window::ffi::WindowRcOpaque>()
|
core::mem::size_of::<i_slint_core::window::ffi::WindowRcOpaque>()
|
||||||
);
|
);
|
||||||
core::ptr::write(out as *mut *const WindowRc, inst.window().window_handle() as *const _)
|
core::ptr::write(out as *mut *const WindowRc, inst.window().window_handle() as *const _)
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ impl Model for ModelAdaptorWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn model_tracker(&self) -> &dyn slint_core_internal::model::ModelTracker {
|
fn model_tracker(&self) -> &dyn i_slint_core::model::ModelTracker {
|
||||||
self.0.get_notify().as_model_notify()
|
self.0.get_notify().as_model_notify()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,12 +786,8 @@ pub unsafe extern "C" fn slint_interpreter_component_compiler_get_diagnostics(
|
||||||
line,
|
line,
|
||||||
column,
|
column,
|
||||||
level: match diagnostic.level() {
|
level: match diagnostic.level() {
|
||||||
slint_compiler_internal::diagnostics::DiagnosticLevel::Error => {
|
i_slint_compiler::diagnostics::DiagnosticLevel::Error => DiagnosticLevel::Error,
|
||||||
DiagnosticLevel::Error
|
i_slint_compiler::diagnostics::DiagnosticLevel::Warning => DiagnosticLevel::Warning,
|
||||||
}
|
|
||||||
slint_compiler_internal::diagnostics::DiagnosticLevel::Warning => {
|
|
||||||
DiagnosticLevel::Warning
|
|
||||||
}
|
|
||||||
_ => DiagnosticLevel::Warning,
|
_ => DiagnosticLevel::Warning,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,16 @@ use std::rc::Rc;
|
||||||
use crate::api::Value;
|
use crate::api::Value;
|
||||||
use crate::dynamic_component::{ErasedComponentBox, ErasedComponentDescription};
|
use crate::dynamic_component::{ErasedComponentBox, ErasedComponentDescription};
|
||||||
use crate::SetPropertyError;
|
use crate::SetPropertyError;
|
||||||
use slint_compiler_internal::namedreference::NamedReference;
|
use i_slint_compiler::namedreference::NamedReference;
|
||||||
use slint_compiler_internal::object_tree::PropertyDeclaration;
|
use i_slint_compiler::object_tree::PropertyDeclaration;
|
||||||
use slint_compiler_internal::{langtype::Type, object_tree::Component};
|
use i_slint_compiler::{langtype::Type, object_tree::Component};
|
||||||
use slint_core_internal::component::ComponentVTable;
|
use i_slint_core::component::ComponentVTable;
|
||||||
use slint_core_internal::rtti;
|
use i_slint_core::rtti;
|
||||||
|
|
||||||
pub enum CompiledGlobal {
|
pub enum CompiledGlobal {
|
||||||
Builtin {
|
Builtin {
|
||||||
name: String,
|
name: String,
|
||||||
element: Rc<slint_compiler_internal::langtype::BuiltinElement>,
|
element: Rc<i_slint_compiler::langtype::BuiltinElement>,
|
||||||
// dummy needed for iterator accessor
|
// dummy needed for iterator accessor
|
||||||
public_properties: BTreeMap<String, PropertyDeclaration>,
|
public_properties: BTreeMap<String, PropertyDeclaration>,
|
||||||
},
|
},
|
||||||
|
@ -107,7 +107,7 @@ pub fn instantiate(description: &CompiledGlobal) -> (String, Pin<Rc<dyn GlobalCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let g = slint_backend_selector_internal::NativeGlobals::instantiate(
|
let g = i_slint_backend_selector::NativeGlobals::instantiate(
|
||||||
element.native_class.class_name.as_ref(),
|
element.native_class.class_name.as_ref(),
|
||||||
);
|
);
|
||||||
(name.clone(), g)
|
(name.clone(), g)
|
||||||
|
|
|
@ -91,12 +91,12 @@ pub use api::*;
|
||||||
pub(crate) fn register_font_from_path<P: AsRef<std::path::Path>>(
|
pub(crate) fn register_font_from_path<P: AsRef<std::path::Path>>(
|
||||||
path: P,
|
path: P,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
slint_backend_selector_internal::backend().register_font_from_path(path.as_ref())
|
i_slint_backend_selector::backend().register_font_from_path(path.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// (Re-export from corelib.)
|
/// (Re-export from corelib.)
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use slint_core_internal::{Brush, Color, SharedString, SharedVector};
|
pub use i_slint_core::{Brush, Color, SharedString, SharedVector};
|
||||||
|
|
||||||
/// One need to use at least one function in each module in order to get them
|
/// One need to use at least one function in each module in order to get them
|
||||||
/// exported in the final binary.
|
/// exported in the final binary.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reuse_window() {
|
fn reuse_window() {
|
||||||
slint_backend_testing_internal::init();
|
i_slint_backend_testing::init();
|
||||||
use crate::{ComponentCompiler, ComponentHandle, SharedString, Value};
|
use crate::{ComponentCompiler, ComponentHandle, SharedString, Value};
|
||||||
let code = r#"
|
let code = r#"
|
||||||
MainWindow := Window {
|
MainWindow := Window {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
use crate::api::Value;
|
use crate::api::Value;
|
||||||
use slint_core_internal::model::{Model, ModelTracker};
|
use i_slint_core::model::{Model, ModelTracker};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
pub struct ValueModel {
|
pub struct ValueModel {
|
||||||
|
@ -16,7 +16,7 @@ impl ValueModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ModelTracker for ValueModel {
|
impl ModelTracker for ValueModel {
|
||||||
fn attach_peer(&self, peer: slint_core_internal::model::ModelPeer) {
|
fn attach_peer(&self, peer: i_slint_core::model::ModelPeer) {
|
||||||
if let Value::Model(ref model_ptr) = *self.value.borrow() {
|
if let Value::Model(ref model_ptr) = *self.value.borrow() {
|
||||||
model_ptr.model_tracker().attach_peer(peer)
|
model_ptr.model_tracker().attach_peer(peer)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ path = "main.rs"
|
||||||
name = "doctests"
|
name = "doctests"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
slint-compiler-internal = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
i-slint-compiler = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
||||||
slint-interpreter = { path = "../../internal/interpreter" }
|
slint-interpreter = { path = "../../internal/interpreter" }
|
||||||
slint = { path = "../../api/rs/slint" }
|
slint = { path = "../../api/rs/slint" }
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ name = "test-driver-cpp"
|
||||||
slint-cpp = { path = "../../../api/cpp", features = ["testing"] }
|
slint-cpp = { path = "../../../api/cpp", features = ["testing"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
slint-compiler-internal = { path = "../../../internal/compiler", features = ["cpp", "display-diagnostics"] }
|
i-slint-compiler = { path = "../../../internal/compiler", features = ["cpp", "display-diagnostics"] }
|
||||||
|
|
||||||
cc = "1.0.54"
|
cc = "1.0.54"
|
||||||
scopeguard = "1.1.0"
|
scopeguard = "1.1.0"
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue