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

Side by Side Diff: athena/util/fill_layout_manager.cc

Issue 697143005: Fills athena background always. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: visibility changed Created 6 years, 1 month 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
« no previous file with comments | « athena/util/fill_layout_manager.h ('k') | athena/util/fill_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/util/fill_layout_manager.h" 5 #include "athena/util/fill_layout_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 #include "ui/aura/window_property.h"
10
11 // This is to avoid creating type definitoin for kAlwaysFillWindowKey.
12 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ATHENA_EXPORT, bool);
9 13
10 namespace athena { 14 namespace athena {
11 namespace { 15 namespace {
12 16
17 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(bool, kAlwaysFillWindowKey, false);
18
13 // TODO(oshima): Implement real window/layout manager. crbug.com/388362. 19 // TODO(oshima): Implement real window/layout manager. crbug.com/388362.
14 bool ShouldFill(aura::Window* window) { 20 bool ShouldFill(aura::Window* window) {
15 return window->type() != ui::wm::WINDOW_TYPE_MENU && 21 return window->GetProperty(kAlwaysFillWindowKey) ||
16 window->type() != ui::wm::WINDOW_TYPE_TOOLTIP && 22 (window->type() != ui::wm::WINDOW_TYPE_MENU &&
17 window->type() != ui::wm::WINDOW_TYPE_POPUP; 23 window->type() != ui::wm::WINDOW_TYPE_TOOLTIP &&
24 window->type() != ui::wm::WINDOW_TYPE_POPUP);
18 } 25 }
19 26
20 } // namespace 27 } // namespace
21 28
29 // static
30 void FillLayoutManager::SetAlwaysFill(aura::Window* window) {
31 window->SetProperty(kAlwaysFillWindowKey, true);
32 }
33
22 FillLayoutManager::FillLayoutManager(aura::Window* container) 34 FillLayoutManager::FillLayoutManager(aura::Window* container)
23 : container_(container) { 35 : container_(container) {
24 DCHECK(container_); 36 DCHECK(container_);
25 } 37 }
26 38
27 FillLayoutManager::~FillLayoutManager() { 39 FillLayoutManager::~FillLayoutManager() {
28 } 40 }
29 41
30 void FillLayoutManager::OnWindowResized() { 42 void FillLayoutManager::OnWindowResized() {
31 gfx::Rect full_bounds = gfx::Rect(container_->bounds().size()); 43 gfx::Rect full_bounds = gfx::Rect(container_->bounds().size());
32 for (aura::Window::Windows::const_iterator iter = 44 for (aura::Window::Windows::const_iterator iter =
33 container_->children().begin(); 45 container_->children().begin();
34 iter != container_->children().end(); 46 iter != container_->children().end();
35 ++iter) { 47 ++iter) {
36 if (ShouldFill(*iter)) 48 if (ShouldFill(*iter))
37 SetChildBoundsDirect(*iter, full_bounds); 49 SetChildBoundsDirect(*iter, full_bounds);
38 } 50 }
39 } 51 }
40 52
41 void FillLayoutManager::OnWindowAddedToLayout(aura::Window* child) { 53 void FillLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
42 if (ShouldFill(child)) 54 if (ShouldFill(child))
43 SetChildBoundsDirect(child, (gfx::Rect(container_->bounds().size()))); 55 SetChildBoundsDirect(child, gfx::Rect(container_->bounds().size()));
44 } 56 }
45 57
46 void FillLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { 58 void FillLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
47 } 59 }
60
48 void FillLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { 61 void FillLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
49 } 62 }
63
50 void FillLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, 64 void FillLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
51 bool visible) { 65 bool visible) {
66 if (visible && ShouldFill(child))
67 SetChildBoundsDirect(child, gfx::Rect(container_->bounds().size()));
52 } 68 }
69
53 void FillLayoutManager::SetChildBounds(aura::Window* child, 70 void FillLayoutManager::SetChildBounds(aura::Window* child,
54 const gfx::Rect& requested_bounds) { 71 const gfx::Rect& requested_bounds) {
55 if (!ShouldFill(child)) 72 if (!ShouldFill(child))
56 SetChildBoundsDirect(child, requested_bounds); 73 SetChildBoundsDirect(child, requested_bounds);
57 } 74 }
58 75
59 } // namespace athena 76 } // namespace athena
OLDNEW
« no previous file with comments | « athena/util/fill_layout_manager.h ('k') | athena/util/fill_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698