mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +00:00
MCU backend: build with no_std
This commit is contained in:
parent
6ca63aac9c
commit
691d43d416
3 changed files with 19 additions and 7 deletions
|
@ -25,6 +25,13 @@ In order for the crate to be available at runtime, they need to be added as feat
|
|||
|
||||
*/
|
||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||
#![cfg_attr(
|
||||
not(any(
|
||||
feature = "sixtyfps-rendering-backend-qt",
|
||||
feature = "sixtyfps-rendering-backend-gl"
|
||||
)),
|
||||
no_std
|
||||
)]
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "sixtyfps-rendering-backend-qt")] {
|
||||
|
|
|
@ -18,13 +18,18 @@ only be used with `version = "=x.y.z"` in Cargo.toml.
|
|||
|
||||
*/
|
||||
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
|
||||
#![cfg_attr(not(feature = "simulator"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use alloc::rc::Rc;
|
||||
use alloc::string::String;
|
||||
use sixtyfps_corelib::{
|
||||
graphics::{Image, Size},
|
||||
window::Window,
|
||||
ImageInner,
|
||||
};
|
||||
use std::rc::Rc;
|
||||
|
||||
#[cfg(feature = "simulator")]
|
||||
mod simulator;
|
||||
|
@ -33,7 +38,6 @@ mod simulator;
|
|||
use simulator::*;
|
||||
|
||||
mod renderer;
|
||||
|
||||
pub struct Backend;
|
||||
|
||||
impl sixtyfps_corelib::backend::Backend for Backend {
|
||||
|
@ -101,5 +105,5 @@ 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));
|
||||
sixtyfps_corelib::backend::instance_or_init(|| alloc::boxed::Box::new(Backend));
|
||||
}
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
Please contact info@sixtyfps.io for more information.
|
||||
LICENSE END */
|
||||
|
||||
use alloc::collections::VecDeque;
|
||||
use alloc::rc::Rc;
|
||||
use alloc::{vec, vec::Vec};
|
||||
use core::pin::Pin;
|
||||
use std::collections::VecDeque;
|
||||
use std::rc::Rc;
|
||||
|
||||
use embedded_graphics::pixelcolor::Rgb888;
|
||||
use embedded_graphics::prelude::*;
|
||||
|
@ -25,7 +26,7 @@ pub fn render_window_frame<T: DrawTarget<Color = Rgb888>>(
|
|||
background: Rgb888,
|
||||
display: &mut T,
|
||||
) where
|
||||
T::Error: std::fmt::Debug,
|
||||
T::Error: core::fmt::Debug,
|
||||
{
|
||||
let size = display.bounding_box().size;
|
||||
let mut scene = prepare_scene(runtime_window, SizeF::new(size.width as _, size.height as _));
|
||||
|
@ -244,7 +245,7 @@ struct LineCommand {
|
|||
spans: Vec<SceneItem>,
|
||||
}
|
||||
|
||||
fn compare_scene_item(a: &SceneItem, b: &SceneItem) -> std::cmp::Ordering {
|
||||
fn compare_scene_item(a: &SceneItem, b: &SceneItem) -> core::cmp::Ordering {
|
||||
// First, order by line (top to bottom)
|
||||
match a.y.partial_cmp(&b.y) {
|
||||
None | Some(core::cmp::Ordering::Equal) => {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue