| 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/header_painter_util.h" | 5 #include "ash/frame/header_painter_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return kDefaultIconSize; | 61 return kDefaultIconSize; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 int HeaderPainterUtil::GetThemeBackgroundXInset() { | 65 int HeaderPainterUtil::GetThemeBackgroundXInset() { |
| 66 return kThemeFrameImageInsetX; | 66 return kThemeFrameImageInsetX; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // static | 69 // static |
| 70 gfx::Rect HeaderPainterUtil::GetTitleBounds( | 70 gfx::Rect HeaderPainterUtil::GetTitleBounds( |
| 71 const views::View* icon, | 71 const views::View* left_view, |
| 72 const views::View* caption_button_container, | 72 const views::View* right_view, |
| 73 const gfx::FontList& title_font_list) { | 73 const gfx::FontList& title_font_list) { |
| 74 int x = icon ? | 74 int x = left_view ? left_view->bounds().right() + kTitleIconOffsetX |
| 75 icon->bounds().right() + kTitleIconOffsetX : kTitleNoIconOffsetX; | 75 : kTitleNoIconOffsetX; |
| 76 int height = title_font_list.GetHeight(); | 76 int height = title_font_list.GetHeight(); |
| 77 // Floor when computing the center of |caption_button_container| and when | 77 // Floor when computing the center of |caption_button_container| and when |
| 78 // computing the center of the text. | 78 // computing the center of the text. |
| 79 int y = std::max(0, (caption_button_container->height() / 2) - (height / 2)); | 79 int y = std::max(0, (right_view->height() / 2) - (height / 2)); |
| 80 int width = std::max( | 80 int width = std::max(0, right_view->x() - kTitleCaptionButtonSpacing - x); |
| 81 0, caption_button_container->x() - kTitleCaptionButtonSpacing - x); | |
| 82 return gfx::Rect(x, y, width, height); | 81 return gfx::Rect(x, y, width, height); |
| 83 } | 82 } |
| 84 | 83 |
| 85 // static | 84 // static |
| 86 bool HeaderPainterUtil::CanAnimateActivation(views::Widget* widget) { | 85 bool HeaderPainterUtil::CanAnimateActivation(views::Widget* widget) { |
| 87 // Do not animate the header if the parent (e.g. | 86 // Do not animate the header if the parent (e.g. |
| 88 // kShellWindowId_DefaultContainer) is already animating. All of the | 87 // kShellWindowId_DefaultContainer) is already animating. All of the |
| 89 // implementers of HeaderPainter animate activation by continuously painting | 88 // implementers of HeaderPainter animate activation by continuously painting |
| 90 // during the animation. This gives the parent's animation a slower frame | 89 // during the animation. This gives the parent's animation a slower frame |
| 91 // rate. | 90 // rate. |
| 92 // TODO(sky): Expose a better way to determine this rather than assuming the | 91 // TODO(sky): Expose a better way to determine this rather than assuming the |
| 93 // parent is a toplevel container. | 92 // parent is a toplevel container. |
| 94 aura::Window* window = widget->GetNativeWindow(); | 93 aura::Window* window = widget->GetNativeWindow(); |
| 95 if (!window->parent()) | 94 if (!window->parent()) |
| 96 return true; | 95 return true; |
| 97 | 96 |
| 98 ui::LayerAnimator* parent_layer_animator = | 97 ui::LayerAnimator* parent_layer_animator = |
| 99 window->parent()->layer()->GetAnimator(); | 98 window->parent()->layer()->GetAnimator(); |
| 100 return !parent_layer_animator->IsAnimatingProperty( | 99 return !parent_layer_animator->IsAnimatingProperty( |
| 101 ui::LayerAnimationElement::OPACITY) && | 100 ui::LayerAnimationElement::OPACITY) && |
| 102 !parent_layer_animator->IsAnimatingProperty( | 101 !parent_layer_animator->IsAnimatingProperty( |
| 103 ui::LayerAnimationElement::VISIBILITY); | 102 ui::LayerAnimationElement::VISIBILITY); |
| 104 } | 103 } |
| 105 | 104 |
| 106 } // namespace ash | 105 } // namespace ash |
| OLD | NEW |