summaryrefslogtreecommitdiffstats
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
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
-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/resize_shadow.cc4
-rw-r--r--ash/wm/resize_shadow.h9
-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
-rw-r--r--ui/aura/test/test_activation_client.cc10
-rw-r--r--ui/aura/test/test_activation_client.h2
-rw-r--r--ui/views/corewm/image_grid.cc (renamed from ash/wm/image_grid.cc)10
-rw-r--r--ui/views/corewm/image_grid.h (renamed from ash/wm/image_grid.h)20
-rw-r--r--ui/views/corewm/image_grid_unittest.cc (renamed from ash/wm/image_grid_unittest.cc)16
-rw-r--r--ui/views/corewm/shadow.cc (renamed from ash/wm/shadow.cc)21
-rw-r--r--ui/views/corewm/shadow.h (renamed from ash/wm/shadow.h)18
-rw-r--r--ui/views/corewm/shadow_controller.cc (renamed from ash/wm/shadow_controller.cc)27
-rw-r--r--ui/views/corewm/shadow_controller.h (renamed from ash/wm/shadow_controller.h)23
-rw-r--r--ui/views/corewm/shadow_controller_unittest.cc (renamed from ash/wm/shadow_controller_unittest.cc)86
-rw-r--r--ui/views/corewm/shadow_types.cc (renamed from ash/wm/shadow_types.cc)17
-rw-r--r--ui/views/corewm/shadow_types.h36
-rw-r--r--ui/views/views.gyp11
25 files changed, 211 insertions, 180 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/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_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_)
diff --git a/ui/aura/test/test_activation_client.cc b/ui/aura/test/test_activation_client.cc
index b451efa..78e36ad 100644
--- a/ui/aura/test/test_activation_client.cc
+++ b/ui/aura/test/test_activation_client.cc
@@ -4,6 +4,7 @@
#include "ui/aura/test/test_activation_client.h"
+#include "ui/aura/client/activation_change_observer.h"
#include "ui/aura/client/activation_delegate.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -29,20 +30,27 @@ TestActivationClient::~TestActivationClient() {
void TestActivationClient::AddObserver(
client::ActivationChangeObserver* observer) {
+ observers_.AddObserver(observer);
}
void TestActivationClient::RemoveObserver(
client::ActivationChangeObserver* observer) {
+ observers_.RemoveObserver(observer);
}
void TestActivationClient::ActivateWindow(Window* window) {
- Window *last_active = GetActiveWindow();
+ Window* last_active = GetActiveWindow();
if (last_active == window)
return;
RemoveActiveWindow(window);
active_windows_.push_back(window);
window->AddObserver(this);
+
+ FOR_EACH_OBSERVER(client::ActivationChangeObserver,
+ observers_,
+ OnWindowActivated(window, last_active));
+
if (aura::client::GetActivationDelegate(window))
aura::client::GetActivationDelegate(window)->OnActivated();
diff --git a/ui/aura/test/test_activation_client.h b/ui/aura/test/test_activation_client.h
index 835df83..2bfe884 100644
--- a/ui/aura/test/test_activation_client.h
+++ b/ui/aura/test/test_activation_client.h
@@ -47,6 +47,8 @@ class TestActivationClient : public client::ActivationClient,
// fail.
std::vector<Window*> active_windows_;
+ ObserverList<client::ActivationChangeObserver> observers_;
+
DISALLOW_COPY_AND_ASSIGN(TestActivationClient);
};
diff --git a/ash/wm/image_grid.cc b/ui/views/corewm/image_grid.cc
index 369ab82..b98af63 100644
--- a/ash/wm/image_grid.cc
+++ b/ui/views/corewm/image_grid.cc
@@ -2,7 +2,7 @@
// 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 "ui/views/corewm/image_grid.h"
#include <algorithm>
@@ -17,8 +17,8 @@
using std::max;
using std::min;
-namespace ash {
-namespace internal {
+namespace views {
+namespace corewm {
gfx::RectF ImageGrid::TestAPI::GetTransformedLayerBounds(
const ui::Layer& layer) {
@@ -280,5 +280,5 @@ void ImageGrid::SetImage(const gfx::Image* image,
layer_->Add(layer_ptr->get());
}
-} // namespace internal
-} // namespace ash
+} // namespace corewm
+} // namespace views
diff --git a/ash/wm/image_grid.h b/ui/views/corewm/image_grid.h
index cb3b7bb..3ef7310 100644
--- a/ash/wm/image_grid.h
+++ b/ui/views/corewm/image_grid.h
@@ -2,10 +2,9 @@
// 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_
+#ifndef UI_VIEWS_COREWM_IMAGE_GRID_H_
+#define UI_VIEWS_COREWM_IMAGE_GRID_H_
-#include "ash/ash_export.h"
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
@@ -13,13 +12,14 @@
#include "ui/compositor/layer_delegate.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Image;
} // namespace gfx
-namespace ash {
-namespace internal {
+namespace views {
+namespace corewm {
// An ImageGrid is a 3x3 array of ui::Layers, each containing an image.
//
@@ -57,10 +57,10 @@ namespace internal {
// | xXX|
// ...
//
-class ASH_EXPORT ImageGrid {
+class VIEWS_EXPORT ImageGrid {
public:
// Helper class for use by tests.
- class ASH_EXPORT TestAPI {
+ class VIEWS_EXPORT TestAPI {
public:
TestAPI(ImageGrid* grid) : grid_(grid) {}
@@ -212,7 +212,7 @@ class ASH_EXPORT ImageGrid {
DISALLOW_COPY_AND_ASSIGN(ImageGrid);
};
-} // namespace internal
-} // namespace ash
+} // namespace corewm
+} // namespace views
-#endif // ASH_WM_IMAGE_GRID_H_
+#endif // UI_VIEWS_COREWM_IMAGE_GRID_H_
diff --git a/ash/wm/image_grid_unittest.cc b/ui/views/corewm/image_grid_unittest.cc
index 73a07f1..169c1ed 100644
--- a/ash/wm/image_grid_unittest.cc
+++ b/ui/views/corewm/image_grid_unittest.cc
@@ -2,16 +2,14 @@
// 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/views/test/views_test_base.h"
#include "ui/gfx/image/image.h"
+#include "ui/views/corewm/image_grid.h"
-using ash::internal::ImageGrid;
-
-namespace ash {
-namespace test {
+namespace views {
+namespace corewm {
namespace {
@@ -24,7 +22,7 @@ gfx::Image* CreateImage(const gfx::Size& size) {
} // namespace
-typedef ash::test::AshTestBase ImageGridTest;
+typedef ViewsTestBase ImageGridTest;
// Test that an ImageGrid's layers are transformed correctly when SetSize() is
// called.
@@ -338,5 +336,5 @@ TEST_F(ImageGridTest, TooSmall) {
EXPECT_TRUE(test_api.bottom_right_clip_rect().IsEmpty());
}
-} // namespace test
-} // namespace ash
+} // namespace corewm
+} // namespace views
diff --git a/ash/wm/shadow.cc b/ui/views/corewm/shadow.cc
index 01bc5ed..9b690e9 100644
--- a/ash/wm/shadow.cc
+++ b/ui/views/corewm/shadow.cc
@@ -2,13 +2,12 @@
// 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 "ui/views/corewm/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"
+#include "ui/views/corewm/image_grid.h"
namespace {
@@ -20,13 +19,13 @@ const float kSmallShadowOpacity = 1.0f;
// Duration for opacity animation in milliseconds.
const int kShadowAnimationDurationMs = 100;
-float GetOpacityForStyle(ash::internal::Shadow::Style style) {
+float GetOpacityForStyle(views::corewm::Shadow::Style style) {
switch (style) {
- case ash::internal::Shadow::STYLE_ACTIVE:
+ case views::corewm::Shadow::STYLE_ACTIVE:
return kActiveShadowOpacity;
- case ash::internal::Shadow::STYLE_INACTIVE:
+ case views::corewm::Shadow::STYLE_INACTIVE:
return kInactiveShadowOpacity;
- case ash::internal::Shadow::STYLE_SMALL:
+ case views::corewm::Shadow::STYLE_SMALL:
return kSmallShadowOpacity;
default:
NOTREACHED() << "Unhandled style " << style;
@@ -36,8 +35,8 @@ float GetOpacityForStyle(ash::internal::Shadow::Style style) {
} // namespace
-namespace ash {
-namespace internal {
+namespace views {
+namespace corewm {
Shadow::Shadow() : style_(STYLE_ACTIVE) {
}
@@ -172,5 +171,5 @@ void Shadow::UpdateImageGridBounds() {
image_grid_->SetContentBounds(content_bounds_);
}
-} // namespace internal
-} // namespace ash
+} // namespace corewm
+} // namespace views
diff --git a/ash/wm/shadow.h b/ui/views/corewm/shadow.h
index 0dd84d0..ae203eb 100644
--- a/ash/wm/shadow.h
+++ b/ui/views/corewm/shadow.h
@@ -2,26 +2,26 @@
// 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_
+#ifndef UI_VIEWS_COREWM_SHADOW_H_
+#define UI_VIEWS_COREWM_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"
+#include "ui/views/views_export.h"
namespace ui {
class Layer;
} // namespace ui
-namespace ash {
-namespace internal {
+namespace views {
+namespace corewm {
class ImageGrid;
// Simple class that draws a drop shadow around content at given bounds.
-class ASH_EXPORT Shadow : public ui::ImplicitAnimationObserver {
+class VIEWS_EXPORT Shadow : public ui::ImplicitAnimationObserver {
public:
enum Style {
// Active windows have more opaque shadows, shifted down to make the window
@@ -78,7 +78,7 @@ class ASH_EXPORT Shadow : public ui::ImplicitAnimationObserver {
DISALLOW_COPY_AND_ASSIGN(Shadow);
};
-} // namespace internal
-} // namespace ash
+} // namespace corewm
+} // namespace views
-#endif // ASH_WM_SHADOW_H_
+#endif // UI_VIEWS_COREWM_SHADOW_H_
diff --git a/ash/wm/shadow_controller.cc b/ui/views/corewm/shadow_controller.cc
index abfb6ea..2e97aac 100644
--- a/ash/wm/shadow_controller.cc
+++ b/ui/views/corewm/shadow_controller.cc
@@ -2,14 +2,10 @@
// 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 "ui/views/corewm/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"
@@ -17,11 +13,13 @@
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
+#include "ui/views/corewm/shadow.h"
+#include "ui/views/corewm/shadow_types.h"
using std::make_pair;
-namespace ash {
-namespace internal {
+namespace views {
+namespace corewm {
namespace {
@@ -68,17 +66,16 @@ Shadow::Style GetShadowStyleForWindowLosingActive(
} // namespace
-ShadowController::ShadowController()
- : ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) {
+ShadowController::ShadowController(aura::RootWindow* root_window)
+ : ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)),
+ root_window_(root_window) {
aura::Env::GetInstance()->AddObserver(this);
// Watch for window activation changes.
- aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
- AddObserver(this);
+ aura::client::GetActivationClient(root_window_)->AddObserver(this);
}
ShadowController::~ShadowController() {
- aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
- RemoveObserver(this);
+ aura::client::GetActivationClient(root_window_)->RemoveObserver(this);
aura::Env::GetInstance()->RemoveObserver(this);
}
@@ -165,5 +162,5 @@ void ShadowController::CreateShadowForWindow(aura::Window* window) {
window->layer()->Add(shadow->layer());
}
-} // namespace internal
-} // namespace ash
+} // namespace corewm
+} // namespace views
diff --git a/ash/wm/shadow_controller.h b/ui/views/corewm/shadow_controller.h
index c3c3702..32ca0b9 100644
--- a/ash/wm/shadow_controller.h
+++ b/ui/views/corewm/shadow_controller.h
@@ -2,12 +2,11 @@
// 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_
+#ifndef UI_VIEWS_COREWM_SHADOW_CONTROLLER_H_
+#define UI_VIEWS_COREWM_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"
@@ -15,22 +14,24 @@
#include "ui/aura/client/activation_change_observer.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/window_observer.h"
+#include "ui/views/views_export.h"
namespace aura {
+class RootWindow;
class Window;
}
namespace gfx {
class Rect;
}
-namespace ash {
-namespace internal {
+namespace views {
+namespace corewm {
class Shadow;
// ShadowController observes changes to windows and creates and updates drop
// shadows as needed.
-class ASH_EXPORT ShadowController :
+class VIEWS_EXPORT ShadowController :
public aura::EnvObserver,
public aura::WindowObserver,
public aura::client::ActivationChangeObserver {
@@ -50,7 +51,7 @@ class ASH_EXPORT ShadowController :
DISALLOW_COPY_AND_ASSIGN(TestApi);
};
- explicit ShadowController();
+ explicit ShadowController(aura::RootWindow* root_window);
virtual ~ShadowController();
// aura::EnvObserver override:
@@ -95,10 +96,12 @@ class ASH_EXPORT ShadowController :
ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_;
+ aura::RootWindow* root_window_;
+
DISALLOW_COPY_AND_ASSIGN(ShadowController);
};
-} // namespace internal
-} // namespace ash
+} // namespace corewm
+} // namespace views
-#endif // ASH_WM_SHADOW_CONTROLLER_H_
+#endif // UI_VIEWS_COREWM_SHADOW_CONTROLLER_H_
diff --git a/ash/wm/shadow_controller_unittest.cc b/ui/views/corewm/shadow_controller_unittest.cc
index 9879f55..798159a 100644
--- a/ash/wm/shadow_controller_unittest.cc
+++ b/ui/views/corewm/shadow_controller_unittest.cc
@@ -2,27 +2,52 @@
// 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 "ui/views/corewm/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/test/aura_test_base.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
-
-namespace ash {
-namespace internal {
-
-typedef ash::test::AshTestBase ShadowControllerTest;
+#include "ui/views/corewm/shadow.h"
+#include "ui/views/corewm/shadow_types.h"
+
+namespace views {
+namespace corewm {
+
+class ShadowControllerTest : public aura::test::AuraTestBase {
+ public:
+ ShadowControllerTest() {}
+ virtual ~ShadowControllerTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ AuraTestBase::SetUp();
+ shadow_controller_.reset(new ShadowController(root_window()));
+ }
+ virtual void TearDown() OVERRIDE {
+ shadow_controller_.reset();
+ AuraTestBase::TearDown();
+ }
+
+ protected:
+ ShadowController* shadow_controller() { return shadow_controller_.get(); }
+
+ void ActivateWindow(aura::Window* window) {
+ DCHECK(window);
+ DCHECK(window->GetRootWindow());
+ aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow(
+ window);
+ }
+
+ private:
+ scoped_ptr<ShadowController> shadow_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShadowControllerTest);
+};
// Tests that various methods in Window update the Shadow object as expected.
TEST_F(ShadowControllerTest, Shadow) {
@@ -33,9 +58,8 @@ TEST_F(ShadowControllerTest, Shadow) {
// 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());
+ ShadowController::TestApi api(shadow_controller());
+ const Shadow* shadow = api.GetShadowForWindow(window.get());
ASSERT_TRUE(shadow != NULL);
EXPECT_TRUE(shadow->layer()->visible());
@@ -46,10 +70,10 @@ TEST_F(ShadowControllerTest, Shadow) {
EXPECT_TRUE(shadow->layer()->visible());
// If the shadow is disabled, it should be hidden.
- internal::SetShadowType(window.get(), internal::SHADOW_TYPE_NONE);
+ SetShadowType(window.get(), SHADOW_TYPE_NONE);
window->Show();
EXPECT_FALSE(shadow->layer()->visible());
- internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR);
+ SetShadowType(window.get(), SHADOW_TYPE_RECTANGULAR);
EXPECT_TRUE(shadow->layer()->visible());
// The shadow's layer should be a child of the window's layer.
@@ -74,10 +98,9 @@ TEST_F(ShadowControllerTest, ShadowBounds) {
// 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());
+ SetShadowType(window.get(), SHADOW_TYPE_RECTANGULAR);
+ ShadowController::TestApi api(shadow_controller());
+ const Shadow* shadow = api.GetShadowForWindow(window.get());
ASSERT_TRUE(shadow != NULL);
EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(),
shadow->content_bounds().ToString());
@@ -91,8 +114,7 @@ TEST_F(ShadowControllerTest, ShadowBounds) {
// Tests that activating a window changes the shadow style.
TEST_F(ShadowControllerTest, ShadowStyle) {
- ShadowController::TestApi api(
- ash::Shell::GetInstance()->shadow_controller());
+ ShadowController::TestApi api(shadow_controller());
scoped_ptr<aura::Window> window1(new aura::Window(NULL));
window1->SetType(aura::client::WINDOW_TYPE_NORMAL);
@@ -100,7 +122,7 @@ TEST_F(ShadowControllerTest, ShadowStyle) {
window1->SetParent(NULL);
window1->SetBounds(gfx::Rect(10, 20, 300, 400));
window1->Show();
- wm::ActivateWindow(window1.get());
+ ActivateWindow(window1.get());
// window1 is active, so style should have active appearance.
Shadow* shadow1 = api.GetShadowForWindow(window1.get());
@@ -114,7 +136,7 @@ TEST_F(ShadowControllerTest, ShadowStyle) {
window2->SetParent(NULL);
window2->SetBounds(gfx::Rect(11, 21, 301, 401));
window2->Show();
- wm::ActivateWindow(window2.get());
+ ActivateWindow(window2.get());
// window1 is now inactive, so shadow should go inactive.
Shadow* shadow2 = api.GetShadowForWindow(window2.get());
@@ -125,8 +147,7 @@ TEST_F(ShadowControllerTest, ShadowStyle) {
// Tests that we use smaller shadows for tooltips and menus.
TEST_F(ShadowControllerTest, SmallShadowsForTooltipsAndMenus) {
- ShadowController::TestApi api(
- ash::Shell::GetInstance()->shadow_controller());
+ ShadowController::TestApi api(shadow_controller());
scoped_ptr<aura::Window> tooltip_window(new aura::Window(NULL));
tooltip_window->SetType(aura::client::WINDOW_TYPE_TOOLTIP);
@@ -154,8 +175,7 @@ TEST_F(ShadowControllerTest, SmallShadowsForTooltipsAndMenus) {
// 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());
+ ShadowController::TestApi api(shadow_controller());
scoped_ptr<aura::Window> window1(new aura::Window(NULL));
window1->SetType(aura::client::WINDOW_TYPE_NORMAL);
@@ -163,7 +183,7 @@ TEST_F(ShadowControllerTest, TransientParentKeepsActiveShadow) {
window1->SetParent(NULL);
window1->SetBounds(gfx::Rect(10, 20, 300, 400));
window1->Show();
- wm::ActivateWindow(window1.get());
+ ActivateWindow(window1.get());
// window1 is active, so style should have active appearance.
Shadow* shadow1 = api.GetShadowForWindow(window1.get());
@@ -181,11 +201,11 @@ TEST_F(ShadowControllerTest, TransientParentKeepsActiveShadow) {
window1->AddTransientChild(window2.get());
aura::client::SetHideOnDeactivate(window2.get(), true);
window2->Show();
- wm::ActivateWindow(window2.get());
+ 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
+} // namespace corewm
+} // namespace views
diff --git a/ash/wm/shadow_types.cc b/ui/views/corewm/shadow_types.cc
index 296986a..1e3a937 100644
--- a/ash/wm/shadow_types.cc
+++ b/ui/views/corewm/shadow_types.cc
@@ -2,13 +2,14 @@
// 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 "ui/views/corewm/shadow_types.h"
-#include "ash/wm/window_properties.h"
-#include "ui/aura/window.h"
+#include "ui/aura/window_property.h"
-namespace ash {
-namespace internal {
+DECLARE_WINDOW_PROPERTY_TYPE(views::corewm::ShadowType);
+
+namespace views {
+namespace corewm {
void SetShadowType(aura::Window* window, ShadowType shadow_type) {
window->SetProperty(kShadowTypeKey, shadow_type);
@@ -18,5 +19,7 @@ ShadowType GetShadowType(aura::Window* window) {
return window->GetProperty(kShadowTypeKey);
}
-} // namespace internal
-} // namespace ash
+DEFINE_WINDOW_PROPERTY_KEY(ShadowType, kShadowTypeKey, SHADOW_TYPE_NONE);
+
+} // namespace corewm
+} // namespace views
diff --git a/ui/views/corewm/shadow_types.h b/ui/views/corewm/shadow_types.h
new file mode 100644
index 0000000..046ad70
--- /dev/null
+++ b/ui/views/corewm/shadow_types.h
@@ -0,0 +1,36 @@
+// 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 UI_VIEWS_COREWM_SHADOW_TYPES_H_
+#define UI_VIEWS_COREWM_SHADOW_TYPES_H_
+
+#include "ui/aura/window.h"
+#include "ui/views/views_export.h"
+
+namespace aura {
+class Window;
+}
+
+namespace views {
+namespace corewm {
+
+// 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,
+};
+
+VIEWS_EXPORT void SetShadowType(aura::Window* window, ShadowType shadow_type);
+VIEWS_EXPORT ShadowType GetShadowType(aura::Window* window);
+
+// 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;
+
+} // namespace corewm
+} // namespace views
+
+#endif // UI_VIEWS_COREWM_SHADOW_TYPES_H_
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index 4c342b7..e99c72b 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -5,7 +5,6 @@
'variables': {
'chromium_code': 1,
},
-
'target_defaults': {
'conditions': [
['use_aura==1', {
@@ -240,8 +239,16 @@
'controls/tree/tree_view_win.h',
'corewm/compound_event_filter.cc',
'corewm/compound_event_filter.h',
+ 'corewm/image_grid.cc',
+ 'corewm/image_grid.h',
'corewm/input_method_event_filter.cc',
'corewm/input_method_event_filter.h',
+ 'corewm/shadow.cc',
+ 'corewm/shadow.h',
+ 'corewm/shadow_controller.cc',
+ 'corewm/shadow_controller.h',
+ 'corewm/shadow_types.cc',
+ 'corewm/shadow_types.h',
'debug_utils.cc',
'debug_utils.h',
'drag_controller.h',
@@ -621,7 +628,9 @@
'controls/textfield/textfield_views_model_unittest.cc',
'controls/tree/tree_view_views_unittest.cc',
'corewm/compound_event_filter_unittest.cc',
+ 'corewm/image_grid_unittest.cc',
'corewm/input_method_event_filter_unittest.cc',
+ 'corewm/shadow_controller_unittest.cc',
'focus/focus_manager_test.h',
'focus/focus_manager_test.cc',
'focus/focus_manager_unittest.cc',