mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an alias because we need to also "wrap" it to C++ via cbindgen, but that's about it.
This commit is contained in:
parent
57389c1731
commit
eaddbe664e
22 changed files with 274 additions and 300 deletions
|
@ -79,36 +79,33 @@ using ItemTreeNode = cbindgen_private::ItemTreeNode<uint8_t>;
|
|||
using cbindgen_private::KeyboardModifiers;
|
||||
using cbindgen_private::KeyEvent;
|
||||
|
||||
class ComponentWindow
|
||||
class WindowRc
|
||||
{
|
||||
public:
|
||||
ComponentWindow() { cbindgen_private::sixtyfps_component_window_init(&inner); }
|
||||
~ComponentWindow() { cbindgen_private::sixtyfps_component_window_drop(&inner); }
|
||||
ComponentWindow(const ComponentWindow &other)
|
||||
WindowRc() { cbindgen_private::sixtyfps_windowrc_init(&inner); }
|
||||
~WindowRc() { cbindgen_private::sixtyfps_windowrc_drop(&inner); }
|
||||
WindowRc(const WindowRc &other)
|
||||
{
|
||||
cbindgen_private::sixtyfps_component_window_clone(&other.inner, &inner);
|
||||
cbindgen_private::sixtyfps_windowrc_clone(&other.inner, &inner);
|
||||
}
|
||||
ComponentWindow(ComponentWindow &&) = delete;
|
||||
ComponentWindow &operator=(const ComponentWindow &) = delete;
|
||||
WindowRc(WindowRc &&) = delete;
|
||||
WindowRc &operator=(const WindowRc &) = delete;
|
||||
|
||||
void show() const { sixtyfps_component_window_show(&inner); }
|
||||
void hide() const { sixtyfps_component_window_hide(&inner); }
|
||||
void show() const { sixtyfps_windowrc_show(&inner); }
|
||||
void hide() const { sixtyfps_windowrc_hide(&inner); }
|
||||
|
||||
float scale_factor() const { return sixtyfps_component_window_get_scale_factor(&inner); }
|
||||
void set_scale_factor(float value) const
|
||||
{
|
||||
sixtyfps_component_window_set_scale_factor(&inner, value);
|
||||
}
|
||||
float scale_factor() const { return sixtyfps_windowrc_get_scale_factor(&inner); }
|
||||
void set_scale_factor(float value) const { sixtyfps_windowrc_set_scale_factor(&inner, value); }
|
||||
|
||||
void free_graphics_resources(const sixtyfps::Slice<ItemRef> &items) const
|
||||
{
|
||||
cbindgen_private::sixtyfps_component_window_free_graphics_resources(&inner, &items);
|
||||
cbindgen_private::sixtyfps_windowrc_free_graphics_resources(&inner, &items);
|
||||
}
|
||||
|
||||
void set_focus_item(const ComponentRc &component_rc, uintptr_t item_index)
|
||||
{
|
||||
cbindgen_private::ItemRc item_rc { component_rc, item_index };
|
||||
cbindgen_private::sixtyfps_component_window_set_focus_item(&inner, &item_rc);
|
||||
cbindgen_private::sixtyfps_windowrc_set_focus_item(&inner, &item_rc);
|
||||
}
|
||||
|
||||
template<typename Component, typename ItemTree>
|
||||
|
@ -122,18 +119,18 @@ public:
|
|||
void set_component(const Component &c) const
|
||||
{
|
||||
auto self_rc = c.self_weak.lock().value().into_dyn();
|
||||
sixtyfps_component_window_set_component(&inner, &self_rc);
|
||||
sixtyfps_windowrc_set_component(&inner, &self_rc);
|
||||
}
|
||||
|
||||
template<typename Component, typename Parent>
|
||||
void show_popup(const Parent *parent_component, cbindgen_private::Point p) const
|
||||
{
|
||||
auto popup = Component::create(parent_component).into_dyn();
|
||||
cbindgen_private::sixtyfps_component_window_show_popup(&inner, &popup, p);
|
||||
cbindgen_private::sixtyfps_windowrc_show_popup(&inner, &popup, p);
|
||||
}
|
||||
|
||||
private:
|
||||
cbindgen_private::ComponentWindowOpaque inner;
|
||||
cbindgen_private::WindowRcOpaque inner;
|
||||
};
|
||||
|
||||
constexpr inline ItemTreeNode make_item_node(std::uintptr_t offset,
|
||||
|
|
|
@ -244,8 +244,8 @@ private:
|
|||
/// Note that models are only represented in one direction: You can create a sixtyfps::Model<Value>
|
||||
/// in C++, store it in a std::shared_ptr and construct Value from it. Then you can set it on a
|
||||
/// property in your .60 code that was declared to be either an array (`property <[sometype]> foo;`)
|
||||
/// or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are dynamic
|
||||
/// and accept models implemented in C++.
|
||||
/// or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are
|
||||
/// dynamic and accept models implemented in C++.
|
||||
///
|
||||
/// ```
|
||||
/// Value v(42.0); // Creates a value that holds a double with the value 42.
|
||||
|
@ -582,11 +582,11 @@ public:
|
|||
/// it may return nullptr if the Qt backend is not used at runtime.
|
||||
QWidget *qwidget() const
|
||||
{
|
||||
cbindgen_private::ComponentWindowOpaque win;
|
||||
cbindgen_private::WindowRcOpaque win;
|
||||
cbindgen_private::sixtyfps_interpreter_component_instance_window(inner(), &win);
|
||||
auto wid = reinterpret_cast<QWidget *>(cbindgen_private::sixtyfps_qt_get_widget(
|
||||
reinterpret_cast<cbindgen_private::ComponentWindow *>(&win)));
|
||||
cbindgen_private::sixtyfps_component_window_drop(&win);
|
||||
reinterpret_cast<cbindgen_private::WindowRc *>(&win)));
|
||||
cbindgen_private::sixtyfps_windowrc_drop(&win);
|
||||
return wid;
|
||||
}
|
||||
#endif
|
||||
|
@ -925,11 +925,11 @@ inline void send_keyboard_string_sequence(const sixtyfps::interpreter::Component
|
|||
const sixtyfps::SharedString &str,
|
||||
KeyboardModifiers modifiers = {})
|
||||
{
|
||||
cbindgen_private::ComponentWindowOpaque win;
|
||||
cbindgen_private::WindowRcOpaque win;
|
||||
cbindgen_private::sixtyfps_interpreter_component_instance_window(
|
||||
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win);
|
||||
cbindgen_private::send_keyboard_string_sequence(
|
||||
&str, modifiers, reinterpret_cast<cbindgen_private::ComponentWindow *>(&win));
|
||||
cbindgen_private::sixtyfps_component_window_drop(&win);
|
||||
&str, modifiers, reinterpret_cast<cbindgen_private::WindowRc *>(&win));
|
||||
cbindgen_private::sixtyfps_windowrc_drop(&win);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ LICENSE END */
|
|||
/*! This crate just expose the function used by the C++ integration */
|
||||
|
||||
use core::ffi::c_void;
|
||||
use sixtyfps_corelib::window::ffi::ComponentWindowOpaque;
|
||||
use sixtyfps_corelib::window::ComponentWindow;
|
||||
use sixtyfps_corelib::window::ffi::WindowRcOpaque;
|
||||
use sixtyfps_corelib::window::WindowRc;
|
||||
use sixtyfps_rendering_backend_default::backend;
|
||||
|
||||
#[doc(hidden)]
|
||||
|
@ -24,12 +24,9 @@ pub fn use_modules() -> usize {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sixtyfps_component_window_init(out: *mut ComponentWindowOpaque) {
|
||||
assert_eq!(
|
||||
core::mem::size_of::<ComponentWindow>(),
|
||||
core::mem::size_of::<ComponentWindowOpaque>()
|
||||
);
|
||||
core::ptr::write(out as *mut ComponentWindow, crate::backend().create_window().into());
|
||||
pub unsafe extern "C" fn sixtyfps_windowrc_init(out: *mut WindowRcOpaque) {
|
||||
assert_eq!(core::mem::size_of::<WindowRc>(), core::mem::size_of::<WindowRcOpaque>());
|
||||
core::ptr::write(out as *mut WindowRc, crate::backend().create_window().into());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
|
@ -78,7 +78,7 @@ TEST_CASE("Image")
|
|||
using namespace sixtyfps;
|
||||
|
||||
// ensure a backend exists, using private api
|
||||
private_api::ComponentWindow wnd;
|
||||
private_api::WindowRc wnd;
|
||||
|
||||
Image img;
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue