summaryrefslogtreecommitdiffstats
path: root/ash/wm/image_grid.cc
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 23:05:54 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 23:05:54 +0000
commita8bd1cba75804f6d448acf0b5e4c91d0c4073c4b (patch)
tree63d3c722d19a3c873271576be3567d2aed60c8b0 /ash/wm/image_grid.cc
parentf7b1b2a21ea145f6c1042d51a62b751ba45c722e (diff)
downloadchromium_src-a8bd1cba75804f6d448acf0b5e4c91d0c4073c4b.zip
chromium_src-a8bd1cba75804f6d448acf0b5e4c91d0c4073c4b.tar.gz
chromium_src-a8bd1cba75804f6d448acf0b5e4c91d0c4073c4b.tar.bz2
Aura: New window shadows, desktop background debug toggle
+ Shadows support different appearances for active and inactive states. + Shadow opacity animates on activation change. + ImageGrid supports changing its images, allowing us to maintain our use of a single set of shadow layers per window. + Press control-alt-B in a debug build to reset the desktop background to a solid color, useful with a white background for testing shadows. + Window shadow art assets were added in an earlier revision. After this change lands I will delete the previous art assets, ui/resources/aura/shadow_rect_* BUG=113075 TEST=aura_shell_unittests, added to ShadowControllerTest and ImageGridTest TBR=sky@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=122547 Reverted: https://src.chromium.org/viewvc/chrome?view=rev&revision=122551 Review URL: http://codereview.chromium.org/9414028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/image_grid.cc')
-rw-r--r--ash/wm/image_grid.cc58
1 files changed, 34 insertions, 24 deletions
diff --git a/ash/wm/image_grid.cc b/ash/wm/image_grid.cc
index d888762..99ef5c7 100644
--- a/ash/wm/image_grid.cc
+++ b/ash/wm/image_grid.cc
@@ -26,7 +26,8 @@ gfx::Rect ImageGrid::TestAPI::GetTransformedLayerBounds(
}
ImageGrid::ImageGrid()
- : top_image_height_(0),
+ : layer_(new ui::Layer(ui::Layer::LAYER_NOT_DRAWN)),
+ top_image_height_(0),
bottom_image_height_(0),
left_image_width_(0),
right_image_width_(0),
@@ -39,26 +40,24 @@ ImageGrid::ImageGrid()
ImageGrid::~ImageGrid() {
}
-void ImageGrid::Init(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) {
- layer_.reset(new ui::Layer(ui::Layer::LAYER_NOT_DRAWN));
-
- InitImage(top_left_image, &top_left_layer_, &top_left_painter_);
- InitImage(top_image, &top_layer_, &top_painter_);
- InitImage(top_right_image, &top_right_layer_, &top_right_painter_);
- InitImage(left_image, &left_layer_, &left_painter_);
- InitImage(center_image, &center_layer_, &center_painter_);
- InitImage(right_image, &right_layer_, &right_painter_);
- InitImage(bottom_left_image, &bottom_left_layer_, &bottom_left_painter_);
- InitImage(bottom_image, &bottom_layer_, &bottom_painter_);
- InitImage(bottom_right_image, &bottom_right_layer_, &bottom_right_painter_);
+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();
@@ -77,6 +76,9 @@ void ImageGrid::Init(const gfx::Image* top_left_image,
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) {
@@ -224,12 +226,20 @@ bool ImageGrid::LayerExceedsSize(const ui::Layer* layer,
layer->bounds().height() > size.height();
}
-void ImageGrid::InitImage(const gfx::Image* image,
- scoped_ptr<ui::Layer>* layer_ptr,
- scoped_ptr<ImagePainter>* painter_ptr) {
+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::LAYER_TEXTURED));
const gfx::Size size = GetImageSize(image);