Start work on displaying modified status in tabs

This commit is contained in:
Max Brunsfeld
2021-04-06 14:37:21 -07:00
parent 0f157d5083
commit dabd6abe37
5 changed files with 138 additions and 2 deletions
+73
View File
@@ -0,0 +1,73 @@
use super::Element;
use crate::PaintContext;
use pathfinder_geometry::{
rect::RectF,
vector::{vec2f, Vector2F},
};
pub struct Canvas<F>(F)
where
F: FnMut(RectF, &mut PaintContext);
impl<F> Canvas<F>
where
F: FnMut(RectF, &mut PaintContext),
{
pub fn new(f: F) -> Self {
Self(f)
}
}
impl<F> Element for Canvas<F>
where
F: FnMut(RectF, &mut PaintContext),
{
type LayoutState = ();
type PaintState = ();
fn layout(
&mut self,
constraint: crate::SizeConstraint,
_: &mut crate::LayoutContext,
) -> (Vector2F, Self::LayoutState) {
let x = if constraint.max.x().is_finite() {
constraint.max.x()
} else {
constraint.min.x()
};
let y = if constraint.max.y().is_finite() {
constraint.max.y()
} else {
constraint.min.y()
};
(vec2f(x, y), ())
}
fn paint(
&mut self,
bounds: RectF,
_: &mut Self::LayoutState,
ctx: &mut PaintContext,
) -> Self::PaintState {
self.0(bounds, ctx)
}
fn after_layout(
&mut self,
_: Vector2F,
_: &mut Self::LayoutState,
_: &mut crate::AfterLayoutContext,
) {
}
fn dispatch_event(
&mut self,
_: &crate::Event,
_: RectF,
_: &mut Self::LayoutState,
_: &mut Self::PaintState,
_: &mut crate::EventContext,
) -> bool {
false
}
}
+2
View File
@@ -1,4 +1,5 @@
mod align;
mod canvas;
mod constrained_box;
mod container;
mod empty;
@@ -13,6 +14,7 @@ mod uniform_list;
pub use crate::presenter::ChildView;
pub use align::*;
pub use canvas::*;
pub use constrained_box::*;
pub use container::*;
pub use empty::*;