From 3acf5a57a0f4a68c45838e21bf928ee6760f8390 Mon Sep 17 00:00:00 2001 From: "oshima@google.com" Date: Thu, 20 Oct 2011 16:24:10 +0000 Subject: LayoutManager controls child bounds. Added SetChildBounds and several listener methods to LayoutManager class. They will be used to implement more sophisticated behavior. Implemented DefaultContainerLayoutManager. Added test_support_aura component so that it can be shared between aura and aura_shell. Fixed component build for aura_shell_unittests BUG=none TEST=default_container_layout_manager_unittests. Review URL: http://codereview.chromium.org/8296002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106508 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/aura_shell/default_container_layout_manager.cc | 67 +++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 ui/aura_shell/default_container_layout_manager.cc (limited to 'ui/aura_shell/default_container_layout_manager.cc') diff --git a/ui/aura_shell/default_container_layout_manager.cc b/ui/aura_shell/default_container_layout_manager.cc new file mode 100644 index 0000000..d3c23c3 --- /dev/null +++ b/ui/aura_shell/default_container_layout_manager.cc @@ -0,0 +1,67 @@ +// Copyright (c) 2011 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 "ui/aura_shell/default_container_layout_manager.h" + +#include "ui/aura/desktop.h" +#include "ui/aura/window.h" +#include "ui/aura/screen_aura.h" +#include "ui/aura/window_types.h" +#include "ui/gfx/rect.h" + +namespace aura_shell { +namespace internal { + +//////////////////////////////////////////////////////////////////////////////// +// DefaultContainerLayoutManager, public: + +DefaultContainerLayoutManager::DefaultContainerLayoutManager( + aura::Window* owner) + : owner_(owner) { +} + +DefaultContainerLayoutManager::~DefaultContainerLayoutManager() {} + +//////////////////////////////////////////////////////////////////////////////// +// DefaultContainerLayoutManager, aura::LayoutManager implementation: + +void DefaultContainerLayoutManager::OnWindowResized() { + aura::Window::Windows::const_iterator i = owner_->children().begin(); + // Use SetBounds because window may be maximized or fullscreen. + for (; i != owner_->children().end(); ++i) + (*i)->SetBounds((*i)->bounds()); + NOTIMPLEMENTED(); +} + +void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { + child->SetBounds(child->bounds()); + NOTIMPLEMENTED(); +} + +void DefaultContainerLayoutManager::OnWillRemoveWindow(aura::Window* child) { + NOTIMPLEMENTED(); +} + +void DefaultContainerLayoutManager::OnChildWindowVisibilityChanged( + aura::Window* window, bool visibile) { + NOTIMPLEMENTED(); +} + +void DefaultContainerLayoutManager::CalculateBoundsForChild( + aura::Window* child, gfx::Rect* requested_bounds) { + if (child->type() != aura::kWindowType_Toplevel) + return; + // TODO(oshima): Figure out bounds for default windows. + gfx::Rect viewport_bounds = owner_->bounds(); + + // A window can still be placed outside of the screen. + requested_bounds->SetRect( + requested_bounds->x(), + viewport_bounds.y(), + std::min(requested_bounds->width(), viewport_bounds.width()), + std::min(requested_bounds->height(), viewport_bounds.height())); +} + +} // namespace internal +} // namespace aura_shell -- cgit v1.1