OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/aura_shell/shadow.h" | |
6 | |
7 #include "grit/ui_resources.h" | |
8 #include "ui/aura_shell/image_grid.h" | |
9 #include "ui/base/resource/resource_bundle.h" | |
10 | |
11 namespace aura_shell { | |
12 namespace internal { | |
13 | |
14 Shadow::Shadow() { | |
15 } | |
16 | |
17 Shadow::~Shadow() { | |
18 } | |
19 | |
20 ui::Layer* Shadow::layer() const { return image_grid_->layer(); } | |
21 | |
22 void Shadow::Init() { | |
23 image_grid_.reset(new ImageGrid); | |
24 | |
25 ResourceBundle& res = ResourceBundle::GetSharedInstance(); | |
26 image_grid_->Init(&res.GetImageNamed(IDR_AURA_SHADOW_RECT_TOP_LEFT), | |
27 &res.GetImageNamed(IDR_AURA_SHADOW_RECT_TOP), | |
28 &res.GetImageNamed(IDR_AURA_SHADOW_RECT_TOP_RIGHT), | |
29 &res.GetImageNamed(IDR_AURA_SHADOW_RECT_LEFT), | |
30 NULL, | |
31 &res.GetImageNamed(IDR_AURA_SHADOW_RECT_RIGHT), | |
32 &res.GetImageNamed(IDR_AURA_SHADOW_RECT_BOTTOM_LEFT), | |
33 &res.GetImageNamed(IDR_AURA_SHADOW_RECT_BOTTOM), | |
34 &res.GetImageNamed(IDR_AURA_SHADOW_RECT_BOTTOM_RIGHT)); | |
35 } | |
36 | |
37 void Shadow::SetContentBounds(const gfx::Rect& content_bounds) { | |
38 content_bounds_ = content_bounds; | |
39 image_grid_->SetSize( | |
40 gfx::Size(content_bounds.width() + | |
41 image_grid_->left_image_width() + | |
42 image_grid_->right_image_width(), | |
43 content_bounds.height() + | |
44 image_grid_->top_image_height() + | |
45 image_grid_->bottom_image_height())); | |
46 image_grid_->layer()->SetBounds( | |
47 gfx::Rect(content_bounds.x() - image_grid_->left_image_width(), | |
48 content_bounds.y() - image_grid_->top_image_height(), | |
49 image_grid_->layer()->bounds().width(), | |
50 image_grid_->layer()->bounds().height())); | |
51 } | |
52 | |
53 } // namespace internal | |
54 } // namespace aura_shell | |
OLD | NEW |