Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Nov 20, 2023
1 parent c49e6ec commit b6d4687
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<C> App<C> {
}
}

pub fn handle<'a>(&mut self, msg: C::Message)
pub fn handle(&mut self, msg: C::Message)
where
C: Component,
{
Expand Down
3 changes: 1 addition & 2 deletions src/element/linear_layout.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::{Element, Node, WindowMessage};
use kurbo::Point;
use skia_safe::surfaces;
use taffy::geometry::Size;

use crate::{Element, Node, WindowMessage};

pub struct LinearLayoutElement {
pub(crate) nodes: Vec<Node>,
pub(crate) points: Vec<(Point, Size<f64>)>,
Expand Down
14 changes: 6 additions & 8 deletions src/element/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use std::any::Any;

use crate::WindowMessage;
use skia_safe::Canvas;
use std::any::Any;
use taffy::geometry::Size;

mod linear_layout;
pub use linear_layout::LinearLayoutElement;

mod text;
use taffy::geometry::Size;
pub use text::TextElement;

use crate::WindowMessage;

pub trait Element {
fn layout(&mut self) -> Size<f64>;

Expand All @@ -21,14 +19,14 @@ pub trait Element {

impl<T: Element + ?Sized> Element for &mut T {
fn layout(&mut self) -> Size<f64> {
(&mut **self).layout()
(**self).layout()
}

fn handle(&mut self, msg: WindowMessage, output: &mut Vec<Box<dyn Any>>) {
(&mut **self).handle(msg, output)
(**self).handle(msg, output)
}

fn render(&mut self, canvas: &mut Canvas) {
(&mut **self).render(canvas)
(**self).render(canvas)
}
}
4 changes: 1 addition & 3 deletions src/element/text.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::borrow::Cow;

use crate::{Element, WindowMessage};
use kurbo::Point;
use skia_safe::{Color4f, Font, FontStyle, Paint, TextBlob, Typeface};
use std::borrow::Cow;
use taffy::geometry::Size;

pub struct TextElement<M> {
Expand Down Expand Up @@ -51,7 +50,6 @@ impl<M: 'static> Element for TextElement<M> {
}

fn handle(&mut self, msg: WindowMessage, output: &mut Vec<Box<dyn std::any::Any>>) {
dbg!(&self.content);
match msg {
WindowMessage::Click { position } => {
if let Some(ref mut f) = self.on_click {
Expand Down
2 changes: 1 addition & 1 deletion src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub fn run<C: Component>(app: &mut App<C>) {
draw_frame = true;
}
WindowEvent::CursorMoved {
device_id,
device_id: _,
position,
} => {
cursor = Some(position);
Expand Down

0 comments on commit b6d4687

Please sign in to comment.