| Index: athena/wm/window_manager_impl.cc
|
| diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..39a1d75d236110e024529d3b8b298824007361a4
|
| --- /dev/null
|
| +++ b/athena/wm/window_manager_impl.cc
|
| @@ -0,0 +1,97 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "athena/wm/public/window_manager.h"
|
| +
|
| +#include "athena/screen/public/screen_manager.h"
|
| +#include "base/logging.h"
|
| +#include "ui/aura/layout_manager.h"
|
| +#include "ui/aura/window.h"
|
| +
|
| +namespace athena {
|
| +namespace {
|
| +
|
| +class WindowManagerImpl : public WindowManager {
|
| + public:
|
| + WindowManagerImpl();
|
| + virtual ~WindowManagerImpl();
|
| +
|
| + void Layout();
|
| +
|
| + private:
|
| + aura::Window* container_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
|
| +};
|
| +
|
| +class WindowManagerImpl* instance = NULL;
|
| +
|
| +class AthenaContainerLayoutManager : public aura::LayoutManager {
|
| + public:
|
| + AthenaContainerLayoutManager() {}
|
| + virtual ~AthenaContainerLayoutManager() {}
|
| +
|
| + private:
|
| + // aura::LayoutManager:
|
| + virtual void OnWindowResized() OVERRIDE { instance->Layout(); }
|
| + virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
|
| + instance->Layout();
|
| + }
|
| + virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {}
|
| + virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {
|
| + instance->Layout();
|
| + }
|
| + virtual void OnChildWindowVisibilityChanged(aura::Window* child,
|
| + bool visible) OVERRIDE {
|
| + instance->Layout();
|
| + }
|
| + virtual void SetChildBounds(aura::Window* child,
|
| + const gfx::Rect& requested_bounds) OVERRIDE {
|
| + if (!requested_bounds.IsEmpty())
|
| + SetChildBoundsDirect(child, requested_bounds);
|
| + }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager);
|
| +};
|
| +
|
| +WindowManagerImpl::WindowManagerImpl()
|
| + : container_(ScreenManager::Get()->GetContainerWindow()) {
|
| + container_->SetLayoutManager(new AthenaContainerLayoutManager);
|
| + instance = this;
|
| +}
|
| +
|
| +WindowManagerImpl::~WindowManagerImpl() {
|
| + instance = NULL;
|
| +}
|
| +
|
| +void WindowManagerImpl::Layout() {
|
| + gfx::Rect bounds = gfx::Rect(container_->bounds().size());
|
| + // Just make it small a bit so that the background is visible.
|
| + bounds.Inset(10, 10, 10, 10);
|
| + const aura::Window::Windows& children = container_->children();
|
| + for (aura::Window::Windows::const_iterator iter = children.begin();
|
| + iter != children.end();
|
| + ++iter) {
|
| + (*iter)->SetBounds(bounds);
|
| + }
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +// static
|
| +WindowManager* WindowManager::Create() {
|
| + DCHECK(!instance);
|
| + new WindowManagerImpl;
|
| + DCHECK(instance);
|
| + return instance;
|
| +}
|
| +
|
| +// static
|
| +void WindowManager::Shutdown() {
|
| + DCHECK(instance);
|
| + delete instance;
|
| + DCHECK(!instance);
|
| +}
|
| +
|
| +} // namespace athena
|
|
|