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
3 // found in the LICENSE file.
5 #include "athena/util/fill_layout_manager.h"
7 #include "base/logging.h"
8 #include "ui/aura/window.h"
13 // TODO(oshima): Implement real window/layout manager. crbug.com/388362.
14 bool ShouldFill(aura::Window* window) {
15 return window->type() != ui::wm::WINDOW_TYPE_MENU &&
16 window->type() != ui::wm::WINDOW_TYPE_TOOLTIP &&
17 window->type() != ui::wm::WINDOW_TYPE_POPUP;
22 FillLayoutManager::FillLayoutManager(aura::Window* container)
23 : container_(container) {
27 FillLayoutManager::~FillLayoutManager() {
30 void FillLayoutManager::OnWindowResized() {
31 gfx::Rect full_bounds = gfx::Rect(container_->bounds().size());
32 for (aura::Window::Windows::const_iterator iter =
33 container_->children().begin();
34 iter != container_->children().end();
36 if (ShouldFill(*iter))
37 SetChildBoundsDirect(*iter, full_bounds);
41 void FillLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
42 if (ShouldFill(child))
43 SetChildBoundsDirect(child, (gfx::Rect(container_->bounds().size())));
46 void FillLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
48 void FillLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
50 void FillLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
53 void FillLayoutManager::SetChildBounds(aura::Window* child,
54 const gfx::Rect& requested_bounds) {
55 if (!ShouldFill(child))
56 SetChildBoundsDirect(child, requested_bounds);