custom panels
This commit is contained in:
@@ -2,9 +2,9 @@ use crate::{
|
||||
i18n::Translation,
|
||||
layout::WidgetID,
|
||||
parser::{
|
||||
AttribPair, ParserContext, ParserFile, parse_check_i32, parse_children, parse_i32, parse_widget_universal,
|
||||
print_invalid_attrib,
|
||||
parse_children, parse_i32, parse_widget_universal, print_invalid_attrib,
|
||||
style::{parse_style, parse_text_style},
|
||||
AttribPair, ParserContext, ParserFile,
|
||||
},
|
||||
widget::label::{WidgetLabel, WidgetLabelParams},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
assets::AssetPath,
|
||||
layout::WidgetID,
|
||||
parser::{AttribPair, ParserContext, ParserFile, parse_children, parse_widget_universal, style::parse_style},
|
||||
parser::{parse_children, parse_widget_universal, style::parse_style, AttribPair, ParserContext, ParserFile},
|
||||
renderer_vk::text::custom_glyph::{CustomGlyphContent, CustomGlyphData},
|
||||
widget::sprite::{WidgetSprite, WidgetSpriteParams},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{
|
||||
f32,
|
||||
sync::{
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@ use crate::{assets::AssetPath, globals::WguiGlobals};
|
||||
|
||||
static AUTO_INCREMENT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
/// The raw content of a glyph.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum CustomGlyphContent {
|
||||
Svg(Box<Tree>),
|
||||
@@ -43,6 +44,8 @@ impl CustomGlyphContent {
|
||||
}
|
||||
}
|
||||
|
||||
/// The cached contents of a glyph.
|
||||
/// Clone and reuse this to avoid atlasing the same content twice.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CustomGlyphData {
|
||||
pub(super) id: usize,
|
||||
|
||||
@@ -8,8 +8,8 @@ use crate::{
|
||||
globals::Globals,
|
||||
layout::WidgetID,
|
||||
renderer_vk::text::{
|
||||
DEFAULT_METRICS,
|
||||
custom_glyph::{CustomGlyph, CustomGlyphData},
|
||||
DEFAULT_METRICS,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct WidgetSpriteParams {
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct WidgetSprite {
|
||||
pub params: WidgetSpriteParams,
|
||||
params: WidgetSpriteParams,
|
||||
id: WidgetID,
|
||||
}
|
||||
|
||||
@@ -34,6 +34,22 @@ impl WidgetSprite {
|
||||
id: WidgetID::null(),
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn set_color(&mut self, color: drawing::Color) {
|
||||
self.params.color = Some(color);
|
||||
}
|
||||
|
||||
pub fn get_color(&self) -> Option<drawing::Color> {
|
||||
self.params.color
|
||||
}
|
||||
|
||||
pub fn set_content(&mut self, content: Option<CustomGlyphData>) {
|
||||
self.params.glyph_data = content;
|
||||
}
|
||||
|
||||
pub fn get_content(&self) -> Option<CustomGlyphData> {
|
||||
self.params.glyph_data.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetObj for WidgetSprite {
|
||||
|
||||
Reference in New Issue
Block a user