2025-02-27 09:43:07 +00:00
|
|
|
use crate::{gui_handler::gui::iconizable::IconBuilderType, prelude::*};
|
2023-01-16 09:53:52 +00:00
|
|
|
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;
|
2025-02-27 09:43:07 +00:00
|
|
|
pub mod ui_element;
|
2023-01-16 09:53:52 +00:00
|
|
|
|
|
|
|
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(
|
2025-03-04 10:37:45 +00:00
|
|
|
gui_handler: &mut GuiHandler<'_>,
|
2023-01-19 12:05:48 +00:00
|
|
|
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 {
|
2025-03-04 10:37:45 +00:00
|
|
|
let fill_type = FillType::new(gui_handler, framable.clone(), fill_info)?;
|
2023-01-19 12:05:48 +00:00
|
|
|
|
|
|
|
if framable.is_framed() {
|
2025-03-04 10:37:45 +00:00
|
|
|
fill_type.update_frame(gui_handler)?;
|
2023-01-19 12:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if visible {
|
2025-03-04 10:37:45 +00:00
|
|
|
fill_type.enable(gui_handler)?;
|
2023-01-19 12:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*current_background = Some(fill_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|