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

Side by Side Diff: mash/wm/frame/header_painter_util.cc

Issue 1459653002: Gets mustash frames looking like that of ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update test Created 5 years, 1 month 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
« no previous file with comments | « mash/wm/frame/header_painter_util.h ('k') | mash/wm/frame/move_loop.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mash/wm/frame/header_painter_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/aura/window.h"
10 #include "ui/compositor/layer.h"
11 #include "ui/compositor/layer_animator.h"
12 #include "ui/gfx/font_list.h" 9 #include "ui/gfx/font_list.h"
13 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
14 #include "ui/views/view.h" 11 #include "ui/views/view.h"
15 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
16 13
17 namespace { 14 namespace {
18 15
19 // Radius of the header's top corners when the window is restored. 16 // Radius of the header's top corners when the window is restored.
20 const int kTopCornerRadiusWhenRestored = 2; 17 const int kTopCornerRadiusWhenRestored = 2;
21 18
(...skipping 12 matching lines...) Expand all
34 // In the pre-Ash era the web content area had a frame along the left edge, so 31 // In the pre-Ash era the web content area had a frame along the left edge, so
35 // user-generated theme images for the new tab page assume they are shifted 32 // user-generated theme images for the new tab page assume they are shifted
36 // right relative to the header. Now that we have removed the left edge frame 33 // right relative to the header. Now that we have removed the left edge frame
37 // we need to copy the theme image for the window header from a few pixels 34 // we need to copy the theme image for the window header from a few pixels
38 // inset to preserve alignment with the NTP image, or else we'll break a bunch 35 // inset to preserve alignment with the NTP image, or else we'll break a bunch
39 // of existing themes. We do something similar on OS X for the same reason. 36 // of existing themes. We do something similar on OS X for the same reason.
40 const int kThemeFrameImageInsetX = 5; 37 const int kThemeFrameImageInsetX = 5;
41 38
42 } // namespace 39 } // namespace
43 40
44 namespace ash { 41 namespace mash {
42 namespace wm {
45 43
46 // static 44 // static
47 int HeaderPainterUtil::GetTopCornerRadiusWhenRestored() { 45 int HeaderPainterUtil::GetTopCornerRadiusWhenRestored() {
48 return kTopCornerRadiusWhenRestored; 46 return kTopCornerRadiusWhenRestored;
49 } 47 }
50 48
51 // static 49 // static
52 int HeaderPainterUtil::GetDefaultLeftViewXInset() { 50 int HeaderPainterUtil::GetDefaultLeftViewXInset() {
53 return kDefaultLeftViewXInset; 51 return kDefaultLeftViewXInset;
54 } 52 }
(...skipping 13 matching lines...) Expand all
68 int height = title_font_list.GetHeight(); 66 int height = title_font_list.GetHeight();
69 // Floor when computing the center of |caption_button_container| and when 67 // Floor when computing the center of |caption_button_container| and when
70 // computing the center of the text. 68 // computing the center of the text.
71 int y = std::max(0, (right_view->height() / 2) - (height / 2)); 69 int y = std::max(0, (right_view->height() / 2) - (height / 2));
72 int width = std::max(0, right_view->x() - kTitleCaptionButtonSpacing - x); 70 int width = std::max(0, right_view->x() - kTitleCaptionButtonSpacing - x);
73 return gfx::Rect(x, y, width, height); 71 return gfx::Rect(x, y, width, height);
74 } 72 }
75 73
76 // static 74 // static
77 bool HeaderPainterUtil::CanAnimateActivation(views::Widget* widget) { 75 bool HeaderPainterUtil::CanAnimateActivation(views::Widget* widget) {
78 // Do not animate the header if the parent (e.g. 76 return true;
79 // kShellWindowId_DefaultContainer) is already animating. All of the
80 // implementers of HeaderPainter animate activation by continuously painting
81 // during the animation. This gives the parent's animation a slower frame
82 // rate.
83 // TODO(sky): Expose a better way to determine this rather than assuming the
84 // parent is a toplevel container.
85 aura::Window* window = widget->GetNativeWindow();
86 if (!window->parent())
87 return true;
88
89 ui::LayerAnimator* parent_layer_animator =
90 window->parent()->layer()->GetAnimator();
91 return !parent_layer_animator->IsAnimatingProperty(
92 ui::LayerAnimationElement::OPACITY) &&
93 !parent_layer_animator->IsAnimatingProperty(
94 ui::LayerAnimationElement::VISIBILITY);
95 } 77 }
96 78
97 } // namespace ash 79 } // namespace wm
80 } // namespace mash
OLDNEW
« no previous file with comments | « mash/wm/frame/header_painter_util.h ('k') | mash/wm/frame/move_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698