Window * ContainerWindow::event_child_at(int x, int y) { if (capture) return NULL; else if (capture_child != NULL) return capture_child; else return child_at(x, y); }
// Overridden from view::View: virtual void Layout() { views::View::Layout(); for(int i=0; i<child_count(); ++i) { AppView* child = static_cast<AppView*>(child_at(i)); child->SaveBounds(); } }
bool ContainerWindow::on_mouse_up(int x, int y) { Window *child = child_at(x, y); if (child != NULL) { child->on_mouse_up(x - child->get_left(), y - child->get_top()); return true; } return PaintWindow::on_mouse_up(x, y); }
bool ContainerWindow::on_mouse_move(int x, int y, unsigned keys) { Window *child = child_at(x, y); if (child != NULL) { child->on_mouse_move(x - child->get_left(), y - child->get_top(), keys); return true; } return PaintWindow::on_mouse_move(x, y, keys); }
// Overridden from view::BoundsAnimatorObserver: virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) { DCHECK(animator == &bounds_animator_); if(show_) { for(int i=0; i<child_count(); ++i) { AppView* child = static_cast<AppView*>(child_at(i)); child->SaveBounds(); } } }
Window * ContainerWindow::event_child_at(int x, int y) { if (capture) /* if this window is capturing the mouse, events must go exactly here */ return NULL; else if (capture_child != NULL) /* all mouse events go to the capturing child */ return capture_child; else /* find the child window at the specified position */ return child_at(x, y); }
void AppContainer::DoAnimate() { show_ = !show_; for(int i=0; i<child_count(); ++i) { AppView* child = static_cast<AppView*>(child_at(i)); if(show_) { bounds_animator_.AnimateViewTo(child, child->GetSaveBounds()); } else { gfx::Point target_orign(-child->width(), -child->height()); gfx::Rect layout_rect = child->bounds(); gfx::Point app_view_center = layout_rect.CenterPoint(); gfx::Point view_center = GetLocalBounds().CenterPoint(); if(app_view_center.x() >= view_center.x() && app_view_center.y() <= view_center.y()) { target_orign.set_x(GetLocalBounds().right()); } else if(app_view_center.x() <= view_center.x() && app_view_center.y() >= view_center.y()) { target_orign.set_y(GetLocalBounds().bottom()); } else if(app_view_center.x() >= view_center.x() && app_view_center.y() >= view_center.y()) { target_orign.set_x(GetLocalBounds().right()); target_orign.set_y(GetLocalBounds().bottom()); } bounds_animator_.AnimateViewTo(child, gfx::Rect(target_orign, child->size())); } } }
const TreeNode& childAt(int index) const { return child_at(m_children, index); }