Add a Debug layer
This commit is contained in:
parent
fbedc2e9ab
commit
680d1888da
3 changed files with 10 additions and 6 deletions
|
@ -194,7 +194,7 @@ impl Context {
|
||||||
|
|
||||||
pub fn show_error(&self, pos: Pos2, text: &str) {
|
pub fn show_error(&self, pos: Pos2, text: &str) {
|
||||||
let align = (Align::Min, Align::Min);
|
let align = (Align::Min, Align::Min);
|
||||||
let layer = Layer::Popup; // TODO: Layer::Debug
|
let layer = Layer::Debug;
|
||||||
let text_style = TextStyle::Monospace;
|
let text_style = TextStyle::Monospace;
|
||||||
let font = &self.fonts[text_style];
|
let font = &self.fonts[text_style];
|
||||||
let (text, size) = font.layout_multiline(text, f32::INFINITY);
|
let (text, size) = font.layout_multiline(text, f32::INFINITY);
|
||||||
|
@ -212,7 +212,7 @@ impl Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_text(&self, pos: Pos2, text: &str) {
|
pub fn debug_text(&self, pos: Pos2, text: &str) {
|
||||||
let layer = Layer::Popup; // TODO: Layer::Debug
|
let layer = Layer::Debug;
|
||||||
let align = (Align::Min, Align::Min);
|
let align = (Align::Min, Align::Min);
|
||||||
self.floating_text(
|
self.floating_text(
|
||||||
layer,
|
layer,
|
||||||
|
|
|
@ -83,11 +83,10 @@ impl Fonts {
|
||||||
|
|
||||||
// TODO: figure out a way to make the wasm smaller despite including a font. Zip it?
|
// TODO: figure out a way to make the wasm smaller despite including a font. Zip it?
|
||||||
let monospae_typeface_data = include_bytes!("../fonts/ProggyClean.ttf"); // Use 13 for this. NOTHING ELSE.
|
let monospae_typeface_data = include_bytes!("../fonts/ProggyClean.ttf"); // Use 13 for this. NOTHING ELSE.
|
||||||
|
|
||||||
// let monospae_typeface_data = include_bytes!("../fonts/Roboto-Regular.ttf");
|
// let monospae_typeface_data = include_bytes!("../fonts/Roboto-Regular.ttf");
|
||||||
|
|
||||||
let variable_typeface_data = include_bytes!("../fonts/Comfortaa-Regular.ttf");
|
// let variable_typeface_data = include_bytes!("../fonts/Comfortaa-Regular.ttf"); // Funny, hard to read
|
||||||
// let variable_typeface_data = include_bytes!("../fonts/DejaVuSans.ttf");
|
let variable_typeface_data = include_bytes!("../fonts/DejaVuSans.ttf"); // Basic, boring
|
||||||
|
|
||||||
self.definitions = definitions.clone();
|
self.definitions = definitions.clone();
|
||||||
self.fonts = definitions
|
self.fonts = definitions
|
||||||
|
|
|
@ -9,6 +9,8 @@ pub enum Layer {
|
||||||
Window(Id),
|
Window(Id),
|
||||||
/// Tooltips etc
|
/// Tooltips etc
|
||||||
Popup,
|
Popup,
|
||||||
|
/// Debug text
|
||||||
|
Debug,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Each PaintCmd is paired with a clip rectangle.
|
/// Each PaintCmd is paired with a clip rectangle.
|
||||||
|
@ -20,6 +22,7 @@ pub struct GraphicLayers {
|
||||||
bg: PaintList,
|
bg: PaintList,
|
||||||
windows: HashMap<Id, PaintList>,
|
windows: HashMap<Id, PaintList>,
|
||||||
popup: PaintList,
|
popup: PaintList,
|
||||||
|
debug: PaintList,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GraphicLayers {
|
impl GraphicLayers {
|
||||||
|
@ -28,6 +31,7 @@ impl GraphicLayers {
|
||||||
Layer::Background => &mut self.bg,
|
Layer::Background => &mut self.bg,
|
||||||
Layer::Window(id) => self.windows.entry(id).or_default(),
|
Layer::Window(id) => self.windows.entry(id).or_default(),
|
||||||
Layer::Popup => &mut self.popup,
|
Layer::Popup => &mut self.popup,
|
||||||
|
Layer::Debug => &mut self.debug,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +48,7 @@ impl GraphicLayers {
|
||||||
}
|
}
|
||||||
|
|
||||||
all_commands.extend(self.popup.drain(..));
|
all_commands.extend(self.popup.drain(..));
|
||||||
|
all_commands.extend(self.debug.drain(..));
|
||||||
all_commands.into_iter()
|
all_commands.into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue