[voila] Revert "Add toggle to control sync in replicas."

This reverts commit c6025a932cdcab0cf144751c2be94ff8072d5342.

The original change is breaking the mac host build.

Change-Id: I28fe4154ac64864eb18abf601461cf635fa3a04f
diff --git a/peridot/bin/voila/src/layout.rs b/peridot/bin/voila/src/layout.rs
index fb243bf..6e83076 100644
--- a/peridot/bin/voila/src/layout.rs
+++ b/peridot/bin/voila/src/layout.rs
@@ -4,32 +4,18 @@
 
 use carnelian::{Point, Rect, Size};
 use fidl_fuchsia_ui_gfx::{BoundingBox, Vec3, ViewProperties};
-use fuchsia_scenic::{EntityNode, SessionPtr, ViewHolder};
-
-use crate::toggle::Toggle;
-
-const CONTROLLER_VIEW_HEIGHT: f32 = 25.0;
+use fuchsia_scenic::{EntityNode, ViewHolder};
 
 /// Container for data related to a single child view displaying an emulated session.
 pub struct ChildViewData {
     bounds: Option<Rect>,
     host_node: EntityNode,
     host_view_holder: ViewHolder,
-    pub toggle: Toggle,
 }
 
 impl ChildViewData {
-    pub fn new(
-        host_node: EntityNode,
-        host_view_holder: ViewHolder,
-        toggle: Toggle,
-    ) -> ChildViewData {
-        ChildViewData {
-            bounds: None,
-            host_node: host_node,
-            host_view_holder: host_view_holder,
-            toggle: toggle,
-        }
+    pub fn new(host_node: EntityNode, host_view_holder: ViewHolder) -> ChildViewData {
+        ChildViewData { bounds: None, host_node: host_node, host_view_holder: host_view_holder }
     }
 
     pub fn id(&self) -> u32 {
@@ -40,78 +26,37 @@
 /// Lays out the given child views using the given container.
 ///
 /// Voila uses a column layout to display 2 or more emulated sessions side by side.
-pub fn layout(
-    child_views: &mut [&mut ChildViewData],
-    size: &Size,
-    session: &SessionPtr,
-) -> Result<(), failure::Error> {
+pub fn layout(child_views: &mut [&mut ChildViewData], size: &Size) -> Result<(), failure::Error> {
     if child_views.is_empty() {
         return Ok(());
     }
     let num_views = child_views.len();
 
-    let tile_width = (size.width / num_views as f32).floor();
     let tile_height = size.height;
+    let tile_width = (size.width / num_views as f32).floor();
     for (column_index, view) in child_views.iter_mut().enumerate() {
         let tile_bounds = Rect::new(
             Point::new(column_index as f32 * tile_width, 0.0),
             Size::new(tile_width, tile_height),
         );
-        layout_replica(view, &tile_bounds, session)?;
+        let tile_bounds = inset(&tile_bounds, 5.0);
+        let view_properties = ViewProperties {
+            bounding_box: BoundingBox {
+                min: Vec3 { x: 0.0, y: 0.0, z: 0.0 },
+                max: Vec3 { x: tile_bounds.size.width, y: tile_bounds.size.height, z: 0.0 },
+            },
+            inset_from_min: Vec3 { x: 0.0, y: 0.0, z: 0.0 },
+            inset_from_max: Vec3 { x: 0.0, y: 0.0, z: 0.0 },
+            focus_change: true,
+            downward_input: false,
+        };
+        view.host_view_holder.set_view_properties(view_properties);
+        view.host_node.set_translation(tile_bounds.origin.x, tile_bounds.origin.y, 0.0);
+        view.bounds = Some(tile_bounds);
     }
     Ok(())
 }
 
-fn layout_replica(
-    view: &mut ChildViewData,
-    bounds: &Rect,
-    session: &SessionPtr,
-) -> Result<(), failure::Error> {
-    let (replica_bounds, controller_bounds) = split_bounds(&bounds, CONTROLLER_VIEW_HEIGHT);
-
-    // Update the session view.
-    let replica_bounds = inset(&replica_bounds, 5.0);
-    let view_properties = ViewProperties {
-        bounding_box: BoundingBox {
-            min: Vec3 { x: 0.0, y: 0.0, z: 0.0 },
-            max: Vec3 { x: replica_bounds.size.width, y: replica_bounds.size.height, z: 0.0 },
-        },
-        inset_from_min: Vec3 { x: 0.0, y: 0.0, z: 0.0 },
-        inset_from_max: Vec3 { x: 0.0, y: 0.0, z: 0.0 },
-        focus_change: true,
-        downward_input: false,
-    };
-    view.host_view_holder.set_view_properties(view_properties);
-    view.host_node.set_translation(replica_bounds.origin.x, replica_bounds.origin.y, 0.0);
-    view.bounds = Some(replica_bounds);
-
-    // Update the controller view.
-    match controller_bounds {
-        None => {
-            // TODO(ppi): hide the controller when it doesn't fit on the screen.
-        }
-        Some(rect) => view.toggle.update(&inset(&rect, 5.0), session)?,
-    }
-
-    Ok(())
-}
-
-/// Splits the screen area available for one replica into a replica view and a controller view.
-fn split_bounds(bounds: &Rect, controller_view_height: f32) -> (Rect, Option<Rect>) {
-    if bounds.size.height < controller_view_height * 2.0 {
-        return ((*bounds).clone(), None);
-    }
-    let replica_bounds = Rect::new(
-        bounds.origin.clone(),
-        Size::new(bounds.size.width, bounds.size.height - controller_view_height),
-    );
-    let controller_bounds = Rect::new(
-        Point::new(bounds.origin.x, bounds.origin.y + bounds.size.height - controller_view_height),
-        Size::new(bounds.size.width, controller_view_height),
-    );
-    (replica_bounds, Some(controller_bounds))
-}
-
 /// Reduces the given bounds to leave the given amount of padding around it.
 ///
 /// The added padding is no bigger than a third of the smaller dimension of the
@@ -130,33 +75,6 @@
     use super::*;
 
     #[test]
-    fn split_bounds_works_correctly() {
-        let bounds = Rect::new(Point::new(10.0, 20.0), Size::new(75.0, 80.0));
-
-        let (replica_bounds, maybe_controller_bounds) = split_bounds(&bounds, 10.0);
-
-        assert_eq!(replica_bounds.origin.x, 10.0);
-        assert_eq!(replica_bounds.origin.y, 20.0);
-        assert_eq!(replica_bounds.size.width, 75.0);
-        assert_eq!(replica_bounds.size.height, 70.0);
-
-        assert_eq!(maybe_controller_bounds.is_some(), true);
-        let controller_bounds = maybe_controller_bounds.expect("expected bounds to be present");
-        assert_eq!(controller_bounds.origin.x, 10.0);
-        assert_eq!(controller_bounds.origin.y, 90.0);
-        assert_eq!(controller_bounds.size.width, 75.0);
-        assert_eq!(controller_bounds.size.height, 10.0);
-    }
-
-    #[test]
-    fn split_bounds_with_no_space_for_controller_hides_controller() {
-        let bounds = Rect::new(Point::new(0.0, 0.0), Size::new(10.0, 10.0));
-
-        let (_replica_bounds, maybe_controller_bounds) = split_bounds(&bounds, 6.0);
-        assert_eq!(maybe_controller_bounds.is_none(), true);
-    }
-
-    #[test]
     fn inset_empty_returns_empty() {
         let empty = Rect::zero();
 
diff --git a/peridot/bin/voila/src/main.rs b/peridot/bin/voila/src/main.rs
index f95ae35..de1f2b4 100644
--- a/peridot/bin/voila/src/main.rs
+++ b/peridot/bin/voila/src/main.rs
@@ -5,7 +5,7 @@
 #![feature(async_await, await_macro, futures_api)]
 
 use carnelian::{
-    set_node_color, App, AppAssistant, Color, Message, Point, ViewAssistant, ViewAssistantContext,
+    set_node_color, App, AppAssistant, Color, ViewAssistant, ViewAssistantContext,
     ViewAssistantPtr, ViewKey,
 };
 use failure::{Error, ResultExt};
@@ -15,7 +15,6 @@
 use fidl_fuchsia_modular_auth::{Account, IdentityProvider};
 use fidl_fuchsia_modular_internal::{SessionContextMarker, SessionmgrMarker};
 use fidl_fuchsia_sys::EnvironmentControllerProxy;
-use fidl_fuchsia_ui_input::PointerEvent;
 use fidl_fuchsia_ui_views::ViewHolderToken;
 use fidl_fuchsia_ui_viewsv1token::ViewOwnerMarker;
 use fuchsia_app::{
@@ -32,16 +31,12 @@
 use std::sync::Arc;
 
 mod layout;
-mod message;
 mod replica;
 mod session_context;
-mod toggle;
 
 use crate::layout::{layout, ChildViewData};
-use crate::message::VoilaMessage;
 use crate::replica::make_replica_env;
 use crate::session_context::SessionContext;
-use crate::toggle::Toggle;
 
 const CLOUD_PROVIDER_URI: &str = fuchsia_single_component_package_url!("cloud_provider_in_memory");
 const ERMINE_URI: &str = fuchsia_single_component_package_url!("ermine");
@@ -69,6 +64,7 @@
     }
 }
 
+#[allow(unused)]
 struct VoilaViewAssistant {
     background_node: ShapeNode,
     circle_node: ShapeNode,
@@ -125,8 +121,7 @@
         host_node.attach(&host_view_holder);
         root_node.add_child(&host_node);
 
-        let view_data = ChildViewData::new(host_node, host_view_holder, Toggle::new(&session)?);
-        root_node.add_child(&view_data.toggle.node());
+        let view_data = ChildViewData::new(host_node, host_view_holder);
         let session_data = ReplicaData {
             environment_ctrl: environment_ctrl,
             sessionmgr_app: app,
@@ -166,6 +161,7 @@
 
 impl ViewAssistant for VoilaViewAssistant {
     fn setup(&mut self, context: &ViewAssistantContext) -> Result<(), Error> {
+        fx_log_info!("setup");
         set_node_color(
             context.session,
             &self.background_node,
@@ -203,41 +199,7 @@
 
         let mut views: Vec<&mut ChildViewData> =
             self.replicas.iter_mut().map(|(_key, child_session)| &mut child_session.view).collect();
-        layout(&mut views, &context.size, &context.session)?;
-        Ok(())
-    }
-
-    fn handle_message(&mut self, message: Message) {
-        if let Some(voila_message) = message.downcast_ref::<VoilaMessage>() {
-            match voila_message {
-                VoilaMessage::ReplicaConnectivityToggled(key) => {
-                    let maybe_replica = self.replicas.get_mut(key);
-                    match maybe_replica {
-                        Some(replica) => replica.view.toggle.toggle(),
-                        None => {
-                            fx_log_warn!("did not find the toggle to toggle");
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    fn handle_pointer_event(
-        &mut self,
-        context: &mut ViewAssistantContext,
-        pointer_event: &PointerEvent,
-    ) -> Result<(), Error> {
-        for (key, child_session) in &mut self.replicas {
-            if child_session
-                .view
-                .toggle
-                .bounds
-                .contains(&Point::new(pointer_event.x, pointer_event.y))
-            {
-                child_session.view.toggle.handle_pointer_event(context, pointer_event, *key);
-            }
-        }
+        layout(&mut views, &context.size)?;
         Ok(())
     }
 }
diff --git a/peridot/bin/voila/src/message.rs b/peridot/bin/voila/src/message.rs
deleted file mode 100644
index ab21888..0000000
--- a/peridot/bin/voila/src/message.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2019 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-pub enum VoilaMessage {
-    ReplicaConnectivityToggled(u32),
-}
diff --git a/peridot/bin/voila/src/toggle.rs b/peridot/bin/voila/src/toggle.rs
deleted file mode 100644
index 22c4aaf..0000000
--- a/peridot/bin/voila/src/toggle.rs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2019 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-use carnelian::{make_message, set_node_color, Color, Point, Rect, ViewAssistantContext};
-use failure::Error;
-use fidl_fuchsia_ui_input::{PointerEvent, PointerEventPhase};
-use fuchsia_scenic::{EntityNode, Rectangle, SessionPtr, ShapeNode};
-
-use crate::message::VoilaMessage;
-
-pub struct Toggle {
-    background_node: ShapeNode,
-    container: EntityNode,
-    pub bounds: Rect,
-    bg_color_on: Color,
-    bg_color_off: Color,
-    is_on: bool,
-}
-
-impl Toggle {
-    pub fn new(session: &SessionPtr) -> Result<Toggle, Error> {
-        let toggle = Toggle {
-            background_node: ShapeNode::new(session.clone()),
-            container: EntityNode::new(session.clone()),
-            bounds: Rect::zero(),
-            bg_color_on: Color::from_hash_code("#00C0DE")?,
-            bg_color_off: Color::from_hash_code("#404040")?,
-            is_on: false,
-        };
-
-        toggle.container.add_child(&toggle.background_node);
-        Ok(toggle)
-    }
-
-    pub fn toggle(&mut self) {
-        self.is_on = !self.is_on;
-    }
-
-    pub fn update(&mut self, bounds: &Rect, session: &SessionPtr) -> Result<(), Error> {
-        self.container.set_translation(
-            bounds.origin.x + (bounds.size.width / 2.0),
-            bounds.origin.y + (bounds.size.height / 2.0),
-            0.0,
-        );
-
-        let color = if self.is_on { self.bg_color_on } else { self.bg_color_off };
-        set_node_color(session, &self.background_node, &color);
-
-        // Record bounds for hit testing.
-        self.bounds = bounds.clone();
-
-        self.background_node.set_shape(&Rectangle::new(
-            session.clone(),
-            self.bounds.size.width,
-            self.bounds.size.height,
-        ));
-
-        Ok(())
-    }
-
-    pub fn node(&self) -> &EntityNode {
-        &self.container
-    }
-
-    pub fn handle_pointer_event(
-        &mut self,
-        context: &mut ViewAssistantContext,
-        pointer_event: &PointerEvent,
-        key: u32,
-    ) {
-        match pointer_event.phase {
-            PointerEventPhase::Down => {}
-            PointerEventPhase::Add => {}
-            PointerEventPhase::Hover => {}
-            PointerEventPhase::Move => {}
-            PointerEventPhase::Up => {
-                if self.bounds.contains(&Point::new(pointer_event.x, pointer_event.y)) {
-                    context
-                        .queue_message(make_message(VoilaMessage::ReplicaConnectivityToggled(key)));
-                }
-            }
-            PointerEventPhase::Remove => {}
-            PointerEventPhase::Cancel => {}
-        }
-    }
-}