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

Side by Side Diff: athena/wm/window_manager_impl.cc

Issue 287253003: Add initial home card impl. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "athena/wm/public/window_manager.h" 5 #include "athena/wm/public/window_manager.h"
6 6
7 #include "athena/screen/public/screen_manager.h" 7 #include "athena/screen/public/screen_manager.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/aura/layout_manager.h" 9 #include "ui/aura/layout_manager.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 11
12 namespace athena { 12 namespace athena {
13 namespace { 13 namespace {
14 14
15 class WindowManagerImpl : public WindowManager { 15 class WindowManagerImpl : public WindowManager,
16 public aura::WindowObserver {
16 public: 17 public:
17 WindowManagerImpl(); 18 WindowManagerImpl();
18 virtual ~WindowManagerImpl(); 19 virtual ~WindowManagerImpl();
19 20
20 void Layout(); 21 void Layout();
21 22
22 private: 23 private:
24 // aura::WindowObserver
25 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
26 if (window == container_)
27 container_ = NULL;
28 }
29
23 aura::Window* container_; 30 aura::Window* container_;
24 31
25 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 32 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
26 }; 33 };
27 34
28 class WindowManagerImpl* instance = NULL; 35 class WindowManagerImpl* instance = NULL;
29 36
30 class AthenaContainerLayoutManager : public aura::LayoutManager { 37 class AthenaContainerLayoutManager : public aura::LayoutManager {
31 public: 38 public:
32 AthenaContainerLayoutManager() {} 39 AthenaContainerLayoutManager() {}
33 virtual ~AthenaContainerLayoutManager() {} 40 virtual ~AthenaContainerLayoutManager() {}
34 41
35 private: 42 private:
36 // aura::LayoutManager: 43 // aura::LayoutManager:
37 virtual void OnWindowResized() OVERRIDE { instance->Layout(); } 44 virtual void OnWindowResized() OVERRIDE { instance->Layout(); }
38 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { 45 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
39 instance->Layout(); 46 instance->Layout();
40 } 47 }
41 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} 48 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {}
42 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE { 49 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {
43 instance->Layout(); 50 // TODO(oshima): Delete root window after athena is cleaned up.
Albert Bodenhamer 2014/05/22 19:22:02 File a bug to track the TODO so it doesn't get los
oshima 2014/05/22 21:23:05 The comment wasn't correct. If fixed the root caus
51 if (instance)
52 instance->Layout();
44 } 53 }
45 virtual void OnChildWindowVisibilityChanged(aura::Window* child, 54 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
46 bool visible) OVERRIDE { 55 bool visible) OVERRIDE {
47 instance->Layout(); 56 instance->Layout();
48 } 57 }
49 virtual void SetChildBounds(aura::Window* child, 58 virtual void SetChildBounds(aura::Window* child,
50 const gfx::Rect& requested_bounds) OVERRIDE { 59 const gfx::Rect& requested_bounds) OVERRIDE {
51 if (!requested_bounds.IsEmpty()) 60 if (!requested_bounds.IsEmpty())
52 SetChildBoundsDirect(child, requested_bounds); 61 SetChildBoundsDirect(child, requested_bounds);
53 } 62 }
54 63
55 DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager); 64 DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager);
56 }; 65 };
57 66
58 WindowManagerImpl::WindowManagerImpl() 67 WindowManagerImpl::WindowManagerImpl()
59 : container_(ScreenManager::Get()->GetContainerWindow()) { 68 : container_(
69 ScreenManager::Get()->CreateDefaultContainer("MainConttainer")) {
Mr4D (OOO till 08-26) 2014/05/22 20:53:28 tt -> t
oshima 2014/05/22 21:23:05 Done.
60 container_->SetLayoutManager(new AthenaContainerLayoutManager); 70 container_->SetLayoutManager(new AthenaContainerLayoutManager);
71 container_->AddObserver(this);
61 instance = this; 72 instance = this;
62 } 73 }
63 74
64 WindowManagerImpl::~WindowManagerImpl() { 75 WindowManagerImpl::~WindowManagerImpl() {
76 if (container_)
77 container_->RemoveObserver(this);
65 instance = NULL; 78 instance = NULL;
66 } 79 }
67 80
68 void WindowManagerImpl::Layout() { 81 void WindowManagerImpl::Layout() {
82 if (!container_)
83 return;
69 gfx::Rect bounds = gfx::Rect(container_->bounds().size()); 84 gfx::Rect bounds = gfx::Rect(container_->bounds().size());
70 // Just make it small a bit so that the background is visible. 85 // Just make it small a bit so that the background is visible.
71 bounds.Inset(10, 10, 10, 10); 86 bounds.Inset(10, 10, 10, 10);
72 const aura::Window::Windows& children = container_->children(); 87 const aura::Window::Windows& children = container_->children();
73 for (aura::Window::Windows::const_iterator iter = children.begin(); 88 for (aura::Window::Windows::const_iterator iter = children.begin();
74 iter != children.end(); 89 iter != children.end();
75 ++iter) { 90 ++iter) {
76 (*iter)->SetBounds(bounds); 91 (*iter)->SetBounds(bounds);
77 } 92 }
78 } 93 }
79 94
80 } // namespace 95 } // namespace
81 96
82 // static 97 // static
83 WindowManager* WindowManager::Create() { 98 WindowManager* WindowManager::Create() {
84 DCHECK(!instance); 99 DCHECK(!instance);
85 new WindowManagerImpl; 100 new WindowManagerImpl;
86 DCHECK(instance); 101 DCHECK(instance);
87 return instance; 102 return instance;
88 } 103 }
89 104
90 // static 105 // static
91 void WindowManager::Shutdown() { 106 void WindowManager::Shutdown() {
92 DCHECK(instance); 107 DCHECK(instance);
93 delete instance; 108 delete instance;
94 DCHECK(!instance); 109 DCHECK(!instance);
95 } 110 }
96 111
97 } // namespace athena 112 } // namespace athena
OLDNEW
« athena/main/placeholder.cc ('K') | « athena/screen/screen_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698