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

Side by Side Diff: ash/common/frame/default_header_painter.cc

Issue 2679423002: ash: Clean up naming of paint-related identifiers (Closed)
Patch Set: Created 3 years, 10 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 "ash/common/frame/default_header_painter.h" 5 #include "ash/common/frame/default_header_painter.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 "ash/resources/vector_icons/vector_icons.h" 10 #include "ash/resources/vector_icons/vector_icons.h"
(...skipping 26 matching lines...) Expand all
37 // Color of the inactive window header/content separator line. 37 // Color of the inactive window header/content separator line.
38 const SkColor kHeaderContentSeparatorInactiveColor = 38 const SkColor kHeaderContentSeparatorInactiveColor =
39 SkColorSetRGB(180, 180, 182); 39 SkColorSetRGB(180, 180, 182);
40 // The default color of the frame. 40 // The default color of the frame.
41 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); 41 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242);
42 // Duration of crossfade animation for activating and deactivating frame. 42 // Duration of crossfade animation for activating and deactivating frame.
43 const int kActivationCrossfadeDurationMs = 200; 43 const int kActivationCrossfadeDurationMs = 200;
44 44
45 // Tiles an image into an area, rounding the top corners. 45 // Tiles an image into an area, rounding the top corners.
46 void TileRoundRect(gfx::Canvas* canvas, 46 void TileRoundRect(gfx::Canvas* canvas,
47 const cc::PaintFlags& paint, 47 const cc::PaintFlags& flags,
48 const gfx::Rect& bounds, 48 const gfx::Rect& bounds,
49 int corner_radius) { 49 int corner_radius) {
50 SkRect rect = gfx::RectToSkRect(bounds); 50 SkRect rect = gfx::RectToSkRect(bounds);
51 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius); 51 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius);
52 SkScalar radii[8] = {corner_radius_scalar, 52 SkScalar radii[8] = {corner_radius_scalar,
53 corner_radius_scalar, // top-left 53 corner_radius_scalar, // top-left
54 corner_radius_scalar, 54 corner_radius_scalar,
55 corner_radius_scalar, // top-right 55 corner_radius_scalar, // top-right
56 0, 56 0,
57 0, // bottom-right 57 0, // bottom-right
58 0, 58 0,
59 0}; // bottom-left 59 0}; // bottom-left
60 SkPath path; 60 SkPath path;
61 path.addRoundRect(rect, radii, SkPath::kCW_Direction); 61 path.addRoundRect(rect, radii, SkPath::kCW_Direction);
62 canvas->DrawPath(path, paint); 62 canvas->DrawPath(path, flags);
63 } 63 }
64 64
65 // Returns the FontList to use for the title. 65 // Returns the FontList to use for the title.
66 const gfx::FontList& GetTitleFontList() { 66 const gfx::FontList& GetTitleFontList() {
67 static const gfx::FontList* title_font_list = 67 static const gfx::FontList* title_font_list =
68 new gfx::FontList(views::NativeWidgetAura::GetWindowTitleFontList()); 68 new gfx::FontList(views::NativeWidgetAura::GetWindowTitleFontList());
69 ANNOTATE_LEAKING_OBJECT_PTR(title_font_list); 69 ANNOTATE_LEAKING_OBJECT_PTR(title_font_list);
70 return *title_font_list; 70 return *title_font_list;
71 } 71 }
72 72
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 else 131 else
132 activation_animation_->Reset(0); 132 activation_animation_->Reset(0);
133 } 133 }
134 initial_paint_ = false; 134 initial_paint_ = false;
135 } 135 }
136 136
137 int corner_radius = (frame_->IsMaximized() || frame_->IsFullscreen()) 137 int corner_radius = (frame_->IsMaximized() || frame_->IsFullscreen())
138 ? 0 138 ? 0
139 : HeaderPainterUtil::GetTopCornerRadiusWhenRestored(); 139 : HeaderPainterUtil::GetTopCornerRadiusWhenRestored();
140 140
141 cc::PaintFlags paint; 141 cc::PaintFlags flags;
142 int active_alpha = activation_animation_->CurrentValueBetween(0, 255); 142 int active_alpha = activation_animation_->CurrentValueBetween(0, 255);
143 paint.setColor(color_utils::AlphaBlend(active_frame_color_, 143 flags.setColor(color_utils::AlphaBlend(active_frame_color_,
144 inactive_frame_color_, active_alpha)); 144 inactive_frame_color_, active_alpha));
145 paint.setAntiAlias(true); 145 flags.setAntiAlias(true);
146 TileRoundRect(canvas, paint, GetLocalBounds(), corner_radius); 146 TileRoundRect(canvas, flags, GetLocalBounds(), corner_radius);
147 147
148 if (!frame_->IsMaximized() && !frame_->IsFullscreen() && 148 if (!frame_->IsMaximized() && !frame_->IsFullscreen() &&
149 mode_ == MODE_INACTIVE && !UsesCustomFrameColors()) { 149 mode_ == MODE_INACTIVE && !UsesCustomFrameColors()) {
150 PaintHighlightForInactiveRestoredWindow(canvas); 150 PaintHighlightForInactiveRestoredWindow(canvas);
151 } 151 }
152 if (frame_->widget_delegate()->ShouldShowWindowTitle()) 152 if (frame_->widget_delegate()->ShouldShowWindowTitle())
153 PaintTitleBar(canvas); 153 PaintTitleBar(canvas);
154 if (!UsesCustomFrameColors()) 154 if (!UsesCustomFrameColors())
155 PaintHeaderContentSeparator(canvas); 155 PaintHeaderContentSeparator(canvas);
156 } 156 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); 262 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds));
263 canvas->DrawStringRectWithFlags( 263 canvas->DrawStringRectWithFlags(
264 frame_->widget_delegate()->GetWindowTitle(), GetTitleFontList(), 264 frame_->widget_delegate()->GetWindowTitle(), GetTitleFontList(),
265 kTitleTextColor, title_bounds, gfx::Canvas::NO_SUBPIXEL_RENDERING); 265 kTitleTextColor, title_bounds, gfx::Canvas::NO_SUBPIXEL_RENDERING);
266 } 266 }
267 267
268 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { 268 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) {
269 gfx::ScopedCanvas scoped_canvas(canvas); 269 gfx::ScopedCanvas scoped_canvas(canvas);
270 const float scale = canvas->UndoDeviceScaleFactor(); 270 const float scale = canvas->UndoDeviceScaleFactor();
271 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); 271 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1);
272 cc::PaintFlags paint; 272 cc::PaintFlags flags;
273 paint.setColor((mode_ == MODE_ACTIVE) ? kHeaderContentSeparatorColor 273 flags.setColor((mode_ == MODE_ACTIVE) ? kHeaderContentSeparatorColor
274 : kHeaderContentSeparatorInactiveColor); 274 : kHeaderContentSeparatorInactiveColor);
275 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); 275 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), flags);
276 } 276 }
277 277
278 bool DefaultHeaderPainter::ShouldUseLightImages() { 278 bool DefaultHeaderPainter::ShouldUseLightImages() {
279 return color_utils::IsDark(mode_ == MODE_INACTIVE ? inactive_frame_color_ 279 return color_utils::IsDark(mode_ == MODE_INACTIVE ? inactive_frame_color_
280 : active_frame_color_); 280 : active_frame_color_);
281 } 281 }
282 282
283 void DefaultHeaderPainter::UpdateAllButtonImages() { 283 void DefaultHeaderPainter::UpdateAllButtonImages() {
284 caption_button_container_->SetUseLightImages(ShouldUseLightImages()); 284 caption_button_container_->SetUseLightImages(ShouldUseLightImages());
285 caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_MINIMIZE, 285 caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_MINIMIZE,
(...skipping 27 matching lines...) Expand all
313 return HeaderPainterUtil::GetTitleBounds( 313 return HeaderPainterUtil::GetTitleBounds(
314 left_header_view_, caption_button_container_, GetTitleFontList()); 314 left_header_view_, caption_button_container_, GetTitleFontList());
315 } 315 }
316 316
317 bool DefaultHeaderPainter::UsesCustomFrameColors() const { 317 bool DefaultHeaderPainter::UsesCustomFrameColors() const {
318 return active_frame_color_ != kDefaultFrameColor || 318 return active_frame_color_ != kDefaultFrameColor ||
319 inactive_frame_color_ != kDefaultFrameColor; 319 inactive_frame_color_ != kDefaultFrameColor;
320 } 320 }
321 321
322 } // namespace ash 322 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/frame/caption_buttons/frame_caption_button.cc ('k') | ash/common/shelf/app_list_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698