diff --git a/src/elements/button.rs b/src/elements/button.rs index 72f9236..08e3d60 100644 --- a/src/elements/button.rs +++ b/src/elements/button.rs @@ -185,7 +185,7 @@ impl ButtonBuilder { self.margin, )?; - let button_info = IconizableWrapper::new( + let info_icon = IconizableWrapper::new( framable.clone(), None, Some(IconizablePositioning { @@ -204,7 +204,7 @@ impl ButtonBuilder { selectable, textable, iconizable, - button_info, + info_icon, #[cfg(feature = "audio")] _click_sound: click_sound, @@ -252,7 +252,7 @@ pub struct Button { framable: Arc, iconizable: IconizableWrapper, textable: TextableWrapper, - button_info: IconizableWrapper, + info_icon: IconizableWrapper, #[cfg(feature = "audio")] _click_sound: Option>, @@ -340,12 +340,12 @@ impl Button { self.iconizable.icon() } - pub fn set_button_info(&self, button: &Arc) -> Result<()> { - self.button_info.set_icon(button, self.visible()) + pub fn set_info_icon(&self, button: &Arc) -> Result<()> { + self.info_icon.set_icon(button, self.visible()) } - pub fn clear_button_info(&self) -> Result<()> { - self.button_info.clear_icon(self.visible()) + pub fn clear_info_icon(&self) -> Result<()> { + self.info_icon.clear_icon(self.visible()) } pub fn text(&self) -> Result> { @@ -439,7 +439,7 @@ impl Visibility for Button { self.textable.enable()?; self.iconizable.enable()?; - self.button_info.enable()?; + self.info_icon.enable()?; match *self.button_state.lock().unwrap() { ButtonState::Normal => self.normal.enable()?, @@ -470,7 +470,7 @@ impl Gridable for Button { self.selected.update_frame()?; self.textable.update()?; self.iconizable.update_frame()?; - self.button_info.update_frame()?; + self.info_icon.update_frame()?; if self.select_mode == ButtonSelectMode::Bigger { self.modify_hovered_vbo()?; @@ -494,7 +494,7 @@ impl Gridable for Button { self.framable.set_ui_layer(layer); self.iconizable.set_ui_layer(layer)?; self.textable.set_ui_layer(layer)?; - self.button_info.set_ui_layer(layer)?; + self.info_icon.set_ui_layer(layer)?; self.normal.set_ui_layer(layer); self.selected.set_ui_layer(layer); @@ -643,7 +643,7 @@ impl Button { self.textable.disable()?; self.iconizable.disable()?; - self.button_info.disable()?; + self.info_icon.disable()?; self.normal.disable()?; self.selected.disable()?; diff --git a/src/elements/label.rs b/src/elements/label.rs index 379ec89..e7ea5fb 100644 --- a/src/elements/label.rs +++ b/src/elements/label.rs @@ -1,6 +1,14 @@ -use crate::{builder::validator::labelinfo::LabelInfo, prelude::*}; +use crate::{ + builder::validator::labelinfo::LabelInfo, guihandler::gui::iconizable::IconizablePositioning, + prelude::*, +}; -use super::{fill_type::FillType, wrapper::TextableWrapper}; +use super::{ + fill_type::FillType, + wrapper::{IconizableWrapper, TextableWrapper}, +}; + +use vulkan_rs::prelude::*; use std::sync::{ atomic::{AtomicBool, Ordering::SeqCst}, @@ -8,7 +16,6 @@ use std::sync::{ }; use anyhow::Result; -use utilities::prelude::*; pub struct LabelBuilder { text_alignment: TextAlignment, @@ -69,10 +76,23 @@ impl LabelBuilder { .map(|info| FillType::new(framable.clone(), info)) .transpose()?; + 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(Label { framable, background: RwLock::new(background), textable_wrapper, + info_icon, visible: AtomicBool::new(false), })) @@ -83,6 +103,7 @@ pub struct Label { pub(crate) framable: Arc, background: RwLock>, textable_wrapper: TextableWrapper, + info_icon: IconizableWrapper, visible: AtomicBool, } @@ -123,6 +144,14 @@ impl Label { self.textable_wrapper.height_ratio() } + pub fn set_info_icon(&self, button: &Arc) -> 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 set_background(&self, background: impl Into) -> Result<()> { super::set_background(self.visible(), &self.framable, &self.background, background) }