Add info icon to icon
This commit is contained in:
parent
34b569b59b
commit
5eec536a27
1 changed files with 30 additions and 1 deletions
|
@ -1,4 +1,7 @@
|
|||
use crate::{builder::validator::iconinfo::IconInfo, prelude::*};
|
||||
use crate::{
|
||||
builder::validator::iconinfo::IconInfo, guihandler::gui::iconizable::IconizablePositioning,
|
||||
prelude::*,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use utilities::prelude::*;
|
||||
use vulkan_rs::prelude::*;
|
||||
|
@ -84,11 +87,24 @@ impl IconBuilder {
|
|||
textable_wrapper.set_text(&text, false)?;
|
||||
}
|
||||
|
||||
let info_icon = IconizableWrapper::new(
|
||||
framable.clone(),
|
||||
None,
|
||||
Some(IconizablePositioning {
|
||||
left: 1.2,
|
||||
right: 0.0,
|
||||
top: 1.2,
|
||||
bottom: 0.0,
|
||||
}),
|
||||
0,
|
||||
)?;
|
||||
|
||||
Ok(Arc::new(Icon {
|
||||
framable,
|
||||
background,
|
||||
iconizable_wrapper,
|
||||
textable_wrapper,
|
||||
info_icon,
|
||||
|
||||
visible: AtomicBool::new(false),
|
||||
}))
|
||||
|
@ -100,6 +116,7 @@ pub struct Icon {
|
|||
background: RwLock<Option<FillType>>,
|
||||
iconizable_wrapper: IconizableWrapper,
|
||||
textable_wrapper: TextableWrapper,
|
||||
info_icon: IconizableWrapper,
|
||||
|
||||
visible: AtomicBool,
|
||||
}
|
||||
|
@ -149,6 +166,14 @@ impl Icon {
|
|||
self.textable_wrapper.set_text_color(color)
|
||||
}
|
||||
|
||||
pub fn set_info_icon(&self, button: &Arc<Image>) -> Result<()> {
|
||||
self.info_icon.set_icon(button, self.visible())
|
||||
}
|
||||
|
||||
pub fn clear_info_icon(&self) -> Result<()> {
|
||||
self.info_icon.clear_icon(self.visible())
|
||||
}
|
||||
|
||||
pub fn try_from(icon_info: &IconInfo, gui_handler: &Arc<GuiHandler>) -> Result<Arc<Self>> {
|
||||
let mut icon_builder = Icon::builder().set_text_color(icon_info.text_color);
|
||||
|
||||
|
@ -196,6 +221,7 @@ impl Icon {
|
|||
|
||||
self.iconizable_wrapper.disable()?;
|
||||
self.textable_wrapper.disable()?;
|
||||
self.info_icon.disable()?;
|
||||
|
||||
if let Some(background) = self.background.read().unwrap().as_ref() {
|
||||
background.disable()?;
|
||||
|
@ -233,6 +259,7 @@ impl Visibility for Icon {
|
|||
|
||||
self.iconizable_wrapper.enable()?;
|
||||
self.textable_wrapper.enable()?;
|
||||
self.info_icon.enable()?;
|
||||
|
||||
if let Some(background) = self.background.read().unwrap().as_ref() {
|
||||
background.enable()?;
|
||||
|
@ -260,6 +287,7 @@ impl Gridable for Icon {
|
|||
|
||||
self.iconizable_wrapper.update_frame()?;
|
||||
self.textable_wrapper.update()?;
|
||||
self.info_icon.update_frame()?;
|
||||
|
||||
if let Some(background) = self.background.read().unwrap().as_ref() {
|
||||
background.update_frame()?;
|
||||
|
@ -280,6 +308,7 @@ impl Gridable for Icon {
|
|||
self.framable.set_ui_layer(layer);
|
||||
self.iconizable_wrapper.set_ui_layer(layer)?;
|
||||
self.textable_wrapper.set_ui_layer(layer)?;
|
||||
self.info_icon.set_ui_layer(layer)?;
|
||||
|
||||
if let Some(background) = self.background.read().unwrap().as_ref() {
|
||||
background.set_ui_layer(layer);
|
||||
|
|
Loading…
Reference in a new issue