Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
- Remove PartialEq for Command/Selector
- remove `pub` from Selector.object
- rename send_ to do_ in win_handler
  • Loading branch information
cmyr committed Sep 16, 2019
1 parent 1c061b2 commit 41b1739
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
14 changes: 1 addition & 13 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct Selector(&'static str);
#[derive(Debug, Clone)]
pub struct Command {
pub selector: Selector,
pub object: Option<Arc<dyn Any>>,
object: Option<Arc<dyn Any>>,
}

impl Selector {
Expand Down Expand Up @@ -87,18 +87,6 @@ impl From<Selector> for Command {
}
}

impl PartialEq<Selector> for Command {
fn eq(&self, other: &Selector) -> bool {
self.selector == *other
}
}

impl PartialEq<Command> for Selector {
fn eq(&self, other: &Command) -> bool {
*self == other.selector
}
}

impl std::fmt::Display for Selector {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "Selector('{}')", self.0)
Expand Down
12 changes: 6 additions & 6 deletions src/win_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ impl<T: Data> Windows<T> {

impl<'a, T: Data> SingleWindowState<'a, T> {
fn paint(&mut self, piet: &mut Piet, ctx: &mut dyn WinCtx) -> bool {
let request_anim = self.send_anim_frame(ctx);
self.send_layout(piet);
let request_anim = self.do_anim_frame(ctx);
self.do_layout(piet);
piet.clear(BACKGROUND_COLOR);
self.send_paint(piet);
self.do_paint(piet);
request_anim
}

fn send_anim_frame(&mut self, ctx: &mut dyn WinCtx) -> bool {
fn do_anim_frame(&mut self, ctx: &mut dyn WinCtx) -> bool {
// TODO: this calculation uses wall-clock time of the paint call, which
// potentially has jitter.
//
Expand All @@ -159,15 +159,15 @@ impl<'a, T: Data> SingleWindowState<'a, T> {
request_anim
}

fn send_layout(&mut self, piet: &mut Piet) {
fn do_layout(&mut self, piet: &mut Piet) {
let mut layout_ctx = LayoutCtx {
text_factory: piet.text(),
window_id: self.window_id,
};
self.window.layout(&mut layout_ctx, self.data, self.env);
}

fn send_paint(&mut self, piet: &mut Piet) {
fn do_paint(&mut self, piet: &mut Piet) {
let mut paint_ctx = PaintCtx {
render_ctx: piet,
window_id: self.window_id,
Expand Down

0 comments on commit 41b1739

Please sign in to comment.