Skip to content

Commit

Permalink
re #25. Remove print functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Jun 29, 2022
1 parent 1744188 commit 945483f
Show file tree
Hide file tree
Showing 28 changed files with 1 addition and 173 deletions.
3 changes: 0 additions & 3 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ pub trait View: private::Sealed + 'static {
/// Lays out subviews and return the size of the view.
fn layout(&self, id: ViewId, sz: LocalSize, cx: &mut Context, vger: &mut Vger) -> LocalSize;

/// Prints a description of the view for debugging.
fn print(&self, id: ViewId, cx: &mut Context);

/// Processes an event.
fn process(&self, _event: &Event, _id: ViewId, _cx: &mut Context, _vger: &mut Vger) {}

Expand Down
4 changes: 0 additions & 4 deletions src/views/anim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ where
V: View,
F: Fn(&mut Context, f32) + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
self.child.print(id.child(&0), cx);
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
if let Event::Anim = event {
(self.func)(cx, 1.0 / 60.0) // XXX: assume 60fps for now.
Expand Down
6 changes: 0 additions & 6 deletions src/views/anyview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ impl View for AnyView {
self.child.tid()
}

fn print(&self, id: ViewId, cx: &mut Context) {
println!("AnyView {{");
(self.child).print(id.child(&self.id()), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
self.child.process(event, id.child(&self.id()), cx, vger);
}
Expand Down
7 changes: 0 additions & 7 deletions src/views/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ where
V: View,
BG: View,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Background {{");
(self.child).print(id.child(&0), cx);
(self.background).print(id.child(&1), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
self.child.process(event, id.child(&0), cx, vger);
}
Expand Down
4 changes: 0 additions & 4 deletions src/views/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ impl<F> View for Canvas<F>
where
F: Fn(&mut Context, LocalRect, &mut Vger) + 'static,
{
fn print(&self, _id: ViewId, _cx: &mut Context) {
println!("canvas");
}

fn draw(&self, id: ViewId, cx: &mut Context, vger: &mut Vger) {
let rect = cx.layout.entry(id).or_default().rect;

Expand Down
12 changes: 0 additions & 12 deletions src/views/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ where
V: View,
F: Fn(&mut Context) + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Command {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
if let Event::Command(name) = &event {
if *name == self.name {
Expand Down Expand Up @@ -253,12 +247,6 @@ where
V: View,
C: CommandTuple + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Command {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
if let Event::Command(name) = &event {
self.cmds.foreach_cmd(&mut |cmd| {
Expand Down
8 changes: 0 additions & 8 deletions src/views/cond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ where
V0: View,
V1: View,
{
fn print(&self, id: ViewId, cx: &mut Context) {
if self.cond {
self.if_true.print(id.child(&0), cx)
} else {
self.if_false.print(id.child(&1), cx)
}
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
if self.cond {
self.if_true.process(event, id.child(&0), cx, vger)
Expand Down
6 changes: 0 additions & 6 deletions src/views/drag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ where
V: View,
F: Fn(&mut Context, LocalOffset, GestureState, Option<MouseButton>) + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Drag {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, vid: ViewId, cx: &mut Context, vger: &mut Vger) {
match &event {
Event::TouchBegin { id, position } => {
Expand Down
3 changes: 0 additions & 3 deletions src/views/emptyview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use crate::*;
pub struct EmptyView {}

impl View for EmptyView {
fn print(&self, _id: ViewId, _cx: &mut Context) {
println!("EmptyView");
}
fn draw(&self, _id: ViewId, _cx: &mut Context, _vger: &mut Vger) {}
fn layout(
&self,
Expand Down
11 changes: 0 additions & 11 deletions src/views/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ where
S: Clone + Default + 'static,
F: Fn(S, &mut Context) -> V + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
(self.func)(cx.init_env(&S::default), cx).print(id.child(&0), cx);
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
(self.func)(cx.init_env(&S::default), cx).process(event, id.child(&0), cx, vger);
}
Expand Down Expand Up @@ -106,13 +102,6 @@ where
V: View,
E: Clone + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
let old = cx.set_env(&self.env_val);
(self.child).print(id.child(&0), cx);
println!(".env()");
old.and_then(|s| cx.set_env(&s));
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
let old = cx.set_env(&self.env_val);
self.child.process(event, id.child(&0), cx, vger);
Expand Down
6 changes: 0 additions & 6 deletions src/views/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ impl<V> View for Flex<V>
where
V: View,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Flex {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
self.child.process(event, id.child(&0), cx, vger);
}
Expand Down
6 changes: 0 additions & 6 deletions src/views/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ where
V: View,
F: Fn(bool) -> V + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("focus(");
(self.func)(Some(id) == cx.focused_id).print(id.child(&0), cx);
println!(")");
}

fn process(&self, event: &Event, vid: ViewId, cx: &mut Context, vger: &mut Vger) {
match &event {
Event::TouchBegin { id: _, position } => {
Expand Down
6 changes: 0 additions & 6 deletions src/views/geom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ where
V: View,
F: Fn(&mut Context, LocalSize) + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Geom {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
self.child.process(event, id.child(&0), cx, vger);
}
Expand Down
6 changes: 0 additions & 6 deletions src/views/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ where
V: View,
F: Fn(&mut Context, Key) + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Key {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, _vid: ViewId, cx: &mut Context, _vger: &mut Vger) {
if let Event::Key(key) = &event {
(self.func)(cx, key.clone())
Expand Down
8 changes: 0 additions & 8 deletions src/views/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ where
V: View,
F: Fn(&ID) -> V + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("List {{");
for child in &self.ids {
((self.func)(child)).print(id.child(child), cx);
}
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
for child in &self.ids {
let child_id = id.child(child);
Expand Down
5 changes: 0 additions & 5 deletions src/views/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ where
SF: Fn(S1, &mut Context) + 'static,
F: Fn(State<S1>, &mut Context) -> V + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
cx.set_state(id, self.value.clone());
(self.func)(State::new(id), cx).print(id.child(&0), cx);
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
cx.set_state(id, self.value.clone());
let s = State::new(id);
Expand Down
4 changes: 0 additions & 4 deletions src/views/modview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ where
S: Clone + Default + 'static,
F: Fn(S, &mut Context) -> V + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
(self.func)(self.value.clone(), cx).print(id.child(&0), cx);
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
(self.func)(self.value.clone(), cx).process(event, id.child(&0), cx, vger);
}
Expand Down
6 changes: 0 additions & 6 deletions src/views/offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ impl<V> View for Offset<V>
where
V: View,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Offset {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
self.child
.process(&event.offset(-self.offset), id.child(&0), cx, vger);
Expand Down
6 changes: 0 additions & 6 deletions src/views/padding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ impl<V> View for Padding<V>
where
V: View,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Padding {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
let off = LocalOffset::new(self.padding, self.padding);
self.child
Expand Down
5 changes: 0 additions & 5 deletions src/views/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ impl<V> View for RoleView<V>
where
V: View,
{
fn print(&self, id: ViewId, cx: &mut Context) {
(self.child).print(id.child(&0), cx);
println!(".role()");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
self.child.process(event, id.child(&0), cx, vger);
}
Expand Down
7 changes: 0 additions & 7 deletions src/views/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ impl Circle {
}

impl View for Circle {
fn print(&self, _id: ViewId, _cx: &mut Context) {
println!("circle");
}

fn draw(&self, id: ViewId, cx: &mut Context, vger: &mut Vger) {
let (center, radius) = self.geom(id, cx);

Expand Down Expand Up @@ -97,9 +93,6 @@ impl Rectangle {
}

impl View for Rectangle {
fn print(&self, _id: ViewId, _cx: &mut Context) {
println!("rectangle");
}

fn draw(&self, id: ViewId, cx: &mut Context, vger: &mut Vger) {
let rect = self.geom(id, cx);
Expand Down
6 changes: 0 additions & 6 deletions src/views/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ impl<V> View for Size<V>
where
V: View,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Size {{");
self.child.print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
self.child.process(event, id.child(&0), cx, vger);
}
Expand Down
3 changes: 0 additions & 3 deletions src/views/spacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use crate::*;
pub struct Spacer {}

impl View for Spacer {
fn print(&self, _id: ViewId, _cx: &mut Context) {
println!("Spacer");
}
fn draw(&self, _id: ViewId, _cx: &mut Context, _vger: &mut Vger) {}
fn layout(
&self,
Expand Down
9 changes: 0 additions & 9 deletions src/views/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ struct Stack<VT> {
}

impl<VT: ViewTuple + 'static> View for Stack<VT> {
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Stack {{");
let mut c = 0;
self.children.foreach_view(&mut |child| {
(*child).print(id.child(&c), cx);
c += 1;
});
println!("}}");
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
self.children.process(event, id, cx, vger);
Expand Down
5 changes: 0 additions & 5 deletions src/views/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ where
D: Fn() -> S + 'static,
F: Fn(State<S>, &mut Context) -> V + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
cx.init_state(id, &self.default);
(self.func)(State::new(id), cx).print(id.child(&0), cx);
}

fn process(&self, event: &Event, id: ViewId, cx: &mut Context, vger: &mut Vger) {
cx.init_state(id, &self.default);
(self.func)(State::new(id), cx).process(event, id.child(&0), cx, vger);
Expand Down
5 changes: 0 additions & 5 deletions src/views/tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ where
V: View,
F: Fn(&mut Context) + 'static,
{
fn print(&self, id: ViewId, cx: &mut Context) {
println!("Tap {{");
(self.child).print(id.child(&0), cx);
println!("}}");
}

fn process(&self, event: &Event, vid: ViewId, cx: &mut Context, vger: &mut Vger) {
match &event {
Expand Down
7 changes: 1 addition & 6 deletions src/views/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ impl Text {
}

impl View for Text {
fn print(&self, _id: ViewId, _cx: &mut Context) {
println!("Text({:?})", self.text);
}

fn draw(&self, _id: ViewId, _cx: &mut Context, vger: &mut Vger) {
let origin = vger.text_bounds(self.text.as_str(), self.size, None).origin;

Expand Down Expand Up @@ -83,9 +81,6 @@ impl<V> View for V
where
V: std::fmt::Display + std::fmt::Debug + 'static,
{
fn print(&self, _id: ViewId, _cx: &mut Context) {
println!("Text({:?})", self);
}
fn process(&self, _event: &Event, _id: ViewId, _cx: &mut Context, _vger: &mut Vger) {}
fn draw(&self, _id: ViewId, _cx: &mut Context, vger: &mut Vger) {
let txt = &format!("{}", self);
Expand Down
Loading

0 comments on commit 945483f

Please sign in to comment.