mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 04:48:27 +00:00
Rename ComponentVTable to ItemTreeVTable
and their related name. Also move the component module in the item_Tree module register_component -> register_item_tree ComponentItemTree -> ItemTreeNodeArray For #3323 Rationale from that issue: Right now, we use the term `component` in the Slint language and in the compiler to be a a tree of elements that can be used as an element in a .slint file. The term is also currently used in the runtime as a tree of runtime Items that are allocated together. (declared in ComponentVTable) But there are no 1 to 1 mapping between a `component` in the slint language, and a runtime Component. (for example, the items behind a `if` or `for` or `PopupMenu` are in a different runtime component. And `component` declared in Slint are often inlined) So we should rename the internal runtime `Component` to `ItemTree` The currently public `slint::ComponentHandle` wraps the "root" of the ItemTree, but that's ok because it is generated from a .slint `component`, so it doesn't change name
This commit is contained in:
parent
186c3ef3cb
commit
852b4d906d
37 changed files with 641 additions and 690 deletions
|
|
@ -260,7 +260,7 @@ fn gen_corelib(
|
|||
|
||||
config.export.include = [
|
||||
"Clipboard",
|
||||
"ComponentVTable",
|
||||
"ItemTreeVTable",
|
||||
"Slice",
|
||||
"WindowAdapterRcOpaque",
|
||||
"PropertyAnimation",
|
||||
|
|
@ -653,7 +653,7 @@ namespace slint {
|
|||
using LogicalRect = Rect;
|
||||
using LogicalPoint = Point2D<float>;
|
||||
using LogicalLength = float;
|
||||
struct ComponentVTable;
|
||||
struct ItemTreeVTable;
|
||||
struct ItemVTable;
|
||||
using types::IntRect;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ class ComponentInstance : vtable::Dyn
|
|||
ComponentInstance &operator=(ComponentInstance &) = delete;
|
||||
friend class ComponentDefinition;
|
||||
|
||||
// ComponentHandle<ComponentInstance> is in fact a VRc<ComponentVTable, ErasedComponentBox>
|
||||
// ComponentHandle<ComponentInstance> is in fact a VRc<ItemTreeVTable, ErasedComponentBox>
|
||||
const cbindgen_private::ErasedComponentBox *inner() const
|
||||
{
|
||||
slint::private_api::assert_main_thread();
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ namespace slint {
|
|||
|
||||
// Bring opaque structure in scope
|
||||
namespace private_api {
|
||||
using cbindgen_private::ComponentVTable;
|
||||
using cbindgen_private::ItemTreeVTable;
|
||||
using cbindgen_private::ItemVTable;
|
||||
using ComponentRef = vtable::VRef<private_api::ComponentVTable>;
|
||||
using ItemTreeRef = vtable::VRef<private_api::ItemTreeVTable>;
|
||||
using IndexRange = cbindgen_private::IndexRange;
|
||||
using ItemRef = vtable::VRef<private_api::ItemVTable>;
|
||||
using ItemVisitorRefMut = vtable::VRefMut<cbindgen_private::ItemVisitorVTable>;
|
||||
using cbindgen_private::ComponentWeak;
|
||||
using cbindgen_private::ItemTreeWeak;
|
||||
using cbindgen_private::ItemWeak;
|
||||
using cbindgen_private::TraversalOrder;
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ constexpr inline ItemTreeNode make_dyn_node(std::uint32_t offset, std::uint32_t
|
|||
parent_index } };
|
||||
}
|
||||
|
||||
inline ItemRef get_item_ref(ComponentRef component,
|
||||
inline ItemRef get_item_ref(ItemTreeRef component,
|
||||
const cbindgen_private::Slice<ItemTreeNode> item_tree,
|
||||
const private_api::ItemArray item_array, int index)
|
||||
{
|
||||
|
|
@ -94,7 +94,7 @@ inline cbindgen_private::Rect convert_anonymous_rect(std::tuple<float, float, fl
|
|||
return cbindgen_private::Rect { .x = x, .y = y, .width = w, .height = h };
|
||||
}
|
||||
|
||||
inline void dealloc(const ComponentVTable *, uint8_t *ptr, vtable::Layout layout)
|
||||
inline void dealloc(const ItemTreeVTable *, uint8_t *ptr, vtable::Layout layout)
|
||||
{
|
||||
#ifdef __cpp_sized_deallocation
|
||||
::operator delete(reinterpret_cast<void *>(ptr), layout.size,
|
||||
|
|
@ -107,7 +107,7 @@ inline void dealloc(const ComponentVTable *, uint8_t *ptr, vtable::Layout layout
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline vtable::Layout drop_in_place(ComponentRef component)
|
||||
inline vtable::Layout drop_in_place(ItemTreeRef component)
|
||||
{
|
||||
reinterpret_cast<T *>(component.instance)->~T();
|
||||
return vtable::Layout { sizeof(T), alignof(T) };
|
||||
|
|
@ -137,12 +137,12 @@ class ComponentWeakHandle;
|
|||
template<typename T>
|
||||
class ComponentHandle
|
||||
{
|
||||
vtable::VRc<private_api::ComponentVTable, T> inner;
|
||||
vtable::VRc<private_api::ItemTreeVTable, T> inner;
|
||||
friend class ComponentWeakHandle<T>;
|
||||
|
||||
public:
|
||||
/// internal constructor
|
||||
ComponentHandle(const vtable::VRc<private_api::ComponentVTable, T> &inner) : inner(inner) { }
|
||||
ComponentHandle(const vtable::VRc<private_api::ItemTreeVTable, T> &inner) : inner(inner) { }
|
||||
|
||||
/// Arrow operator that implements pointer semantics.
|
||||
const T *operator->() const
|
||||
|
|
@ -170,14 +170,14 @@ public:
|
|||
}
|
||||
|
||||
/// internal function that returns the internal handle
|
||||
vtable::VRc<private_api::ComponentVTable> into_dyn() const { return inner.into_dyn(); }
|
||||
vtable::VRc<private_api::ItemTreeVTable> into_dyn() const { return inner.into_dyn(); }
|
||||
};
|
||||
|
||||
/// A weak reference to the component. Can be constructed from a `ComponentHandle<T>`
|
||||
template<typename T>
|
||||
class ComponentWeakHandle
|
||||
{
|
||||
vtable::VWeak<private_api::ComponentVTable, T> inner;
|
||||
vtable::VWeak<private_api::ItemTreeVTable, T> inner;
|
||||
|
||||
public:
|
||||
/// Constructs a null ComponentWeakHandle. lock() will always return empty.
|
||||
|
|
@ -273,12 +273,12 @@ inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const
|
|||
|
||||
namespace private_api {
|
||||
|
||||
inline static void register_component(const vtable::VRc<ComponentVTable> *c,
|
||||
inline static void register_item_tree(const vtable::VRc<ItemTreeVTable> *c,
|
||||
const std::optional<slint::Window> &maybe_window)
|
||||
{
|
||||
const cbindgen_private::WindowAdapterRcOpaque *window_ptr =
|
||||
maybe_window.has_value() ? &maybe_window->window_handle().handle() : nullptr;
|
||||
cbindgen_private::slint_register_component(c, window_ptr);
|
||||
cbindgen_private::slint_register_item_tree(c, window_ptr);
|
||||
}
|
||||
|
||||
inline SharedVector<float> solve_box_layout(const cbindgen_private::BoxLayoutData &data,
|
||||
|
|
@ -1189,16 +1189,16 @@ public:
|
|||
return std::numeric_limits<uint64_t>::max();
|
||||
}
|
||||
|
||||
vtable::VRef<private_api::ComponentVTable> item_at(int i) const
|
||||
vtable::VRef<private_api::ItemTreeVTable> item_at(int i) const
|
||||
{
|
||||
const auto &x = inner->data.at(i);
|
||||
return { &C::static_vtable, const_cast<C *>(&(**x.ptr)) };
|
||||
}
|
||||
|
||||
vtable::VWeak<private_api::ComponentVTable> component_at(int i) const
|
||||
vtable::VWeak<private_api::ItemTreeVTable> component_at(int i) const
|
||||
{
|
||||
const auto &x = inner->data.at(i);
|
||||
return vtable::VWeak<private_api::ComponentVTable> { x.ptr->into_dyn() };
|
||||
return vtable::VWeak<private_api::ItemTreeVTable> { x.ptr->into_dyn() };
|
||||
}
|
||||
|
||||
private_api::IndexRange index_range() const
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ inline void assert_main_thread()
|
|||
#endif
|
||||
}
|
||||
|
||||
using ComponentRc = vtable::VRc<cbindgen_private::ComponentVTable>;
|
||||
using ItemTreeRc = vtable::VRc<cbindgen_private::ItemTreeVTable>;
|
||||
|
||||
class WindowAdapterRc
|
||||
{
|
||||
|
|
@ -83,14 +83,14 @@ public:
|
|||
}
|
||||
|
||||
template<typename Component, typename ItemArray>
|
||||
void unregister_component(Component *c, ItemArray items) const
|
||||
void unregister_item_tree(Component *c, ItemArray items) const
|
||||
{
|
||||
cbindgen_private::slint_unregister_component(
|
||||
vtable::VRef<cbindgen_private::ComponentVTable> { &Component::static_vtable, c },
|
||||
cbindgen_private::slint_unregister_item_tree(
|
||||
vtable::VRef<cbindgen_private::ItemTreeVTable> { &Component::static_vtable, c },
|
||||
items, &inner);
|
||||
}
|
||||
|
||||
void set_focus_item(const ComponentRc &component_rc, uint32_t item_index)
|
||||
void set_focus_item(const ItemTreeRc &component_rc, uint32_t item_index)
|
||||
{
|
||||
cbindgen_private::ItemRc item_rc { component_rc, item_index };
|
||||
cbindgen_private::slint_windowrc_set_focus_item(&inner, &item_rc);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ mod js_model;
|
|||
mod persistent_context;
|
||||
|
||||
struct WrappedComponentType(Option<slint_interpreter::ComponentDefinition>);
|
||||
struct WrappedComponentRc(Option<slint_interpreter::ComponentInstance>);
|
||||
struct WrappedItemTreeRc(Option<slint_interpreter::ComponentInstance>);
|
||||
struct WrappedWindow(Option<std::rc::Rc<dyn i_slint_core::window::WindowAdapter>>);
|
||||
|
||||
/// We need to do some gymnastic with closures to pass the ExecuteContext with the right lifetime
|
||||
|
|
@ -334,9 +334,9 @@ declare_types! {
|
|||
}
|
||||
}
|
||||
|
||||
class SlintComponent for WrappedComponentRc {
|
||||
class SlintComponent for WrappedItemTreeRc {
|
||||
init(_) {
|
||||
Ok(WrappedComponentRc(None))
|
||||
Ok(WrappedItemTreeRc(None))
|
||||
}
|
||||
method run(mut cx) {
|
||||
let this = cx.this();
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ pub mod generated_code {
|
|||
|
||||
#[doc(hidden)]
|
||||
fn from_inner(
|
||||
_: vtable::VRc<crate::private_unstable_api::re_exports::ComponentVTable, Self::Inner>,
|
||||
_: vtable::VRc<crate::private_unstable_api::re_exports::ItemTreeVTable, Self::Inner>,
|
||||
) -> Self {
|
||||
unimplemented!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@ use re_exports::*;
|
|||
// extra copies of the original functions for each call site due to
|
||||
// the impl Fn() they are taking.
|
||||
|
||||
pub trait StrongComponentRef: Sized {
|
||||
pub trait StrongItemTreeRef: Sized {
|
||||
type Weak: Clone + 'static;
|
||||
fn to_weak(&self) -> Self::Weak;
|
||||
fn from_weak(weak: &Self::Weak) -> Option<Self>;
|
||||
}
|
||||
|
||||
impl<C: 'static> StrongComponentRef for VRc<ComponentVTable, C> {
|
||||
type Weak = VWeak<ComponentVTable, C>;
|
||||
impl<C: 'static> StrongItemTreeRef for VRc<ItemTreeVTable, C> {
|
||||
type Weak = VWeak<ItemTreeVTable, C>;
|
||||
fn to_weak(&self) -> Self::Weak {
|
||||
VRc::downgrade(self)
|
||||
}
|
||||
|
|
@ -31,8 +31,8 @@ impl<C: 'static> StrongComponentRef for VRc<ComponentVTable, C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: 'static> StrongComponentRef for VRcMapped<ComponentVTable, C> {
|
||||
type Weak = VWeakMapped<ComponentVTable, C>;
|
||||
impl<C: 'static> StrongItemTreeRef for VRcMapped<ItemTreeVTable, C> {
|
||||
type Weak = VWeakMapped<ItemTreeVTable, C>;
|
||||
fn to_weak(&self) -> Self::Weak {
|
||||
VRcMapped::downgrade(self)
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ impl<C: 'static> StrongComponentRef for VRcMapped<ComponentVTable, C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: 'static> StrongComponentRef for Pin<Rc<C>> {
|
||||
impl<C: 'static> StrongItemTreeRef for Pin<Rc<C>> {
|
||||
type Weak = PinWeak<C>;
|
||||
fn to_weak(&self) -> Self::Weak {
|
||||
PinWeak::downgrade(self.clone())
|
||||
|
|
@ -51,19 +51,19 @@ impl<C: 'static> StrongComponentRef for Pin<Rc<C>> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_property_binding<T: Clone + 'static, StrongRef: StrongComponentRef + 'static>(
|
||||
pub fn set_property_binding<T: Clone + 'static, StrongRef: StrongItemTreeRef + 'static>(
|
||||
property: Pin<&Property<T>>,
|
||||
component_strong: &StrongRef,
|
||||
binding: fn(StrongRef) -> T,
|
||||
) {
|
||||
let weak = component_strong.to_weak();
|
||||
property
|
||||
.set_binding(move || binding(<StrongRef as StrongComponentRef>::from_weak(&weak).unwrap()))
|
||||
.set_binding(move || binding(<StrongRef as StrongItemTreeRef>::from_weak(&weak).unwrap()))
|
||||
}
|
||||
|
||||
pub fn set_animated_property_binding<
|
||||
T: Clone + i_slint_core::properties::InterpolatedPropertyValue + 'static,
|
||||
StrongRef: StrongComponentRef + 'static,
|
||||
StrongRef: StrongItemTreeRef + 'static,
|
||||
>(
|
||||
property: Pin<&Property<T>>,
|
||||
component_strong: &StrongRef,
|
||||
|
|
@ -72,14 +72,14 @@ pub fn set_animated_property_binding<
|
|||
) {
|
||||
let weak = component_strong.to_weak();
|
||||
property.set_animated_binding(
|
||||
move || binding(<StrongRef as StrongComponentRef>::from_weak(&weak).unwrap()),
|
||||
move || binding(<StrongRef as StrongItemTreeRef>::from_weak(&weak).unwrap()),
|
||||
animation_data,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn set_animated_property_binding_for_transition<
|
||||
T: Clone + i_slint_core::properties::InterpolatedPropertyValue + 'static,
|
||||
StrongRef: StrongComponentRef + 'static,
|
||||
StrongRef: StrongItemTreeRef + 'static,
|
||||
>(
|
||||
property: Pin<&Property<T>>,
|
||||
component_strong: &StrongRef,
|
||||
|
|
@ -91,30 +91,28 @@ pub fn set_animated_property_binding_for_transition<
|
|||
let weak_1 = component_strong.to_weak();
|
||||
let weak_2 = weak_1.clone();
|
||||
property.set_animated_binding_for_transition(
|
||||
move || binding(<StrongRef as StrongComponentRef>::from_weak(&weak_1).unwrap()),
|
||||
move || binding(<StrongRef as StrongItemTreeRef>::from_weak(&weak_1).unwrap()),
|
||||
move || {
|
||||
compute_animation_details(
|
||||
<StrongRef as StrongComponentRef>::from_weak(&weak_2).unwrap(),
|
||||
)
|
||||
compute_animation_details(<StrongRef as StrongItemTreeRef>::from_weak(&weak_2).unwrap())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn set_property_state_binding<StrongRef: StrongComponentRef + 'static>(
|
||||
pub fn set_property_state_binding<StrongRef: StrongItemTreeRef + 'static>(
|
||||
property: Pin<&Property<StateInfo>>,
|
||||
component_strong: &StrongRef,
|
||||
binding: fn(StrongRef) -> i32,
|
||||
) {
|
||||
let weak = component_strong.to_weak();
|
||||
re_exports::set_state_binding(property, move || {
|
||||
binding(<StrongRef as StrongComponentRef>::from_weak(&weak).unwrap())
|
||||
binding(<StrongRef as StrongItemTreeRef>::from_weak(&weak).unwrap())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_callback_handler<
|
||||
Arg: ?Sized + 'static,
|
||||
Ret: Default + 'static,
|
||||
StrongRef: StrongComponentRef + 'static,
|
||||
StrongRef: StrongItemTreeRef + 'static,
|
||||
>(
|
||||
callback: Pin<&Callback<Arg, Ret>>,
|
||||
component_strong: &StrongRef,
|
||||
|
|
@ -122,7 +120,7 @@ pub fn set_callback_handler<
|
|||
) {
|
||||
let weak = component_strong.to_weak();
|
||||
callback.set_handler(move |arg| {
|
||||
handler(<StrongRef as StrongComponentRef>::from_weak(&weak).unwrap(), arg)
|
||||
handler(<StrongRef as StrongItemTreeRef>::from_weak(&weak).unwrap(), arg)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -181,15 +179,15 @@ pub mod re_exports {
|
|||
pub use i_slint_core::accessibility::AccessibleStringProperty;
|
||||
pub use i_slint_core::animations::{animation_tick, EasingCurve};
|
||||
pub use i_slint_core::callbacks::Callback;
|
||||
pub use i_slint_core::component::{
|
||||
register_component, unregister_component, Component, ComponentRefPin, ComponentVTable,
|
||||
ComponentWeak, IndexRange,
|
||||
};
|
||||
pub use i_slint_core::graphics::*;
|
||||
pub use i_slint_core::input::{
|
||||
key_codes::Key, FocusEvent, InputEventResult, KeyEvent, KeyEventResult, KeyboardModifiers,
|
||||
MouseEvent,
|
||||
};
|
||||
pub use i_slint_core::item_tree::{
|
||||
register_item_tree, unregister_item_tree, IndexRange, ItemTree, ItemTreeRefPin,
|
||||
ItemTreeVTable, ItemTreeWeak,
|
||||
};
|
||||
pub use i_slint_core::item_tree::{
|
||||
visit_item_tree, ItemTreeNode, ItemVisitorRefMut, ItemVisitorVTable, ItemWeak,
|
||||
TraversalOrder, VisitChildrenResult,
|
||||
|
|
@ -206,8 +204,8 @@ pub mod re_exports {
|
|||
InputMethodRequest, WindowAdapter, WindowAdapterRc, WindowInner,
|
||||
};
|
||||
pub use i_slint_core::Color;
|
||||
pub use i_slint_core::ComponentVTable_static;
|
||||
pub use i_slint_core::Coord;
|
||||
pub use i_slint_core::ItemTreeVTable_static;
|
||||
pub use i_slint_core::SharedString;
|
||||
pub use i_slint_core::SharedVector;
|
||||
pub use num_traits::float::Float;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
use cpp::*;
|
||||
use euclid::approxeq::ApproxEq;
|
||||
use i_slint_core::component::{ComponentRc, ComponentRef};
|
||||
use i_slint_core::graphics::euclid::num::Zero;
|
||||
use i_slint_core::graphics::rendering_metrics_collector::{
|
||||
RenderingMetrics, RenderingMetricsCollector,
|
||||
|
|
@ -13,6 +12,7 @@ use i_slint_core::graphics::rendering_metrics_collector::{
|
|||
use i_slint_core::graphics::{euclid, Brush, Color, FontRequest, Image, Point, SharedImageBuffer};
|
||||
use i_slint_core::input::{KeyEventType, KeyInputEvent, MouseEvent};
|
||||
use i_slint_core::item_rendering::{ItemCache, ItemRenderer};
|
||||
use i_slint_core::item_tree::{ItemTreeRc, ItemTreeRef};
|
||||
use i_slint_core::items::{
|
||||
self, FillRule, ImageRendering, ItemRc, ItemRef, Layer, MouseCursor, Opacity,
|
||||
PointerEventButton, RenderingResult, TextOverflow, TextWrap,
|
||||
|
|
@ -228,7 +228,7 @@ cpp! {{
|
|||
QSize sizeHint() const override {
|
||||
auto preferred_size = rust!(Slint_sizeHint [rust_window: &QtWindow as "void*"] -> qttypes::QSize as "QSize" {
|
||||
let component_rc = WindowInner::from_pub(&rust_window.window).component();
|
||||
let component = ComponentRc::borrow_pin(&component_rc);
|
||||
let component = ItemTreeRc::borrow_pin(&component_rc);
|
||||
let layout_info_h = component.as_ref().layout_info(Orientation::Horizontal);
|
||||
let layout_info_v = component.as_ref().layout_info(Orientation::Vertical);
|
||||
qttypes::QSize {
|
||||
|
|
@ -1327,7 +1327,7 @@ impl QtItemRenderer<'_> {
|
|||
|
||||
i_slint_core::item_rendering::render_item_children(
|
||||
self,
|
||||
&item_rc.component(),
|
||||
&item_rc.item_tree(),
|
||||
item_rc.index() as isize,
|
||||
);
|
||||
|
||||
|
|
@ -1345,7 +1345,7 @@ impl QtItemRenderer<'_> {
|
|||
let children_rect = i_slint_core::properties::evaluate_no_tracking(|| {
|
||||
self_rc.geometry().union(
|
||||
&i_slint_core::item_rendering::item_children_bounding_rect(
|
||||
&self_rc.component(),
|
||||
&self_rc.item_tree(),
|
||||
self_rc.index() as isize,
|
||||
¤t_clip,
|
||||
),
|
||||
|
|
@ -1683,13 +1683,13 @@ fn into_qsize(logical_size: i_slint_core::api::LogicalSize) -> qttypes::QSize {
|
|||
}
|
||||
|
||||
impl WindowAdapterInternal for QtWindow {
|
||||
fn register_component(&self) {
|
||||
fn register_item_tree(&self) {
|
||||
self.tree_structure_changed.replace(true);
|
||||
}
|
||||
|
||||
fn unregister_component(
|
||||
fn unregister_item_tree(
|
||||
&self,
|
||||
_component: ComponentRef,
|
||||
_component: ItemTreeRef,
|
||||
_: &mut dyn Iterator<Item = Pin<ItemRef<'_>>>,
|
||||
) {
|
||||
self.tree_structure_changed.replace(true);
|
||||
|
|
@ -1968,7 +1968,7 @@ impl i_slint_core::renderer::RendererSealed for QtWindow {
|
|||
|
||||
fn free_graphics_resources(
|
||||
&self,
|
||||
component: ComponentRef,
|
||||
component: ItemTreeRef,
|
||||
_items: &mut dyn Iterator<Item = Pin<i_slint_core::items::ItemRef<'_>>>,
|
||||
) -> Result<(), i_slint_core::platform::PlatformError> {
|
||||
// Invalidate caches:
|
||||
|
|
|
|||
|
|
@ -228,8 +228,8 @@ mod for_unit_test {
|
|||
|
||||
/// Simulate a mouse click
|
||||
pub fn send_mouse_click<
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable> + 'static,
|
||||
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||
X: vtable::HasStaticVTable<i_slint_core::item_tree::ItemTreeVTable> + 'static,
|
||||
Component: Into<vtable::VRc<i_slint_core::item_tree::ItemTreeVTable, X>> + ComponentHandle,
|
||||
>(
|
||||
component: &Component,
|
||||
x: f32,
|
||||
|
|
@ -247,8 +247,8 @@ mod for_unit_test {
|
|||
|
||||
/// Simulate entering a sequence of ascii characters key by (pressed or released).
|
||||
pub fn send_keyboard_char<
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||
X: vtable::HasStaticVTable<i_slint_core::item_tree::ItemTreeVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::item_tree::ItemTreeVTable, X>> + ComponentHandle,
|
||||
>(
|
||||
component: &Component,
|
||||
string: char,
|
||||
|
|
@ -263,8 +263,8 @@ mod for_unit_test {
|
|||
|
||||
/// Simulate entering a sequence of ascii characters key by key.
|
||||
pub fn send_keyboard_string_sequence<
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||
X: vtable::HasStaticVTable<i_slint_core::item_tree::ItemTreeVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::item_tree::ItemTreeVTable, X>> + ComponentHandle,
|
||||
>(
|
||||
component: &Component,
|
||||
sequence: &str,
|
||||
|
|
@ -278,8 +278,8 @@ mod for_unit_test {
|
|||
/// Applies the specified scale factor to the window that's associated with the given component.
|
||||
/// This overrides the value provided by the windowing system.
|
||||
pub fn set_window_scale_factor<
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||
X: vtable::HasStaticVTable<i_slint_core::item_tree::ItemTreeVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::item_tree::ItemTreeVTable, X>> + ComponentHandle,
|
||||
>(
|
||||
component: &Component,
|
||||
factor: f32,
|
||||
|
|
|
|||
|
|
@ -12,12 +12,10 @@ use accesskit::{
|
|||
Action, ActionRequest, CheckedState, Node, NodeBuilder, NodeId, Role, Tree, TreeUpdate,
|
||||
};
|
||||
use i_slint_core::accessibility::AccessibleStringProperty;
|
||||
use i_slint_core::item_tree::{ItemTreeRc, ItemTreeRef, ItemTreeWeak};
|
||||
use i_slint_core::items::{ItemRc, WindowItem};
|
||||
use i_slint_core::lengths::ScaleFactor;
|
||||
use i_slint_core::window::WindowInner;
|
||||
use i_slint_core::{
|
||||
component::{ComponentRc, ComponentRef, ComponentWeak},
|
||||
lengths::ScaleFactor,
|
||||
};
|
||||
use i_slint_core::{properties::PropertyTracker, window::WindowAdapter};
|
||||
|
||||
use super::WinitWindowAdapter;
|
||||
|
|
@ -33,7 +31,7 @@ use super::WinitWindowAdapter;
|
|||
/// the `on_event` function that needs calling.
|
||||
///
|
||||
/// Similarly, when the window adapter is informed about a focus change, handle_focus_change must be called.
|
||||
/// Finally, when a component is destroyed, `unregister_component` must be called, which rebuilds the entire
|
||||
/// Finally, when a component is destroyed, `unregister_item_tree` must be called, which rebuilds the entire
|
||||
/// tree at the moment.
|
||||
///
|
||||
/// If we wanted to move this to corelib, `on_event` gets replaced with listening to the events sent from the
|
||||
|
|
@ -45,7 +43,7 @@ pub struct AccessKitAdapter {
|
|||
|
||||
node_classes: RefCell<accesskit::NodeClassSet>,
|
||||
next_component_id: Cell<usize>,
|
||||
components_by_id: RefCell<HashMap<usize, ComponentWeak>>,
|
||||
components_by_id: RefCell<HashMap<usize, ItemTreeWeak>>,
|
||||
component_ids: RefCell<HashMap<NonNull<u8>, usize>>,
|
||||
all_nodes: RefCell<Vec<CachedNode>>,
|
||||
global_property_tracker: Pin<Box<PropertyTracker<AccessibilitiesPropertyTracker>>>,
|
||||
|
|
@ -125,7 +123,7 @@ impl AccessKitAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn register_component(&self) {
|
||||
pub fn register_item_tree(&self) {
|
||||
let win = self.window_adapter_weak.clone();
|
||||
i_slint_core::timers::Timer::single_shot(Default::default(), move || {
|
||||
if let Some(window_adapter) = win.upgrade() {
|
||||
|
|
@ -135,8 +133,8 @@ impl AccessKitAdapter {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn unregister_component(&self, component: ComponentRef) {
|
||||
let component_ptr = ComponentRef::as_ptr(component);
|
||||
pub fn unregister_item_tree(&self, component: ItemTreeRef) {
|
||||
let component_ptr = ItemTreeRef::as_ptr(component);
|
||||
if let Some(component_id) = self.component_ids.borrow_mut().remove(&component_ptr) {
|
||||
self.components_by_id.borrow_mut().remove(&component_id);
|
||||
}
|
||||
|
|
@ -170,8 +168,8 @@ impl AccessKitAdapter {
|
|||
}
|
||||
|
||||
fn encode_item_node_id(&self, item: &ItemRc) -> Option<NodeId> {
|
||||
let component = item.component();
|
||||
let component_ptr = ComponentRef::as_ptr(ComponentRc::borrow(component));
|
||||
let component = item.item_tree();
|
||||
let component_ptr = ItemTreeRef::as_ptr(ItemTreeRc::borrow(component));
|
||||
let component_id = *(self.component_ids.borrow().get(&component_ptr)?);
|
||||
let index = item.index();
|
||||
Some(NodeId(
|
||||
|
|
@ -236,15 +234,15 @@ impl AccessKitAdapter {
|
|||
|
||||
builder.set_children(children.clone());
|
||||
|
||||
let component = item.component();
|
||||
let component_ptr = ComponentRef::as_ptr(ComponentRc::borrow(component));
|
||||
let component = item.item_tree();
|
||||
let component_ptr = ItemTreeRef::as_ptr(ItemTreeRc::borrow(component));
|
||||
if !self.component_ids.borrow().contains_key(&component_ptr) {
|
||||
let component_id = self.next_component_id.get();
|
||||
self.next_component_id.set(component_id + 1);
|
||||
self.component_ids.borrow_mut().insert(component_ptr, component_id);
|
||||
self.components_by_id
|
||||
.borrow_mut()
|
||||
.insert(component_id, ComponentRc::downgrade(component));
|
||||
.insert(component_id, ItemTreeRc::downgrade(component));
|
||||
}
|
||||
|
||||
let id = self.encode_item_node_id(&item).unwrap();
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ use winit::platform::web::WindowExtWebSys;
|
|||
use crate::renderer::WinitCompatibleRenderer;
|
||||
use const_field_offset::FieldOffsets;
|
||||
|
||||
use corelib::component::ComponentRc;
|
||||
use corelib::item_tree::ItemTreeRc;
|
||||
#[cfg(enable_accesskit)]
|
||||
use corelib::component::ComponentRef;
|
||||
use corelib::item_tree::ItemTreeRef;
|
||||
use corelib::items::MouseCursor;
|
||||
#[cfg(enable_accesskit)]
|
||||
use corelib::items::{ItemRc, ItemRef};
|
||||
|
|
@ -323,7 +323,7 @@ impl WindowAdapter for WinitWindowAdapter {
|
|||
let scale_factor = runtime_window.scale_factor() as f64;
|
||||
|
||||
let component_rc = runtime_window.component();
|
||||
let component = ComponentRc::borrow_pin(&component_rc);
|
||||
let component = ItemTreeRc::borrow_pin(&component_rc);
|
||||
|
||||
let layout_info_h = component.as_ref().layout_info(Orientation::Horizontal);
|
||||
if let Some(window_item) = runtime_window.window_item() {
|
||||
|
|
@ -668,17 +668,17 @@ impl WindowAdapterInternal for WinitWindowAdapter {
|
|||
}
|
||||
|
||||
#[cfg(enable_accesskit)]
|
||||
fn register_component(&self) {
|
||||
self.accesskit_adapter.register_component();
|
||||
fn register_item_tree(&self) {
|
||||
self.accesskit_adapter.register_item_tree();
|
||||
}
|
||||
|
||||
#[cfg(enable_accesskit)]
|
||||
fn unregister_component(
|
||||
fn unregister_item_tree(
|
||||
&self,
|
||||
_component: ComponentRef,
|
||||
_component: ItemTreeRef,
|
||||
_: &mut dyn Iterator<Item = Pin<ItemRef<'_>>>,
|
||||
) {
|
||||
self.accesskit_adapter.unregister_component(_component);
|
||||
self.accesskit_adapter.unregister_item_tree(_component);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1047,10 +1047,9 @@ fn generate_item_tree(
|
|||
file: &mut File,
|
||||
conditional_includes: &ConditionalIncludes,
|
||||
) {
|
||||
target_struct.friends.push(format!(
|
||||
"vtable::VRc<slint::private_api::ComponentVTable, {}>",
|
||||
item_tree_class_name
|
||||
));
|
||||
target_struct
|
||||
.friends
|
||||
.push(format!("vtable::VRc<slint::private_api::ItemTreeVTable, {}>", item_tree_class_name));
|
||||
|
||||
generate_sub_component(
|
||||
target_struct,
|
||||
|
|
@ -1147,7 +1146,7 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "visit_children".into(),
|
||||
signature: "(slint::private_api::ComponentRef component, intptr_t index, slint::private_api::TraversalOrder order, slint::private_api::ItemVisitorRefMut visitor) -> uint64_t".into(),
|
||||
signature: "(slint::private_api::ItemTreeRef component, intptr_t index, slint::private_api::TraversalOrder order, slint::private_api::ItemVisitorRefMut visitor) -> uint64_t".into(),
|
||||
is_static: true,
|
||||
statements: Some(visit_children_statements),
|
||||
..Default::default()
|
||||
|
|
@ -1158,7 +1157,7 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "get_item_ref".into(),
|
||||
signature: "(slint::private_api::ComponentRef component, uint32_t index) -> slint::private_api::ItemRef".into(),
|
||||
signature: "(slint::private_api::ItemTreeRef component, uint32_t index) -> slint::private_api::ItemRef".into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![
|
||||
"return slint::private_api::get_item_ref(component, get_item_tree(component), item_array(), index);".to_owned(),
|
||||
|
|
@ -1171,7 +1170,7 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "get_subtree_range".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ComponentRef component, [[maybe_unused]] uint32_t dyn_index) -> slint::private_api::IndexRange".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ItemTreeRef component, [[maybe_unused]] uint32_t dyn_index) -> slint::private_api::IndexRange".into(),
|
||||
is_static: true,
|
||||
statements: Some(subtree_range_statement),
|
||||
..Default::default()
|
||||
|
|
@ -1181,8 +1180,8 @@ fn generate_item_tree(
|
|||
target_struct.members.push((
|
||||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "get_subtree_component".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ComponentRef component, [[maybe_unused]] uint32_t dyn_index, [[maybe_unused]] uintptr_t subtree_index, [[maybe_unused]] slint::private_api::ComponentWeak *result) -> void".into(),
|
||||
name: "get_subtree".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ItemTreeRef component, [[maybe_unused]] uint32_t dyn_index, [[maybe_unused]] uintptr_t subtree_index, [[maybe_unused]] slint::private_api::ItemTreeWeak *result) -> void".into(),
|
||||
is_static: true,
|
||||
statements: Some(subtree_component_statement),
|
||||
..Default::default()
|
||||
|
|
@ -1193,7 +1192,7 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "get_item_tree".into(),
|
||||
signature: "(slint::private_api::ComponentRef) -> slint::cbindgen_private::Slice<slint::private_api::ItemTreeNode>".into(),
|
||||
signature: "(slint::private_api::ItemTreeRef) -> slint::cbindgen_private::Slice<slint::private_api::ItemTreeNode>".into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![
|
||||
"return item_tree();".to_owned(),
|
||||
|
|
@ -1223,7 +1222,7 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "parent_node".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ComponentRef component, [[maybe_unused]] slint::private_api::ItemWeak *result) -> void".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ItemTreeRef component, [[maybe_unused]] slint::private_api::ItemWeak *result) -> void".into(),
|
||||
is_static: true,
|
||||
statements: Some(parent_item_from_parent_component,),
|
||||
..Default::default()
|
||||
|
|
@ -1234,7 +1233,7 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "embed_component".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ComponentRef component, [[maybe_unused]] const slint::private_api::ComponentWeak *parent_component, [[maybe_unused]] const uint32_t parent_index) -> bool".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ItemTreeRef component, [[maybe_unused]] const slint::private_api::ItemTreeWeak *parent_component, [[maybe_unused]] const uint32_t parent_index) -> bool".into(),
|
||||
is_static: true,
|
||||
statements: Some(vec!["return false; /* todo! */".into()]),
|
||||
..Default::default()
|
||||
|
|
@ -1246,7 +1245,7 @@ fn generate_item_tree(
|
|||
Access::Private,
|
||||
Declaration::Function(Function {
|
||||
name: "subtree_index".into(),
|
||||
signature: "([[maybe_unused]] slint::private_api::ComponentRef component) -> uintptr_t"
|
||||
signature: "([[maybe_unused]] slint::private_api::ItemTreeRef component) -> uintptr_t"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec!["return std::numeric_limits<uintptr_t>::max();".into()]),
|
||||
|
|
@ -1291,7 +1290,7 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "layout_info".into(),
|
||||
signature:
|
||||
"([[maybe_unused]] slint::private_api::ComponentRef component, slint::cbindgen_private::Orientation o) -> slint::cbindgen_private::LayoutInfo"
|
||||
"([[maybe_unused]] slint::private_api::ItemTreeRef component, slint::cbindgen_private::Orientation o) -> slint::cbindgen_private::LayoutInfo"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![format!(
|
||||
|
|
@ -1307,7 +1306,7 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "item_geometry".into(),
|
||||
signature:
|
||||
"([[maybe_unused]] slint::private_api::ComponentRef component, uint32_t index) -> slint::cbindgen_private::LogicalRect"
|
||||
"([[maybe_unused]] slint::private_api::ItemTreeRef component, uint32_t index) -> slint::cbindgen_private::LogicalRect"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![format!(
|
||||
|
|
@ -1323,7 +1322,7 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "accessible_role".into(),
|
||||
signature:
|
||||
"([[maybe_unused]] slint::private_api::ComponentRef component, uint32_t index) -> slint::cbindgen_private::AccessibleRole"
|
||||
"([[maybe_unused]] slint::private_api::ItemTreeRef component, uint32_t index) -> slint::cbindgen_private::AccessibleRole"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![format!(
|
||||
|
|
@ -1339,7 +1338,7 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "accessible_string_property".into(),
|
||||
signature:
|
||||
"([[maybe_unused]] slint::private_api::ComponentRef component, uint32_t index, slint::cbindgen_private::AccessibleStringProperty what, slint::SharedString *result) -> void"
|
||||
"([[maybe_unused]] slint::private_api::ItemTreeRef component, uint32_t index, slint::cbindgen_private::AccessibleStringProperty what, slint::SharedString *result) -> void"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![format!(
|
||||
|
|
@ -1355,7 +1354,7 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "window_adapter".into(),
|
||||
signature:
|
||||
"([[maybe_unused]] slint::private_api::ComponentRef component, [[maybe_unused]] bool do_create, [[maybe_unused]] slint::cbindgen_private::Option<slint::private_api::WindowAdapterRc>* result) -> void"
|
||||
"([[maybe_unused]] slint::private_api::ItemTreeRef component, [[maybe_unused]] bool do_create, [[maybe_unused]] slint::cbindgen_private::Option<slint::private_api::WindowAdapterRc>* result) -> void"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![format!(
|
||||
|
|
@ -1368,17 +1367,17 @@ fn generate_item_tree(
|
|||
target_struct.members.push((
|
||||
Access::Public,
|
||||
Declaration::Var(Var {
|
||||
ty: "static const slint::private_api::ComponentVTable".to_owned(),
|
||||
ty: "static const slint::private_api::ItemTreeVTable".to_owned(),
|
||||
name: "static_vtable".to_owned(),
|
||||
..Default::default()
|
||||
}),
|
||||
));
|
||||
|
||||
file.definitions.push(Declaration::Var(Var {
|
||||
ty: "inline const slint::private_api::ComponentVTable".to_owned(),
|
||||
ty: "inline const slint::private_api::ItemTreeVTable".to_owned(),
|
||||
name: format!("{}::static_vtable", item_tree_class_name),
|
||||
init: Some(format!(
|
||||
"{{ visit_children, get_item_ref, get_subtree_range, get_subtree_component, \
|
||||
"{{ visit_children, get_item_ref, get_subtree_range, get_subtree, \
|
||||
get_item_tree, parent_node, embed_component, subtree_index, layout_info, \
|
||||
item_geometry, accessible_role, accessible_string_property, window_adapter, \
|
||||
slint::private_api::drop_in_place<{}>, slint::private_api::dealloc }}",
|
||||
|
|
@ -1400,7 +1399,7 @@ fn generate_item_tree(
|
|||
|
||||
let mut create_code = vec![
|
||||
format!(
|
||||
"auto self_rc = vtable::VRc<slint::private_api::ComponentVTable, {0}>::make();",
|
||||
"auto self_rc = vtable::VRc<slint::private_api::ItemTreeVTable, {0}>::make();",
|
||||
target_struct.name
|
||||
),
|
||||
format!("auto self = const_cast<{0} *>(&*self_rc);", target_struct.name),
|
||||
|
|
@ -1414,7 +1413,7 @@ fn generate_item_tree(
|
|||
let root_access = if parent_ctx.is_some() { "parent->root" } else { "self" };
|
||||
create_code.extend([
|
||||
format!(
|
||||
"slint::private_api::register_component(&self_rc.into_dyn(), {root_access}->m_window);",
|
||||
"slint::private_api::register_item_tree(&self_rc.into_dyn(), {root_access}->m_window);",
|
||||
),
|
||||
format!("self->init({}, self->self_weak, 0, 1 {});", root_access, init_parent_parameters),
|
||||
]);
|
||||
|
|
@ -1445,7 +1444,7 @@ fn generate_item_tree(
|
|||
|
||||
let root_access = if parent_ctx.is_some() { "root" } else { "this" };
|
||||
let destructor = vec![format!(
|
||||
"if (auto &window = {root_access}->m_window) window->window_handle().unregister_component(this, item_array());"
|
||||
"if (auto &window = {root_access}->m_window) window->window_handle().unregister_item_tree(this, item_array());"
|
||||
)];
|
||||
|
||||
target_struct.members.push((
|
||||
|
|
@ -1473,7 +1472,7 @@ fn generate_sub_component(
|
|||
|
||||
let mut init_parameters = vec![
|
||||
format!("{} root", root_ptr_type),
|
||||
"slint::cbindgen_private::ComponentWeak enclosing_component".into(),
|
||||
"slint::cbindgen_private::ItemTreeWeak enclosing_component".into(),
|
||||
"uint32_t tree_index".into(),
|
||||
"uint32_t tree_index_of_first_child".into(),
|
||||
];
|
||||
|
|
@ -1484,7 +1483,7 @@ fn generate_sub_component(
|
|||
target_struct.members.push((
|
||||
Access::Public,
|
||||
Declaration::Var(Var {
|
||||
ty: "slint::cbindgen_private::ComponentWeak".into(),
|
||||
ty: "slint::cbindgen_private::ItemTreeWeak".into(),
|
||||
name: "self_weak".into(),
|
||||
..Default::default()
|
||||
}),
|
||||
|
|
@ -1940,7 +1939,7 @@ fn generate_sub_component(
|
|||
field_access,
|
||||
Declaration::Function(Function {
|
||||
name: "subtree_component".into(),
|
||||
signature: "(uintptr_t dyn_index, [[maybe_unused]] uintptr_t subtree_index, [[maybe_unused]] slint::private_api::ComponentWeak *result) const -> void".into(),
|
||||
signature: "(uintptr_t dyn_index, [[maybe_unused]] uintptr_t subtree_index, [[maybe_unused]] slint::private_api::ItemTreeWeak *result) const -> void".into(),
|
||||
statements: Some(vec![
|
||||
"[[maybe_unused]] auto self = this;".to_owned(),
|
||||
format!(" switch(dyn_index) {{ {} }};", subtrees_components_cases.join("")),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
Some convention used in the generated code:
|
||||
- `_self` is of type `Pin<&ComponentType>` where ComponentType is the type of the generated sub component,
|
||||
this is existing for any evaluation of a binding
|
||||
- `self_rc` is of type `VRc<ComponentVTable, ComponentType>` or `Rc<ComponentType>` for globals
|
||||
- `self_rc` is of type `VRc<ItemTreeVTable, ComponentType>` or `Rc<ComponentType>` for globals
|
||||
this is usually a local variable to the init code that shouldn't rbe relied upon by the binding code.
|
||||
*/
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
|
|||
|
||||
quote!(
|
||||
#component
|
||||
pub struct #public_component_id(vtable::VRc<sp::ComponentVTable, #inner_component_id>);
|
||||
pub struct #public_component_id(vtable::VRc<sp::ItemTreeVTable, #inner_component_id>);
|
||||
|
||||
impl #public_component_id {
|
||||
pub fn new() -> core::result::Result<Self, slint::PlatformError> {
|
||||
|
|
@ -267,7 +267,7 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
|
|||
#property_and_callback_accessors
|
||||
}
|
||||
|
||||
impl From<#public_component_id> for vtable::VRc<sp::ComponentVTable, #inner_component_id> {
|
||||
impl From<#public_component_id> for vtable::VRc<sp::ItemTreeVTable, #inner_component_id> {
|
||||
fn from(value: #public_component_id) -> Self {
|
||||
value.0
|
||||
}
|
||||
|
|
@ -283,7 +283,7 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
|
|||
Self(self.0.clone())
|
||||
}
|
||||
|
||||
fn from_inner(inner: vtable::VRc<sp::ComponentVTable, #inner_component_id>) -> Self {
|
||||
fn from_inner(inner: vtable::VRc<sp::ItemTreeVTable, #inner_component_id>) -> Self {
|
||||
Self(inner)
|
||||
}
|
||||
|
||||
|
|
@ -916,7 +916,7 @@ fn generate_sub_component(
|
|||
let parent_component_type = parent_ctx.iter().map(|parent| {
|
||||
let parent_component_id =
|
||||
self::inner_component_id(parent.ctx.current_sub_component.unwrap());
|
||||
quote!(sp::VWeakMapped::<sp::ComponentVTable, #parent_component_id>)
|
||||
quote!(sp::VWeakMapped::<sp::ItemTreeVTable, #parent_component_id>)
|
||||
});
|
||||
|
||||
user_init_code.extend(component.init_code.iter().map(|e| {
|
||||
|
|
@ -955,17 +955,17 @@ fn generate_sub_component(
|
|||
#(#declared_property_vars : sp::Property<#declared_property_types>,)*
|
||||
#(#declared_callbacks : sp::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)*
|
||||
#(#repeated_element_names : sp::Repeater<#repeated_element_components>,)*
|
||||
self_weak : sp::OnceCell<sp::VWeakMapped<sp::ComponentVTable, #inner_component_id>>,
|
||||
self_weak : sp::OnceCell<sp::VWeakMapped<sp::ItemTreeVTable, #inner_component_id>>,
|
||||
#(parent : #parent_component_type,)*
|
||||
root : sp::OnceCell<sp::VWeak<sp::ComponentVTable, #root_component_id>>,
|
||||
root : sp::OnceCell<sp::VWeak<sp::ItemTreeVTable, #root_component_id>>,
|
||||
tree_index: ::core::cell::Cell<u32>,
|
||||
tree_index_of_first_child: ::core::cell::Cell<u32>,
|
||||
#extra_fields
|
||||
}
|
||||
|
||||
impl #inner_component_id {
|
||||
pub fn init(self_rc: sp::VRcMapped<sp::ComponentVTable, Self>,
|
||||
root : &sp::VRc<sp::ComponentVTable, #root_component_id>,
|
||||
pub fn init(self_rc: sp::VRcMapped<sp::ItemTreeVTable, Self>,
|
||||
root : &sp::VRc<sp::ItemTreeVTable, #root_component_id>,
|
||||
tree_index: u32, tree_index_of_first_child: u32) {
|
||||
#![allow(unused)]
|
||||
let _self = self_rc.as_pin_ref();
|
||||
|
|
@ -976,7 +976,7 @@ fn generate_sub_component(
|
|||
#(#init)*
|
||||
}
|
||||
|
||||
pub fn user_init(self_rc: sp::VRcMapped<sp::ComponentVTable, Self>) {
|
||||
pub fn user_init(self_rc: sp::VRcMapped<sp::ItemTreeVTable, Self>) {
|
||||
let _self = self_rc.as_pin_ref();
|
||||
#(#user_init_code)*
|
||||
}
|
||||
|
|
@ -1013,7 +1013,7 @@ fn generate_sub_component(
|
|||
}
|
||||
}
|
||||
|
||||
fn subtree_component(self: ::core::pin::Pin<&Self>, dyn_index: u32, subtree_index: usize, result: &mut sp::ComponentWeak) {
|
||||
fn subtree_component(self: ::core::pin::Pin<&Self>, dyn_index: u32, subtree_index: usize, result: &mut sp::ItemTreeWeak) {
|
||||
#![allow(unused)]
|
||||
let _self = self;
|
||||
match dyn_index {
|
||||
|
|
@ -1210,14 +1210,14 @@ fn generate_global(global: &llr::GlobalComponent, root: &llr::PublicComponent) -
|
|||
struct #inner_component_id {
|
||||
#(#declared_property_vars: sp::Property<#declared_property_types>,)*
|
||||
#(#declared_callbacks: sp::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)*
|
||||
root : sp::OnceCell<sp::VWeak<sp::ComponentVTable, #root_component_id>>,
|
||||
root : sp::OnceCell<sp::VWeak<sp::ItemTreeVTable, #root_component_id>>,
|
||||
}
|
||||
|
||||
impl #inner_component_id {
|
||||
fn new() -> ::core::pin::Pin<sp::Rc<Self>> {
|
||||
sp::Rc::pin(Self::default())
|
||||
}
|
||||
fn init(self: ::core::pin::Pin<sp::Rc<Self>>, root: &sp::VRc<sp::ComponentVTable, #root_component_id>) {
|
||||
fn init(self: ::core::pin::Pin<sp::Rc<Self>>, root: &sp::VRc<sp::ItemTreeVTable, #root_component_id>) {
|
||||
#![allow(unused)]
|
||||
self.root.set(VRc::downgrade(root));
|
||||
let self_rc = self;
|
||||
|
|
@ -1253,7 +1253,7 @@ fn generate_item_tree(
|
|||
.map(|parent| {
|
||||
let parent_component_id =
|
||||
self::inner_component_id(parent.ctx.current_sub_component.unwrap());
|
||||
quote!(sp::VWeakMapped::<sp::ComponentVTable, #parent_component_id>)
|
||||
quote!(sp::VWeakMapped::<sp::ItemTreeVTable, #parent_component_id>)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let root_token = if parent_ctx.is_some() {
|
||||
|
|
@ -1278,7 +1278,7 @@ fn generate_item_tree(
|
|||
.and_then(|root| root.maybe_window_adapter_impl())
|
||||
}
|
||||
),
|
||||
quote!(vtable::VRc<sp::ComponentVTable, Self>),
|
||||
quote!(vtable::VRc<sp::ItemTreeVTable, Self>),
|
||||
if parent_ctx.repeater_index.is_some() {
|
||||
// Repeaters run their user_init() code from RepeatedComponent::init() after update() initialized model_data/index.
|
||||
quote!(self_rc)
|
||||
|
|
@ -1315,7 +1315,7 @@ fn generate_item_tree(
|
|||
}
|
||||
),
|
||||
quote!(
|
||||
core::result::Result<vtable::VRc<sp::ComponentVTable, Self>, slint::PlatformError>
|
||||
core::result::Result<vtable::VRc<sp::ItemTreeVTable, Self>, slint::PlatformError>
|
||||
),
|
||||
quote!(core::result::Result::Ok(self_rc)),
|
||||
)
|
||||
|
|
@ -1399,7 +1399,7 @@ fn generate_item_tree(
|
|||
#(_self.parent = parent.clone() as #parent_component_type;)*
|
||||
let self_rc = VRc::new(_self);
|
||||
let self_dyn_rc = vtable::VRc::into_dyn(self_rc.clone());
|
||||
sp::register_component(&self_dyn_rc, (*#root_token).maybe_window_adapter_impl());
|
||||
sp::register_item_tree(&self_dyn_rc, (*#root_token).maybe_window_adapter_impl());
|
||||
Self::init(sp::VRc::map(self_rc.clone(), |x| x), #root_token, 0, 1);
|
||||
#new_end
|
||||
}
|
||||
|
|
@ -1423,15 +1423,15 @@ fn generate_item_tree(
|
|||
impl sp::PinnedDrop for #inner_component_id {
|
||||
fn drop(self: core::pin::Pin<&mut #inner_component_id>) {
|
||||
use slint::private_unstable_api::re_exports::*;
|
||||
ComponentVTable_static!(static VT for self::#inner_component_id);
|
||||
new_vref!(let vref : VRef<ComponentVTable> for Component = self.as_ref().get_ref());
|
||||
ItemTreeVTable_static!(static VT for self::#inner_component_id);
|
||||
new_vref!(let vref : VRef<ItemTreeVTable> for ItemTree = self.as_ref().get_ref());
|
||||
if let Some(wa) = self.maybe_window_adapter_impl() {
|
||||
sp::unregister_component(self.as_ref(), vref, Self::item_array(), &wa);
|
||||
sp::unregister_item_tree(self.as_ref(), vref, Self::item_array(), &wa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl sp::Component for #inner_component_id {
|
||||
impl sp::ItemTree for #inner_component_id {
|
||||
fn visit_children_item(self: ::core::pin::Pin<&Self>, index: isize, order: sp::TraversalOrder, visitor: sp::ItemVisitorRefMut<'_>)
|
||||
-> sp::VisitChildrenResult
|
||||
{
|
||||
|
|
@ -1464,8 +1464,8 @@ fn generate_item_tree(
|
|||
self.subtree_range(index)
|
||||
}
|
||||
|
||||
fn get_subtree_component(
|
||||
self: ::core::pin::Pin<&Self>, index: u32, subtree_index: usize, result: &mut sp::ComponentWeak)
|
||||
fn get_subtree(
|
||||
self: ::core::pin::Pin<&Self>, index: u32, subtree_index: usize, result: &mut sp::ItemTreeWeak)
|
||||
{
|
||||
self.subtree_component(index, subtree_index, result);
|
||||
}
|
||||
|
|
@ -1480,7 +1480,7 @@ fn generate_item_tree(
|
|||
#parent_item_expression
|
||||
}
|
||||
|
||||
fn embed_component(self: ::core::pin::Pin<&Self>, _parent_component: &sp::ComponentWeak, _item_tree_index: u32) -> bool {
|
||||
fn embed_component(self: ::core::pin::Pin<&Self>, _parent_component: &sp::ItemTreeWeak, _item_tree_index: u32) -> bool {
|
||||
#embedding_function
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ This module contains types that are public and re-exported in the slint-rs as we
|
|||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use crate::component::ComponentVTable;
|
||||
#[cfg(target_has_atomic = "ptr")]
|
||||
pub use crate::future::*;
|
||||
use crate::input::{KeyEventType, KeyInputEvent, MouseEvent};
|
||||
use crate::item_tree::ItemTreeVTable;
|
||||
use crate::window::{WindowAdapter, WindowInner};
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
|
|
@ -591,7 +591,7 @@ pub trait ComponentHandle {
|
|||
|
||||
/// Internal function used when upgrading a weak reference to a strong one.
|
||||
#[doc(hidden)]
|
||||
fn from_inner(_: vtable::VRc<ComponentVTable, Self::Inner>) -> Self;
|
||||
fn from_inner(_: vtable::VRc<ItemTreeVTable, Self::Inner>) -> Self;
|
||||
|
||||
/// Convenience function for [`crate::Window::show()`](struct.Window.html#method.show).
|
||||
/// This shows the window on the screen and maintains an extra strong reference while
|
||||
|
|
@ -638,7 +638,7 @@ mod weak_handle {
|
|||
/// as the one it has been created from.
|
||||
/// This is useful to use with [`invoke_from_event_loop()`] or [`Self::upgrade_in_event_loop()`].
|
||||
pub struct Weak<T: ComponentHandle> {
|
||||
inner: vtable::VWeak<ComponentVTable, T::Inner>,
|
||||
inner: vtable::VWeak<ItemTreeVTable, T::Inner>,
|
||||
#[cfg(feature = "std")]
|
||||
thread: std::thread::ThreadId,
|
||||
}
|
||||
|
|
@ -665,7 +665,7 @@ mod weak_handle {
|
|||
|
||||
impl<T: ComponentHandle> Weak<T> {
|
||||
#[doc(hidden)]
|
||||
pub fn new(rc: &vtable::VRc<ComponentVTable, T::Inner>) -> Self {
|
||||
pub fn new(rc: &vtable::VRc<ItemTreeVTable, T::Inner>) -> Self {
|
||||
Self {
|
||||
inner: vtable::VRc::downgrade(rc),
|
||||
#[cfg(feature = "std")]
|
||||
|
|
@ -699,7 +699,7 @@ mod weak_handle {
|
|||
|
||||
/// A helper function to allow creation on `component_factory::Component` from
|
||||
/// a `ComponentHandle`
|
||||
pub(crate) fn inner(&self) -> vtable::VWeak<ComponentVTable, T::Inner> {
|
||||
pub(crate) fn inner(&self) -> vtable::VWeak<ItemTreeVTable, T::Inner> {
|
||||
self.inner.clone()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,211 +0,0 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
//! This module contains the basic datastructures that are exposed to the C API
|
||||
|
||||
use crate::accessibility::AccessibleStringProperty;
|
||||
use crate::item_tree::{
|
||||
ItemTreeNode, ItemVisitorVTable, ItemWeak, TraversalOrder, VisitChildrenResult,
|
||||
};
|
||||
use crate::items::{AccessibleRole, ItemRc, ItemVTable};
|
||||
use crate::layout::{LayoutInfo, Orientation};
|
||||
use crate::lengths::LogicalRect;
|
||||
use crate::slice::Slice;
|
||||
use crate::window::WindowAdapterRc;
|
||||
use crate::SharedString;
|
||||
use vtable::*;
|
||||
|
||||
#[repr(C)]
|
||||
/// A range of indices
|
||||
pub struct IndexRange {
|
||||
/// Start index
|
||||
pub start: usize,
|
||||
/// Index one past the last index
|
||||
pub end: usize,
|
||||
}
|
||||
|
||||
impl From<core::ops::Range<usize>> for IndexRange {
|
||||
fn from(r: core::ops::Range<usize>) -> Self {
|
||||
Self { start: r.start, end: r.end }
|
||||
}
|
||||
}
|
||||
impl From<IndexRange> for core::ops::Range<usize> {
|
||||
fn from(r: IndexRange) -> Self {
|
||||
Self { start: r.start, end: r.end }
|
||||
}
|
||||
}
|
||||
|
||||
/// A Component is representing an unit that is allocated together
|
||||
#[vtable]
|
||||
#[repr(C)]
|
||||
pub struct ComponentVTable {
|
||||
/// Visit the children of the item at index `index`.
|
||||
/// Note that the root item is at index 0, so passing 0 would visit the item under root (the children of root).
|
||||
/// If you want to visit the root item, you need to pass -1 as an index.
|
||||
pub visit_children_item: extern "C" fn(
|
||||
core::pin::Pin<VRef<ComponentVTable>>,
|
||||
index: isize,
|
||||
order: TraversalOrder,
|
||||
visitor: VRefMut<ItemVisitorVTable>,
|
||||
) -> VisitChildrenResult,
|
||||
|
||||
/// Return a reference to an item using the given index
|
||||
pub get_item_ref: extern "C" fn(
|
||||
core::pin::Pin<VRef<ComponentVTable>>,
|
||||
index: u32,
|
||||
) -> core::pin::Pin<VRef<ItemVTable>>,
|
||||
|
||||
/// Return the range of indices below the dynamic `ItemTreeNode` at `index`
|
||||
pub get_subtree_range:
|
||||
extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>, index: u32) -> IndexRange,
|
||||
|
||||
/// Return the `ComponentRc` at `subindex` below the dynamic `ItemTreeNode` at `index`
|
||||
pub get_subtree_component: extern "C" fn(
|
||||
core::pin::Pin<VRef<ComponentVTable>>,
|
||||
index: u32,
|
||||
subindex: usize,
|
||||
result: &mut vtable::VWeak<ComponentVTable, Dyn>,
|
||||
),
|
||||
|
||||
/// Return the item tree that is defined by this `Component`.
|
||||
/// The return value is an item weak because it can be null if there is no parent.
|
||||
/// And the return value is passed by &mut because ItemWeak has a destructor
|
||||
pub get_item_tree: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>) -> Slice<ItemTreeNode>,
|
||||
|
||||
/// Return the node this component is a part of in the parent component.
|
||||
///
|
||||
/// The return value is an item weak because it can be null if there is no parent.
|
||||
/// And the return value is passed by &mut because ItemWeak has a destructor
|
||||
/// Note that the returned value will typically point to a repeater node, which is
|
||||
/// strictly speaking not an Item at all!
|
||||
pub parent_node: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>, result: &mut ItemWeak),
|
||||
|
||||
/// This embeds this component into the item tree of another component
|
||||
///
|
||||
/// Returns `true` if this component was embedded into the `parent_component`
|
||||
/// at `parent_item_tree_index`.
|
||||
pub embed_component: extern "C" fn(
|
||||
core::pin::Pin<VRef<ComponentVTable>>,
|
||||
parent_component: &VWeak<ComponentVTable>,
|
||||
parent_item_tree_index: u32,
|
||||
) -> bool,
|
||||
|
||||
/// Return the index of the current subtree or usize::MAX if this is not a subtree
|
||||
pub subtree_index: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>) -> usize,
|
||||
|
||||
/// Returns the layout info for this component
|
||||
pub layout_info:
|
||||
extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>, Orientation) -> LayoutInfo,
|
||||
|
||||
/// Returns the item's geometry (relative to its parent item)
|
||||
pub item_geometry:
|
||||
extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>, item_index: u32) -> LogicalRect,
|
||||
|
||||
/// Returns the accessible role for a given item
|
||||
pub accessible_role:
|
||||
extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>, item_index: u32) -> AccessibleRole,
|
||||
|
||||
/// Returns the accessible property
|
||||
pub accessible_string_property: extern "C" fn(
|
||||
core::pin::Pin<VRef<ComponentVTable>>,
|
||||
item_index: u32,
|
||||
what: AccessibleStringProperty,
|
||||
result: &mut SharedString,
|
||||
),
|
||||
|
||||
/// Returns a Window, creating a fresh one if `do_create` is true.
|
||||
pub window_adapter: extern "C" fn(
|
||||
core::pin::Pin<VRef<ComponentVTable>>,
|
||||
do_create: bool,
|
||||
result: &mut Option<WindowAdapterRc>,
|
||||
),
|
||||
|
||||
/// in-place destructor (for VRc)
|
||||
pub drop_in_place: unsafe fn(VRefMut<ComponentVTable>) -> vtable::Layout,
|
||||
/// dealloc function (for VRc)
|
||||
pub dealloc: unsafe fn(&ComponentVTable, ptr: *mut u8, layout: vtable::Layout),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) use ComponentVTable_static;
|
||||
|
||||
/// Alias for `vtable::VRef<ComponentVTable>` which represent a pointer to a `dyn Component` with
|
||||
/// the associated vtable
|
||||
pub type ComponentRef<'a> = vtable::VRef<'a, ComponentVTable>;
|
||||
|
||||
/// Type alias to the commonly used `Pin<VRef<ComponentVTable>>>`
|
||||
pub type ComponentRefPin<'a> = core::pin::Pin<ComponentRef<'a>>;
|
||||
|
||||
/// Type alias to the commonly used VRc<ComponentVTable, Dyn>>
|
||||
pub type ComponentRc = vtable::VRc<ComponentVTable, Dyn>;
|
||||
/// Type alias to the commonly used VWeak<ComponentVTable, Dyn>>
|
||||
pub type ComponentWeak = vtable::VWeak<ComponentVTable, Dyn>;
|
||||
|
||||
/// Call init() on the ItemVTable for each item of the component.
|
||||
pub fn register_component(component_rc: &ComponentRc, window_adapter: Option<WindowAdapterRc>) {
|
||||
let c = vtable::VRc::borrow_pin(component_rc);
|
||||
let item_tree = c.as_ref().get_item_tree();
|
||||
item_tree.iter().enumerate().for_each(|(tree_index, node)| {
|
||||
let tree_index = tree_index as u32;
|
||||
if let ItemTreeNode::Item { .. } = &node {
|
||||
let item = ItemRc::new(component_rc.clone(), tree_index);
|
||||
c.as_ref().get_item_ref(tree_index).as_ref().init(&item);
|
||||
}
|
||||
});
|
||||
if let Some(adapter) = window_adapter.as_ref().and_then(|a| a.internal(crate::InternalToken)) {
|
||||
adapter.register_component();
|
||||
}
|
||||
}
|
||||
|
||||
/// Free the backend graphics resources allocated by the component's items.
|
||||
pub fn unregister_component<Base>(
|
||||
base: core::pin::Pin<&Base>,
|
||||
component: ComponentRef,
|
||||
item_array: &[vtable::VOffset<Base, ItemVTable, vtable::AllowPin>],
|
||||
window_adapter: &WindowAdapterRc,
|
||||
) {
|
||||
window_adapter.renderer().free_graphics_resources(
|
||||
component,
|
||||
&mut item_array.iter().map(|item| item.apply_pin(base)),
|
||||
).expect("Fatal error encountered when freeing graphics resources while destroying Slint component");
|
||||
if let Some(w) = window_adapter.internal(crate::InternalToken) {
|
||||
w.unregister_component(component, &mut item_array.iter().map(|item| item.apply_pin(base)));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ffi")]
|
||||
pub(crate) mod ffi {
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use crate::window::WindowAdapterRc;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// Call init() on the ItemVTable of each item in the item array.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_register_component(
|
||||
component_rc: &ComponentRc,
|
||||
window_handle: *const crate::window::ffi::WindowAdapterRcOpaque,
|
||||
) {
|
||||
let window_adapter = (window_handle as *const WindowAdapterRc).as_ref().cloned();
|
||||
super::register_component(component_rc, window_adapter)
|
||||
}
|
||||
|
||||
/// Free the backend graphics resources allocated in the item array.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_unregister_component(
|
||||
component: ComponentRefPin,
|
||||
item_array: Slice<vtable::VOffset<u8, ItemVTable, vtable::AllowPin>>,
|
||||
window_handle: *const crate::window::ffi::WindowAdapterRcOpaque,
|
||||
) {
|
||||
let window_adapter = &*(window_handle as *const WindowAdapterRc);
|
||||
super::unregister_component(
|
||||
core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)),
|
||||
core::pin::Pin::into_inner(component),
|
||||
item_array.as_slice(),
|
||||
window_adapter,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,18 +4,14 @@
|
|||
#![warn(missing_docs)]
|
||||
|
||||
//! This module defines a `ComponentFactory` and related code.
|
||||
use core::fmt::Debug;
|
||||
|
||||
use crate::api::ComponentHandle;
|
||||
use crate::item_tree::{ItemTreeRc, ItemTreeVTable};
|
||||
use alloc::boxed::Box;
|
||||
use alloc::rc::Rc;
|
||||
|
||||
use crate::{
|
||||
api::ComponentHandle,
|
||||
component::{ComponentRc, ComponentVTable},
|
||||
};
|
||||
use core::fmt::Debug;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct ComponentFactoryInner(Rc<dyn Fn() -> Option<ComponentRc> + 'static>);
|
||||
struct ComponentFactoryInner(Rc<dyn Fn() -> Option<ItemTreeRc> + 'static>);
|
||||
|
||||
impl PartialEq for ComponentFactoryInner {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
|
|
@ -46,18 +42,18 @@ impl ComponentFactory {
|
|||
/// Create a new `ComponentFactory`
|
||||
pub fn new<T: ComponentHandle + 'static>(factory: impl Fn() -> Option<T> + 'static) -> Self
|
||||
where
|
||||
T::Inner: vtable::HasStaticVTable<ComponentVTable> + 'static,
|
||||
T::Inner: vtable::HasStaticVTable<ItemTreeVTable> + 'static,
|
||||
{
|
||||
let factory = Box::new(factory) as Box<dyn Fn() -> Option<T> + 'static>;
|
||||
|
||||
Self(Some(ComponentFactoryInner(Rc::new(move || -> Option<ComponentRc> {
|
||||
Self(Some(ComponentFactoryInner(Rc::new(move || -> Option<ItemTreeRc> {
|
||||
let product = (factory)();
|
||||
product.map(|p| vtable::VRc::into_dyn(p.as_weak().inner().upgrade().unwrap()))
|
||||
}))))
|
||||
}
|
||||
|
||||
/// Build a `Component`
|
||||
pub(crate) fn build(&self) -> Option<ComponentRc> {
|
||||
pub(crate) fn build(&self) -> Option<ItemTreeRc> {
|
||||
self.0.as_ref().and_then(|b| (b.0)()).into()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use crate::component::ComponentRc;
|
||||
use crate::item_tree::ItemTreeRc;
|
||||
use crate::item_tree::{ItemRc, ItemWeak, VisitChildrenResult};
|
||||
pub use crate::items::PointerEventButton;
|
||||
use crate::items::{ItemRef, TextCursorDirection};
|
||||
|
|
@ -658,7 +658,7 @@ fn send_exit_events(
|
|||
/// of mouse grabber.
|
||||
/// Returns a new mouse grabber stack.
|
||||
pub fn process_mouse_input(
|
||||
component: ComponentRc,
|
||||
component: ItemTreeRc,
|
||||
mouse_event: MouseEvent,
|
||||
window_adapter: &Rc<dyn WindowAdapter>,
|
||||
mut mouse_input_state: MouseInputState,
|
||||
|
|
@ -704,7 +704,7 @@ pub(crate) fn process_delayed_event(
|
|||
};
|
||||
|
||||
let mut actual_visitor =
|
||||
|component: &ComponentRc, index: u32, _: Pin<ItemRef>| -> VisitChildrenResult {
|
||||
|component: &ItemTreeRc, index: u32, _: Pin<ItemRef>| -> VisitChildrenResult {
|
||||
send_mouse_event_to_item(
|
||||
event,
|
||||
ItemRc::new(component.clone(), index),
|
||||
|
|
@ -714,7 +714,7 @@ pub(crate) fn process_delayed_event(
|
|||
)
|
||||
};
|
||||
vtable::new_vref!(let mut actual_visitor : VRefMut<crate::item_tree::ItemVisitorVTable> for crate::item_tree::ItemVisitor = &mut actual_visitor);
|
||||
vtable::VRc::borrow_pin(top_item.component()).as_ref().visit_children_item(
|
||||
vtable::VRc::borrow_pin(top_item.item_tree()).as_ref().visit_children_item(
|
||||
top_item.index() as isize,
|
||||
crate::item_tree::TraversalOrder::FrontToBack,
|
||||
actual_visitor,
|
||||
|
|
@ -780,7 +780,7 @@ fn send_mouse_event_to_item(
|
|||
result.item_stack.push((item_rc.downgrade(), filter_result));
|
||||
if forward_to_children {
|
||||
let mut actual_visitor =
|
||||
|component: &ComponentRc, index: u32, _: Pin<ItemRef>| -> VisitChildrenResult {
|
||||
|component: &ItemTreeRc, index: u32, _: Pin<ItemRef>| -> VisitChildrenResult {
|
||||
send_mouse_event_to_item(
|
||||
event_for_children,
|
||||
ItemRc::new(component.clone(), index),
|
||||
|
|
@ -790,7 +790,7 @@ fn send_mouse_event_to_item(
|
|||
)
|
||||
};
|
||||
vtable::new_vref!(let mut actual_visitor : VRefMut<crate::item_tree::ItemVisitorVTable> for crate::item_tree::ItemVisitor = &mut actual_visitor);
|
||||
let r = vtable::VRc::borrow_pin(item_rc.component()).as_ref().visit_children_item(
|
||||
let r = vtable::VRc::borrow_pin(item_rc.item_tree()).as_ref().visit_children_item(
|
||||
item_rc.index() as isize,
|
||||
crate::item_tree::TraversalOrder::FrontToBack,
|
||||
actual_visitor,
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
This module contains the code moving the keyboard focus between items
|
||||
*/
|
||||
|
||||
use crate::item_tree::ComponentItemTree;
|
||||
use crate::item_tree::ItemTreeNodeArray;
|
||||
|
||||
pub fn step_out_of_node(
|
||||
index: u32,
|
||||
item_tree: &crate::item_tree::ComponentItemTree,
|
||||
item_tree: &crate::item_tree::ItemTreeNodeArray,
|
||||
) -> Option<u32> {
|
||||
let mut self_or_ancestor = index;
|
||||
loop {
|
||||
|
|
@ -28,7 +28,7 @@ pub fn step_out_of_node(
|
|||
|
||||
pub fn default_next_in_local_focus_chain(
|
||||
index: u32,
|
||||
item_tree: &crate::item_tree::ComponentItemTree,
|
||||
item_tree: &crate::item_tree::ItemTreeNodeArray,
|
||||
) -> Option<u32> {
|
||||
if let Some(child) = item_tree.first_child(index) {
|
||||
return Some(child);
|
||||
|
|
@ -37,7 +37,7 @@ pub fn default_next_in_local_focus_chain(
|
|||
step_out_of_node(index, item_tree)
|
||||
}
|
||||
|
||||
fn step_into_node(item_tree: &ComponentItemTree, index: u32) -> u32 {
|
||||
fn step_into_node(item_tree: &ItemTreeNodeArray, index: u32) -> u32 {
|
||||
let mut node = index;
|
||||
loop {
|
||||
if let Some(last_child) = item_tree.last_child(node) {
|
||||
|
|
@ -50,7 +50,7 @@ fn step_into_node(item_tree: &ComponentItemTree, index: u32) -> u32 {
|
|||
|
||||
pub fn default_previous_in_local_focus_chain(
|
||||
index: u32,
|
||||
item_tree: &crate::item_tree::ComponentItemTree,
|
||||
item_tree: &crate::item_tree::ItemTreeNodeArray,
|
||||
) -> Option<u32> {
|
||||
if let Some(previous) = item_tree.previous_sibling(index) {
|
||||
Some(step_into_node(item_tree, previous))
|
||||
|
|
@ -65,7 +65,7 @@ mod tests {
|
|||
|
||||
use crate::item_tree::ItemTreeNode;
|
||||
|
||||
fn validate_focus_chains<'a>(item_tree: ComponentItemTree<'a>) {
|
||||
fn validate_focus_chains<'a>(item_tree: ItemTreeNodeArray<'a>) {
|
||||
let forward_chain = {
|
||||
let mut tmp = alloc::vec::Vec::with_capacity(item_tree.node_count());
|
||||
let mut node = 0;
|
||||
|
|
@ -110,7 +110,7 @@ mod tests {
|
|||
item_array_index: 0,
|
||||
}];
|
||||
|
||||
let tree: ComponentItemTree = (nodes.as_slice()).into();
|
||||
let tree: ItemTreeNodeArray = (nodes.as_slice()).into();
|
||||
validate_focus_chains(tree);
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ mod tests {
|
|||
},
|
||||
];
|
||||
|
||||
let tree: ComponentItemTree = (nodes.as_slice()).into();
|
||||
let tree: ItemTreeNodeArray = (nodes.as_slice()).into();
|
||||
validate_focus_chains(tree);
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ mod tests {
|
|||
},
|
||||
];
|
||||
|
||||
let tree: ComponentItemTree = (nodes.as_slice()).into();
|
||||
let tree: ItemTreeNodeArray = (nodes.as_slice()).into();
|
||||
validate_focus_chains(tree);
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ mod tests {
|
|||
},
|
||||
];
|
||||
|
||||
let tree: ComponentItemTree = (nodes.as_slice()).into();
|
||||
let tree: ItemTreeNodeArray = (nodes.as_slice()).into();
|
||||
validate_focus_chains(tree);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
use super::graphics::RenderingCache;
|
||||
use super::items::*;
|
||||
use crate::component::ComponentRc;
|
||||
use crate::graphics::CachedGraphicsData;
|
||||
use crate::item_tree::ItemTreeRc;
|
||||
use crate::item_tree::{
|
||||
ItemRc, ItemVisitor, ItemVisitorResult, ItemVisitorVTable, VisitChildrenResult,
|
||||
};
|
||||
|
|
@ -93,7 +93,7 @@ impl<T: Clone> ItemCache<T> {
|
|||
/// Otherwise call the `update_fn` to compute that value, and track property access
|
||||
/// so it is automatically invalided when property becomes dirty.
|
||||
pub fn get_or_update_cache_entry(&self, item_rc: &ItemRc, update_fn: impl FnOnce() -> T) -> T {
|
||||
let component = &(**item_rc.component()) as *const _;
|
||||
let component = &(**item_rc.item_tree()) as *const _;
|
||||
let mut borrowed = self.map.borrow_mut();
|
||||
match borrowed.entry(component).or_default().entry(item_rc.index()) {
|
||||
std::collections::hash_map::Entry::Occupied(mut entry) => {
|
||||
|
|
@ -134,7 +134,7 @@ impl<T: Clone> ItemCache<T> {
|
|||
item_rc: &ItemRc,
|
||||
callback: impl FnOnce(&T) -> Option<U>,
|
||||
) -> Option<U> {
|
||||
let component = &(**item_rc.component()) as *const _;
|
||||
let component = &(**item_rc.item_tree()) as *const _;
|
||||
self.map
|
||||
.borrow()
|
||||
.get(&component)
|
||||
|
|
@ -159,16 +159,16 @@ impl<T: Clone> ItemCache<T> {
|
|||
|
||||
/// Function that must be called when a component is destroyed.
|
||||
///
|
||||
/// Usually can be called from [`crate::window::WindowAdapterInternal::unregister_component`]
|
||||
pub fn component_destroyed(&self, component: crate::component::ComponentRef) {
|
||||
/// Usually can be called from [`crate::window::WindowAdapterInternal::unregister_item_tree`]
|
||||
pub fn component_destroyed(&self, component: crate::item_tree::ItemTreeRef) {
|
||||
let component_ptr: *const _ =
|
||||
crate::component::ComponentRef::as_ptr(component).cast().as_ptr();
|
||||
crate::item_tree::ItemTreeRef::as_ptr(component).cast().as_ptr();
|
||||
self.map.borrow_mut().remove(&component_ptr);
|
||||
}
|
||||
|
||||
/// free the cache for a given item
|
||||
pub fn release(&self, item_rc: &ItemRc) {
|
||||
let component = &(**item_rc.component()) as *const _;
|
||||
let component = &(**item_rc.item_tree()) as *const _;
|
||||
if let Some(sub) = self.map.borrow_mut().get_mut(&component) {
|
||||
sub.remove(&item_rc.index());
|
||||
}
|
||||
|
|
@ -183,13 +183,9 @@ pub(crate) fn is_clipping_item(item: Pin<ItemRef>) -> bool {
|
|||
}
|
||||
|
||||
/// Renders the children of the item with the specified index into the renderer.
|
||||
pub fn render_item_children(
|
||||
renderer: &mut dyn ItemRenderer,
|
||||
component: &ComponentRc,
|
||||
index: isize,
|
||||
) {
|
||||
pub fn render_item_children(renderer: &mut dyn ItemRenderer, component: &ItemTreeRc, index: isize) {
|
||||
let mut actual_visitor =
|
||||
|component: &ComponentRc, index: u32, item: Pin<ItemRef>| -> VisitChildrenResult {
|
||||
|component: &ItemTreeRc, index: u32, item: Pin<ItemRef>| -> VisitChildrenResult {
|
||||
renderer.save_state();
|
||||
let item_rc = ItemRc::new(component.clone(), index);
|
||||
|
||||
|
|
@ -231,7 +227,7 @@ pub fn render_item_children(
|
|||
/// Renders the tree of items that component holds, using the specified renderer. Rendering is done
|
||||
/// relative to the specified origin.
|
||||
pub fn render_component_items(
|
||||
component: &ComponentRc,
|
||||
component: &ItemTreeRc,
|
||||
renderer: &mut dyn ItemRenderer,
|
||||
origin: LogicalPoint,
|
||||
) {
|
||||
|
|
@ -246,15 +242,15 @@ pub fn render_component_items(
|
|||
/// Compute the bounding rect of all children. This does /not/ include item's own bounding rect. Remember to run this
|
||||
/// via `evaluate_no_tracking`.
|
||||
pub fn item_children_bounding_rect(
|
||||
component: &ComponentRc,
|
||||
component: &ItemTreeRc,
|
||||
index: isize,
|
||||
clip_rect: &LogicalRect,
|
||||
) -> LogicalRect {
|
||||
let mut bounding_rect = LogicalRect::zero();
|
||||
|
||||
let mut actual_visitor =
|
||||
|component: &ComponentRc, index: u32, item: Pin<ItemRef>| -> VisitChildrenResult {
|
||||
let item_geometry = ComponentRc::borrow_pin(component).as_ref().item_geometry(index);
|
||||
|component: &ItemTreeRc, index: u32, item: Pin<ItemRef>| -> VisitChildrenResult {
|
||||
let item_geometry = ItemTreeRc::borrow_pin(component).as_ref().item_geometry(index);
|
||||
|
||||
let local_clip_rect = clip_rect.translate(-item_geometry.origin.to_vector());
|
||||
|
||||
|
|
@ -450,7 +446,7 @@ impl<'a, T> PartialRenderer<'a, T> {
|
|||
}
|
||||
|
||||
/// Visit the tree of item and compute what are the dirty regions
|
||||
pub fn compute_dirty_regions(&mut self, component: &ComponentRc, origin: LogicalPoint) {
|
||||
pub fn compute_dirty_regions(&mut self, component: &ItemTreeRc, origin: LogicalPoint) {
|
||||
#[derive(Clone, Copy)]
|
||||
struct ComputeDirtyRegionState {
|
||||
offset: euclid::Vector2D<Coord, LogicalPx>,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1367,7 +1367,7 @@ i_slint_common::for_each_builtin_structs!(declare_builtin_structs);
|
|||
#[cfg(feature = "ffi")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_item_absolute_position(
|
||||
self_component: &vtable::VRc<crate::component::ComponentVTable>,
|
||||
self_component: &vtable::VRc<crate::item_tree::ItemTreeVTable>,
|
||||
self_index: u32,
|
||||
) -> LogicalPoint {
|
||||
let self_rc = ItemRc::new(self_component.clone(), self_index);
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ When adding an item or a property, it needs to be kept in sync with different pl
|
|||
Lookup the [`crate::items`] module documentation.
|
||||
*/
|
||||
use super::{Item, ItemConsts, ItemRc, RenderingResult};
|
||||
use crate::component::{ComponentRc, ComponentWeak, IndexRange};
|
||||
use crate::component_factory::ComponentFactory;
|
||||
use crate::input::{
|
||||
FocusEvent, FocusEventResult, InputEventFilterResult, InputEventResult, KeyEvent,
|
||||
KeyEventResult, MouseEvent,
|
||||
};
|
||||
use crate::item_rendering::CachedRenderingData;
|
||||
use crate::item_tree::{IndexRange, ItemTreeRc, ItemTreeWeak};
|
||||
use crate::item_tree::{ItemTreeNode, ItemVisitorVTable, TraversalOrder, VisitChildrenResult};
|
||||
use crate::layout::{LayoutInfo, Orientation};
|
||||
use crate::lengths::{LogicalLength, LogicalSize};
|
||||
|
|
@ -57,9 +57,9 @@ pub struct ComponentContainer {
|
|||
pub cached_rendering_data: CachedRenderingData,
|
||||
|
||||
component_tracker: OnceCell<Pin<Box<PropertyTracker>>>,
|
||||
component: RefCell<Option<ComponentRc>>,
|
||||
component: RefCell<Option<ItemTreeRc>>,
|
||||
|
||||
my_component: OnceCell<ComponentWeak>,
|
||||
my_component: OnceCell<ItemTreeWeak>,
|
||||
embedding_item_tree_index: OnceCell<u32>,
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ impl ComponentContainer {
|
|||
IndexRange { start: 0, end: if self.component.borrow().is_some() { 1 } else { 0 } }
|
||||
}
|
||||
|
||||
pub fn subtree_component(self: Pin<&Self>) -> ComponentWeak {
|
||||
pub fn subtree_component(self: Pin<&Self>) -> ItemTreeWeak {
|
||||
let rc = self.component.borrow().clone();
|
||||
vtable::VRc::downgrade(rc.as_ref().unwrap())
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ impl ComponentContainer {
|
|||
|
||||
impl Item for ComponentContainer {
|
||||
fn init(self: Pin<&Self>, self_rc: &ItemRc) {
|
||||
let rc = self_rc.component();
|
||||
let rc = self_rc.item_tree();
|
||||
|
||||
self.my_component.set(vtable::VRc::downgrade(rc)).ok().unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -1233,7 +1233,7 @@ fn next_word_boundary(text: &str, last_cursor_pos: usize) -> usize {
|
|||
pub unsafe extern "C" fn slint_textinput_select_all(
|
||||
text_input: *const TextInput,
|
||||
window_adapter: *const crate::window::ffi::WindowAdapterRcOpaque,
|
||||
self_component: &vtable::VRc<crate::component::ComponentVTable>,
|
||||
self_component: &vtable::VRc<crate::item_tree::ItemTreeVTable>,
|
||||
self_index: u32,
|
||||
) {
|
||||
let window_adapter = &*(window_adapter as *const Rc<dyn WindowAdapter>);
|
||||
|
|
@ -1246,7 +1246,7 @@ pub unsafe extern "C" fn slint_textinput_select_all(
|
|||
pub unsafe extern "C" fn slint_textinput_clear_selection(
|
||||
text_input: *const TextInput,
|
||||
window_adapter: *const crate::window::ffi::WindowAdapterRcOpaque,
|
||||
self_component: &vtable::VRc<crate::component::ComponentVTable>,
|
||||
self_component: &vtable::VRc<crate::item_tree::ItemTreeVTable>,
|
||||
self_index: u32,
|
||||
) {
|
||||
let window_adapter = &*(window_adapter as *const Rc<dyn WindowAdapter>);
|
||||
|
|
@ -1259,7 +1259,7 @@ pub unsafe extern "C" fn slint_textinput_clear_selection(
|
|||
pub unsafe extern "C" fn slint_textinput_cut(
|
||||
text_input: *const TextInput,
|
||||
window_adapter: *const crate::window::ffi::WindowAdapterRcOpaque,
|
||||
self_component: &vtable::VRc<crate::component::ComponentVTable>,
|
||||
self_component: &vtable::VRc<crate::item_tree::ItemTreeVTable>,
|
||||
self_index: u32,
|
||||
) {
|
||||
let window_adapter = &*(window_adapter as *const Rc<dyn WindowAdapter>);
|
||||
|
|
@ -1272,7 +1272,7 @@ pub unsafe extern "C" fn slint_textinput_cut(
|
|||
pub unsafe extern "C" fn slint_textinput_copy(
|
||||
text_input: *const TextInput,
|
||||
window_adapter: *const crate::window::ffi::WindowAdapterRcOpaque,
|
||||
self_component: &vtable::VRc<crate::component::ComponentVTable>,
|
||||
self_component: &vtable::VRc<crate::item_tree::ItemTreeVTable>,
|
||||
self_index: u32,
|
||||
) {
|
||||
let window_adapter = &*(window_adapter as *const Rc<dyn WindowAdapter>);
|
||||
|
|
@ -1285,7 +1285,7 @@ pub unsafe extern "C" fn slint_textinput_copy(
|
|||
pub unsafe extern "C" fn slint_textinput_paste(
|
||||
text_input: *const TextInput,
|
||||
window_adapter: *const crate::window::ffi::WindowAdapterRcOpaque,
|
||||
self_component: &vtable::VRc<crate::component::ComponentVTable>,
|
||||
self_component: &vtable::VRc<crate::item_tree::ItemTreeVTable>,
|
||||
self_index: u32,
|
||||
) {
|
||||
let window_adapter = &*(window_adapter as *const Rc<dyn WindowAdapter>);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ pub mod accessibility;
|
|||
pub mod animations;
|
||||
pub mod api;
|
||||
pub mod callbacks;
|
||||
pub mod component;
|
||||
pub mod component_factory;
|
||||
pub mod future;
|
||||
pub mod graphics;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
//! Model and Repeater
|
||||
|
||||
use crate::component::ComponentVTable;
|
||||
use crate::item_tree::ItemTreeVTable;
|
||||
use crate::item_tree::TraversalOrder;
|
||||
pub use crate::items::{StandardListViewItem, TableColumn};
|
||||
use crate::layout::Orientation;
|
||||
|
|
@ -27,7 +27,7 @@ use pin_project::pin_project;
|
|||
mod adapters;
|
||||
mod model_peer;
|
||||
|
||||
type ComponentRc<C> = vtable::VRc<crate::component::ComponentVTable, C>;
|
||||
type ItemTreeRc<C> = vtable::VRc<crate::item_tree::ItemTreeVTable, C>;
|
||||
|
||||
/// This trait defines the interface that users of a model can use to track changes
|
||||
/// to a model. It is supplied via [`Model::model_tracker`] and implementation usually
|
||||
|
|
@ -685,7 +685,7 @@ impl<T> Model for ModelRc<T> {
|
|||
|
||||
/// Component that can be instantiated by a repeater.
|
||||
pub trait RepeatedComponent:
|
||||
crate::component::Component + vtable::HasStaticVTable<ComponentVTable> + 'static
|
||||
crate::item_tree::ItemTree + vtable::HasStaticVTable<ItemTreeVTable> + 'static
|
||||
{
|
||||
/// The data corresponding to the model
|
||||
type Data: 'static;
|
||||
|
|
@ -725,7 +725,7 @@ enum RepeatedComponentState {
|
|||
Dirty,
|
||||
}
|
||||
struct RepeaterInner<C: RepeatedComponent> {
|
||||
components: Vec<(RepeatedComponentState, Option<ComponentRc<C>>)>,
|
||||
components: Vec<(RepeatedComponentState, Option<ItemTreeRc<C>>)>,
|
||||
|
||||
// The remaining properties only make sense for ListView
|
||||
/// The model row (index) of the first component in the `components` vector.
|
||||
|
|
@ -881,7 +881,7 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
|
|||
|
||||
/// Call this function to make sure that the model is updated.
|
||||
/// The init function is the function to create a component
|
||||
pub fn ensure_updated(self: Pin<&Self>, init: impl Fn() -> ComponentRc<C>) {
|
||||
pub fn ensure_updated(self: Pin<&Self>, init: impl Fn() -> ItemTreeRc<C>) {
|
||||
let model = self.model();
|
||||
if self.data().project_ref().is_dirty.get() {
|
||||
self.ensure_updated_impl(init, &model, model.row_count());
|
||||
|
|
@ -891,7 +891,7 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
|
|||
// returns true if new items were created
|
||||
fn ensure_updated_impl(
|
||||
self: Pin<&Self>,
|
||||
init: impl Fn() -> ComponentRc<C>,
|
||||
init: impl Fn() -> ItemTreeRc<C>,
|
||||
model: &ModelRc<C::Data>,
|
||||
count: usize,
|
||||
) -> bool {
|
||||
|
|
@ -922,7 +922,7 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
|
|||
/// Same as `Self::ensure_updated` but for a ListView
|
||||
pub fn ensure_updated_listview(
|
||||
self: Pin<&Self>,
|
||||
init: impl Fn() -> ComponentRc<C>,
|
||||
init: impl Fn() -> ItemTreeRc<C>,
|
||||
viewport_width: Pin<&Property<LogicalLength>>,
|
||||
viewport_height: Pin<&Property<LogicalLength>>,
|
||||
viewport_y: Pin<&Property<LogicalLength>>,
|
||||
|
|
@ -950,7 +950,7 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
|
|||
} else {
|
||||
let total_height = Cell::new(LogicalLength::zero());
|
||||
let count = Cell::new(0);
|
||||
let get_height_visitor = |x: &ComponentRc<C>| {
|
||||
let get_height_visitor = |x: &ItemTreeRc<C>| {
|
||||
let height = x.as_pin_ref().item_geometry(0).height_length();
|
||||
count.set(count.get() + 1);
|
||||
total_height.set(total_height.get() + height);
|
||||
|
|
@ -1182,7 +1182,7 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
|
|||
|
||||
/// Return the component instance for the given model index.
|
||||
/// The index should be within [`Self::range()`]
|
||||
pub fn component_at(&self, index: usize) -> Option<ComponentRc<C>> {
|
||||
pub fn component_at(&self, index: usize) -> Option<ItemTreeRc<C>> {
|
||||
let inner = self.0.inner.borrow();
|
||||
inner
|
||||
.components
|
||||
|
|
@ -1196,7 +1196,7 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
|
|||
}
|
||||
|
||||
/// Returns a vector containing all components
|
||||
pub fn components_vec(&self) -> Vec<ComponentRc<C>> {
|
||||
pub fn components_vec(&self) -> Vec<ItemTreeRc<C>> {
|
||||
self.0.inner.borrow().components.iter().flat_map(|x| x.1.clone()).collect()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use alloc::rc::Rc;
|
|||
use core::pin::Pin;
|
||||
|
||||
use crate::api::PlatformError;
|
||||
use crate::component::ComponentRef;
|
||||
use crate::item_tree::ItemTreeRef;
|
||||
use crate::lengths::{LogicalLength, LogicalPoint, LogicalRect, LogicalSize, ScaleFactor};
|
||||
use crate::window::WindowAdapter;
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ pub trait RendererSealed {
|
|||
/// Clear the caches for the items that are being removed
|
||||
fn free_graphics_resources(
|
||||
&self,
|
||||
_component: ComponentRef,
|
||||
_component: ItemTreeRef,
|
||||
_items: &mut dyn Iterator<Item = Pin<crate::items::ItemRef<'_>>>,
|
||||
) -> Result<(), crate::platform::PlatformError> {
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ impl SoftwareRenderer {
|
|||
};
|
||||
let window_inner = WindowInner::from_pub(window.window());
|
||||
let component_rc = window_inner.component();
|
||||
let component = crate::component::ComponentRc::borrow_pin(&component_rc);
|
||||
let component = crate::item_tree::ItemTreeRc::borrow_pin(&component_rc);
|
||||
if let Some(window_item) = crate::items::ItemRef::downcast_pin::<crate::items::WindowItem>(
|
||||
component.as_ref().get_item_ref(0),
|
||||
) {
|
||||
|
|
@ -492,7 +492,7 @@ impl RendererSealed for SoftwareRenderer {
|
|||
|
||||
fn free_graphics_resources(
|
||||
&self,
|
||||
_component: crate::component::ComponentRef,
|
||||
_component: crate::item_tree::ItemTreeRef,
|
||||
items: &mut dyn Iterator<Item = Pin<crate::items::ItemRef<'_>>>,
|
||||
) -> Result<(), crate::platform::PlatformError> {
|
||||
for item in items {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub extern "C" fn slint_mock_elapsed_time(time_in_ms: u64) {
|
|||
/// Simulate a click on a position within the component.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn slint_send_mouse_click(
|
||||
_component: &crate::component::ComponentRc,
|
||||
_component: &crate::item_tree::ItemTreeRc,
|
||||
x: f32,
|
||||
y: f32,
|
||||
window_adapter: &crate::window::WindowAdapterRc,
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ use crate::api::{
|
|||
CloseRequestResponse, PhysicalPosition, PhysicalSize, PlatformError, Window, WindowPosition,
|
||||
WindowSize,
|
||||
};
|
||||
use crate::component::{ComponentRc, ComponentRef, ComponentVTable, ComponentWeak};
|
||||
use crate::graphics::Point;
|
||||
use crate::input::{
|
||||
key_codes, ClickState, InternalKeyboardModifierState, KeyEvent, KeyEventType, KeyInputEvent,
|
||||
KeyboardModifiers, MouseEvent, MouseInputState, TextCursorBlinker,
|
||||
};
|
||||
use crate::item_tree::ItemRc;
|
||||
use crate::item_tree::{ItemTreeRc, ItemTreeRef, ItemTreeVTable, ItemTreeWeak};
|
||||
use crate::items::{ItemRef, MouseCursor};
|
||||
use crate::lengths::{LogicalLength, LogicalPoint, LogicalRect, LogicalSize, SizeLengths};
|
||||
use crate::properties::{Property, PropertyTracker};
|
||||
|
|
@ -158,13 +158,13 @@ pub trait WindowAdapter {
|
|||
#[doc(hidden)]
|
||||
pub trait WindowAdapterInternal {
|
||||
/// This function is called by the generated code when a component and therefore its tree of items are created.
|
||||
fn register_component(&self) {}
|
||||
fn register_item_tree(&self) {}
|
||||
|
||||
/// This function is called by the generated code when a component and therefore its tree of items are destroyed. The
|
||||
/// implementation typically uses this to free the underlying graphics resources cached via [`crate::graphics::RenderingCache`].
|
||||
fn unregister_component(
|
||||
fn unregister_item_tree(
|
||||
&self,
|
||||
_component: ComponentRef,
|
||||
_component: ItemTreeRef,
|
||||
_items: &mut dyn Iterator<Item = Pin<ItemRef<'_>>>,
|
||||
) {
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ impl<'a> WindowProperties<'a> {
|
|||
pub fn background(&self) -> crate::Brush {
|
||||
self.0
|
||||
.window_item()
|
||||
.map(|w: VRcMapped<ComponentVTable, crate::items::WindowItem>| {
|
||||
.map(|w: VRcMapped<ItemTreeVTable, crate::items::WindowItem>| {
|
||||
w.as_pin_ref().background()
|
||||
})
|
||||
.unwrap_or_default()
|
||||
|
|
@ -262,7 +262,7 @@ impl<'a> WindowProperties<'a> {
|
|||
/// Returns the layout constraints of the window
|
||||
pub fn layout_constraints(&self) -> LayoutConstraints {
|
||||
let component = self.0.component();
|
||||
let component = ComponentRc::borrow_pin(&component);
|
||||
let component = ItemTreeRc::borrow_pin(&component);
|
||||
let h = component.as_ref().layout_info(crate::layout::Orientation::Horizontal);
|
||||
let v = component.as_ref().layout_info(crate::layout::Orientation::Vertical);
|
||||
let (min, max) = crate::layout::min_max_size_for_layout_constraints(h, v);
|
||||
|
|
@ -318,7 +318,7 @@ struct PopupWindow {
|
|||
/// The location defines where the pop up is rendered.
|
||||
location: PopupWindowLocation,
|
||||
/// The component that is responsible for providing the popup content.
|
||||
component: ComponentRc,
|
||||
component: ItemTreeRc,
|
||||
/// If true, Slint will close the popup after any mouse click within the popup.
|
||||
/// Set to false and call close() on the PopupWindow to close it manually.
|
||||
close_on_click: bool,
|
||||
|
|
@ -342,9 +342,9 @@ struct WindowPinnedFields {
|
|||
/// Inner datastructure for the [`crate::api::Window`]
|
||||
pub struct WindowInner {
|
||||
window_adapter_weak: Weak<dyn WindowAdapter>,
|
||||
component: RefCell<ComponentWeak>,
|
||||
component: RefCell<ItemTreeWeak>,
|
||||
/// When the window is visible, keep a strong reference
|
||||
strong_component_ref: RefCell<Option<ComponentRc>>,
|
||||
strong_component_ref: RefCell<Option<ItemTreeRc>>,
|
||||
mouse_input_state: Cell<MouseInputState>,
|
||||
pub(crate) modifiers: Cell<InternalKeyboardModifierState>,
|
||||
|
||||
|
|
@ -413,17 +413,17 @@ impl WindowInner {
|
|||
|
||||
/// Associates this window with the specified component. Further event handling and rendering, etc. will be
|
||||
/// done with that component.
|
||||
pub fn set_component(&self, component: &ComponentRc) {
|
||||
pub fn set_component(&self, component: &ItemTreeRc) {
|
||||
self.close_popup();
|
||||
self.focus_item.replace(Default::default());
|
||||
self.mouse_input_state.replace(Default::default());
|
||||
self.modifiers.replace(Default::default());
|
||||
self.component.replace(ComponentRc::downgrade(component));
|
||||
self.component.replace(ItemTreeRc::downgrade(component));
|
||||
self.pinned_fields.window_properties_tracker.set_dirty(); // component changed, layout constraints for sure must be re-calculated
|
||||
let window_adapter = self.window_adapter();
|
||||
window_adapter.renderer().set_window_adapter(&window_adapter);
|
||||
{
|
||||
let component = ComponentRc::borrow_pin(component);
|
||||
let component = ItemTreeRc::borrow_pin(component);
|
||||
let root_item = component.as_ref().get_item_ref(0);
|
||||
let window_item = ItemRef::downcast_pin::<crate::items::WindowItem>(root_item).unwrap();
|
||||
|
||||
|
|
@ -444,12 +444,12 @@ impl WindowInner {
|
|||
|
||||
/// return the component.
|
||||
/// Panics if it wasn't set.
|
||||
pub fn component(&self) -> ComponentRc {
|
||||
pub fn component(&self) -> ItemTreeRc {
|
||||
self.component.borrow().upgrade().unwrap()
|
||||
}
|
||||
|
||||
/// returns the component or None if it isn't set.
|
||||
pub fn try_component(&self) -> Option<ComponentRc> {
|
||||
pub fn try_component(&self) -> Option<ItemTreeRc> {
|
||||
self.component.borrow().upgrade()
|
||||
}
|
||||
|
||||
|
|
@ -483,7 +483,7 @@ impl WindowInner {
|
|||
|
||||
if let MouseEvent::Pressed { position, .. } = &event {
|
||||
// close the popup if one press outside the popup
|
||||
let geom = ComponentRc::borrow_pin(popup_component).as_ref().item_geometry(0);
|
||||
let geom = ItemTreeRc::borrow_pin(popup_component).as_ref().item_geometry(0);
|
||||
if !geom.contains(*position) {
|
||||
self.close_popup();
|
||||
return None;
|
||||
|
|
@ -732,7 +732,7 @@ impl WindowInner {
|
|||
/// Returns None if no component is set yet.
|
||||
pub fn draw_contents<T>(
|
||||
&self,
|
||||
render_components: impl FnOnce(&[(&ComponentRc, LogicalPoint)]) -> T,
|
||||
render_components: impl FnOnce(&[(&ItemTreeRc, LogicalPoint)]) -> T,
|
||||
) -> Option<T> {
|
||||
let draw_fn = || {
|
||||
let component_rc = self.try_component()?;
|
||||
|
|
@ -796,7 +796,7 @@ impl WindowInner {
|
|||
/// Show a popup at the given position relative to the item
|
||||
pub fn show_popup(
|
||||
&self,
|
||||
popup_componentrc: &ComponentRc,
|
||||
popup_componentrc: &ItemTreeRc,
|
||||
position: Point,
|
||||
close_on_click: bool,
|
||||
parent_item: &ItemRc,
|
||||
|
|
@ -804,7 +804,7 @@ impl WindowInner {
|
|||
let position = parent_item.map_to_window(
|
||||
parent_item.geometry().origin + LogicalPoint::from_untyped(position).to_vector(),
|
||||
);
|
||||
let popup_component = ComponentRc::borrow_pin(popup_componentrc);
|
||||
let popup_component = ItemTreeRc::borrow_pin(popup_componentrc);
|
||||
let popup_root = popup_component.as_ref().get_item_ref(0);
|
||||
|
||||
let (mut w, mut h) = if let Some(window_item) =
|
||||
|
|
@ -870,7 +870,7 @@ impl WindowInner {
|
|||
if let PopupWindowLocation::ChildWindow(offset) = current_popup.location {
|
||||
// Refresh the area that was previously covered by the popup.
|
||||
let popup_region = crate::properties::evaluate_no_tracking(|| {
|
||||
let popup_component = ComponentRc::borrow_pin(¤t_popup.component);
|
||||
let popup_component = ItemTreeRc::borrow_pin(¤t_popup.component);
|
||||
popup_component.as_ref().item_geometry(0)
|
||||
})
|
||||
.translate(offset.to_vector());
|
||||
|
|
@ -915,7 +915,7 @@ impl WindowInner {
|
|||
}
|
||||
|
||||
/// Returns the window item that is the first item in the component.
|
||||
pub fn window_item(&self) -> Option<VRcMapped<ComponentVTable, crate::items::WindowItem>> {
|
||||
pub fn window_item(&self) -> Option<VRcMapped<ItemTreeVTable, crate::items::WindowItem>> {
|
||||
self.try_component().and_then(|component_rc| {
|
||||
ItemRc::new(component_rc, 0).downcast::<crate::items::WindowItem>()
|
||||
})
|
||||
|
|
@ -925,7 +925,7 @@ impl WindowInner {
|
|||
/// window resize event from the windowing system.
|
||||
pub(crate) fn set_window_item_geometry(&self, size: LogicalSize) {
|
||||
if let Some(component_rc) = self.try_component() {
|
||||
let component = ComponentRc::borrow_pin(&component_rc);
|
||||
let component = ItemTreeRc::borrow_pin(&component_rc);
|
||||
let root_item = component.as_ref().get_item_ref(0);
|
||||
if let Some(window_item) = ItemRef::downcast_pin::<crate::items::WindowItem>(root_item)
|
||||
{
|
||||
|
|
@ -1100,7 +1100,7 @@ pub mod ffi {
|
|||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_windowrc_set_component(
|
||||
handle: *const WindowAdapterRcOpaque,
|
||||
component: &ComponentRc,
|
||||
component: &ItemTreeRc,
|
||||
) {
|
||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||
WindowInner::from_pub(window_adapter.window()).set_component(component)
|
||||
|
|
@ -1110,7 +1110,7 @@ pub mod ffi {
|
|||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_windowrc_show_popup(
|
||||
handle: *const WindowAdapterRcOpaque,
|
||||
popup: &ComponentRc,
|
||||
popup: &ItemTreeRc,
|
||||
position: crate::graphics::Point,
|
||||
close_on_click: bool,
|
||||
parent_item: &ItemRc,
|
||||
|
|
|
|||
|
|
@ -1136,7 +1136,7 @@ impl ComponentHandle for ComponentInstance {
|
|||
}
|
||||
|
||||
fn from_inner(
|
||||
inner: vtable::VRc<i_slint_core::component::ComponentVTable, Self::Inner>,
|
||||
inner: vtable::VRc<i_slint_core::item_tree::ItemTreeVTable, Self::Inner>,
|
||||
) -> Self {
|
||||
Self { inner }
|
||||
}
|
||||
|
|
@ -1168,7 +1168,7 @@ impl ComponentHandle for ComponentInstance {
|
|||
}
|
||||
|
||||
impl From<ComponentInstance>
|
||||
for vtable::VRc<i_slint_core::component::ComponentVTable, ErasedComponentBox>
|
||||
for vtable::VRc<i_slint_core::item_tree::ItemTreeVTable, ErasedComponentBox>
|
||||
{
|
||||
fn from(value: ComponentInstance) -> Self {
|
||||
value.inner
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
// cSpell: ignore unerase
|
||||
|
||||
//! FIXME! rename dynamic_item_tree
|
||||
|
||||
use crate::{api::Value, dynamic_type, eval};
|
||||
|
||||
use core::convert::TryInto;
|
||||
|
|
@ -15,10 +17,10 @@ use i_slint_compiler::object_tree::ElementRc;
|
|||
use i_slint_compiler::*;
|
||||
use i_slint_compiler::{diagnostics::BuildDiagnostics, object_tree::PropertyDeclaration};
|
||||
use i_slint_core::accessibility::AccessibleStringProperty;
|
||||
use i_slint_core::component::{
|
||||
Component, ComponentRef, ComponentRefPin, ComponentVTable, ComponentWeak, IndexRange,
|
||||
};
|
||||
use i_slint_core::component_factory::ComponentFactory;
|
||||
use i_slint_core::item_tree::{
|
||||
IndexRange, ItemTree, ItemTreeRef, ItemTreeRefPin, ItemTreeVTable, ItemTreeWeak,
|
||||
};
|
||||
use i_slint_core::item_tree::{
|
||||
ItemRc, ItemTreeNode, ItemVisitorRefMut, ItemVisitorVTable, ItemWeak, TraversalOrder,
|
||||
VisitChildrenResult,
|
||||
|
|
@ -45,8 +47,8 @@ pub struct ComponentBox<'id> {
|
|||
}
|
||||
|
||||
impl<'id> ComponentBox<'id> {
|
||||
/// Borrow this component as a `Pin<ComponentRef>`
|
||||
pub fn borrow(&self) -> ComponentRefPin {
|
||||
/// Borrow this component as a `Pin<ItemTreeRef>`
|
||||
pub fn borrow(&self) -> ItemTreeRefPin {
|
||||
self.borrow_instance().borrow()
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +159,7 @@ impl RepeatedComponent for ErasedComponentBox {
|
|||
}
|
||||
}
|
||||
|
||||
impl Component for ErasedComponentBox {
|
||||
impl ItemTree for ErasedComponentBox {
|
||||
fn visit_children_item(
|
||||
self: Pin<&Self>,
|
||||
index: isize,
|
||||
|
|
@ -177,7 +179,7 @@ impl Component for ErasedComponentBox {
|
|||
|
||||
fn get_item_ref(self: Pin<&Self>, index: u32) -> Pin<ItemRef> {
|
||||
// We're having difficulties transferring the lifetime to a pinned reference
|
||||
// to the other ComponentVTable with the same life time. So skip the vtable
|
||||
// to the other ItemTreeVTable with the same life time. So skip the vtable
|
||||
// indirection and call our implementation directly.
|
||||
unsafe { get_item_ref(self.get_ref().borrow(), index) }
|
||||
}
|
||||
|
|
@ -186,13 +188,8 @@ impl Component for ErasedComponentBox {
|
|||
self.borrow().as_ref().get_subtree_range(index)
|
||||
}
|
||||
|
||||
fn get_subtree_component(
|
||||
self: Pin<&Self>,
|
||||
index: u32,
|
||||
subindex: usize,
|
||||
result: &mut ComponentWeak,
|
||||
) {
|
||||
self.borrow().as_ref().get_subtree_component(index, subindex, result);
|
||||
fn get_subtree(self: Pin<&Self>, index: u32, subindex: usize, result: &mut ItemTreeWeak) {
|
||||
self.borrow().as_ref().get_subtree(index, subindex, result);
|
||||
}
|
||||
|
||||
fn parent_node(self: Pin<&Self>, result: &mut ItemWeak) {
|
||||
|
|
@ -201,7 +198,7 @@ impl Component for ErasedComponentBox {
|
|||
|
||||
fn embed_component(
|
||||
self: core::pin::Pin<&Self>,
|
||||
parent_component: &ComponentWeak,
|
||||
parent_component: &ItemTreeWeak,
|
||||
item_tree_index: u32,
|
||||
) -> bool {
|
||||
self.borrow().as_ref().embed_component(parent_component, item_tree_index)
|
||||
|
|
@ -233,7 +230,7 @@ impl Component for ErasedComponentBox {
|
|||
}
|
||||
}
|
||||
|
||||
i_slint_core::ComponentVTable_static!(static COMPONENT_BOX_VT for ErasedComponentBox);
|
||||
i_slint_core::ItemTreeVTable_static!(static COMPONENT_BOX_VT for ErasedComponentBox);
|
||||
|
||||
impl<'id> Drop for ErasedComponentBox {
|
||||
fn drop(&mut self) {
|
||||
|
|
@ -242,7 +239,7 @@ impl<'id> Drop for ErasedComponentBox {
|
|||
let instance_ref = unerase.borrow_instance();
|
||||
// Do not walk out of our component here:
|
||||
if let Some(window_adapter) = instance_ref.maybe_window_adapter() {
|
||||
i_slint_core::component::unregister_component(
|
||||
i_slint_core::item_tree::unregister_item_tree(
|
||||
instance_ref.instance,
|
||||
vtable::VRef::new(self),
|
||||
instance_ref.component_type.item_array.as_slice(),
|
||||
|
|
@ -252,13 +249,13 @@ impl<'id> Drop for ErasedComponentBox {
|
|||
}
|
||||
}
|
||||
|
||||
pub type DynamicComponentVRc = vtable::VRc<ComponentVTable, ErasedComponentBox>;
|
||||
pub type DynamicComponentVRc = vtable::VRc<ItemTreeVTable, ErasedComponentBox>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct ComponentExtraData {
|
||||
pub(crate) globals: OnceCell<crate::global_component::GlobalStorage>,
|
||||
pub(crate) self_weak: OnceCell<vtable::VWeak<ComponentVTable, ErasedComponentBox>>,
|
||||
pub(crate) embedding_position: OnceCell<(ComponentWeak, u32)>,
|
||||
pub(crate) self_weak: OnceCell<vtable::VWeak<ItemTreeVTable, ErasedComponentBox>>,
|
||||
pub(crate) embedding_position: OnceCell<(ItemTreeWeak, u32)>,
|
||||
// resource id -> file path
|
||||
pub(crate) embedded_file_resources: OnceCell<HashMap<usize, String>>,
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
|
@ -334,12 +331,12 @@ impl<'id> From<Rc<ComponentDescription<'id>>> for ErasedComponentDescription {
|
|||
/// ComponentDescription is a representation of a component suitable for interpretation
|
||||
///
|
||||
/// It contains information about how to create and destroy the Component.
|
||||
/// Its first member is the ComponentVTable for this component, since it is a `#[repr(C)]`
|
||||
/// structure, it is valid to cast a pointer to the ComponentVTable back to a
|
||||
/// Its first member is the ItemTreeVTable for this component, since it is a `#[repr(C)]`
|
||||
/// structure, it is valid to cast a pointer to the ItemTreeVTable back to a
|
||||
/// ComponentDescription to access the extra field that are needed at runtime
|
||||
#[repr(C)]
|
||||
pub struct ComponentDescription<'id> {
|
||||
pub(crate) ct: ComponentVTable,
|
||||
pub(crate) ct: ItemTreeVTable,
|
||||
/// INVARIANT: both dynamic_type and item_tree have the same lifetime id. Here it is erased to 'static
|
||||
dynamic_type: Rc<dynamic_type::TypeInfo<'id>>,
|
||||
item_tree: Vec<ItemTreeNode>,
|
||||
|
|
@ -353,9 +350,9 @@ pub struct ComponentDescription<'id> {
|
|||
pub repeater_names: HashMap<String, usize>,
|
||||
/// Offset to a Option<ComponentPinRef>
|
||||
pub(crate) parent_component_offset:
|
||||
Option<FieldOffset<Instance<'id>, OnceCell<ComponentRefPin<'id>>>>,
|
||||
Option<FieldOffset<Instance<'id>, OnceCell<ItemTreeRefPin<'id>>>>,
|
||||
pub(crate) root_offset:
|
||||
FieldOffset<Instance<'id>, OnceCell<vtable::VWeak<ComponentVTable, ErasedComponentBox>>>,
|
||||
FieldOffset<Instance<'id>, OnceCell<vtable::VWeak<ItemTreeVTable, ErasedComponentBox>>>,
|
||||
/// Offset to the window reference
|
||||
pub(crate) window_adapter_offset: FieldOffset<Instance<'id>, OnceCell<WindowAdapterRc>>,
|
||||
/// Offset of a ComponentExtraData
|
||||
|
|
@ -459,7 +456,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
/// Panics if the component is not an instance corresponding to this ComponentDescription,
|
||||
pub fn set_property(
|
||||
&self,
|
||||
component: ComponentRefPin,
|
||||
component: ItemTreeRefPin,
|
||||
name: &str,
|
||||
value: Value,
|
||||
) -> Result<(), crate::api::SetPropertyError> {
|
||||
|
|
@ -489,7 +486,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
#[allow(unused)]
|
||||
pub fn set_binding(
|
||||
&self,
|
||||
component: ComponentRefPin,
|
||||
component: ItemTreeRefPin,
|
||||
name: &str,
|
||||
binding: Box<dyn Fn() -> Value>,
|
||||
) -> Result<(), ()> {
|
||||
|
|
@ -513,7 +510,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
///
|
||||
/// Returns an error if the component is not an instance corresponding to this ComponentDescription,
|
||||
/// or if a callback with this name does not exist in this component
|
||||
pub fn get_property(&self, component: ComponentRefPin, name: &str) -> Result<Value, ()> {
|
||||
pub fn get_property(&self, component: ItemTreeRefPin, name: &str) -> Result<Value, ()> {
|
||||
if !core::ptr::eq((&self.ct) as *const _, component.get_vtable() as *const _) {
|
||||
return Err(());
|
||||
}
|
||||
|
|
@ -540,7 +537,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
/// or if the property with this name does not exist in this component
|
||||
pub fn set_callback_handler(
|
||||
&self,
|
||||
component: Pin<ComponentRef>,
|
||||
component: Pin<ItemTreeRef>,
|
||||
name: &str,
|
||||
handler: Box<dyn Fn(&[Value]) -> Value>,
|
||||
) -> Result<(), ()> {
|
||||
|
|
@ -599,7 +596,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
/// or if the callback with this name does not exist in this component
|
||||
pub fn invoke(
|
||||
&self,
|
||||
component: ComponentRefPin,
|
||||
component: ItemTreeRefPin,
|
||||
name: &str,
|
||||
args: &[Value],
|
||||
) -> Result<Value, ()> {
|
||||
|
|
@ -630,7 +627,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
// Return the global with the given name
|
||||
pub fn get_global(
|
||||
&self,
|
||||
component: ComponentRefPin,
|
||||
component: ItemTreeRefPin,
|
||||
global_name: &str,
|
||||
) -> Result<Pin<Rc<dyn crate::global_component::GlobalComponent>>, ()> {
|
||||
if !core::ptr::eq((&self.ct) as *const _, component.get_vtable() as *const _) {
|
||||
|
|
@ -645,7 +642,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
}
|
||||
|
||||
extern "C" fn visit_children_item(
|
||||
component: ComponentRefPin,
|
||||
component: ItemTreeRefPin,
|
||||
index: isize,
|
||||
order: TraversalOrder,
|
||||
v: ItemVisitorRefMut,
|
||||
|
|
@ -1074,14 +1071,14 @@ pub(crate) fn generate_component<'id>(
|
|||
}
|
||||
|
||||
let parent_component_offset = if component.parent_element.upgrade().is_some() {
|
||||
Some(builder.type_builder.add_field_type::<OnceCell<ComponentRefPin>>())
|
||||
Some(builder.type_builder.add_field_type::<OnceCell<ItemTreeRefPin>>())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let root_offset = builder
|
||||
.type_builder
|
||||
.add_field_type::<OnceCell<vtable::VWeak<ComponentVTable, ErasedComponentBox>>>();
|
||||
.add_field_type::<OnceCell<vtable::VWeak<ItemTreeVTable, ErasedComponentBox>>>();
|
||||
|
||||
let window_adapter_offset = builder.type_builder.add_field_type::<OnceCell<WindowAdapterRc>>();
|
||||
|
||||
|
|
@ -1118,13 +1115,13 @@ pub(crate) fn generate_component<'id>(
|
|||
})
|
||||
.collect();
|
||||
|
||||
let t = ComponentVTable {
|
||||
let t = ItemTreeVTable {
|
||||
visit_children_item,
|
||||
layout_info,
|
||||
get_item_ref,
|
||||
get_item_tree,
|
||||
get_subtree_range,
|
||||
get_subtree_component,
|
||||
get_subtree,
|
||||
parent_node,
|
||||
embed_component,
|
||||
subtree_index,
|
||||
|
|
@ -1217,7 +1214,7 @@ pub fn animation_for_property(
|
|||
|
||||
fn make_callback_eval_closure(
|
||||
expr: Expression,
|
||||
self_weak: &vtable::VWeak<ComponentVTable, ErasedComponentBox>,
|
||||
self_weak: &vtable::VWeak<ItemTreeVTable, ErasedComponentBox>,
|
||||
) -> impl Fn(&[Value]) -> Value {
|
||||
let self_weak = self_weak.clone();
|
||||
move |args| {
|
||||
|
|
@ -1233,7 +1230,7 @@ fn make_callback_eval_closure(
|
|||
|
||||
fn make_binding_eval_closure(
|
||||
expr: Expression,
|
||||
self_weak: &vtable::VWeak<ComponentVTable, ErasedComponentBox>,
|
||||
self_weak: &vtable::VWeak<ItemTreeVTable, ErasedComponentBox>,
|
||||
) -> impl Fn() -> Value {
|
||||
let self_weak = self_weak.clone();
|
||||
move || {
|
||||
|
|
@ -1250,8 +1247,8 @@ fn make_binding_eval_closure(
|
|||
|
||||
pub fn instantiate(
|
||||
component_type: Rc<ComponentDescription>,
|
||||
parent_ctx: Option<ComponentRefPin>,
|
||||
root: Option<vtable::VWeak<ComponentVTable, ErasedComponentBox>>,
|
||||
parent_ctx: Option<ItemTreeRefPin>,
|
||||
root: Option<vtable::VWeak<ItemTreeVTable, ErasedComponentBox>>,
|
||||
window_options: Option<&WindowOptions>,
|
||||
mut globals: crate::global_component::GlobalStorage,
|
||||
) -> DynamicComponentVRc {
|
||||
|
|
@ -1282,7 +1279,7 @@ pub fn instantiate(
|
|||
};
|
||||
|
||||
let component_rc = vtable::VRc::into_dyn(self_rc.clone());
|
||||
i_slint_core::component::register_component(&component_rc, maybe_window_adapter);
|
||||
i_slint_core::item_tree::register_item_tree(&component_rc, maybe_window_adapter);
|
||||
}
|
||||
|
||||
if let Some(parent) = parent_ctx {
|
||||
|
|
@ -1534,7 +1531,7 @@ impl ErasedComponentBox {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn borrow(&self) -> ComponentRefPin {
|
||||
pub fn borrow(&self) -> ItemTreeRefPin {
|
||||
// Safety: it is safe to access self.0 here because the 'id lifetime does not leak
|
||||
self.0.borrow()
|
||||
}
|
||||
|
|
@ -1577,7 +1574,7 @@ pub fn get_repeater_by_name<'a, 'id>(
|
|||
(rep_in_comp.offset.apply_pin(instance_ref.instance), rep_in_comp.component_to_repeat.clone())
|
||||
}
|
||||
|
||||
extern "C" fn layout_info(component: ComponentRefPin, orientation: Orientation) -> LayoutInfo {
|
||||
extern "C" fn layout_info(component: ItemTreeRefPin, orientation: Orientation) -> LayoutInfo {
|
||||
generativity::make_guard!(guard);
|
||||
// This is fine since we can only be called with a component that with our vtable which is a ComponentDescription
|
||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||
|
|
@ -1607,7 +1604,7 @@ extern "C" fn layout_info(component: ComponentRefPin, orientation: Orientation)
|
|||
result
|
||||
}
|
||||
|
||||
unsafe extern "C" fn get_item_ref(component: ComponentRefPin, index: u32) -> Pin<ItemRef> {
|
||||
unsafe extern "C" fn get_item_ref(component: ItemTreeRefPin, index: u32) -> Pin<ItemRef> {
|
||||
let tree = get_item_tree(component);
|
||||
match &tree[index as usize] {
|
||||
ItemTreeNode::Item { item_array_index, .. } => {
|
||||
|
|
@ -1622,7 +1619,7 @@ unsafe extern "C" fn get_item_ref(component: ComponentRefPin, index: u32) -> Pin
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" fn get_subtree_range(component: ComponentRefPin, index: u32) -> IndexRange {
|
||||
extern "C" fn get_subtree_range(component: ItemTreeRefPin, index: u32) -> IndexRange {
|
||||
generativity::make_guard!(guard);
|
||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||
if let Some(container_index) = ComponentContainerIndex::try_from_repeater_index(index) {
|
||||
|
|
@ -1643,11 +1640,11 @@ extern "C" fn get_subtree_range(component: ComponentRefPin, index: u32) -> Index
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" fn get_subtree_component(
|
||||
component: ComponentRefPin,
|
||||
extern "C" fn get_subtree(
|
||||
component: ItemTreeRefPin,
|
||||
index: u32,
|
||||
subtree_index: usize,
|
||||
result: &mut ComponentWeak,
|
||||
result: &mut ItemTreeWeak,
|
||||
) {
|
||||
generativity::make_guard!(guard);
|
||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||
|
|
@ -1671,14 +1668,14 @@ extern "C" fn get_subtree_component(
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" fn get_item_tree(component: ComponentRefPin) -> Slice<ItemTreeNode> {
|
||||
extern "C" fn get_item_tree(component: ItemTreeRefPin) -> Slice<ItemTreeNode> {
|
||||
generativity::make_guard!(guard);
|
||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||
let tree = instance_ref.component_type.item_tree.as_slice();
|
||||
unsafe { core::mem::transmute::<&[ItemTreeNode], &[ItemTreeNode]>(tree) }.into()
|
||||
}
|
||||
|
||||
extern "C" fn subtree_index(component: ComponentRefPin) -> usize {
|
||||
extern "C" fn subtree_index(component: ItemTreeRefPin) -> usize {
|
||||
generativity::make_guard!(guard);
|
||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||
if let Ok(value) = instance_ref.component_type.get_property(component, "index") {
|
||||
|
|
@ -1688,7 +1685,7 @@ extern "C" fn subtree_index(component: ComponentRefPin) -> usize {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn parent_node(component: ComponentRefPin, result: &mut ItemWeak) {
|
||||
unsafe extern "C" fn parent_node(component: ItemTreeRefPin, result: &mut ItemWeak) {
|
||||
generativity::make_guard!(guard);
|
||||
let instance_ref = InstanceRef::from_pin_ref(component, guard);
|
||||
|
||||
|
|
@ -1727,8 +1724,8 @@ unsafe extern "C" fn parent_node(component: ComponentRefPin, result: &mut ItemWe
|
|||
}
|
||||
|
||||
unsafe extern "C" fn embed_component(
|
||||
component: ComponentRefPin,
|
||||
parent_component: &ComponentWeak,
|
||||
component: ItemTreeRefPin,
|
||||
parent_component: &ItemTreeWeak,
|
||||
parent_item_tree_index: u32,
|
||||
) -> bool {
|
||||
generativity::make_guard!(guard);
|
||||
|
|
@ -1756,7 +1753,7 @@ unsafe extern "C" fn embed_component(
|
|||
extra_data.embedding_position.set((parent_component.clone(), parent_item_tree_index)).is_ok()
|
||||
}
|
||||
|
||||
extern "C" fn item_geometry(component: ComponentRefPin, item_index: u32) -> LogicalRect {
|
||||
extern "C" fn item_geometry(component: ItemTreeRefPin, item_index: u32) -> LogicalRect {
|
||||
generativity::make_guard!(guard);
|
||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||
|
||||
|
|
@ -1776,7 +1773,7 @@ extern "C" fn item_geometry(component: ComponentRefPin, item_index: u32) -> Logi
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" fn accessible_role(component: ComponentRefPin, item_index: u32) -> AccessibleRole {
|
||||
extern "C" fn accessible_role(component: ItemTreeRefPin, item_index: u32) -> AccessibleRole {
|
||||
generativity::make_guard!(guard);
|
||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||
let nr = instance_ref.component_type.original_elements[item_index as usize]
|
||||
|
|
@ -1795,7 +1792,7 @@ extern "C" fn accessible_role(component: ComponentRefPin, item_index: u32) -> Ac
|
|||
}
|
||||
|
||||
extern "C" fn accessible_string_property(
|
||||
component: ComponentRefPin,
|
||||
component: ItemTreeRefPin,
|
||||
item_index: u32,
|
||||
what: AccessibleStringProperty,
|
||||
result: &mut SharedString,
|
||||
|
|
@ -1821,7 +1818,7 @@ extern "C" fn accessible_string_property(
|
|||
}
|
||||
|
||||
extern "C" fn window_adapter(
|
||||
component: ComponentRefPin,
|
||||
component: ItemTreeRefPin,
|
||||
do_create: bool,
|
||||
result: &mut Option<WindowAdapterRc>,
|
||||
) {
|
||||
|
|
@ -1834,14 +1831,14 @@ extern "C" fn window_adapter(
|
|||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn drop_in_place(component: vtable::VRefMut<ComponentVTable>) -> vtable::Layout {
|
||||
unsafe extern "C" fn drop_in_place(component: vtable::VRefMut<ItemTreeVTable>) -> vtable::Layout {
|
||||
let instance_ptr = component.as_ptr() as *mut Instance<'static>;
|
||||
let layout = (*instance_ptr).type_info().layout();
|
||||
dynamic_type::TypeInfo::drop_in_place(instance_ptr);
|
||||
layout.into()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn dealloc(_vtable: &ComponentVTable, ptr: *mut u8, layout: vtable::Layout) {
|
||||
unsafe extern "C" fn dealloc(_vtable: &ItemTreeVTable, ptr: *mut u8, layout: vtable::Layout) {
|
||||
std::alloc::dealloc(ptr, layout.try_into().unwrap());
|
||||
}
|
||||
|
||||
|
|
@ -1853,13 +1850,13 @@ pub struct InstanceRef<'a, 'id> {
|
|||
|
||||
impl<'a, 'id> InstanceRef<'a, 'id> {
|
||||
pub unsafe fn from_pin_ref(
|
||||
component: ComponentRefPin<'a>,
|
||||
component: ItemTreeRefPin<'a>,
|
||||
_guard: generativity::Guard<'id>,
|
||||
) -> Self {
|
||||
Self {
|
||||
instance: Pin::new_unchecked(&*(component.as_ref().as_ptr() as *const Instance<'id>)),
|
||||
component_type: &*(Pin::into_inner_unchecked(component).get_vtable()
|
||||
as *const ComponentVTable
|
||||
as *const ItemTreeVTable
|
||||
as *const ComponentDescription<'id>),
|
||||
}
|
||||
}
|
||||
|
|
@ -1872,8 +1869,8 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
|
|||
&self.instance
|
||||
}
|
||||
|
||||
/// Borrow this component as a `Pin<ComponentRef>`
|
||||
pub fn borrow(self) -> ComponentRefPin<'a> {
|
||||
/// Borrow this component as a `Pin<ItemTreeRef>`
|
||||
pub fn borrow(self) -> ItemTreeRefPin<'a> {
|
||||
unsafe {
|
||||
Pin::new_unchecked(vtable::VRef::from_raw(
|
||||
NonNull::from(&self.component_type.ct).cast(),
|
||||
|
|
@ -1882,12 +1879,12 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn self_weak(&self) -> &OnceCell<vtable::VWeak<ComponentVTable, ErasedComponentBox>> {
|
||||
pub fn self_weak(&self) -> &OnceCell<vtable::VWeak<ItemTreeVTable, ErasedComponentBox>> {
|
||||
let extra_data = self.component_type.extra_data_offset.apply(self.as_ref());
|
||||
&extra_data.self_weak
|
||||
}
|
||||
|
||||
pub fn root_weak(&self) -> &vtable::VWeak<ComponentVTable, ErasedComponentBox> {
|
||||
pub fn root_weak(&self) -> &vtable::VWeak<ItemTreeVTable, ErasedComponentBox> {
|
||||
self.component_type.root_offset.apply(self.as_ref()).get().unwrap()
|
||||
}
|
||||
|
||||
|
|
@ -1908,7 +1905,7 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
|
|||
|
||||
pub fn get_or_init_window_adapter_ref<'b, 'id2>(
|
||||
component_type: &'b ComponentDescription<'id2>,
|
||||
root_weak: ComponentWeak,
|
||||
root_weak: ItemTreeWeak,
|
||||
do_create: bool,
|
||||
instance: &'b Instance<'id2>,
|
||||
) -> Result<&'b WindowAdapterRc, PlatformError> {
|
||||
|
|
@ -1922,7 +1919,7 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
|
|||
if let Some(parent) = parent_node.upgrade() {
|
||||
// We are embedded: Get window adapter from our parent
|
||||
let mut result = None;
|
||||
vtable::VRc::borrow_pin(parent.component())
|
||||
vtable::VRc::borrow_pin(parent.item_tree())
|
||||
.as_ref()
|
||||
.window_adapter(do_create, &mut result);
|
||||
result.ok_or(PlatformError::NoPlatform)
|
||||
|
|
@ -1979,7 +1976,7 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
|
|||
&*(parent.as_ref().as_ptr() as *const Instance<'id>),
|
||||
),
|
||||
component_type: &*(Pin::into_inner_unchecked(*parent).get_vtable()
|
||||
as *const ComponentVTable
|
||||
as *const ItemTreeVTable
|
||||
as *const ComponentDescription<'id>),
|
||||
}
|
||||
};
|
||||
|
|
@ -2003,7 +2000,7 @@ pub fn show_popup(
|
|||
popup: &object_tree::PopupWindow,
|
||||
pos: i_slint_core::graphics::Point,
|
||||
close_on_click: bool,
|
||||
parent_comp: ComponentRefPin,
|
||||
parent_comp: ItemTreeRefPin,
|
||||
parent_window_adapter: WindowAdapterRc,
|
||||
parent_item: &ItemRc,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use i_slint_compiler::langtype::ElementType;
|
|||
use i_slint_compiler::namedreference::NamedReference;
|
||||
use i_slint_compiler::object_tree::Component;
|
||||
use i_slint_compiler::object_tree::PropertyDeclaration;
|
||||
use i_slint_core::component::ComponentVTable;
|
||||
use i_slint_core::item_tree::ItemTreeVTable;
|
||||
use i_slint_core::rtti;
|
||||
|
||||
pub type GlobalStorage = HashMap<String, Pin<Rc<dyn GlobalComponent>>>;
|
||||
|
|
@ -98,7 +98,7 @@ pub trait GlobalComponent {
|
|||
pub fn instantiate(
|
||||
description: &CompiledGlobal,
|
||||
globals: &mut GlobalStorage,
|
||||
root: vtable::VWeak<ComponentVTable, ErasedComponentBox>,
|
||||
root: vtable::VWeak<ItemTreeVTable, ErasedComponentBox>,
|
||||
) {
|
||||
let instance = match description {
|
||||
CompiledGlobal::Builtin { element, .. } => {
|
||||
|
|
@ -143,7 +143,7 @@ pub fn instantiate(
|
|||
|
||||
/// For the global components, we don't use the dynamic_type optimization,
|
||||
/// and we don't try to optimize the property to their real type
|
||||
pub struct GlobalComponentInstance(vtable::VRc<ComponentVTable, ErasedComponentBox>);
|
||||
pub struct GlobalComponentInstance(vtable::VRc<ItemTreeVTable, ErasedComponentBox>);
|
||||
|
||||
impl GlobalComponent for GlobalComponentInstance {
|
||||
fn set_property(
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ pub fn on_element_selected(
|
|||
|
||||
state.borrow_mut().current_item = Some(i.downgrade());
|
||||
|
||||
let component = i.component();
|
||||
let component = i.item_tree();
|
||||
let component_ref = VRc::borrow(component);
|
||||
let Some(component_box) = component_ref.downcast::<ErasedComponentBox>() else {
|
||||
continue; // Skip components of unexpected type!
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,7 @@ impl<'a> GLItemRenderer<'a> {
|
|||
|
||||
i_slint_core::item_rendering::render_item_children(
|
||||
self,
|
||||
&item_rc.component(),
|
||||
&item_rc.item_tree(),
|
||||
item_rc.index() as isize,
|
||||
);
|
||||
|
||||
|
|
@ -1185,7 +1185,7 @@ impl<'a> GLItemRenderer<'a> {
|
|||
let children_rect = i_slint_core::properties::evaluate_no_tracking(|| {
|
||||
item_rc.geometry().union(
|
||||
&i_slint_core::item_rendering::item_children_bounding_rect(
|
||||
&item_rc.component(),
|
||||
&item_rc.item_tree(),
|
||||
item_rc.index() as isize,
|
||||
¤t_clip,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -500,7 +500,7 @@ impl RendererSealed for FemtoVGRenderer {
|
|||
|
||||
fn free_graphics_resources(
|
||||
&self,
|
||||
component: i_slint_core::component::ComponentRef,
|
||||
component: i_slint_core::item_tree::ItemTreeRef,
|
||||
_items: &mut dyn Iterator<Item = Pin<i_slint_core::items::ItemRef<'_>>>,
|
||||
) -> Result<(), i_slint_core::platform::PlatformError> {
|
||||
self.opengl_context.ensure_current()?;
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ impl<'a> SkiaItemRenderer<'a> {
|
|||
let children_rect = i_slint_core::properties::evaluate_no_tracking(|| {
|
||||
item_rc.geometry().union(
|
||||
&i_slint_core::item_rendering::item_children_bounding_rect(
|
||||
&item_rc.component(),
|
||||
&item_rc.item_tree(),
|
||||
item_rc.index() as isize,
|
||||
¤t_clip,
|
||||
),
|
||||
|
|
@ -261,7 +261,7 @@ impl<'a> SkiaItemRenderer<'a> {
|
|||
|
||||
i_slint_core::item_rendering::render_item_children(
|
||||
&mut sub_renderer,
|
||||
&item_rc.component(),
|
||||
&item_rc.item_tree(),
|
||||
item_rc.index() as isize,
|
||||
);
|
||||
|
||||
|
|
@ -853,7 +853,7 @@ impl<'a> ItemRenderer for SkiaItemRenderer<'a> {
|
|||
|
||||
i_slint_core::item_rendering::render_item_children(
|
||||
self,
|
||||
&item_rc.component(),
|
||||
&item_rc.item_tree(),
|
||||
item_rc.index() as isize,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ impl i_slint_core::renderer::RendererSealed for SkiaRenderer {
|
|||
|
||||
fn free_graphics_resources(
|
||||
&self,
|
||||
component: i_slint_core::component::ComponentRef,
|
||||
component: i_slint_core::item_tree::ItemTreeRef,
|
||||
_items: &mut dyn Iterator<Item = std::pin::Pin<i_slint_core::items::ItemRef<'_>>>,
|
||||
) -> Result<(), i_slint_core::platform::PlatformError> {
|
||||
self.image_cache.component_destroyed(component);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue