#![allow(unreachable_code)]
use std::future::Future;
use crate::{
elements::ImageElement,
foundation::{colorspace::Color, Id, Key, WidgetProperties},
material::{AlignmentGeometry, NoneAlignmentGeometry},
painting::{ImageProvider, DecoderCallback, ImageErrorListener, ImageConfiguration, ImageCacheStatus, ImageStreamCompleter, ImageStream, BoxFit},
ui::{BlendMode, FilterQuality},
widgets::{Element, Widget},
};
pub struct NoneImage;
impl ImageProvider for NoneImage {
fn create_stream(&self, configuration: ImageConfiguration) -> ImageStream {
Default::default()
}
fn evict(
&self,
cache: Option<crate::painting::ImageCache>,
configuration: ImageConfiguration,
) -> Box<dyn Future<Output = bool>> {
todo!()
}
fn load(&self, key: Key, decode: Box<DecoderCallback>) -> ImageStreamCompleter {
todo!()
}
fn obtain_cache_status(
&self,
configuration: ImageConfiguration,
handle_error: Option<Box<ImageErrorListener>>,
) -> Box<dyn Future<Output = Option<ImageCacheStatus>>> {
todo!()
}
fn obtain_key(&self, configuration: ImageConfiguration) -> Box<dyn Future<Output = Key>> {
todo!()
}
fn resolve(&self, configuration: ImageConfiguration) -> ImageStream {
todo!()
}
fn resolve_stream_for_key(
&self,
configuration: ImageConfiguration,
stream: ImageStream,
key: Key,
handle_error: Option<Box<ImageErrorListener>>,
) {
todo!()
}
}
pub struct Image {
pub key: Key,
pub image: Box<dyn ImageProvider>,
pub semantic_label: String,
pub exclude_from_semantics: bool,
pub width: f32,
pub height: f32,
pub color: Color,
pub color_blend_mode: BlendMode,
pub fit: BoxFit,
pub alignment: Box<dyn AlignmentGeometry>,
pub match_text_direction: bool,
pub gapless_playback: bool,
pub is_anti_alias: bool,
pub filter_quality: FilterQuality,
}
impl Default for Image {
fn default() -> Self {
Self {
key: Default::default(),
image: box NoneImage,
semantic_label: Default::default(),
exclude_from_semantics: Default::default(),
width: Default::default(),
height: Default::default(),
color: Default::default(),
color_blend_mode: Default::default(),
fit: Default::default(),
alignment: box NoneAlignmentGeometry,
match_text_direction: Default::default(),
gapless_playback: Default::default(),
is_anti_alias: Default::default(),
filter_quality: Default::default(),
}
}
}
impl Widget for Image {
fn create_element(&self) -> Box<dyn Element> {
box ImageElement::new(self)
}
}
impl WidgetProperties for Image {
fn key(&self) -> &Key {
&self.key
}
fn x(&self) -> f32 {
0.0
}
fn y(&self) -> f32 {
0.0
}
fn w(&self) -> f32 {
0.0
}
fn h(&self) -> f32 {
0.0
}
fn w_min(&self) -> f32 {
0.0
}
fn h_min(&self) -> f32 {
0.0
}
fn w_max(&self) -> f32 {
0.0
}
fn h_max(&self) -> f32 {
0.0
}
fn parent(&self) -> Option<Id> {
None
}
fn depth(&self) -> f32 {
0.0
}
fn visible(&self) -> bool {
true
}
fn mouse_input(&self) -> bool {
true
}
fn key_input(&self) -> bool {
true
}
fn renderable(&self) -> bool {
true
}
fn internal_visible(&self) -> bool {
true
}
}