Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: athena/wm/window_manager_impl.cc

Issue 287163009: [Athena] minimum impl to add screen/background and test windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/wm/public/window_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « athena/wm/public/window_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698