| OLD | NEW |
| 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/frame/default_header_painter.h" | 5 #include "ash/frame/default_header_painter.h" |
| 6 | 6 |
| 7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 8 #include "ash/frame/header_painter_util.h" | 8 #include "ash/frame/header_painter_util.h" |
| 9 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
| 10 #include "base/logging.h" // DCHECK | 10 #include "base/logging.h" // DCHECK |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // Color for the window title text. | 31 // Color for the window title text. |
| 32 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); | 32 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); |
| 33 // Color of the active window header/content separator line. | 33 // Color of the active window header/content separator line. |
| 34 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(150, 150, 152); | 34 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(150, 150, 152); |
| 35 // Color of the inactive window header/content separator line. | 35 // Color of the inactive window header/content separator line. |
| 36 const SkColor kHeaderContentSeparatorInactiveColor = | 36 const SkColor kHeaderContentSeparatorInactiveColor = |
| 37 SkColorSetRGB(180, 180, 182); | 37 SkColorSetRGB(180, 180, 182); |
| 38 // The default color of the frame. | 38 // The default color of the frame. |
| 39 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); | 39 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); |
| 40 // The alpha of the inactive frame. | |
| 41 const SkAlpha kInactiveFrameAlpha = 204; | |
| 42 // Duration of crossfade animation for activating and deactivating frame. | 40 // Duration of crossfade animation for activating and deactivating frame. |
| 43 const int kActivationCrossfadeDurationMs = 200; | 41 const int kActivationCrossfadeDurationMs = 200; |
| 44 | 42 |
| 45 // Tiles an image into an area, rounding the top corners. | 43 // Tiles an image into an area, rounding the top corners. |
| 46 void TileRoundRect(gfx::Canvas* canvas, | 44 void TileRoundRect(gfx::Canvas* canvas, |
| 47 const SkPaint& paint, | 45 const SkPaint& paint, |
| 48 const gfx::Rect& bounds, | 46 const gfx::Rect& bounds, |
| 49 int corner_radius) { | 47 int corner_radius) { |
| 50 SkRect rect = gfx::RectToSkRect(bounds); | 48 SkRect rect = gfx::RectToSkRect(bounds); |
| 51 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius); | 49 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 activation_animation_->Reset(0); | 156 activation_animation_->Reset(0); |
| 159 } | 157 } |
| 160 initial_paint_ = false; | 158 initial_paint_ = false; |
| 161 } | 159 } |
| 162 | 160 |
| 163 int corner_radius = (frame_->IsMaximized() || frame_->IsFullscreen()) ? | 161 int corner_radius = (frame_->IsMaximized() || frame_->IsFullscreen()) ? |
| 164 0 : HeaderPainterUtil::GetTopCornerRadiusWhenRestored(); | 162 0 : HeaderPainterUtil::GetTopCornerRadiusWhenRestored(); |
| 165 | 163 |
| 166 SkPaint paint; | 164 SkPaint paint; |
| 167 int active_alpha = activation_animation_->CurrentValueBetween(0, 255); | 165 int active_alpha = activation_animation_->CurrentValueBetween(0, 255); |
| 168 paint.setColor(color_utils::AlphaBlend( | 166 paint.setColor(color_utils::AlphaBlend(active_frame_color_, |
| 169 active_frame_color_, GetInactiveFrameColor(), active_alpha)); | 167 inactive_frame_color_, active_alpha)); |
| 170 | 168 |
| 171 TileRoundRect(canvas, paint, GetLocalBounds(), corner_radius); | 169 TileRoundRect(canvas, paint, GetLocalBounds(), corner_radius); |
| 172 | 170 |
| 173 if (!frame_->IsMaximized() && !frame_->IsFullscreen() && | 171 if (!frame_->IsMaximized() && !frame_->IsFullscreen() && |
| 174 mode_ == MODE_INACTIVE && !UsesCustomFrameColors()) { | 172 mode_ == MODE_INACTIVE && !UsesCustomFrameColors()) { |
| 175 PaintHighlightForInactiveRestoredWindow(canvas); | 173 PaintHighlightForInactiveRestoredWindow(canvas); |
| 176 } | 174 } |
| 177 if (frame_->widget_delegate() && | 175 if (frame_->widget_delegate() && |
| 178 frame_->widget_delegate()->ShouldShowWindowTitle()) { | 176 frame_->widget_delegate()->ShouldShowWindowTitle()) { |
| 179 PaintTitleBar(canvas); | 177 PaintTitleBar(canvas); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { | 336 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { |
| 339 return HeaderPainterUtil::GetTitleBounds( | 337 return HeaderPainterUtil::GetTitleBounds( |
| 340 left_header_view_, caption_button_container_, GetTitleFontList()); | 338 left_header_view_, caption_button_container_, GetTitleFontList()); |
| 341 } | 339 } |
| 342 | 340 |
| 343 bool DefaultHeaderPainter::UsesCustomFrameColors() const { | 341 bool DefaultHeaderPainter::UsesCustomFrameColors() const { |
| 344 return active_frame_color_ != kDefaultFrameColor || | 342 return active_frame_color_ != kDefaultFrameColor || |
| 345 inactive_frame_color_ != kDefaultFrameColor; | 343 inactive_frame_color_ != kDefaultFrameColor; |
| 346 } | 344 } |
| 347 | 345 |
| 348 SkColor DefaultHeaderPainter::GetInactiveFrameColor() const { | |
| 349 SkColor color = inactive_frame_color_; | |
| 350 if (!frame_->IsMaximized() && !frame_->IsFullscreen()) { | |
| 351 color = SkColorSetARGB(kInactiveFrameAlpha, | |
| 352 SkColorGetR(color), | |
| 353 SkColorGetG(color), | |
| 354 SkColorGetB(color)); | |
| 355 } | |
| 356 return color; | |
| 357 } | |
| 358 | |
| 359 } // namespace ash | 346 } // namespace ash |
| OLD | NEW |