Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / athena / util / fill_layout_manager.cc
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.
4
5 #include "athena/util/fill_layout_manager.h"
6
7 #include "base/logging.h"
8 #include "ui/aura/window.h"
9
10 namespace athena {
11 namespace {
12
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;
18 }
19
20 }  // namespace
21
22 FillLayoutManager::FillLayoutManager(aura::Window* container)
23     : container_(container) {
24   DCHECK(container_);
25 }
26
27 FillLayoutManager::~FillLayoutManager() {
28 }
29
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();
35        ++iter) {
36     if (ShouldFill(*iter))
37       SetChildBoundsDirect(*iter, full_bounds);
38   }
39 }
40
41 void FillLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
42   if (ShouldFill(child))
43     SetChildBoundsDirect(child, (gfx::Rect(container_->bounds().size())));
44 }
45
46 void FillLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
47 }
48 void FillLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
49 }
50 void FillLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
51                                                        bool visible) {
52 }
53 void FillLayoutManager::SetChildBounds(aura::Window* child,
54                                        const gfx::Rect& requested_bounds) {
55   if (!ShouldFill(child))
56     SetChildBoundsDirect(child, requested_bounds);
57 }
58
59 }  // namespace athena