Add a Debug layer

This commit is contained in:
Emil Ernerfeldt 2020-04-27 16:53:14 +02:00
parent fbedc2e9ab
commit 680d1888da
3 changed files with 10 additions and 6 deletions

View file

@ -194,7 +194,7 @@ impl Context {
pub fn show_error(&self, pos: Pos2, text: &str) {
let align = (Align::Min, Align::Min);
let layer = Layer::Popup; // TODO: Layer::Debug
let layer = Layer::Debug;
let text_style = TextStyle::Monospace;
let font = &self.fonts[text_style];
let (text, size) = font.layout_multiline(text, f32::INFINITY);
@ -212,7 +212,7 @@ impl Context {
}
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);
self.floating_text(
layer,

View file

@ -83,11 +83,10 @@ impl Fonts {
// 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/Roboto-Regular.ttf");
let variable_typeface_data = include_bytes!("../fonts/Comfortaa-Regular.ttf");
// let variable_typeface_data = include_bytes!("../fonts/DejaVuSans.ttf");
// let variable_typeface_data = include_bytes!("../fonts/Comfortaa-Regular.ttf"); // Funny, hard to read
let variable_typeface_data = include_bytes!("../fonts/DejaVuSans.ttf"); // Basic, boring
self.definitions = definitions.clone();
self.fonts = definitions

View file

@ -9,6 +9,8 @@ pub enum Layer {
Window(Id),
/// Tooltips etc
Popup,
/// Debug text
Debug,
}
/// Each PaintCmd is paired with a clip rectangle.
@ -20,6 +22,7 @@ pub struct GraphicLayers {
bg: PaintList,
windows: HashMap<Id, PaintList>,
popup: PaintList,
debug: PaintList,
}
impl GraphicLayers {
@ -28,6 +31,7 @@ impl GraphicLayers {
Layer::Background => &mut self.bg,
Layer::Window(id) => self.windows.entry(id).or_default(),
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.debug.drain(..));
all_commands.into_iter()
}
}