mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 13:51:13 +00:00
Initial commit for a new software rendering backend for use in MCUs
This adds the skeleton, including a winit driven simulator window and a dummy ItemRenderer implementation.
This commit is contained in:
parent
8f940a446e
commit
abb423ed33
7 changed files with 586 additions and 0 deletions
102
sixtyfps_runtime/rendering_backends/mcu/lib.rs
Normal file
102
sixtyfps_runtime/rendering_backends/mcu/lib.rs
Normal file
|
@ -0,0 +1,102 @@
|
|||
/* LICENSE BEGIN
|
||||
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-only
|
||||
This file is also available under commercial licensing terms.
|
||||
Please contact info@sixtyfps.io for more information.
|
||||
LICENSE END */
|
||||
/*!
|
||||
|
||||
**NOTE**: This library is an **internal** crate for the [SixtyFPS project](https://sixtyfps.io).
|
||||
This crate should **not be used directly** by applications using SixtyFPS.
|
||||
You should use the `sixtyfps` crate instead.
|
||||
|
||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
||||
|
||||
*/
|
||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||
|
||||
use sixtyfps_corelib::{
|
||||
graphics::{Image, Size},
|
||||
window::Window,
|
||||
ImageInner,
|
||||
};
|
||||
use std::rc::Rc;
|
||||
|
||||
#[cfg(feature = "simulator")]
|
||||
mod simulator;
|
||||
|
||||
#[cfg(feature = "simulator")]
|
||||
use simulator::*;
|
||||
|
||||
mod renderer;
|
||||
|
||||
pub struct Backend;
|
||||
|
||||
impl sixtyfps_corelib::backend::Backend for Backend {
|
||||
fn create_window(&'static self) -> Rc<Window> {
|
||||
sixtyfps_corelib::window::Window::new(|window| SimulatorWindow::new(window))
|
||||
}
|
||||
|
||||
fn run_event_loop(&'static self, behavior: sixtyfps_corelib::backend::EventLoopQuitBehavior) {
|
||||
simulator::event_loop::run(behavior);
|
||||
}
|
||||
|
||||
fn quit_event_loop(&'static self) {
|
||||
crate::event_loop::with_window_target(|event_loop| {
|
||||
event_loop.event_loop_proxy().send_event(simulator::event_loop::CustomEvent::Exit).ok();
|
||||
})
|
||||
}
|
||||
|
||||
fn register_font_from_memory(
|
||||
&'static self,
|
||||
_data: &'static [u8],
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn register_font_from_path(
|
||||
&'static self,
|
||||
_path: &std::path::Path,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_clipboard_text(&'static self, _text: String) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn clipboard_text(&'static self) -> Option<String> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn post_event(&'static self, event: Box<dyn FnOnce() + Send>) {
|
||||
let e = crate::event_loop::CustomEvent::UserEvent(event);
|
||||
crate::event_loop::GLOBAL_PROXY.get_or_init(Default::default).lock().unwrap().send_event(e);
|
||||
}
|
||||
|
||||
fn image_size(&'static self, image: &Image) -> Size {
|
||||
let inner: &ImageInner = image.into();
|
||||
match inner {
|
||||
ImageInner::None => Default::default(),
|
||||
ImageInner::AbsoluteFilePath(_) => todo!(),
|
||||
ImageInner::EmbeddedData { .. } => todo!(),
|
||||
ImageInner::EmbeddedImage(buffer) => {
|
||||
[buffer.width() as f32, buffer.height() as f32].into()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type NativeWidgets = ();
|
||||
pub type NativeGlobals = ();
|
||||
pub mod native_widgets {}
|
||||
pub const HAS_NATIVE_STYLE: bool = false;
|
||||
pub const IS_AVAILABLE: bool = true;
|
||||
|
||||
pub fn init() {
|
||||
sixtyfps_corelib::backend::instance_or_init(|| Box::new(Backend));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue