Add info icon to label
This commit is contained in:
parent
142ff7ae3a
commit
50cacf28bd
2 changed files with 43 additions and 14 deletions
|
@ -185,7 +185,7 @@ impl ButtonBuilder {
|
||||||
self.margin,
|
self.margin,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let button_info = IconizableWrapper::new(
|
let info_icon = IconizableWrapper::new(
|
||||||
framable.clone(),
|
framable.clone(),
|
||||||
None,
|
None,
|
||||||
Some(IconizablePositioning {
|
Some(IconizablePositioning {
|
||||||
|
@ -204,7 +204,7 @@ impl ButtonBuilder {
|
||||||
selectable,
|
selectable,
|
||||||
textable,
|
textable,
|
||||||
iconizable,
|
iconizable,
|
||||||
button_info,
|
info_icon,
|
||||||
|
|
||||||
#[cfg(feature = "audio")]
|
#[cfg(feature = "audio")]
|
||||||
_click_sound: click_sound,
|
_click_sound: click_sound,
|
||||||
|
@ -252,7 +252,7 @@ pub struct Button {
|
||||||
framable: Arc<Framable>,
|
framable: Arc<Framable>,
|
||||||
iconizable: IconizableWrapper,
|
iconizable: IconizableWrapper,
|
||||||
textable: TextableWrapper,
|
textable: TextableWrapper,
|
||||||
button_info: IconizableWrapper,
|
info_icon: IconizableWrapper,
|
||||||
|
|
||||||
#[cfg(feature = "audio")]
|
#[cfg(feature = "audio")]
|
||||||
_click_sound: Option<Arc<Audible>>,
|
_click_sound: Option<Arc<Audible>>,
|
||||||
|
@ -340,12 +340,12 @@ impl Button {
|
||||||
self.iconizable.icon()
|
self.iconizable.icon()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_button_info(&self, button: &Arc<Image>) -> Result<()> {
|
pub fn set_info_icon(&self, button: &Arc<Image>) -> Result<()> {
|
||||||
self.button_info.set_icon(button, self.visible())
|
self.info_icon.set_icon(button, self.visible())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_button_info(&self) -> Result<()> {
|
pub fn clear_info_icon(&self) -> Result<()> {
|
||||||
self.button_info.clear_icon(self.visible())
|
self.info_icon.clear_icon(self.visible())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text(&self) -> Result<Option<String>> {
|
pub fn text(&self) -> Result<Option<String>> {
|
||||||
|
@ -439,7 +439,7 @@ impl Visibility for Button {
|
||||||
|
|
||||||
self.textable.enable()?;
|
self.textable.enable()?;
|
||||||
self.iconizable.enable()?;
|
self.iconizable.enable()?;
|
||||||
self.button_info.enable()?;
|
self.info_icon.enable()?;
|
||||||
|
|
||||||
match *self.button_state.lock().unwrap() {
|
match *self.button_state.lock().unwrap() {
|
||||||
ButtonState::Normal => self.normal.enable()?,
|
ButtonState::Normal => self.normal.enable()?,
|
||||||
|
@ -470,7 +470,7 @@ impl Gridable for Button {
|
||||||
self.selected.update_frame()?;
|
self.selected.update_frame()?;
|
||||||
self.textable.update()?;
|
self.textable.update()?;
|
||||||
self.iconizable.update_frame()?;
|
self.iconizable.update_frame()?;
|
||||||
self.button_info.update_frame()?;
|
self.info_icon.update_frame()?;
|
||||||
|
|
||||||
if self.select_mode == ButtonSelectMode::Bigger {
|
if self.select_mode == ButtonSelectMode::Bigger {
|
||||||
self.modify_hovered_vbo()?;
|
self.modify_hovered_vbo()?;
|
||||||
|
@ -494,7 +494,7 @@ impl Gridable for Button {
|
||||||
self.framable.set_ui_layer(layer);
|
self.framable.set_ui_layer(layer);
|
||||||
self.iconizable.set_ui_layer(layer)?;
|
self.iconizable.set_ui_layer(layer)?;
|
||||||
self.textable.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.normal.set_ui_layer(layer);
|
||||||
self.selected.set_ui_layer(layer);
|
self.selected.set_ui_layer(layer);
|
||||||
|
@ -643,7 +643,7 @@ impl Button {
|
||||||
|
|
||||||
self.textable.disable()?;
|
self.textable.disable()?;
|
||||||
self.iconizable.disable()?;
|
self.iconizable.disable()?;
|
||||||
self.button_info.disable()?;
|
self.info_icon.disable()?;
|
||||||
|
|
||||||
self.normal.disable()?;
|
self.normal.disable()?;
|
||||||
self.selected.disable()?;
|
self.selected.disable()?;
|
||||||
|
|
|
@ -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::{
|
use std::sync::{
|
||||||
atomic::{AtomicBool, Ordering::SeqCst},
|
atomic::{AtomicBool, Ordering::SeqCst},
|
||||||
|
@ -8,7 +16,6 @@ use std::sync::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use utilities::prelude::*;
|
|
||||||
|
|
||||||
pub struct LabelBuilder {
|
pub struct LabelBuilder {
|
||||||
text_alignment: TextAlignment,
|
text_alignment: TextAlignment,
|
||||||
|
@ -69,10 +76,23 @@ impl LabelBuilder {
|
||||||
.map(|info| FillType::new(framable.clone(), info))
|
.map(|info| FillType::new(framable.clone(), info))
|
||||||
.transpose()?;
|
.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 {
|
Ok(Arc::new(Label {
|
||||||
framable,
|
framable,
|
||||||
background: RwLock::new(background),
|
background: RwLock::new(background),
|
||||||
textable_wrapper,
|
textable_wrapper,
|
||||||
|
info_icon,
|
||||||
|
|
||||||
visible: AtomicBool::new(false),
|
visible: AtomicBool::new(false),
|
||||||
}))
|
}))
|
||||||
|
@ -83,6 +103,7 @@ pub struct Label {
|
||||||
pub(crate) framable: Arc<Framable>,
|
pub(crate) framable: Arc<Framable>,
|
||||||
background: RwLock<Option<FillType>>,
|
background: RwLock<Option<FillType>>,
|
||||||
textable_wrapper: TextableWrapper,
|
textable_wrapper: TextableWrapper,
|
||||||
|
info_icon: IconizableWrapper,
|
||||||
|
|
||||||
visible: AtomicBool,
|
visible: AtomicBool,
|
||||||
}
|
}
|
||||||
|
@ -123,6 +144,14 @@ impl Label {
|
||||||
self.textable_wrapper.height_ratio()
|
self.textable_wrapper.height_ratio()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 set_background(&self, background: impl Into<FillTypeInfo>) -> Result<()> {
|
pub fn set_background(&self, background: impl Into<FillTypeInfo>) -> Result<()> {
|
||||||
super::set_background(self.visible(), &self.framable, &self.background, background)
|
super::set_background(self.visible(), &self.framable, &self.background, background)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue