Start work on displaying modified status in tabs
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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::*;
|
||||
|
||||
Reference in New Issue
Block a user