OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/window/frame_background.h" | 5 #include "ui/views/window/frame_background.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkCanvas.h" | 7 #include "third_party/skia/include/core/SkCanvas.h" |
8 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
9 #include "ui/base/theme_provider.h" | 9 #include "ui/base/theme_provider.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 void FrameBackground::SetCornerImages(const gfx::ImageSkia* top_left, | 44 void FrameBackground::SetCornerImages(const gfx::ImageSkia* top_left, |
45 const gfx::ImageSkia* top_right, | 45 const gfx::ImageSkia* top_right, |
46 const gfx::ImageSkia* bottom_left, | 46 const gfx::ImageSkia* bottom_left, |
47 const gfx::ImageSkia* bottom_right) { | 47 const gfx::ImageSkia* bottom_right) { |
48 top_left_corner_ = top_left; | 48 top_left_corner_ = top_left; |
49 top_right_corner_ = top_right; | 49 top_right_corner_ = top_right; |
50 bottom_left_corner_ = bottom_left; | 50 bottom_left_corner_ = bottom_left; |
51 bottom_right_corner_ = bottom_right; | 51 bottom_right_corner_ = bottom_right; |
52 } | 52 } |
53 | 53 |
54 void FrameBackground::PaintRestored(gfx::Canvas* canvas, View* view) const { | 54 void FrameBackground::PaintRestored(gfx::Canvas* canvas, |
| 55 const View* view) const { |
55 // Fill with the frame color first so we have a constant background for | 56 // Fill with the frame color first so we have a constant background for |
56 // areas not covered by the theme image. | 57 // areas not covered by the theme image. |
57 PaintFrameColor(canvas, view); | 58 PaintFrameColor(canvas, view); |
58 | 59 |
59 // Draw the theme frame. | 60 // Draw the theme frame. |
60 canvas->TileImageInt(*theme_image_, | 61 canvas->TileImageInt(*theme_image_, |
61 0, 0, view->width(), theme_image_->height()); | 62 0, 0, view->width(), theme_image_->height()); |
62 | 63 |
63 // Draw the theme frame overlay, if available. | 64 // Draw the theme frame overlay, if available. |
64 if (theme_overlay_image_) | 65 if (theme_overlay_image_) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 view->height() - bottom_left_corner_->height()); | 113 view->height() - bottom_left_corner_->height()); |
113 | 114 |
114 // Left edge. | 115 // Left edge. |
115 int left_edge_height = | 116 int left_edge_height = |
116 view->height() - top_left_height - bottom_left_corner_->height(); | 117 view->height() - top_left_height - bottom_left_corner_->height(); |
117 canvas->TileImageInt(*left_edge_, | 118 canvas->TileImageInt(*left_edge_, |
118 0, top_left_height, | 119 0, top_left_height, |
119 left_edge_->width(), left_edge_height); | 120 left_edge_->width(), left_edge_height); |
120 } | 121 } |
121 | 122 |
122 void FrameBackground::PaintMaximized(gfx::Canvas* canvas, View* view) const { | 123 void FrameBackground::PaintMaximized(gfx::Canvas* canvas, |
| 124 const View* view) const { |
123 // We will be painting from -|maximized_top_inset_| to | 125 // We will be painting from -|maximized_top_inset_| to |
124 // -|maximized_top_inset_| + |theme_image_|->height(). If this is less than | 126 // -|maximized_top_inset_| + |theme_image_|->height(). If this is less than |
125 // |top_area_height_|, we need to paint the frame color to fill in the area | 127 // |top_area_height_|, we need to paint the frame color to fill in the area |
126 // beneath the image. | 128 // beneath the image. |
127 int theme_frame_bottom = -maximized_top_inset_ + theme_image_->height(); | 129 int theme_frame_bottom = -maximized_top_inset_ + theme_image_->height(); |
128 if (top_area_height_ > theme_frame_bottom) { | 130 if (top_area_height_ > theme_frame_bottom) { |
129 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), | 131 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), |
130 frame_color_); | 132 frame_color_); |
131 } | 133 } |
132 | 134 |
133 // Draw the theme frame. | 135 // Draw the theme frame. |
134 canvas->TileImageInt(*theme_image_, | 136 canvas->TileImageInt(*theme_image_, |
135 0, | 137 0, |
136 -maximized_top_inset_, | 138 -maximized_top_inset_, |
137 view->width(), | 139 view->width(), |
138 theme_image_->height()); | 140 theme_image_->height()); |
139 // Draw the theme frame overlay, if available. | 141 // Draw the theme frame overlay, if available. |
140 if (theme_overlay_image_) | 142 if (theme_overlay_image_) |
141 canvas->DrawImageInt(*theme_overlay_image_, 0, -maximized_top_inset_); | 143 canvas->DrawImageInt(*theme_overlay_image_, 0, -maximized_top_inset_); |
142 } | 144 } |
143 | 145 |
144 void FrameBackground::PaintFrameColor(gfx::Canvas* canvas, View* view) const { | 146 void FrameBackground::PaintFrameColor(gfx::Canvas* canvas, |
| 147 const View* view) const { |
145 // Fill the top area. | 148 // Fill the top area. |
146 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), | 149 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), |
147 frame_color_); | 150 frame_color_); |
148 | 151 |
149 // If the window is very short, we're done. | 152 // If the window is very short, we're done. |
150 int remaining_height = view->height() - top_area_height_; | 153 int remaining_height = view->height() - top_area_height_; |
151 if (remaining_height <= 0) | 154 if (remaining_height <= 0) |
152 return; | 155 return; |
153 | 156 |
154 // Fill down the sides. | 157 // Fill down the sides. |
(...skipping 10 matching lines...) Expand all Loading... |
165 return; | 168 return; |
166 | 169 |
167 // Fill the bottom area. | 170 // Fill the bottom area. |
168 canvas->FillRect(gfx::Rect(left_edge_->width(), | 171 canvas->FillRect(gfx::Rect(left_edge_->width(), |
169 view->height() - bottom_edge_->height(), | 172 view->height() - bottom_edge_->height(), |
170 center_width, bottom_edge_->height()), | 173 center_width, bottom_edge_->height()), |
171 frame_color_); | 174 frame_color_); |
172 } | 175 } |
173 | 176 |
174 } // namespace views | 177 } // namespace views |
OLD | NEW |