summaryrefslogtreecommitdiffstats
path: root/ui/aura_shell/shadow.cc
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-21 22:03:34 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-21 22:03:34 +0000
commita54e65be68a438559f1c11c6ac1cbcc8999528cf (patch)
treefa15db2b97e60f247b60b97f63b49e1410c90020 /ui/aura_shell/shadow.cc
parent844b10080bdf0658c1535141d4f24380d7625c7a (diff)
downloadchromium_src-a54e65be68a438559f1c11c6ac1cbcc8999528cf.zip
chromium_src-a54e65be68a438559f1c11c6ac1cbcc8999528cf.tar.gz
chromium_src-a54e65be68a438559f1c11c6ac1cbcc8999528cf.tar.bz2
aura: Draw drop shadows under browsers and menus.
This is largely a port of the existing X window manager's code for drawing shadows around windows. It adds an ImageGrid class for drawing a scaled 3x3 grid of gfx::Images and a Shadow class (managed by aura_shell::ShadowController) that uses ImageGrid to draw a shadow. Shadows can be disabled via --aura-no-shadows. BUG=101977 TEST=added unit tests; also manually checked that shadows get drawn Review URL: http://codereview.chromium.org/8555025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura_shell/shadow.cc')
-rw-r--r--ui/aura_shell/shadow.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/ui/aura_shell/shadow.cc b/ui/aura_shell/shadow.cc
new file mode 100644
index 0000000..2963dd5
--- /dev/null
+++ b/ui/aura_shell/shadow.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura_shell/shadow.h"
+
+#include "grit/ui_resources.h"
+#include "ui/aura_shell/image_grid.h"
+#include "ui/base/resource/resource_bundle.h"
+
+namespace aura_shell {
+namespace internal {
+
+Shadow::Shadow() {
+}
+
+Shadow::~Shadow() {
+}
+
+ui::Layer* Shadow::layer() const { return image_grid_->layer(); }
+
+void Shadow::Init() {
+ image_grid_.reset(new ImageGrid);
+
+ ResourceBundle& res = ResourceBundle::GetSharedInstance();
+ image_grid_->Init(&res.GetImageNamed(IDR_AURA_SHADOW_RECT_TOP_LEFT),
+ &res.GetImageNamed(IDR_AURA_SHADOW_RECT_TOP),
+ &res.GetImageNamed(IDR_AURA_SHADOW_RECT_TOP_RIGHT),
+ &res.GetImageNamed(IDR_AURA_SHADOW_RECT_LEFT),
+ NULL,
+ &res.GetImageNamed(IDR_AURA_SHADOW_RECT_RIGHT),
+ &res.GetImageNamed(IDR_AURA_SHADOW_RECT_BOTTOM_LEFT),
+ &res.GetImageNamed(IDR_AURA_SHADOW_RECT_BOTTOM),
+ &res.GetImageNamed(IDR_AURA_SHADOW_RECT_BOTTOM_RIGHT));
+}
+
+void Shadow::SetContentBounds(const gfx::Rect& content_bounds) {
+ content_bounds_ = content_bounds;
+ image_grid_->SetSize(
+ gfx::Size(content_bounds.width() +
+ image_grid_->left_image_width() +
+ image_grid_->right_image_width(),
+ content_bounds.height() +
+ image_grid_->top_image_height() +
+ image_grid_->bottom_image_height()));
+ image_grid_->layer()->SetBounds(
+ gfx::Rect(content_bounds.x() - image_grid_->left_image_width(),
+ content_bounds.y() - image_grid_->top_image_height(),
+ image_grid_->layer()->bounds().width(),
+ image_grid_->layer()->bounds().height()));
+}
+
+} // namespace internal
+} // namespace aura_shell