Chromium Code Reviews| 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 "grit/ui_resources.h" | 7 #include "grit/ui_resources.h" |
| 8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/base/theme_provider.h" | 10 #include "ui/base/theme_provider.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 maximized_top_right_ = top_right; | 62 maximized_top_right_ = top_right; |
| 63 maximized_top_offset_ = top_offset; | 63 maximized_top_offset_ = top_offset; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void FrameBackground::PaintRestored(gfx::Canvas* canvas, View* view) const { | 66 void FrameBackground::PaintRestored(gfx::Canvas* canvas, View* view) const { |
| 67 // Fill with the frame color first so we have a constant background for | 67 // Fill with the frame color first so we have a constant background for |
| 68 // areas not covered by the theme image. | 68 // areas not covered by the theme image. |
| 69 PaintFrameColor(canvas, view); | 69 PaintFrameColor(canvas, view); |
| 70 | 70 |
| 71 // Draw the theme frame. | 71 // Draw the theme frame. |
| 72 canvas->TileImageInt(*theme_bitmap_, | 72 canvas->TileImage(*theme_bitmap_, |
| 73 0, 0, view->width(), theme_bitmap_->height()); | 73 gfx::Rect(0, 0, view->width(), theme_bitmap_->height())); |
| 74 | 74 |
| 75 // Draw the theme frame overlay, if available. | 75 // Draw the theme frame overlay, if available. |
| 76 if (theme_overlay_bitmap_) | 76 if (theme_overlay_bitmap_) |
| 77 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, 0); | 77 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, 0); |
| 78 | 78 |
| 79 // Draw the top corners and edge, scaling the corner images down if they | 79 // Draw the top corners and edge, scaling the corner images down if they |
| 80 // are too big and relative to the vertical space available. | 80 // are too big and relative to the vertical space available. |
| 81 int top_left_height = | 81 int top_left_height = |
| 82 std::min(top_left_corner_->height(), | 82 std::min(top_left_corner_->height(), |
| 83 view->height() - bottom_left_corner_->height()); | 83 view->height() - bottom_left_corner_->height()); |
| 84 canvas->DrawBitmapInt(*top_left_corner_, | 84 canvas->DrawBitmapInt(*top_left_corner_, |
| 85 0, 0, top_left_corner_->width(), top_left_height, | 85 0, 0, top_left_corner_->width(), top_left_height, |
| 86 0, 0, top_left_corner_->width(), top_left_height, | 86 0, 0, top_left_corner_->width(), top_left_height, |
| 87 false); | 87 false); |
| 88 canvas->TileImageInt(*top_edge_, | 88 canvas->TileImage(*top_edge_, gfx::Rect(top_left_corner_->width(), |
| 89 top_left_corner_->width(), | |
| 90 0, | 89 0, |
| 91 view->width() - top_left_corner_->width() - top_right_corner_->width(), | 90 view->width() - top_left_corner_->width() - top_right_corner_->width(), |
|
tfarina
2012/02/08 19:45:15
Peter, this calculation is resulting in -2.
10 -
Peter Kasting
2012/02/08 20:54:57
Why is the view allowed to reach as small as 10 px
| |
| 92 top_edge_->height()); | 91 top_edge_->height())); |
| 93 int top_right_height = | 92 int top_right_height = |
| 94 std::min(top_right_corner_->height(), | 93 std::min(top_right_corner_->height(), |
| 95 view->height() - bottom_right_corner_->height()); | 94 view->height() - bottom_right_corner_->height()); |
| 96 canvas->DrawBitmapInt(*top_right_corner_, | 95 canvas->DrawBitmapInt(*top_right_corner_, |
| 97 0, 0, | 96 0, 0, |
| 98 top_right_corner_->width(), top_right_height, | 97 top_right_corner_->width(), top_right_height, |
| 99 view->width() - top_right_corner_->width(), 0, | 98 view->width() - top_right_corner_->width(), 0, |
| 100 top_right_corner_->width(), top_right_height, | 99 top_right_corner_->width(), top_right_height, |
| 101 false); | 100 false); |
| 102 | 101 |
| 103 // Right edge. | 102 // Right edge. |
| 104 int right_edge_height = | 103 int right_edge_height = |
| 105 view->height() - top_right_height - bottom_right_corner_->height(); | 104 view->height() - top_right_height - bottom_right_corner_->height(); |
| 106 canvas->TileImageInt(*right_edge_, | 105 canvas->TileImage(*right_edge_, |
| 107 view->width() - right_edge_->width(), | 106 gfx::Rect(view->width() - right_edge_->width(), |
| 108 top_right_height, | 107 top_right_height, |
| 109 right_edge_->width(), | 108 right_edge_->width(), |
| 110 right_edge_height); | 109 right_edge_height)); |
| 111 | 110 |
| 112 // Bottom corners and edge. | 111 // Bottom corners and edge. |
| 113 canvas->DrawBitmapInt(*bottom_right_corner_, | 112 canvas->DrawBitmapInt(*bottom_right_corner_, |
| 114 view->width() - bottom_right_corner_->width(), | 113 view->width() - bottom_right_corner_->width(), |
| 115 view->height() - bottom_right_corner_->height()); | 114 view->height() - bottom_right_corner_->height()); |
| 116 canvas->TileImageInt( | 115 canvas->TileImage(*bottom_edge_, |
| 117 *bottom_edge_, | 116 gfx::Rect(bottom_left_corner_->width(), |
| 118 bottom_left_corner_->width(), | 117 view->height() - bottom_edge_->height(), |
| 119 view->height() - bottom_edge_->height(), | 118 view->width() - bottom_left_corner_->width() - |
| 120 view->width() - bottom_left_corner_->width() | 119 bottom_right_corner_->width(), |
| 121 - bottom_right_corner_->width(), | 120 bottom_edge_->height())); |
| 122 bottom_edge_->height()); | |
| 123 canvas->DrawBitmapInt(*bottom_left_corner_, 0, | 121 canvas->DrawBitmapInt(*bottom_left_corner_, 0, |
| 124 view->height() - bottom_left_corner_->height()); | 122 view->height() - bottom_left_corner_->height()); |
| 125 | 123 |
| 126 // Left edge. | 124 // Left edge. |
| 127 int left_edge_height = | 125 int left_edge_height = |
| 128 view->height() - top_left_height - bottom_left_corner_->height(); | 126 view->height() - top_left_height - bottom_left_corner_->height(); |
| 129 canvas->TileImageInt(*left_edge_, | 127 canvas->TileImage(*left_edge_, gfx::Rect(0, top_left_height, |
| 130 0, top_left_height, | 128 left_edge_->width(), left_edge_height)); |
| 131 left_edge_->width(), left_edge_height); | |
| 132 } | 129 } |
| 133 | 130 |
| 134 void FrameBackground::PaintMaximized(gfx::Canvas* canvas, View* view) const { | 131 void FrameBackground::PaintMaximized(gfx::Canvas* canvas, View* view) const { |
| 135 // We will be painting from top_offset to top_offset + theme_frame_height. If | 132 // We will be painting from top_offset to top_offset + theme_frame_height. If |
| 136 // this is less than top_area_height_, we need to paint the frame color | 133 // this is less than top_area_height_, we need to paint the frame color |
| 137 // to fill in the area beneath the image. | 134 // to fill in the area beneath the image. |
| 138 // TODO(jamescook): I'm not sure this is correct, as it doesn't seem to fully | 135 // TODO(jamescook): I'm not sure this is correct, as it doesn't seem to fully |
| 139 // account for the top_offset, but this is how it worked before. | 136 // account for the top_offset, but this is how it worked before. |
| 140 int theme_frame_bottom = maximized_top_offset_ + theme_bitmap_->height(); | 137 int theme_frame_bottom = maximized_top_offset_ + theme_bitmap_->height(); |
| 141 if (top_area_height_ > theme_frame_bottom) { | 138 if (top_area_height_ > theme_frame_bottom) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 152 // If we have either a left or right we should have both. | 149 // If we have either a left or right we should have both. |
| 153 DCHECK(maximized_top_left_ && maximized_top_right_); | 150 DCHECK(maximized_top_left_ && maximized_top_right_); |
| 154 left_offset = maximized_top_left_->width(); | 151 left_offset = maximized_top_left_->width(); |
| 155 right_offset = maximized_top_right_->width(); | 152 right_offset = maximized_top_right_->width(); |
| 156 canvas->DrawBitmapInt(*maximized_top_left_, 0, 0); | 153 canvas->DrawBitmapInt(*maximized_top_left_, 0, 0); |
| 157 canvas->DrawBitmapInt(*maximized_top_right_, | 154 canvas->DrawBitmapInt(*maximized_top_right_, |
| 158 view->width() - right_offset, 0); | 155 view->width() - right_offset, 0); |
| 159 } | 156 } |
| 160 | 157 |
| 161 // Draw the theme frame. | 158 // Draw the theme frame. |
| 162 canvas->TileImageInt(*theme_bitmap_, | 159 canvas->TileImage(*theme_bitmap_, |
| 163 left_offset, | 160 gfx::Rect(left_offset, |
| 164 maximized_top_offset_, | 161 maximized_top_offset_, |
| 165 view->width() - (left_offset + right_offset), | 162 view->width() - (left_offset + right_offset), |
| 166 theme_bitmap_->height()); | 163 theme_bitmap_->height())); |
| 167 // Draw the theme frame overlay, if available. | 164 // Draw the theme frame overlay, if available. |
| 168 if (theme_overlay_bitmap_) | 165 if (theme_overlay_bitmap_) |
| 169 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, theme_background_y_); | 166 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, theme_background_y_); |
| 170 } | 167 } |
| 171 | 168 |
| 172 void FrameBackground::PaintFrameColor(gfx::Canvas* canvas, View* view) const { | 169 void FrameBackground::PaintFrameColor(gfx::Canvas* canvas, View* view) const { |
| 173 // Fill the top area. | 170 // Fill the top area. |
| 174 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), | 171 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), |
| 175 frame_color_); | 172 frame_color_); |
| 176 | 173 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 193 return; | 190 return; |
| 194 | 191 |
| 195 // Fill the bottom area. | 192 // Fill the bottom area. |
| 196 canvas->FillRect(gfx::Rect(left_edge_->width(), | 193 canvas->FillRect(gfx::Rect(left_edge_->width(), |
| 197 view->height() - bottom_edge_->height(), | 194 view->height() - bottom_edge_->height(), |
| 198 center_width, bottom_edge_->height()), | 195 center_width, bottom_edge_->height()), |
| 199 frame_color_); | 196 frame_color_); |
| 200 } | 197 } |
| 201 | 198 |
| 202 } // namespace views | 199 } // namespace views |
| OLD | NEW |