summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 20:37:00 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 20:37:00 +0000
commit86f2b5e1870debcf167d3a9c8901541db279406b (patch)
tree4f828329ad8b07293370402e7d76457af7a714c4 /ash
parent31882ba1222e0f89e2712d174879dacd4525e64c (diff)
downloadchromium_src-86f2b5e1870debcf167d3a9c8901541db279406b.zip
chromium_src-86f2b5e1870debcf167d3a9c8901541db279406b.tar.gz
chromium_src-86f2b5e1870debcf167d3a9c8901541db279406b.tar.bz2
Move shadow code to views\corewm
http://crbug.com/158115 R=derat@chromium.org Review URL: https://codereview.chromium.org/11275296 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp10
-rw-r--r--ash/dip_unittest.cc6
-rw-r--r--ash/drag_drop/drag_image_view.cc4
-rw-r--r--ash/shell.cc5
-rw-r--r--ash/shell.h6
-rw-r--r--ash/shell/window_type_launcher.cc6
-rw-r--r--ash/wm/image_grid.cc284
-rw-r--r--ash/wm/image_grid.h218
-rw-r--r--ash/wm/image_grid_unittest.cc342
-rw-r--r--ash/wm/resize_shadow.cc4
-rw-r--r--ash/wm/resize_shadow.h9
-rw-r--r--ash/wm/shadow.cc176
-rw-r--r--ash/wm/shadow.h84
-rw-r--r--ash/wm/shadow_controller.cc169
-rw-r--r--ash/wm/shadow_controller.h104
-rw-r--r--ash/wm/shadow_controller_unittest.cc191
-rw-r--r--ash/wm/shadow_types.cc22
-rw-r--r--ash/wm/shadow_types.h31
-rw-r--r--ash/wm/window_properties.cc3
-rw-r--r--ash/wm/window_properties.h5
-rw-r--r--ash/wm/workspace/phantom_window_controller.cc5
21 files changed, 25 insertions, 1659 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index ce847a8..f7b9b55 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -305,8 +305,6 @@
'wm/gestures/two_finger_drag_handler.h',
'wm/image_cursors.cc',
'wm/image_cursors.h',
- 'wm/image_grid.cc',
- 'wm/image_grid.h',
'wm/maximize_bubble_controller.cc',
'wm/maximize_bubble_controller.h',
'wm/overlay_event_filter.cc',
@@ -339,12 +337,6 @@
'wm/session_state_controller_impl.h',
'wm/session_state_controller_impl2.cc',
'wm/session_state_controller_impl2.h',
- 'wm/shadow.cc',
- 'wm/shadow.h',
- 'wm/shadow_controller.cc',
- 'wm/shadow_controller.h',
- 'wm/shadow_types.cc',
- 'wm/shadow_types.h',
'wm/shelf_layout_manager.cc',
'wm/shelf_layout_manager.h',
'wm/shelf_types.h',
@@ -562,11 +554,9 @@
'wm/cursor_manager_unittest.cc',
'wm/custom_frame_view_ash_unittest.cc',
'wm/frame_painter_unittest.cc',
- 'wm/image_grid_unittest.cc',
'wm/panel_layout_manager_unittest.cc',
'wm/power_button_controller_unittest.cc',
'wm/screen_dimmer_unittest.cc',
- 'wm/shadow_controller_unittest.cc',
'wm/shelf_layout_manager_unittest.cc',
'wm/system_gesture_event_filter_unittest.cc',
'wm/system_modal_container_layout_manager_unittest.cc',
diff --git a/ash/dip_unittest.cc b/ash/dip_unittest.cc
index 8ac0adb..84b230d 100644
--- a/ash/dip_unittest.cc
+++ b/ash/dip_unittest.cc
@@ -8,9 +8,6 @@
#include "ash/launcher/launcher.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
-#include "ash/wm/shadow.h"
-#include "ash/wm/shadow_controller.h"
-#include "ash/wm/shadow_types.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "base/memory/scoped_ptr.h"
@@ -21,6 +18,9 @@
#include "ui/gfx/display.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/screen.h"
+#include "ui/views/corewm/shadow.h"
+#include "ui/views/corewm/shadow_controller.h"
+#include "ui/views/corewm/shadow_types.h"
#include "ui/views/widget/widget.h"
namespace ash {
diff --git a/ash/drag_drop/drag_image_view.cc b/ash/drag_drop/drag_image_view.cc
index b6a32f8..6490d6f 100644
--- a/ash/drag_drop/drag_image_view.cc
+++ b/ash/drag_drop/drag_image_view.cc
@@ -4,8 +4,8 @@
#include "ash/drag_drop/drag_image_view.h"
-#include "ash/wm/shadow_types.h"
#include "ui/aura/window.h"
+#include "ui/views/corewm/shadow_types.h"
#include "ui/views/widget/widget.h"
namespace ash {
@@ -25,7 +25,7 @@ Widget* CreateDragWidget() {
drag_widget->Init(params);
drag_widget->SetOpacity(0xFF);
drag_widget->GetNativeWindow()->set_owned_by_parent(false);
- SetShadowType(drag_widget->GetNativeView(), SHADOW_TYPE_NONE);
+ SetShadowType(drag_widget->GetNativeView(), views::corewm::SHADOW_TYPE_NONE);
return drag_widget;
}
}
diff --git a/ash/shell.cc b/ash/shell.cc
index 623df98..078305c 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -51,7 +51,6 @@
#include "ash/wm/session_state_controller.h"
#include "ash/wm/session_state_controller_impl.h"
#include "ash/wm/session_state_controller_impl2.h"
-#include "ash/wm/shadow_controller.h"
#include "ash/wm/stacking_controller.h"
#include "ash/wm/system_gesture_event_filter.h"
#include "ash/wm/system_modal_container_event_filter.h"
@@ -85,6 +84,7 @@
#include "ui/ui_controls/ui_controls.h"
#include "ui/views/corewm/compound_event_filter.h"
#include "ui/views/corewm/input_method_event_filter.h"
+#include "ui/views/corewm/shadow_controller.h"
#include "ui/views/focus/focus_manager_factory.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/views/widget/widget.h"
@@ -505,7 +505,8 @@ void Shell::Init() {
if (!command_line->HasSwitch(switches::kAuraNoShadows)) {
resize_shadow_controller_.reset(new internal::ResizeShadowController());
- shadow_controller_.reset(new internal::ShadowController());
+ shadow_controller_.reset(
+ new views::corewm::ShadowController(GetPrimaryRootWindow()));
}
// Create system_tray_notifier_ before the delegate.
diff --git a/ash/shell.h b/ash/shell.h
index 38fd7e7..7c0c281 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -56,6 +56,7 @@ class Widget;
namespace corewm {
class CompoundEventFilter;
class InputMethodEventFilter;
+class ShadowController;
}
}
@@ -101,7 +102,6 @@ class ResizeShadowController;
class RootWindowController;
class RootWindowLayoutManager;
class ScreenPositionController;
-class ShadowController;
class SlowAnimationEventFilter;
class StatusAreaWidget;
class SystemGestureEventFilter;
@@ -391,7 +391,7 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate,
}
// Made available for tests.
- internal::ShadowController* shadow_controller() {
+ views::corewm::ShadowController* shadow_controller() {
return shadow_controller_.get();
}
@@ -482,7 +482,7 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate,
scoped_ptr<internal::WindowModalityController> window_modality_controller_;
scoped_ptr<internal::DragDropController> drag_drop_controller_;
scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
- scoped_ptr<internal::ShadowController> shadow_controller_;
+ scoped_ptr<views::corewm::ShadowController> shadow_controller_;
scoped_ptr<internal::TooltipController> tooltip_controller_;
scoped_ptr<internal::VisibilityController> visibility_controller_;
scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc
index cd18e27..fe357ee 100644
--- a/ash/shell/window_type_launcher.cc
+++ b/ash/shell/window_type_launcher.cc
@@ -14,7 +14,6 @@
#include "ash/shell_window_ids.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/web_notification/web_notification_tray.h"
-#include "ash/wm/shadow_types.h"
#include "base/bind.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
@@ -26,6 +25,7 @@
#include "ui/views/controls/button/text_button.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_runner.h"
+#include "ui/views/corewm/shadow_types.h"
#include "ui/views/examples/examples_window_with_content.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.h"
@@ -185,8 +185,8 @@ void InitWindowTypeLauncher() {
views::Widget::CreateWindowWithBounds(new WindowTypeLauncher,
gfx::Rect(120, 150, 300, 410));
widget->GetNativeView()->SetName("WindowTypeLauncher");
- ash::internal::SetShadowType(widget->GetNativeView(),
- ash::internal::SHADOW_TYPE_RECTANGULAR);
+ views::corewm::SetShadowType(widget->GetNativeView(),
+ views::corewm::SHADOW_TYPE_RECTANGULAR);
widget->Show();
}
diff --git a/ash/wm/image_grid.cc b/ash/wm/image_grid.cc
deleted file mode 100644
index 369ab82..0000000
--- a/ash/wm/image_grid.cc
+++ /dev/null
@@ -1,284 +0,0 @@
-// Copyright (c) 2012 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 "ash/wm/image_grid.h"
-
-#include <algorithm>
-
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkXfermode.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/rect_conversions.h"
-#include "ui/gfx/transform.h"
-
-using std::max;
-using std::min;
-
-namespace ash {
-namespace internal {
-
-gfx::RectF ImageGrid::TestAPI::GetTransformedLayerBounds(
- const ui::Layer& layer) {
- gfx::RectF bounds = layer.bounds();
- layer.transform().TransformRect(&bounds);
- return bounds;
-}
-
-ImageGrid::ImageGrid()
- : layer_(new ui::Layer(ui::LAYER_NOT_DRAWN)),
- top_image_height_(0),
- bottom_image_height_(0),
- left_image_width_(0),
- right_image_width_(0),
- base_top_row_height_(0),
- base_bottom_row_height_(0),
- base_left_column_width_(0),
- base_right_column_width_(0) {
-}
-
-ImageGrid::~ImageGrid() {
-}
-
-void ImageGrid::SetImages(const gfx::Image* top_left_image,
- const gfx::Image* top_image,
- const gfx::Image* top_right_image,
- const gfx::Image* left_image,
- const gfx::Image* center_image,
- const gfx::Image* right_image,
- const gfx::Image* bottom_left_image,
- const gfx::Image* bottom_image,
- const gfx::Image* bottom_right_image) {
- SetImage(top_left_image, &top_left_layer_, &top_left_painter_);
- SetImage(top_image, &top_layer_, &top_painter_);
- SetImage(top_right_image, &top_right_layer_, &top_right_painter_);
- SetImage(left_image, &left_layer_, &left_painter_);
- SetImage(center_image, &center_layer_, &center_painter_);
- SetImage(right_image, &right_layer_, &right_painter_);
- SetImage(bottom_left_image, &bottom_left_layer_, &bottom_left_painter_);
- SetImage(bottom_image, &bottom_layer_, &bottom_painter_);
- SetImage(bottom_right_image, &bottom_right_layer_, &bottom_right_painter_);
-
- top_image_height_ = GetImageSize(top_image).height();
- bottom_image_height_ = GetImageSize(bottom_image).height();
- left_image_width_ = GetImageSize(left_image).width();
- right_image_width_ = GetImageSize(right_image).width();
-
- base_top_row_height_ = max(GetImageSize(top_left_image).height(),
- max(GetImageSize(top_image).height(),
- GetImageSize(top_right_image).height()));
- base_bottom_row_height_ = max(GetImageSize(bottom_left_image).height(),
- max(GetImageSize(bottom_image).height(),
- GetImageSize(bottom_right_image).height()));
- base_left_column_width_ = max(GetImageSize(top_left_image).width(),
- max(GetImageSize(left_image).width(),
- GetImageSize(bottom_left_image).width()));
- base_right_column_width_ = max(GetImageSize(top_right_image).width(),
- max(GetImageSize(right_image).width(),
- GetImageSize(bottom_right_image).width()));
-
- // Invalidate previous |size_| so calls to SetSize() will recompute it.
- size_.SetSize(0, 0);
-}
-
-void ImageGrid::SetSize(const gfx::Size& size) {
- if (size_ == size)
- return;
-
- size_ = size;
-
- gfx::Rect updated_bounds = layer_->bounds();
- updated_bounds.set_size(size);
- layer_->SetBounds(updated_bounds);
-
- // Calculate the available amount of space for corner images on all sides of
- // the grid. If the images don't fit, we need to clip them.
- const int left = min(base_left_column_width_, size_.width() / 2);
- const int right = min(base_right_column_width_, size_.width() - left);
- const int top = min(base_top_row_height_, size_.height() / 2);
- const int bottom = min(base_bottom_row_height_, size_.height() - top);
-
- // The remaining space goes to the center image.
- int center_width = std::max(size.width() - left - right, 0);
- int center_height = std::max(size.height() - top - bottom, 0);
-
- if (top_layer_.get()) {
- if (center_width > 0) {
- gfx::Transform transform;
- transform.SetScaleX(
- static_cast<float>(center_width) / top_layer_->bounds().width());
- transform.ConcatTranslate(left, 0);
- top_layer_->SetTransform(transform);
- }
- top_layer_->SetVisible(center_width > 0);
- }
- if (bottom_layer_.get()) {
- if (center_width > 0) {
- gfx::Transform transform;
- transform.SetScaleX(
- static_cast<float>(center_width) / bottom_layer_->bounds().width());
- transform.ConcatTranslate(
- left, size.height() - bottom_layer_->bounds().height());
- bottom_layer_->SetTransform(transform);
- }
- bottom_layer_->SetVisible(center_width > 0);
- }
- if (left_layer_.get()) {
- if (center_height > 0) {
- gfx::Transform transform;
- transform.SetScaleY(
- (static_cast<float>(center_height) / left_layer_->bounds().height()));
- transform.ConcatTranslate(0, top);
- left_layer_->SetTransform(transform);
- }
- left_layer_->SetVisible(center_height > 0);
- }
- if (right_layer_.get()) {
- if (center_height > 0) {
- gfx::Transform transform;
- transform.SetScaleY(
- static_cast<float>(center_height) / right_layer_->bounds().height());
- transform.ConcatTranslate(
- size.width() - right_layer_->bounds().width(), top);
- right_layer_->SetTransform(transform);
- }
- right_layer_->SetVisible(center_height > 0);
- }
-
- if (top_left_layer_.get()) {
- // No transformation needed; it should be at (0, 0) and unscaled.
- top_left_painter_->SetClipRect(
- LayerExceedsSize(top_left_layer_.get(), gfx::Size(left, top)) ?
- gfx::Rect(gfx::Rect(0, 0, left, top)) :
- gfx::Rect(),
- top_left_layer_.get());
- }
- if (top_right_layer_.get()) {
- gfx::Transform transform;
- transform.SetTranslateX(size.width() - top_right_layer_->bounds().width());
- top_right_layer_->SetTransform(transform);
- top_right_painter_->SetClipRect(
- LayerExceedsSize(top_right_layer_.get(), gfx::Size(right, top)) ?
- gfx::Rect(top_right_layer_->bounds().width() - right, 0,
- right, top) :
- gfx::Rect(),
- top_right_layer_.get());
- }
- if (bottom_left_layer_.get()) {
- gfx::Transform transform;
- transform.SetTranslateY(
- size.height() - bottom_left_layer_->bounds().height());
- bottom_left_layer_->SetTransform(transform);
- bottom_left_painter_->SetClipRect(
- LayerExceedsSize(bottom_left_layer_.get(), gfx::Size(left, bottom)) ?
- gfx::Rect(0, bottom_left_layer_->bounds().height() - bottom,
- left, bottom) :
- gfx::Rect(),
- bottom_left_layer_.get());
- }
- if (bottom_right_layer_.get()) {
- gfx::Transform transform;
- transform.SetTranslate(
- size.width() - bottom_right_layer_->bounds().width(),
- size.height() - bottom_right_layer_->bounds().height());
- bottom_right_layer_->SetTransform(transform);
- bottom_right_painter_->SetClipRect(
- LayerExceedsSize(bottom_right_layer_.get(), gfx::Size(right, bottom)) ?
- gfx::Rect(bottom_right_layer_->bounds().width() - right,
- bottom_right_layer_->bounds().height() - bottom,
- right, bottom) :
- gfx::Rect(),
- bottom_right_layer_.get());
- }
-
- if (center_layer_.get()) {
- if (center_width > 0 && center_height > 0) {
- gfx::Transform transform;
- transform.SetScale(center_width / center_layer_->bounds().width(),
- center_height / center_layer_->bounds().height());
- transform.ConcatTranslate(left, top);
- center_layer_->SetTransform(transform);
- }
- center_layer_->SetVisible(center_width > 0 && center_height > 0);
- }
-}
-
-void ImageGrid::SetContentBounds(const gfx::Rect& content_bounds) {
- SetSize(gfx::Size(
- content_bounds.width() + left_image_width_ + right_image_width_,
- content_bounds.height() + top_image_height_ +
- bottom_image_height_));
- layer_->SetBounds(
- gfx::Rect(content_bounds.x() - left_image_width_,
- content_bounds.y() - top_image_height_,
- layer_->bounds().width(),
- layer_->bounds().height()));
-}
-
-void ImageGrid::ImagePainter::SetClipRect(const gfx::Rect& clip_rect,
- ui::Layer* layer) {
- if (clip_rect != clip_rect_) {
- clip_rect_ = clip_rect;
- layer->SchedulePaint(layer->bounds());
- }
-}
-
-void ImageGrid::ImagePainter::OnPaintLayer(gfx::Canvas* canvas) {
- if (!clip_rect_.IsEmpty())
- canvas->ClipRect(clip_rect_);
- canvas->DrawImageInt(*(image_->ToImageSkia()), 0, 0);
-}
-
-void ImageGrid::ImagePainter::OnDeviceScaleFactorChanged(
- float device_scale_factor) {
- // Redrawing will take care of scale factor change.
-}
-
-base::Closure ImageGrid::ImagePainter::PrepareForLayerBoundsChange() {
- return base::Closure();
-}
-
-// static
-gfx::Size ImageGrid::GetImageSize(const gfx::Image* image) {
- return image ?
- gfx::Size(image->ToImageSkia()->width(), image->ToImageSkia()->height()) :
- gfx::Size();
-}
-
-// static
-bool ImageGrid::LayerExceedsSize(const ui::Layer* layer,
- const gfx::Size& size) {
- return layer->bounds().width() > size.width() ||
- layer->bounds().height() > size.height();
-}
-
-void ImageGrid::SetImage(const gfx::Image* image,
- scoped_ptr<ui::Layer>* layer_ptr,
- scoped_ptr<ImagePainter>* painter_ptr) {
- // Clean out old layers and painters.
- if (layer_ptr->get())
- layer_->Remove(layer_ptr->get());
- layer_ptr->reset();
- painter_ptr->reset();
-
- // If we're not using an image, we're done.
- if (!image)
- return;
-
- // Set up the new layer and painter.
- layer_ptr->reset(new ui::Layer(ui::LAYER_TEXTURED));
-
- const gfx::Size size = GetImageSize(image);
- layer_ptr->get()->SetBounds(gfx::Rect(0, 0, size.width(), size.height()));
-
- painter_ptr->reset(new ImagePainter(image));
- layer_ptr->get()->set_delegate(painter_ptr->get());
- layer_ptr->get()->SetFillsBoundsOpaquely(false);
- layer_ptr->get()->SetVisible(true);
- layer_->Add(layer_ptr->get());
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/image_grid.h b/ash/wm/image_grid.h
deleted file mode 100644
index cb3b7bb..0000000
--- a/ash/wm/image_grid.h
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_WM_IMAGE_GRID_H_
-#define ASH_WM_IMAGE_GRID_H_
-
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
-#include "ui/compositor/layer.h"
-#include "ui/compositor/layer_delegate.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/size.h"
-
-namespace gfx {
-class Image;
-} // namespace gfx
-
-namespace ash {
-namespace internal {
-
-// An ImageGrid is a 3x3 array of ui::Layers, each containing an image.
-//
-// As the grid is resized, its images fill the requested space:
-// - corner images are not scaled
-// - top and bottom images are scaled horizontally
-// - left and right images are scaled vertically
-// - the center image is scaled in both directions
-//
-// If one of the non-center images is smaller than the largest images in its
-// row or column, it will be aligned with the outside of the grid. For
-// example, given 4x4 top-left and top-right images and a 1x2 top images:
-//
-// +--------+---------------------+--------+
-// | | top | |
-// | top- +---------------------+ top- +
-// | left | | right |
-// +----+---+ +---+----+
-// | | | |
-// ...
-//
-// This may seem odd at first, but it lets ImageGrid be used to draw shadows
-// with curved corners that extend inwards beyond a window's borders. In the
-// below example, the top-left corner image is overlaid on top of the window's
-// top-left corner:
-//
-// +---------+-----------------------
-// | ..xxx|XXXXXXXXXXXXXXXXXX
-// | .xXXXXX|XXXXXXXXXXXXXXXXXX_____
-// | .xXX | ^ window's top edge
-// | .xXX |
-// +---------+
-// | xXX|
-// | xXX|< window's left edge
-// | xXX|
-// ...
-//
-class ASH_EXPORT ImageGrid {
- public:
- // Helper class for use by tests.
- class ASH_EXPORT TestAPI {
- public:
- TestAPI(ImageGrid* grid) : grid_(grid) {}
-
- gfx::Rect top_left_clip_rect() const {
- return grid_->top_left_painter_->clip_rect_;
- }
- gfx::Rect top_right_clip_rect() const {
- return grid_->top_right_painter_->clip_rect_;
- }
- gfx::Rect bottom_left_clip_rect() const {
- return grid_->bottom_left_painter_->clip_rect_;
- }
- gfx::Rect bottom_right_clip_rect() const {
- return grid_->bottom_right_painter_->clip_rect_;
- }
-
- // Returns |layer|'s bounds after applying the layer's current transform.
- gfx::RectF GetTransformedLayerBounds(const ui::Layer& layer);
-
- private:
- ImageGrid* grid_; // not owned
-
- DISALLOW_COPY_AND_ASSIGN(TestAPI);
- };
-
- ImageGrid();
- ~ImageGrid();
-
- ui::Layer* layer() { return layer_.get(); }
- int top_image_height() const { return top_image_height_; }
- int bottom_image_height() const { return bottom_image_height_; }
- int left_image_width() const { return left_image_width_; }
- int right_image_width() const { return right_image_width_; }
-
- // Visible to allow independent layer animations and for testing.
- ui::Layer* top_left_layer() const { return top_left_layer_.get(); }
- ui::Layer* top_layer() const { return top_layer_.get(); }
- ui::Layer* top_right_layer() const { return top_right_layer_.get(); }
- ui::Layer* left_layer() const { return left_layer_.get(); }
- ui::Layer* center_layer() const { return center_layer_.get(); }
- ui::Layer* right_layer() const { return right_layer_.get(); }
- ui::Layer* bottom_left_layer() const { return bottom_left_layer_.get(); }
- ui::Layer* bottom_layer() const { return bottom_layer_.get(); }
- ui::Layer* bottom_right_layer() const { return bottom_right_layer_.get(); }
-
- // Sets the grid to display the passed-in images (any of which can be NULL).
- // Ownership of the images remains with the caller. May be called more than
- // once to switch images.
- void SetImages(const gfx::Image* top_left_image,
- const gfx::Image* top_image,
- const gfx::Image* top_right_image,
- const gfx::Image* left_image,
- const gfx::Image* center_image,
- const gfx::Image* right_image,
- const gfx::Image* bottom_left_image,
- const gfx::Image* bottom_image,
- const gfx::Image* bottom_right_image);
-
- void SetSize(const gfx::Size& size);
-
- // Sets the grid to a position and size such that the inner edges of the top,
- // bottom, left and right images will be flush with |content_bounds_in_dip|.
- void SetContentBounds(const gfx::Rect& content_bounds_in_dip);
-
- private:
- // Delegate responsible for painting a specific image on a layer.
- class ImagePainter : public ui::LayerDelegate {
- public:
- ImagePainter(const gfx::Image* image) : image_(image) {}
- virtual ~ImagePainter() {}
-
- // Clips |layer| to |clip_rect|. Triggers a repaint if the clipping
- // rectangle has changed. An empty rectangle disables clipping.
- void SetClipRect(const gfx::Rect& clip_rect, ui::Layer* layer);
-
- // ui::LayerDelegate implementation:
- virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
- virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
- virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE;
-
- private:
- friend class TestAPI;
-
- const gfx::Image* image_; // not owned
-
- gfx::Rect clip_rect_;
-
- DISALLOW_COPY_AND_ASSIGN(ImagePainter);
- };
-
- // Returns the dimensions of |image| if non-NULL or gfx::Size(0, 0) otherwise.
- static gfx::Size GetImageSize(const gfx::Image* image);
-
- // Returns true if |layer|'s bounds don't fit within |size|.
- static bool LayerExceedsSize(const ui::Layer* layer, const gfx::Size& size);
-
- // Sets |layer_ptr| and |painter_ptr| to display |image| and adds the
- // passed-in layer to |layer_|. If image is NULL resets |layer_ptr| and
- // |painter_ptr| and removes any existing layer from |layer_|.
- void SetImage(const gfx::Image* image,
- scoped_ptr<ui::Layer>* layer_ptr,
- scoped_ptr<ImagePainter>* painter_ptr);
-
- // Layer that contains all of the image layers.
- scoped_ptr<ui::Layer> layer_;
-
- // The grid's dimensions.
- gfx::Size size_;
-
- // Heights and widths of the images displayed by |top_layer_|,
- // |bottom_layer_|, |left_layer_|, and |right_layer_|.
- int top_image_height_;
- int bottom_image_height_;
- int left_image_width_;
- int right_image_width_;
-
- // Heights of the tallest images in the top and bottom rows and the widest
- // images in the left and right columns. Note that we may have less actual
- // space than this available if the images are large and |size_| is small.
- int base_top_row_height_;
- int base_bottom_row_height_;
- int base_left_column_width_;
- int base_right_column_width_;
-
- // Layers used to display the various images. Children of |layer_|.
- // Positions for which no images were supplied are NULL.
- scoped_ptr<ui::Layer> top_left_layer_;
- scoped_ptr<ui::Layer> top_layer_;
- scoped_ptr<ui::Layer> top_right_layer_;
- scoped_ptr<ui::Layer> left_layer_;
- scoped_ptr<ui::Layer> center_layer_;
- scoped_ptr<ui::Layer> right_layer_;
- scoped_ptr<ui::Layer> bottom_left_layer_;
- scoped_ptr<ui::Layer> bottom_layer_;
- scoped_ptr<ui::Layer> bottom_right_layer_;
-
- // Delegates responsible for painting the above layers.
- // Positions for which no images were supplied are NULL.
- scoped_ptr<ImagePainter> top_left_painter_;
- scoped_ptr<ImagePainter> top_painter_;
- scoped_ptr<ImagePainter> top_right_painter_;
- scoped_ptr<ImagePainter> left_painter_;
- scoped_ptr<ImagePainter> center_painter_;
- scoped_ptr<ImagePainter> right_painter_;
- scoped_ptr<ImagePainter> bottom_left_painter_;
- scoped_ptr<ImagePainter> bottom_painter_;
- scoped_ptr<ImagePainter> bottom_right_painter_;
-
- DISALLOW_COPY_AND_ASSIGN(ImageGrid);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_IMAGE_GRID_H_
diff --git a/ash/wm/image_grid_unittest.cc b/ash/wm/image_grid_unittest.cc
deleted file mode 100644
index 73a07f1..0000000
--- a/ash/wm/image_grid_unittest.cc
+++ /dev/null
@@ -1,342 +0,0 @@
-// Copyright (c) 2012 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 "ash/test/ash_test_base.h"
-#include "ash/wm/image_grid.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/image/image.h"
-
-using ash::internal::ImageGrid;
-
-namespace ash {
-namespace test {
-
-namespace {
-
-// Creates a gfx::Image with the requested dimensions.
-gfx::Image* CreateImage(const gfx::Size& size) {
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
- return new gfx::Image(bitmap);
-}
-
-} // namespace
-
-typedef ash::test::AshTestBase ImageGridTest;
-
-// Test that an ImageGrid's layers are transformed correctly when SetSize() is
-// called.
-TEST_F(ImageGridTest, Basic) {
- // Size of the images around the grid's border.
- const int kBorder = 2;
-
- scoped_ptr<gfx::Image> image_1x1(CreateImage(gfx::Size(1, 1)));
- scoped_ptr<gfx::Image> image_1xB(CreateImage(gfx::Size(1, kBorder)));
- scoped_ptr<gfx::Image> image_Bx1(CreateImage(gfx::Size(kBorder, 1)));
- scoped_ptr<gfx::Image> image_BxB(CreateImage(gfx::Size(kBorder, kBorder)));
-
- ImageGrid grid;
- grid.SetImages(image_BxB.get(), image_1xB.get(), image_BxB.get(),
- image_Bx1.get(), image_1x1.get(), image_Bx1.get(),
- image_BxB.get(), image_1xB.get(), image_BxB.get());
-
- ImageGrid::TestAPI test_api(&grid);
- ASSERT_TRUE(grid.top_left_layer() != NULL);
- ASSERT_TRUE(grid.top_layer() != NULL);
- ASSERT_TRUE(grid.top_right_layer() != NULL);
- ASSERT_TRUE(grid.left_layer() != NULL);
- ASSERT_TRUE(grid.center_layer() != NULL);
- ASSERT_TRUE(grid.right_layer() != NULL);
- ASSERT_TRUE(grid.bottom_left_layer() != NULL);
- ASSERT_TRUE(grid.bottom_layer() != NULL);
- ASSERT_TRUE(grid.bottom_right_layer() != NULL);
-
- const gfx::Size size(20, 30);
- grid.SetSize(size);
-
- // The top-left layer should be flush with the top-left corner and unscaled.
- EXPECT_EQ(gfx::RectF(0, 0, kBorder, kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.top_left_layer()).ToString());
-
- // The top layer should be flush with the top edge and stretched horizontally
- // between the two top corners.
- EXPECT_EQ(gfx::RectF(
- kBorder, 0, size.width() - 2 * kBorder, kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.top_layer()).ToString());
-
- // The top-right layer should be flush with the top-right corner and unscaled.
- EXPECT_EQ(gfx::RectF(size.width() - kBorder, 0, kBorder, kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.top_right_layer()).ToString());
-
- // The left layer should be flush with the left edge and stretched vertically
- // between the two left corners.
- EXPECT_EQ(gfx::RectF(
- 0, kBorder, kBorder, size.height() - 2 * kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.left_layer()).ToString());
-
- // The center layer should fill the space in the middle of the grid.
- EXPECT_EQ(gfx::RectF(
- kBorder, kBorder, size.width() - 2 * kBorder,
- size.height() - 2 * kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.center_layer()).ToString());
-
- // The right layer should be flush with the right edge and stretched
- // vertically between the two right corners.
- EXPECT_EQ(gfx::RectF(
- size.width() - kBorder, kBorder,
- kBorder, size.height() - 2 * kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.right_layer()).ToString());
-
- // The bottom-left layer should be flush with the bottom-left corner and
- // unscaled.
- EXPECT_EQ(gfx::RectF(0, size.height() - kBorder, kBorder, kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.bottom_left_layer()).ToString());
-
- // The bottom layer should be flush with the bottom edge and stretched
- // horizontally between the two bottom corners.
- EXPECT_EQ(gfx::RectF(
- kBorder, size.height() - kBorder,
- size.width() - 2 * kBorder, kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.bottom_layer()).ToString());
-
- // The bottom-right layer should be flush with the bottom-right corner and
- // unscaled.
- EXPECT_EQ(gfx::RectF(
- size.width() - kBorder, size.height() - kBorder,
- kBorder, kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.bottom_right_layer()).ToString());
-}
-
-// Test that an ImageGrid's layers are transformed correctly when
-// SetContentBounds() is called.
-TEST_F(ImageGridTest, SetContentBounds) {
- // Size of the images around the grid's border.
- const int kBorder = 2;
-
- scoped_ptr<gfx::Image> image_1x1(CreateImage(gfx::Size(1, 1)));
- scoped_ptr<gfx::Image> image_1xB(CreateImage(gfx::Size(1, kBorder)));
- scoped_ptr<gfx::Image> image_Bx1(CreateImage(gfx::Size(kBorder, 1)));
- scoped_ptr<gfx::Image> image_BxB(CreateImage(gfx::Size(kBorder, kBorder)));
-
- ImageGrid grid;
- grid.SetImages(image_BxB.get(), image_1xB.get(), image_BxB.get(),
- image_Bx1.get(), image_1x1.get(), image_Bx1.get(),
- image_BxB.get(), image_1xB.get(), image_BxB.get());
-
- ImageGrid::TestAPI test_api(&grid);
-
- const gfx::Point origin(5, 10);
- const gfx::Size size(20, 30);
- grid.SetContentBounds(gfx::Rect(origin, size));
-
- // The master layer is positioned above the top-left corner of the content
- // bounds and has height/width that contain the grid and bounds.
- EXPECT_EQ(gfx::RectF(origin.x() - kBorder,
- origin.y() - kBorder,
- size.width() + 2 * kBorder,
- size.height() + 2 * kBorder).ToString(),
- test_api.GetTransformedLayerBounds(*grid.layer()).ToString());
-}
-
-// Check that we don't crash if only a single image is supplied.
-TEST_F(ImageGridTest, SingleImage) {
- const int kBorder = 1;
- scoped_ptr<gfx::Image> image(CreateImage(gfx::Size(kBorder, kBorder)));
-
- ImageGrid grid;
- grid.SetImages(NULL, image.get(), NULL,
- NULL, NULL, NULL,
- NULL, NULL, NULL);
-
- ImageGrid::TestAPI test_api(&grid);
- EXPECT_TRUE(grid.top_left_layer() == NULL);
- ASSERT_TRUE(grid.top_layer() != NULL);
- EXPECT_TRUE(grid.top_right_layer() == NULL);
- EXPECT_TRUE(grid.left_layer() == NULL);
- EXPECT_TRUE(grid.center_layer() == NULL);
- EXPECT_TRUE(grid.right_layer() == NULL);
- EXPECT_TRUE(grid.bottom_left_layer() == NULL);
- EXPECT_TRUE(grid.bottom_layer() == NULL);
- EXPECT_TRUE(grid.bottom_right_layer() == NULL);
-
- const gfx::Size kSize(10, 10);
- grid.SetSize(kSize);
-
- // The top layer should be scaled horizontally across the entire width, but it
- // shouldn't be scaled vertically.
- EXPECT_EQ(gfx::RectF(0, 0, kSize.width(), kBorder).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.top_layer()).ToString());
-}
-
-// Check that we don't crash when we reset existing images to NULL and
-// reset NULL images to new ones.
-TEST_F(ImageGridTest, ResetImages) {
- const int kBorder = 1;
- scoped_ptr<gfx::Image> image(CreateImage(gfx::Size(kBorder, kBorder)));
-
- ImageGrid grid;
- grid.SetImages(NULL, image.get(), NULL,
- NULL, NULL, NULL,
- NULL, NULL, NULL);
-
- // Only the top edge has a layer.
- ImageGrid::TestAPI test_api(&grid);
- ASSERT_TRUE(grid.top_left_layer() == NULL);
- ASSERT_FALSE(grid.top_layer() == NULL);
- ASSERT_TRUE(grid.top_right_layer() == NULL);
- ASSERT_TRUE(grid.left_layer() == NULL);
- ASSERT_TRUE(grid.center_layer() == NULL);
- ASSERT_TRUE(grid.right_layer() == NULL);
- ASSERT_TRUE(grid.bottom_left_layer() == NULL);
- ASSERT_TRUE(grid.bottom_layer() == NULL);
- ASSERT_TRUE(grid.bottom_right_layer() == NULL);
-
- grid.SetImages(NULL, NULL, NULL,
- NULL, NULL, NULL,
- NULL, image.get(), NULL);
-
- // Now only the bottom edge has a layer.
- ASSERT_TRUE(grid.top_left_layer() == NULL);
- ASSERT_TRUE(grid.top_layer() == NULL);
- ASSERT_TRUE(grid.top_right_layer() == NULL);
- ASSERT_TRUE(grid.left_layer() == NULL);
- ASSERT_TRUE(grid.center_layer() == NULL);
- ASSERT_TRUE(grid.right_layer() == NULL);
- ASSERT_TRUE(grid.bottom_left_layer() == NULL);
- ASSERT_FALSE(grid.bottom_layer() == NULL);
- ASSERT_TRUE(grid.bottom_right_layer() == NULL);
-}
-
-// Test that side (top, left, right, bottom) layers that are narrower than their
-// adjacent corner layers stay pinned to the outside edges instead of getting
-// moved inwards or scaled. This exercises the scenario used for shadows.
-TEST_F(ImageGridTest, SmallerSides) {
- const int kCorner = 2;
- const int kEdge = 1;
-
- scoped_ptr<gfx::Image> top_left_image(
- CreateImage(gfx::Size(kCorner, kCorner)));
- scoped_ptr<gfx::Image> top_image(CreateImage(gfx::Size(kEdge, kEdge)));
- scoped_ptr<gfx::Image> top_right_image(
- CreateImage(gfx::Size(kCorner, kCorner)));
- scoped_ptr<gfx::Image> left_image(CreateImage(gfx::Size(kEdge, kEdge)));
- scoped_ptr<gfx::Image> right_image(CreateImage(gfx::Size(kEdge, kEdge)));
-
- ImageGrid grid;
- grid.SetImages(top_left_image.get(), top_image.get(), top_right_image.get(),
- left_image.get(), NULL, right_image.get(),
- NULL, NULL, NULL);
- ImageGrid::TestAPI test_api(&grid);
-
- const gfx::Size kSize(20, 30);
- grid.SetSize(kSize);
-
- // The top layer should be flush with the top edge and stretched horizontally
- // between the two top corners.
- EXPECT_EQ(gfx::RectF(
- kCorner, 0, kSize.width() - 2 * kCorner, kEdge).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.top_layer()).ToString());
-
- // The left layer should be flush with the left edge and stretched vertically
- // between the top left corner and the bottom.
- EXPECT_EQ(gfx::RectF(
- 0, kCorner, kEdge, kSize.height() - kCorner).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.left_layer()).ToString());
-
- // The right layer should be flush with the right edge and stretched
- // vertically between the top right corner and the bottom.
- EXPECT_EQ(gfx::RectF(
- kSize.width() - kEdge, kCorner,
- kEdge, kSize.height() - kCorner).ToString(),
- test_api.GetTransformedLayerBounds(
- *grid.right_layer()).ToString());
-}
-
-// Test that we hide or clip layers as needed when the grid is assigned a small
-// size.
-TEST_F(ImageGridTest, TooSmall) {
- const int kCorner = 5;
- const int kCenter = 3;
- const int kEdge = 3;
-
- scoped_ptr<gfx::Image> top_left_image(
- CreateImage(gfx::Size(kCorner, kCorner)));
- scoped_ptr<gfx::Image> top_image(CreateImage(gfx::Size(kEdge, kEdge)));
- scoped_ptr<gfx::Image> top_right_image(
- CreateImage(gfx::Size(kCorner, kCorner)));
- scoped_ptr<gfx::Image> left_image(CreateImage(gfx::Size(kEdge, kEdge)));
- scoped_ptr<gfx::Image> center_image(CreateImage(gfx::Size(kCenter, kCenter)));
- scoped_ptr<gfx::Image> right_image(CreateImage(gfx::Size(kEdge, kEdge)));
- scoped_ptr<gfx::Image> bottom_left_image(
- CreateImage(gfx::Size(kCorner, kCorner)));
- scoped_ptr<gfx::Image> bottom_image(CreateImage(gfx::Size(kEdge, kEdge)));
- scoped_ptr<gfx::Image> bottom_right_image(
- CreateImage(gfx::Size(kCorner, kCorner)));
-
- ImageGrid grid;
- grid.SetImages(
- top_left_image.get(), top_image.get(), top_right_image.get(),
- left_image.get(), center_image.get(), right_image.get(),
- bottom_left_image.get(), bottom_image.get(), bottom_right_image.get());
- ImageGrid::TestAPI test_api(&grid);
-
- // Set a size that's smaller than the combined (unscaled) corner images.
- const gfx::Size kSmallSize(kCorner + kCorner - 3, kCorner + kCorner - 5);
- grid.SetSize(kSmallSize);
-
- // The scalable images around the sides and in the center should be hidden.
- EXPECT_FALSE(grid.top_layer()->visible());
- EXPECT_FALSE(grid.bottom_layer()->visible());
- EXPECT_FALSE(grid.left_layer()->visible());
- EXPECT_FALSE(grid.right_layer()->visible());
- EXPECT_FALSE(grid.center_layer()->visible());
-
- // The corner images' clip rects should sum to the expected size.
- EXPECT_EQ(kSmallSize.width(),
- test_api.top_left_clip_rect().width() +
- test_api.top_right_clip_rect().width());
- EXPECT_EQ(kSmallSize.width(),
- test_api.bottom_left_clip_rect().width() +
- test_api.bottom_right_clip_rect().width());
- EXPECT_EQ(kSmallSize.height(),
- test_api.top_left_clip_rect().height() +
- test_api.bottom_left_clip_rect().height());
- EXPECT_EQ(kSmallSize.height(),
- test_api.top_right_clip_rect().height() +
- test_api.bottom_right_clip_rect().height());
-
- // Resize the grid to be large enough to show all images.
- const gfx::Size kLargeSize(kCorner + kCorner + kCenter,
- kCorner + kCorner + kCenter);
- grid.SetSize(kLargeSize);
-
- // The scalable images should be visible now.
- EXPECT_TRUE(grid.top_layer()->visible());
- EXPECT_TRUE(grid.bottom_layer()->visible());
- EXPECT_TRUE(grid.left_layer()->visible());
- EXPECT_TRUE(grid.right_layer()->visible());
- EXPECT_TRUE(grid.center_layer()->visible());
-
- // We shouldn't be clipping the corner images anymore.
- EXPECT_TRUE(test_api.top_left_clip_rect().IsEmpty());
- EXPECT_TRUE(test_api.top_right_clip_rect().IsEmpty());
- EXPECT_TRUE(test_api.bottom_left_clip_rect().IsEmpty());
- EXPECT_TRUE(test_api.bottom_right_clip_rect().IsEmpty());
-}
-
-} // namespace test
-} // namespace ash
diff --git a/ash/wm/resize_shadow.cc b/ash/wm/resize_shadow.cc
index 586e735..27ed2b7 100644
--- a/ash/wm/resize_shadow.cc
+++ b/ash/wm/resize_shadow.cc
@@ -4,7 +4,6 @@
#include "ash/wm/resize_shadow.h"
-#include "ash/wm/image_grid.h"
#include "base/time.h"
#include "grit/ash_resources.h"
#include "ui/aura/window.h"
@@ -12,6 +11,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/views/corewm/image_grid.h"
namespace {
@@ -49,7 +49,7 @@ ResizeShadow::~ResizeShadow() {}
void ResizeShadow::Init(aura::Window* window) {
// Set up our image grid and images.
ResourceBundle& res = ResourceBundle::GetSharedInstance();
- image_grid_.reset(new ImageGrid);
+ image_grid_.reset(new views::corewm::ImageGrid);
image_grid_->SetImages(
&res.GetImageNamed(IDR_AURA_RESIZE_SHADOW_TOP_LEFT),
&res.GetImageNamed(IDR_AURA_RESIZE_SHADOW_TOP),
diff --git a/ash/wm/resize_shadow.h b/ash/wm/resize_shadow.h
index 8bc5f7d..d9f2452 100644
--- a/ash/wm/resize_shadow.h
+++ b/ash/wm/resize_shadow.h
@@ -17,12 +17,15 @@ class Rect;
namespace ui {
class Layer;
}
+namespace views {
+namespace corewm {
+class ImageGrid;
+}
+}
namespace ash {
namespace internal {
-class ImageGrid;
-
// A class to render the resize edge effect when the user moves their mouse
// over a sizing edge. This is just a visual effect; the actual resize is
// handled by the EventFilter.
@@ -46,7 +49,7 @@ class ResizeShadow {
private:
// Images for the shadow effect.
- scoped_ptr<ImageGrid> image_grid_;
+ scoped_ptr<views::corewm::ImageGrid> image_grid_;
// Hit test value from last call to ShowForHitTest(). Used to prevent
// repeatedly triggering the same animations for the same hit.
diff --git a/ash/wm/shadow.cc b/ash/wm/shadow.cc
deleted file mode 100644
index 01bc5ed..0000000
--- a/ash/wm/shadow.cc
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright (c) 2012 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 "ash/wm/shadow.h"
-
-#include "ash/wm/image_grid.h"
-#include "grit/ash_resources.h"
-#include "grit/ui_resources.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/compositor/scoped_layer_animation_settings.h"
-
-namespace {
-
-// Shadow opacity for different styles.
-const float kActiveShadowOpacity = 1.0f;
-const float kInactiveShadowOpacity = 0.2f;
-const float kSmallShadowOpacity = 1.0f;
-
-// Duration for opacity animation in milliseconds.
-const int kShadowAnimationDurationMs = 100;
-
-float GetOpacityForStyle(ash::internal::Shadow::Style style) {
- switch (style) {
- case ash::internal::Shadow::STYLE_ACTIVE:
- return kActiveShadowOpacity;
- case ash::internal::Shadow::STYLE_INACTIVE:
- return kInactiveShadowOpacity;
- case ash::internal::Shadow::STYLE_SMALL:
- return kSmallShadowOpacity;
- default:
- NOTREACHED() << "Unhandled style " << style;
- }
- return 1.0f;
-}
-
-} // namespace
-
-namespace ash {
-namespace internal {
-
-Shadow::Shadow() : style_(STYLE_ACTIVE) {
-}
-
-Shadow::~Shadow() {
-}
-
-void Shadow::Init(Style style) {
- style_ = style;
- image_grid_.reset(new ImageGrid);
- UpdateImagesForStyle();
- image_grid_->layer()->set_name("Shadow");
- image_grid_->layer()->SetOpacity(GetOpacityForStyle(style_));
-}
-
-void Shadow::SetContentBounds(const gfx::Rect& content_bounds) {
- content_bounds_ = content_bounds;
- UpdateImageGridBounds();
-}
-
-ui::Layer* Shadow::layer() const {
- return image_grid_->layer();
-}
-
-void Shadow::SetStyle(Style style) {
- if (style_ == style)
- return;
-
- Style old_style = style_;
- style_ = style;
-
- // Stop waiting for any as yet unfinished implicit animations.
- StopObservingImplicitAnimations();
-
- // If we're switching to or from the small style, don't bother with
- // animations.
- if (style == STYLE_SMALL || old_style == STYLE_SMALL) {
- UpdateImagesForStyle();
- image_grid_->layer()->SetOpacity(GetOpacityForStyle(style));
- return;
- }
-
- // If we're becoming active, switch images now. Because the inactive image
- // has a very low opacity the switch isn't noticeable and this approach
- // allows us to use only a single set of shadow images at a time.
- if (style == STYLE_ACTIVE) {
- UpdateImagesForStyle();
- // Opacity was baked into inactive image, start opacity low to match.
- image_grid_->layer()->SetOpacity(kInactiveShadowOpacity);
- }
-
- {
- // Property sets within this scope will be implicitly animated.
- ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
- settings.AddObserver(this);
- settings.SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(kShadowAnimationDurationMs));
- switch (style_) {
- case STYLE_ACTIVE:
- image_grid_->layer()->SetOpacity(kActiveShadowOpacity);
- break;
- case STYLE_INACTIVE:
- image_grid_->layer()->SetOpacity(kInactiveShadowOpacity);
- break;
- default:
- NOTREACHED() << "Unhandled style " << style_;
- break;
- }
- }
-}
-
-void Shadow::OnImplicitAnimationsCompleted() {
- // If we just finished going inactive, switch images. This doesn't cause
- // a visual pop because the inactive image opacity is so low.
- if (style_ == STYLE_INACTIVE) {
- UpdateImagesForStyle();
- // Opacity is baked into inactive image, so set fully opaque.
- image_grid_->layer()->SetOpacity(1.0f);
- }
-}
-
-void Shadow::UpdateImagesForStyle() {
- ResourceBundle& res = ResourceBundle::GetSharedInstance();
- switch (style_) {
- case STYLE_ACTIVE:
- image_grid_->SetImages(
- &res.GetImageNamed(IDR_AURA_SHADOW_ACTIVE_TOP_LEFT),
- &res.GetImageNamed(IDR_AURA_SHADOW_ACTIVE_TOP),
- &res.GetImageNamed(IDR_AURA_SHADOW_ACTIVE_TOP_RIGHT),
- &res.GetImageNamed(IDR_AURA_SHADOW_ACTIVE_LEFT),
- NULL,
- &res.GetImageNamed(IDR_AURA_SHADOW_ACTIVE_RIGHT),
- &res.GetImageNamed(IDR_AURA_SHADOW_ACTIVE_BOTTOM_LEFT),
- &res.GetImageNamed(IDR_AURA_SHADOW_ACTIVE_BOTTOM),
- &res.GetImageNamed(IDR_AURA_SHADOW_ACTIVE_BOTTOM_RIGHT));
- break;
- case STYLE_INACTIVE:
- image_grid_->SetImages(
- &res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE_TOP_LEFT),
- &res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE_TOP),
- &res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE_TOP_RIGHT),
- &res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE_LEFT),
- NULL,
- &res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE_RIGHT),
- &res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE_BOTTOM_LEFT),
- &res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE_BOTTOM),
- &res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE_BOTTOM_RIGHT));
- break;
- case STYLE_SMALL:
- image_grid_->SetImages(
- &res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP_LEFT),
- &res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP),
- &res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP_RIGHT),
- &res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL_LEFT),
- NULL,
- &res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL_RIGHT),
- &res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM_LEFT),
- &res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM),
- &res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM_RIGHT));
- break;
- default:
- NOTREACHED() << "Unhandled style " << style_;
- break;
- }
-
- // Image sizes may have changed.
- UpdateImageGridBounds();
-}
-
-void Shadow::UpdateImageGridBounds() {
- // Update bounds based on content bounds and image sizes.
- image_grid_->SetContentBounds(content_bounds_);
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/shadow.h b/ash/wm/shadow.h
deleted file mode 100644
index 0dd84d0..0000000
--- a/ash/wm/shadow.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_WM_SHADOW_H_
-#define ASH_WM_SHADOW_H_
-
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "ui/compositor/layer_animation_observer.h"
-#include "ui/gfx/rect.h"
-
-namespace ui {
-class Layer;
-} // namespace ui
-
-namespace ash {
-namespace internal {
-
-class ImageGrid;
-
-// Simple class that draws a drop shadow around content at given bounds.
-class ASH_EXPORT Shadow : public ui::ImplicitAnimationObserver {
- public:
- enum Style {
- // Active windows have more opaque shadows, shifted down to make the window
- // appear "higher".
- STYLE_ACTIVE,
-
- // Inactive windows have less opaque shadows.
- STYLE_INACTIVE,
-
- // Small windows like tooltips and context menus have lighter, smaller
- // shadows.
- STYLE_SMALL,
- };
-
- Shadow();
- virtual ~Shadow();
-
- void Init(Style style);
-
- // Returns |image_grid_|'s ui::Layer. This is exposed so it can be added to
- // the same layer as the content and stacked below it. SetContentBounds()
- // should be used to adjust the shadow's size and position (rather than
- // applying transformations to this layer).
- ui::Layer* layer() const;
-
- const gfx::Rect& content_bounds() const { return content_bounds_; }
- Style style() const { return style_; }
-
- // Moves and resizes |image_grid_| to frame |content_bounds|.
- void SetContentBounds(const gfx::Rect& content_bounds);
-
- // Sets the shadow's style, animating opacity as necessary.
- void SetStyle(Style style);
-
- // ui::ImplicitAnimationObserver overrides:
- virtual void OnImplicitAnimationsCompleted() OVERRIDE;
-
- private:
- // Updates the |image_grid_| images to the current |style_|.
- void UpdateImagesForStyle();
-
- // Updates the |image_grid_| bounds based on its image sizes and the
- // current |content_bounds_|.
- void UpdateImageGridBounds();
-
- // The current style, set when the transition animation starts.
- Style style_;
-
- scoped_ptr<ImageGrid> image_grid_;
-
- // Bounds of the content that the shadow encloses.
- gfx::Rect content_bounds_;
-
- DISALLOW_COPY_AND_ASSIGN(Shadow);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_SHADOW_H_
diff --git a/ash/wm/shadow_controller.cc b/ash/wm/shadow_controller.cc
deleted file mode 100644
index abfb6ea..0000000
--- a/ash/wm/shadow_controller.cc
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright (c) 2012 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 "ash/wm/shadow_controller.h"
-
-#include <utility>
-
-#include "ash/shell.h"
-#include "ash/wm/shadow.h"
-#include "ash/wm/shadow_types.h"
-#include "ash/wm/window_properties.h"
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "ui/aura/client/activation_client.h"
-#include "ui/aura/env.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/window.h"
-#include "ui/compositor/layer.h"
-
-using std::make_pair;
-
-namespace ash {
-namespace internal {
-
-namespace {
-
-ShadowType GetShadowTypeFromWindow(aura::Window* window) {
- switch (window->type()) {
- case aura::client::WINDOW_TYPE_NORMAL:
- case aura::client::WINDOW_TYPE_PANEL:
- case aura::client::WINDOW_TYPE_MENU:
- case aura::client::WINDOW_TYPE_TOOLTIP:
- return SHADOW_TYPE_RECTANGULAR;
- default:
- break;
- }
- return SHADOW_TYPE_NONE;
-}
-
-bool ShouldUseSmallShadowForWindow(aura::Window* window) {
- switch (window->type()) {
- case aura::client::WINDOW_TYPE_MENU:
- case aura::client::WINDOW_TYPE_TOOLTIP:
- return true;
- default:
- break;
- }
- return false;
-}
-
-// Returns the shadow style to be applied to |losing_active| when it is losing
-// active to |gaining_active|. |gaining_active| may be of a type that hides when
-// inactive, and as such we do not want to render |losing_active| as inactive.
-Shadow::Style GetShadowStyleForWindowLosingActive(
- aura::Window* losing_active,
- aura::Window* gaining_active) {
- if (gaining_active && aura::client::GetHideOnDeactivate(gaining_active)) {
- aura::Window::Windows::const_iterator it =
- std::find(losing_active->transient_children().begin(),
- losing_active->transient_children().end(),
- gaining_active);
- if (it != losing_active->transient_children().end())
- return Shadow::STYLE_ACTIVE;
- }
- return Shadow::STYLE_INACTIVE;
-}
-
-} // namespace
-
-ShadowController::ShadowController()
- : ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) {
- aura::Env::GetInstance()->AddObserver(this);
- // Watch for window activation changes.
- aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
- AddObserver(this);
-}
-
-ShadowController::~ShadowController() {
- aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
- RemoveObserver(this);
- aura::Env::GetInstance()->RemoveObserver(this);
-}
-
-void ShadowController::OnWindowInitialized(aura::Window* window) {
- observer_manager_.Add(window);
- SetShadowType(window, GetShadowTypeFromWindow(window));
- HandlePossibleShadowVisibilityChange(window);
-}
-
-void ShadowController::OnWindowPropertyChanged(aura::Window* window,
- const void* key,
- intptr_t old) {
- if (key == kShadowTypeKey) {
- HandlePossibleShadowVisibilityChange(window);
- return;
- }
-}
-
-void ShadowController::OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) {
- Shadow* shadow = GetShadowForWindow(window);
- if (shadow)
- shadow->SetContentBounds(gfx::Rect(new_bounds.size()));
-}
-
-void ShadowController::OnWindowDestroyed(aura::Window* window) {
- window_shadows_.erase(window);
- observer_manager_.Remove(window);
-}
-
-void ShadowController::OnWindowActivated(aura::Window* gaining_active,
- aura::Window* losing_active) {
- if (gaining_active) {
- Shadow* shadow = GetShadowForWindow(gaining_active);
- if (shadow && !ShouldUseSmallShadowForWindow(gaining_active))
- shadow->SetStyle(Shadow::STYLE_ACTIVE);
- }
- if (losing_active) {
- Shadow* shadow = GetShadowForWindow(losing_active);
- if (shadow && !ShouldUseSmallShadowForWindow(losing_active)) {
- shadow->SetStyle(GetShadowStyleForWindowLosingActive(losing_active,
- gaining_active));
- }
- }
-}
-
-bool ShadowController::ShouldShowShadowForWindow(aura::Window* window) const {
- const ShadowType type = GetShadowType(window);
- switch (type) {
- case SHADOW_TYPE_NONE:
- return false;
- case SHADOW_TYPE_RECTANGULAR:
- return true;
- default:
- NOTREACHED() << "Unknown shadow type " << type;
- return false;
- }
-}
-
-Shadow* ShadowController::GetShadowForWindow(aura::Window* window) {
- WindowShadowMap::const_iterator it = window_shadows_.find(window);
- return it != window_shadows_.end() ? it->second.get() : NULL;
-}
-
-void ShadowController::HandlePossibleShadowVisibilityChange(
- aura::Window* window) {
- const bool should_show = ShouldShowShadowForWindow(window);
- Shadow* shadow = GetShadowForWindow(window);
- if (shadow)
- shadow->layer()->SetVisible(should_show);
- else if (should_show && !shadow)
- CreateShadowForWindow(window);
-}
-
-void ShadowController::CreateShadowForWindow(aura::Window* window) {
- linked_ptr<Shadow> shadow(new Shadow());
- window_shadows_.insert(make_pair(window, shadow));
-
- shadow->Init(ShouldUseSmallShadowForWindow(window) ?
- Shadow::STYLE_SMALL : Shadow::STYLE_ACTIVE);
- shadow->SetContentBounds(gfx::Rect(window->bounds().size()));
- shadow->layer()->SetVisible(ShouldShowShadowForWindow(window));
- window->layer()->Add(shadow->layer());
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/shadow_controller.h b/ash/wm/shadow_controller.h
deleted file mode 100644
index c3c3702..0000000
--- a/ash/wm/shadow_controller.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_WM_SHADOW_CONTROLLER_H_
-#define ASH_WM_SHADOW_CONTROLLER_H_
-
-#include <map>
-
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/memory/linked_ptr.h"
-#include "base/scoped_observer.h"
-#include "ui/aura/client/activation_change_observer.h"
-#include "ui/aura/env_observer.h"
-#include "ui/aura/window_observer.h"
-
-namespace aura {
-class Window;
-}
-namespace gfx {
-class Rect;
-}
-
-namespace ash {
-namespace internal {
-
-class Shadow;
-
-// ShadowController observes changes to windows and creates and updates drop
-// shadows as needed.
-class ASH_EXPORT ShadowController :
- public aura::EnvObserver,
- public aura::WindowObserver,
- public aura::client::ActivationChangeObserver {
- public:
- class TestApi {
- public:
- explicit TestApi(ShadowController* controller) : controller_(controller) {}
- ~TestApi() {}
-
- Shadow* GetShadowForWindow(aura::Window* window) {
- return controller_->GetShadowForWindow(window);
- }
-
- private:
- ShadowController* controller_; // not owned
-
- DISALLOW_COPY_AND_ASSIGN(TestApi);
- };
-
- explicit ShadowController();
- virtual ~ShadowController();
-
- // aura::EnvObserver override:
- virtual void OnWindowInitialized(aura::Window* window) OVERRIDE;
-
- // aura::WindowObserver overrides:
- virtual void OnWindowPropertyChanged(
- aura::Window* window, const void* key, intptr_t old) OVERRIDE;
- virtual void OnWindowBoundsChanged(
- aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) OVERRIDE;
- virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
-
- // aura::client::ActivationChangeObserver overrides:
- virtual void OnWindowActivated(aura::Window* active,
- aura::Window* old_active) OVERRIDE;
-
- private:
- typedef std::map<aura::Window*, linked_ptr<Shadow> > WindowShadowMap;
-
- // Checks if |window| is visible and contains a property requesting a shadow.
- bool ShouldShowShadowForWindow(aura::Window* window) const;
-
- // Returns |window|'s shadow from |window_shadows_|, or NULL if no shadow
- // exists.
- Shadow* GetShadowForWindow(aura::Window* window);
-
- // Updates the shadow styles for windows when activation changes.
- void HandleWindowActivationChange(aura::Window* gaining_active,
- aura::Window* losing_active);
-
- // Shows or hides |window|'s shadow as needed (creating the shadow if
- // necessary).
- void HandlePossibleShadowVisibilityChange(aura::Window* window);
-
- // Creates a new shadow for |window| and stores it in |window_shadows_|. The
- // shadow's bounds are initialized and it is added to the window's layer.
- void CreateShadowForWindow(aura::Window* window);
-
- WindowShadowMap window_shadows_;
-
- ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(ShadowController);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_SHADOW_CONTROLLER_H_
diff --git a/ash/wm/shadow_controller_unittest.cc b/ash/wm/shadow_controller_unittest.cc
deleted file mode 100644
index 9879f55..0000000
--- a/ash/wm/shadow_controller_unittest.cc
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright (c) 2012 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 "ash/wm/shadow_controller.h"
-
-#include <algorithm>
-#include <vector>
-
-#include "ash/shell.h"
-#include "ash/test/ash_test_base.h"
-#include "ash/wm/shadow.h"
-#include "ash/wm/shadow_types.h"
-#include "ash/wm/window_properties.h"
-#include "ash/wm/window_util.h"
-#include "base/memory/scoped_ptr.h"
-#include "ui/aura/client/activation_client.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/window.h"
-#include "ui/compositor/layer.h"
-
-namespace ash {
-namespace internal {
-
-typedef ash::test::AshTestBase ShadowControllerTest;
-
-// Tests that various methods in Window update the Shadow object as expected.
-TEST_F(ShadowControllerTest, Shadow) {
- scoped_ptr<aura::Window> window(new aura::Window(NULL));
- window->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window->Init(ui::LAYER_TEXTURED);
- window->SetParent(NULL);
-
- // We should create the shadow before the window is visible (the shadow's
- // layer won't get drawn yet since it's a child of the window's layer).
- internal::ShadowController::TestApi api(
- ash::Shell::GetInstance()->shadow_controller());
- const internal::Shadow* shadow = api.GetShadowForWindow(window.get());
- ASSERT_TRUE(shadow != NULL);
- EXPECT_TRUE(shadow->layer()->visible());
-
- // The shadow should remain visible after window visibility changes.
- window->Show();
- EXPECT_TRUE(shadow->layer()->visible());
- window->Hide();
- EXPECT_TRUE(shadow->layer()->visible());
-
- // If the shadow is disabled, it should be hidden.
- internal::SetShadowType(window.get(), internal::SHADOW_TYPE_NONE);
- window->Show();
- EXPECT_FALSE(shadow->layer()->visible());
- internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR);
- EXPECT_TRUE(shadow->layer()->visible());
-
- // The shadow's layer should be a child of the window's layer.
- EXPECT_EQ(window->layer(), shadow->layer()->parent());
-
- window->parent()->RemoveChild(window.get());
- aura::Window* window_ptr = window.get();
- window.reset();
- EXPECT_TRUE(api.GetShadowForWindow(window_ptr) == NULL);
-}
-
-// Tests that the window's shadow's bounds are updated correctly.
-TEST_F(ShadowControllerTest, ShadowBounds) {
- scoped_ptr<aura::Window> window(new aura::Window(NULL));
- window->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window->Init(ui::LAYER_TEXTURED);
- window->SetParent(NULL);
- window->Show();
-
- const gfx::Rect kOldBounds(20, 30, 400, 300);
- window->SetBounds(kOldBounds);
-
- // When the shadow is first created, it should use the window's size (but
- // remain at the origin, since it's a child of the window's layer).
- internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR);
- internal::ShadowController::TestApi api(
- ash::Shell::GetInstance()->shadow_controller());
- const internal::Shadow* shadow = api.GetShadowForWindow(window.get());
- ASSERT_TRUE(shadow != NULL);
- EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(),
- shadow->content_bounds().ToString());
-
- // When we change the window's bounds, the shadow's should be updated too.
- gfx::Rect kNewBounds(50, 60, 500, 400);
- window->SetBounds(kNewBounds);
- EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(),
- shadow->content_bounds().ToString());
-}
-
-// Tests that activating a window changes the shadow style.
-TEST_F(ShadowControllerTest, ShadowStyle) {
- ShadowController::TestApi api(
- ash::Shell::GetInstance()->shadow_controller());
-
- scoped_ptr<aura::Window> window1(new aura::Window(NULL));
- window1->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window1->Init(ui::LAYER_TEXTURED);
- window1->SetParent(NULL);
- window1->SetBounds(gfx::Rect(10, 20, 300, 400));
- window1->Show();
- wm::ActivateWindow(window1.get());
-
- // window1 is active, so style should have active appearance.
- Shadow* shadow1 = api.GetShadowForWindow(window1.get());
- ASSERT_TRUE(shadow1 != NULL);
- EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style());
-
- // Create another window and activate it.
- scoped_ptr<aura::Window> window2(new aura::Window(NULL));
- window2->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window2->Init(ui::LAYER_TEXTURED);
- window2->SetParent(NULL);
- window2->SetBounds(gfx::Rect(11, 21, 301, 401));
- window2->Show();
- wm::ActivateWindow(window2.get());
-
- // window1 is now inactive, so shadow should go inactive.
- Shadow* shadow2 = api.GetShadowForWindow(window2.get());
- ASSERT_TRUE(shadow2 != NULL);
- EXPECT_EQ(Shadow::STYLE_INACTIVE, shadow1->style());
- EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow2->style());
-}
-
-// Tests that we use smaller shadows for tooltips and menus.
-TEST_F(ShadowControllerTest, SmallShadowsForTooltipsAndMenus) {
- ShadowController::TestApi api(
- ash::Shell::GetInstance()->shadow_controller());
-
- scoped_ptr<aura::Window> tooltip_window(new aura::Window(NULL));
- tooltip_window->SetType(aura::client::WINDOW_TYPE_TOOLTIP);
- tooltip_window->Init(ui::LAYER_TEXTURED);
- tooltip_window->SetParent(NULL);
- tooltip_window->SetBounds(gfx::Rect(10, 20, 300, 400));
- tooltip_window->Show();
-
- Shadow* tooltip_shadow = api.GetShadowForWindow(tooltip_window.get());
- ASSERT_TRUE(tooltip_shadow != NULL);
- EXPECT_EQ(Shadow::STYLE_SMALL, tooltip_shadow->style());
-
- scoped_ptr<aura::Window> menu_window(new aura::Window(NULL));
- menu_window->SetType(aura::client::WINDOW_TYPE_MENU);
- menu_window->Init(ui::LAYER_TEXTURED);
- menu_window->SetParent(NULL);
- menu_window->SetBounds(gfx::Rect(10, 20, 300, 400));
- menu_window->Show();
-
- Shadow* menu_shadow = api.GetShadowForWindow(tooltip_window.get());
- ASSERT_TRUE(menu_shadow != NULL);
- EXPECT_EQ(Shadow::STYLE_SMALL, menu_shadow->style());
-}
-
-// http://crbug.com/120210 - transient parents of certain types of transients
-// should not lose their shadow when they lose activation to the transient.
-TEST_F(ShadowControllerTest, TransientParentKeepsActiveShadow) {
- ShadowController::TestApi api(
- ash::Shell::GetInstance()->shadow_controller());
-
- scoped_ptr<aura::Window> window1(new aura::Window(NULL));
- window1->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window1->Init(ui::LAYER_TEXTURED);
- window1->SetParent(NULL);
- window1->SetBounds(gfx::Rect(10, 20, 300, 400));
- window1->Show();
- wm::ActivateWindow(window1.get());
-
- // window1 is active, so style should have active appearance.
- Shadow* shadow1 = api.GetShadowForWindow(window1.get());
- ASSERT_TRUE(shadow1 != NULL);
- EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style());
-
- // Create a window that is transient to window1, and that has the 'hide on
- // deactivate' property set. Upon activation, window1 should still have an
- // active shadow.
- scoped_ptr<aura::Window> window2(new aura::Window(NULL));
- window2->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window2->Init(ui::LAYER_TEXTURED);
- window2->SetParent(NULL);
- window2->SetBounds(gfx::Rect(11, 21, 301, 401));
- window1->AddTransientChild(window2.get());
- aura::client::SetHideOnDeactivate(window2.get(), true);
- window2->Show();
- wm::ActivateWindow(window2.get());
-
- // window1 is now inactive, but its shadow should still appear active.
- EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style());
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/shadow_types.cc b/ash/wm/shadow_types.cc
deleted file mode 100644
index 296986a..0000000
--- a/ash/wm/shadow_types.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2012 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 "ash/wm/shadow_types.h"
-
-#include "ash/wm/window_properties.h"
-#include "ui/aura/window.h"
-
-namespace ash {
-namespace internal {
-
-void SetShadowType(aura::Window* window, ShadowType shadow_type) {
- window->SetProperty(kShadowTypeKey, shadow_type);
-}
-
-ShadowType GetShadowType(aura::Window* window) {
- return window->GetProperty(kShadowTypeKey);
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/shadow_types.h b/ash/wm/shadow_types.h
deleted file mode 100644
index f8c0844c..0000000
--- a/ash/wm/shadow_types.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef ASH_WM_SHADOW_TYPES_H_
-#define ASH_WM_SHADOW_TYPES_H_
-
-#include "ash/ash_export.h"
-
-namespace aura {
-class Window;
-}
-
-namespace ash {
-namespace internal {
-
-// Different types of drop shadows that can be drawn under a window by the
-// shell. Used as a value for the kShadowTypeKey property.
-enum ShadowType {
- // Starts at 0 due to the cast in GetShadowType().
- SHADOW_TYPE_NONE = 0,
- SHADOW_TYPE_RECTANGULAR,
-};
-
-ASH_EXPORT void SetShadowType(aura::Window* window, ShadowType shadow_type);
-ASH_EXPORT ShadowType GetShadowType(aura::Window* window);
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_SHADOW_TYPES_H_
diff --git a/ash/wm/window_properties.cc b/ash/wm/window_properties.cc
index 22468b8..d636717 100644
--- a/ash/wm/window_properties.cc
+++ b/ash/wm/window_properties.cc
@@ -7,13 +7,11 @@
#include "ash/root_window_controller.h"
#include "ash/wm/always_on_top_controller.h"
#include "ash/wm/frame_painter.h"
-#include "ash/wm/shadow_types.h"
#include "ui/aura/window_property.h"
#include "ui/gfx/rect.h"
#include "ui/ui_controls/ui_controls_aura.h"
DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::AlwaysOnTopController*);
-DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::ShadowType);
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, ash::FramePainter*);
DECLARE_WINDOW_PROPERTY_TYPE(ash::WindowPersistsAcrossAllWorkspacesType)
DECLARE_WINDOW_PROPERTY_TYPE(ui_controls::UIControlsAura*)
@@ -31,7 +29,6 @@ DEFINE_WINDOW_PROPERTY_KEY(
ui::WindowShowState, kRestoreShowStateKey, ui::SHOW_STATE_DEFAULT);
DEFINE_WINDOW_PROPERTY_KEY(RootWindowController*,
kRootWindowControllerKey, NULL);
-DEFINE_WINDOW_PROPERTY_KEY(ShadowType, kShadowTypeKey, SHADOW_TYPE_NONE);
DEFINE_WINDOW_PROPERTY_KEY(
ash::FramePainter*, kSoloWindowFramePainterKey, NULL);
DEFINE_WINDOW_PROPERTY_KEY(bool, kStayInSameRootWindowKey, false);
diff --git a/ash/wm/window_properties.h b/ash/wm/window_properties.h
index 3e8e71b..013e08e 100644
--- a/ash/wm/window_properties.h
+++ b/ash/wm/window_properties.h
@@ -7,7 +7,6 @@
#include "ash/ash_export.h"
#include "ash/wm/property_util.h"
-#include "ash/wm/shadow_types.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
@@ -51,10 +50,6 @@ extern const aura::WindowProperty<ui::WindowShowState>* const
extern const aura::WindowProperty<RootWindowController*>* const
kRootWindowControllerKey;
-// A property key describing the drop shadow that should be displayed under the
-// window. If unset, no shadow is displayed.
-extern const aura::WindowProperty<ShadowType>* const kShadowTypeKey;
-
// A property key to remember the frame painter for the solo-window in the root
// window. It is only available for root windows.
ASH_EXPORT extern const aura::WindowProperty<ash::FramePainter*>* const
diff --git a/ash/wm/workspace/phantom_window_controller.cc b/ash/wm/workspace/phantom_window_controller.cc
index 1bb52d1..d00fd7e 100644
--- a/ash/wm/workspace/phantom_window_controller.cc
+++ b/ash/wm/workspace/phantom_window_controller.cc
@@ -7,7 +7,6 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
-#include "ash/wm/shadow_types.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/root_window.h"
@@ -21,6 +20,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/skia_util.h"
+#include "ui/views/corewm/shadow_types.h"
#include "ui/views/painter.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
@@ -180,7 +180,8 @@ void PhantomWindowController::CreatePhantomWidget(const gfx::Rect& bounds,
phantom_widget_->SetContentsView(content_view);
} else if (style_ == STYLE_DRAGGING) {
// Show shadow for the dragging window.
- SetShadowType(phantom_widget_->GetNativeWindow(), SHADOW_TYPE_RECTANGULAR);
+ SetShadowType(phantom_widget_->GetNativeWindow(),
+ views::corewm::SHADOW_TYPE_RECTANGULAR);
}
SetBoundsInternal(bounds);
if (phantom_below_window_)