use crate::compat::String;
use crate::compat::{lock, MiniToString};
#[cfg(widgets_unstripped)]
use crate::control_backend::custom::LABEL_PROPERTY_NAMES;
use crate::control_backend::trait_def::ControlBackend;
use crate::control_backend::types::ControlBackendKind;
use crate::core::ObjectId;
use crate::platform::{WidgetTriggerEvent, WidgetTriggerKind};
use crate::widget::WidgetKind;
include!("create_widgets_base.in.rs");
include!("create_widgets_input.in.rs");
#[cfg(not(embedded_surface))]
include!("create_widgets_view.in.rs");
include!("create_widgets_container.in.rs");
#[cfg(not(embedded_surface))]
include!("create_widgets_dialog.in.rs");
#[cfg(not(embedded_surface))]
include!("create_widgets_menu.in.rs");
#[cfg(not(embedded_surface))]
include!("create_widgets_advanced.in.rs");
#[cfg(not(embedded_surface))]
include!("create_widgets_other.in.rs");
#[cfg(not(embedded_surface))]
include!("create_widgets_modern.in.rs");
include!("create_widgets_helpers.in.rs");
impl ControlBackend for super::CustomPaintControlBackend {
impl_base_widgets!();
impl_input_widgets!();
#[cfg(not(embedded_surface))]
impl_view_widgets!();
impl_container_widgets!();
#[cfg(not(embedded_surface))]
impl_dialog_widgets!();
#[cfg(not(embedded_surface))]
impl_menu_widgets!();
#[cfg(not(embedded_surface))]
impl_advanced_widgets!();
#[cfg(not(embedded_surface))]
impl_other_widgets!();
#[cfg(not(embedded_surface))]
impl_modern_widgets!();
fn create_widget(
&self,
kind: &str,
parent: ObjectId,
text: &str,
x: i32,
y: i32,
width: u32,
height: u32,
) -> ObjectId {
#[cfg(full_widgets)]
{
let factory = crate::widget::WidgetFactory::new_with_defaults();
let Some(capability) = factory.capability(kind) else {
log::warn!(
"custom backend: no control is registered under the name {kind:?}; returning 0"
);
return 0;
};
self.mount_named_widget(capability.canonical_name, parent, text, x, y, width, height)
}
#[cfg(not(full_widgets))]
{
let _ = (kind, parent, text, x, y, width, height);
log::warn!(
"custom backend: name-based creation is unavailable in this profile (no \
constructor registry is compiled in); returning 0"
);
0
}
}
#[cfg(widgets_unstripped)]
fn create_qrcode(&self, parent: ObjectId, x: i32, y: i32, width: u32, height: u32) -> ObjectId {
self.create_qr_code(parent, x, y, width, height)
}
fn destroy_widget(&self, widget_id: ObjectId) -> bool {
#[cfg(not(alloc_frugal))]
let released = crate::widget::runtime::unregister(widget_id);
#[cfg(alloc_frugal)]
let released = false;
let mut state = lock(&self.state);
let had_host_state = state.ime_enabled.remove(&widget_id).is_some()
|| state.accessibility_names.remove(&widget_id).is_some()
|| state.window_client_sizes.remove(&widget_id).is_some();
released || had_host_state
}
impl_helpers!();
}