Add Debug to a lot of structs

This commit is contained in:
Dietrich 2022-12-07 13:50:21 +01:00
parent 08d4e67328
commit e0926a00f7
5 changed files with 29 additions and 11 deletions

View File

@ -17,7 +17,7 @@ use crate::{
* All the possibilities to draw something with turtle. All the commands can get the position, heading,
* color and fill_color from the turtles state.
*/
#[derive(Component, Inspectable)]
#[derive(Component, Inspectable, Debug)]
pub enum MoveCommand {
Forward(Length),
Backward(Length),
@ -35,7 +35,7 @@ impl Default for MoveCommand {
}
/// Different ways to drop breadcrumbs on the way like a dot or a stamp of the turtles shape.
#[derive(Component, Inspectable, Default)]
#[derive(Component, Inspectable, Default, Debug)]
pub enum Breadcrumb {
Dot,
#[default]
@ -43,7 +43,7 @@ pub enum Breadcrumb {
}
/// Different ways that change the orientation of the turtle.
#[derive(Component, Inspectable)]
#[derive(Component, Inspectable, Debug)]
pub enum OrientationCommand {
Left(Angle<Precision>),
Right(Angle<Precision>),
@ -58,7 +58,7 @@ impl Default for OrientationCommand {
}
/// A combination of all commands that can be used while drawing.
#[derive(Component, Inspectable)]
#[derive(Component, Inspectable, Debug)]
pub enum DrawElement {
Draw(MoveCommand),
Move(MoveCommand),
@ -95,7 +95,7 @@ impl ToAnimationSegment for DrawElement {
}
}
#[derive(Component, Inspectable)]
#[derive(Component, Inspectable, Debug)]
pub enum TurtleSegment {
Single(DrawElement),
Outline(Vec<DrawElement>),
@ -119,7 +119,7 @@ impl ToAnimationSegment for TurtleSegment {
}
}
}
#[derive(Component, Inspectable)]
#[derive(Component, Inspectable, Debug)]
pub struct TurtleCommands {
animation_state: usize,
commands: Vec<TurtleSegment>,

View File

@ -6,7 +6,7 @@ pub mod animation;
mod line_segments;
pub(crate) mod run_step;
#[derive(Inspectable, Default)]
#[derive(Inspectable, Default, Debug)]
pub enum TurtleGraphElement {
TurtleLine(TurtleDrawLine),
TurtleCircle(TurtleDrawCircle),

View File

@ -16,7 +16,16 @@ pub struct TurtleDrawLine {
marker: LineMarker,
}
#[derive(Component, Default, Inspectable)]
impl std::fmt::Debug for TurtleDrawLine {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TurtleDrawLine")
.field("name", &self.name)
.field("marker", &self.marker)
.finish()
}
}
#[derive(Component, Default, Inspectable, Debug)]
struct LineMarker;
impl TurtleDrawLine {
@ -45,7 +54,16 @@ pub struct TurtleDrawCircle {
marker: CircleMarker,
}
#[derive(Component, Default, Inspectable)]
impl std::fmt::Debug for TurtleDrawCircle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TurtleDrawCircle")
.field("name", &self.name)
.field("marker", &self.marker)
.finish()
}
}
#[derive(Component, Default, Inspectable, Debug)]
struct CircleMarker;
impl TurtleDrawCircle {

View File

@ -6,7 +6,7 @@ pub use turtle::turtle;
#[derive(Clone, Component, Inspectable)]
pub struct TurtleShape;
#[derive(Clone, Component, Inspectable, Default)]
#[derive(Clone, Component, Inspectable, Default, Debug)]
pub struct TurtleColors {
color: Color,
fill_color: Color,

View File

@ -10,7 +10,7 @@ use crate::{
};
/// Describing the full state of a turtle.
#[derive(Component, Inspectable, Default)]
#[derive(Component, Inspectable, Default, Debug)]
pub struct TurtleState {
drawing: Vec<TurtleSegment>,
position: Coordinate,