Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: chrome/browser/ui/views/frame/browser_header_painter_ash.cc

Issue 2441863002: Remove some more !IsModeMaterial code. (Closed)
Patch Set: pull more shades Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/views/frame/browser_header_painter_ash.h" 5 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h"
6 6
7 #include "ash/common/ash_layout_constants.h" 7 #include "ash/common/ash_layout_constants.h"
8 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h " 8 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h "
9 #include "ash/common/frame/header_painter_util.h" 9 #include "ash/common/frame/header_painter_util.h"
10 #include "base/logging.h" // DCHECK 10 #include "base/logging.h" // DCHECK
11 #include "chrome/browser/themes/theme_properties.h" 11 #include "chrome/browser/themes/theme_properties.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/views/frame/browser_frame.h" 13 #include "chrome/browser/ui/views/frame/browser_frame.h"
14 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" 14 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 15 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/grit/theme_resources.h"
17 #include "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
18 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
19 #include "third_party/skia/include/core/SkPaint.h" 18 #include "third_party/skia/include/core/SkPaint.h"
20 #include "third_party/skia/include/core/SkPath.h" 19 #include "third_party/skia/include/core/SkPath.h"
21 #include "ui/base/material_design/material_design_controller.h"
22 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/base/theme_provider.h"
24 #include "ui/gfx/animation/slide_animation.h" 20 #include "ui/gfx/animation/slide_animation.h"
25 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
26 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
27 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
28 #include "ui/gfx/skia_util.h" 24 #include "ui/gfx/skia_util.h"
29 #include "ui/gfx/vector_icons_public.h" 25 #include "ui/gfx/vector_icons_public.h"
30 #include "ui/views/view.h" 26 #include "ui/views/view.h"
31 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
32 #include "ui/views/widget/widget_delegate.h" 28 #include "ui/views/widget/widget_delegate.h"
33 29
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 activation_animation_->Reset(1); 177 activation_animation_->Reset(1);
182 else 178 else
183 activation_animation_->Reset(0); 179 activation_animation_->Reset(0);
184 } 180 }
185 initial_paint_ = false; 181 initial_paint_ = false;
186 } 182 }
187 183
188 PaintFrameImages(canvas, false); 184 PaintFrameImages(canvas, false);
189 PaintFrameImages(canvas, true); 185 PaintFrameImages(canvas, true);
190 186
191 if (!ui::MaterialDesignController::IsModeMaterial() &&
192 !frame_->IsMaximized() &&
193 !frame_->IsFullscreen()) {
194 PaintHighlightForRestoredWindow(canvas);
195 }
196
197 if (frame_->widget_delegate() && 187 if (frame_->widget_delegate() &&
198 frame_->widget_delegate()->ShouldShowWindowTitle()) { 188 frame_->widget_delegate()->ShouldShowWindowTitle()) {
199 PaintTitleBar(canvas); 189 PaintTitleBar(canvas);
200 } 190 }
201 } 191 }
202 192
203 void BrowserHeaderPainterAsh::LayoutHeader() { 193 void BrowserHeaderPainterAsh::LayoutHeader() {
204 // Purposefully set |painted_height_| to an invalid value. We cannot use 194 // Purposefully set |painted_height_| to an invalid value. We cannot use
205 // |painted_height_| because the computation of |painted_height_| may depend 195 // |painted_height_| because the computation of |painted_height_| may depend
206 // on having laid out the window controls. 196 // on having laid out the window controls.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 266
277 SkPaint paint; 267 SkPaint paint;
278 paint.setBlendMode(SkBlendMode::kPlus); 268 paint.setBlendMode(SkBlendMode::kPlus);
279 paint.setAlpha(alpha); 269 paint.setAlpha(alpha);
280 paint.setColor(SkColorSetA(view_->GetFrameColor(active), alpha)); 270 paint.setColor(SkColorSetA(view_->GetFrameColor(active), alpha));
281 PaintFrameImagesInRoundRect( 271 PaintFrameImagesInRoundRect(
282 canvas, frame_image, frame_overlay_image, paint, GetPaintedBounds(), 272 canvas, frame_image, frame_overlay_image, paint, GetPaintedBounds(),
283 corner_radius, ash::HeaderPainterUtil::GetThemeBackgroundXInset()); 273 corner_radius, ash::HeaderPainterUtil::GetThemeBackgroundXInset());
284 } 274 }
285 275
286 void BrowserHeaderPainterAsh::PaintHighlightForRestoredWindow(
287 gfx::Canvas* canvas) {
288 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
289 gfx::ImageSkia top_left_corner = *rb.GetImageSkiaNamed(
290 IDR_ASH_BROWSER_WINDOW_HEADER_SHADE_TOP_LEFT);
291 gfx::ImageSkia top_right_corner = *rb.GetImageSkiaNamed(
292 IDR_ASH_BROWSER_WINDOW_HEADER_SHADE_TOP_RIGHT);
293 gfx::ImageSkia top_edge = *rb.GetImageSkiaNamed(
294 IDR_ASH_BROWSER_WINDOW_HEADER_SHADE_TOP);
295 gfx::ImageSkia left_edge = *rb.GetImageSkiaNamed(
296 IDR_ASH_BROWSER_WINDOW_HEADER_SHADE_LEFT);
297 gfx::ImageSkia right_edge = *rb.GetImageSkiaNamed(
298 IDR_ASH_BROWSER_WINDOW_HEADER_SHADE_RIGHT);
299
300 int top_left_width = top_left_corner.width();
301 int top_left_height = top_left_corner.height();
302 canvas->DrawImageInt(top_left_corner, 0, 0);
303
304 int top_right_width = top_right_corner.width();
305 int top_right_height = top_right_corner.height();
306 canvas->DrawImageInt(top_right_corner,
307 view_->width() - top_right_width,
308 0);
309
310 canvas->TileImageInt(
311 top_edge,
312 top_left_width,
313 0,
314 view_->width() - top_left_width - top_right_width,
315 top_edge.height());
316
317 canvas->TileImageInt(left_edge,
318 0,
319 top_left_height,
320 left_edge.width(),
321 painted_height_ - top_left_height);
322
323 canvas->TileImageInt(right_edge,
324 view_->width() - right_edge.width(),
325 top_right_height,
326 right_edge.width(),
327 painted_height_ - top_right_height);
328 }
329
330 void BrowserHeaderPainterAsh::PaintTitleBar(gfx::Canvas* canvas) { 276 void BrowserHeaderPainterAsh::PaintTitleBar(gfx::Canvas* canvas) {
331 // The window icon is painted by its own views::View. 277 // The window icon is painted by its own views::View.
332 gfx::Rect title_bounds = GetTitleBounds(); 278 gfx::Rect title_bounds = GetTitleBounds();
333 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); 279 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds));
334 canvas->DrawStringRectWithFlags(frame_->widget_delegate()->GetWindowTitle(), 280 canvas->DrawStringRectWithFlags(frame_->widget_delegate()->GetWindowTitle(),
335 BrowserFrame::GetTitleFontList(), 281 BrowserFrame::GetTitleFontList(),
336 is_incognito_ ? kIncognitoWindowTitleTextColor 282 is_incognito_ ? kIncognitoWindowTitleTextColor
337 : kNormalWindowTitleTextColor, 283 : kNormalWindowTitleTextColor,
338 title_bounds, 284 title_bounds,
339 gfx::Canvas::NO_SUBPIXEL_RENDERING); 285 gfx::Canvas::NO_SUBPIXEL_RENDERING);
(...skipping 27 matching lines...) Expand all
367 } 313 }
368 314
369 gfx::Rect BrowserHeaderPainterAsh::GetPaintedBounds() const { 315 gfx::Rect BrowserHeaderPainterAsh::GetPaintedBounds() const {
370 return gfx::Rect(view_->width(), painted_height_); 316 return gfx::Rect(view_->width(), painted_height_);
371 } 317 }
372 318
373 gfx::Rect BrowserHeaderPainterAsh::GetTitleBounds() const { 319 gfx::Rect BrowserHeaderPainterAsh::GetTitleBounds() const {
374 return ash::HeaderPainterUtil::GetTitleBounds(window_icon_, 320 return ash::HeaderPainterUtil::GetTitleBounds(window_icon_,
375 caption_button_container_, BrowserFrame::GetTitleFontList()); 321 caption_button_container_, BrowserFrame::GetTitleFontList());
376 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698