diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 22:47:50 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 22:47:50 +0000 |
commit | b1b155519ce57a29f336a248080b4e5c61c8a10a (patch) | |
tree | 57d87f20660354f0a24cbb3be362d0a23cf72b26 /aura/window.cc | |
parent | deb02d935d80c1b30d43575378714585a554d7ad (diff) | |
download | chromium_src-b1b155519ce57a29f336a248080b4e5c61c8a10a.zip chromium_src-b1b155519ce57a29f336a248080b4e5c61c8a10a.tar.gz chromium_src-b1b155519ce57a29f336a248080b4e5c61c8a10a.tar.bz2 |
Add support for child Windows to the Aura WM library.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7670075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'aura/window.cc')
-rw-r--r-- | aura/window.cc | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/aura/window.cc b/aura/window.cc index 7725ffc..2d63d80 100644 --- a/aura/window.cc +++ b/aura/window.cc @@ -4,8 +4,11 @@ #include "aura/window.h" +#include <algorithm> + #include "aura/desktop.h" #include "aura/window_delegate.h" +#include "base/logging.h" #include "third_party/skia/include/core/SkCanvas.h" #include "ui/gfx/compositor/compositor.h" #include "ui/gfx/compositor/layer.h" @@ -14,12 +17,12 @@ namespace aura { // TODO: do we need to support child windows? Window::Window(Desktop* desktop) - : desktop_(desktop), - delegate_(NULL), + : delegate_(NULL), visibility_(VISIBILITY_HIDDEN), - // TODO: Need to make layers lazily create the texture. layer_(new ui::Layer(desktop->compositor())), - needs_paint_all_(true) { + needs_paint_all_(true), + parent_(NULL), + id_(-1) { } Window::~Window() { @@ -30,13 +33,6 @@ void Window::SetVisibility(Visibility visibility) { return; visibility_ = visibility; - if (visibility_ == VISIBILITY_SHOWN) { - // TODO: move to top of window stack? - desktop_->AddWindow(this); - } else { - // TODO: hide? - desktop_->RemoveWindow(this); - } } void Window::SetBounds(const gfx::Rect& bounds, int anim_ms) { @@ -61,9 +57,29 @@ void Window::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) { layer_->SetCanvas(canvas, origin); } -void Window::Draw() { - if (visibility_ != VISIBILITY_HIDDEN) - layer_->Draw(); +void Window::DrawTree() { + UpdateLayerCanvas(); + Draw(); + + // First pass updates the layer bitmaps. + for (Windows::iterator i = children_.begin(); i != children_.end(); ++i) + (*i)->DrawTree(); +} + +void Window::AddChild(Window* child) { + DCHECK(std::find(children_.begin(), children_.end(), child) == + children_.end()); + child->parent_ = this; + layer_->Add(child->layer_.get()); + children_.push_back(child); +} + +void Window::RemoveChild(Window* child) { + Windows::iterator i = std::find(children_.begin(), children_.end(), child); + DCHECK(i != children_.end()); + child->parent_ = NULL; + layer_->Remove(child->layer_.get()); + children_.erase(i); } void Window::UpdateLayerCanvas() { @@ -80,4 +96,9 @@ void Window::UpdateLayerCanvas() { delegate_->OnPaint(dirty_rect); } +void Window::Draw() { + if (visibility_ != VISIBILITY_HIDDEN) + layer_->Draw(); +} + } // namespace aura |