ui/src/elements/mod.rs

55 lines
1.1 KiB
Rust
Raw Normal View History

2023-01-16 09:53:52 +00:00
use crate::{guihandler::gui::iconizable::IconBuilderType, prelude::*};
use anyhow::Result;
2024-04-04 15:57:50 +00:00
use std::sync::{Arc, RwLock};
2023-01-16 09:53:52 +00:00
2023-01-19 12:05:48 +00:00
use self::fill_type::FillType;
2023-01-16 09:53:52 +00:00
pub mod button;
pub mod fill_type;
pub mod grid;
pub mod icon;
pub mod label;
pub mod multi_line_label;
pub mod multi_line_textfield;
pub mod progress_bar;
pub mod textfield;
pub mod uielement;
pub mod traits;
2024-04-04 07:11:42 +00:00
mod callback_builder;
2023-01-16 09:53:52 +00:00
pub mod prelude;
2024-04-04 15:57:50 +00:00
mod wrapper;
2023-01-19 12:05:48 +00:00
pub(crate) fn set_background(
visible: bool,
framable: &Arc<Framable>,
current: &RwLock<Option<FillType>>,
new: impl Into<FillTypeInfo>,
) -> Result<()> {
let mut current_background = current.write().unwrap();
let fill_info = new.into();
let update = match &*current_background {
Some(bg) => *bg != fill_info,
None => true,
};
if update {
let fill_type = FillType::new(framable.clone(), fill_info)?;
if framable.is_framed() {
fill_type.update_frame()?;
}
if visible {
fill_type.enable()?;
}
*current_background = Some(fill_type);
}
Ok(())
}