mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 18:08:26 +00:00
Prepare to make operation labels more flexible
This commit is contained in:
parent
d14ba5399e
commit
6d6affee53
@ -1,4 +1,4 @@
|
||||
use std::{ops::Deref, rc::Rc};
|
||||
use std::{fmt, ops::Deref, rc::Rc};
|
||||
|
||||
use super::tri_mesh::TriMesh;
|
||||
|
||||
@ -15,6 +15,23 @@ pub trait Operation {
|
||||
fn display(&self) -> &'static str;
|
||||
fn tri_mesh(&self) -> TriMesh;
|
||||
fn children(&self) -> Vec<AnyOp>;
|
||||
|
||||
fn label(&self) -> OperationDisplay
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
OperationDisplay { op: self as &_ }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OperationDisplay<'r> {
|
||||
pub op: &'r dyn Operation,
|
||||
}
|
||||
|
||||
impl fmt::Display for OperationDisplay<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.op.display())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
|
@ -91,7 +91,7 @@ impl TextRenderer {
|
||||
write!(line, "\t")?;
|
||||
}
|
||||
|
||||
write!(line, "{}", op.display())?;
|
||||
write!(line, "{}", op.label())?;
|
||||
|
||||
buffer.lines.push(glyphon::BufferLine::new(
|
||||
line,
|
||||
|
Loading…
Reference in New Issue
Block a user