OLD | NEW |
---|---|
(Empty) | |
1 #include "ash/wm/header_metrics.h" | |
James Cook
2014/03/10 17:32:30
needs copyright
| |
2 | |
3 #include <algorithm> | |
4 | |
5 #include "ui/gfx/font_list.h" | |
6 #include "ui/gfx/rect.h" | |
7 #include "ui/views/view.h" | |
8 | |
9 namespace { | |
10 | |
11 // Radius of the header's top corners when the window is restored. | |
12 const int kTopCornerRadiusWhenRestored = 2; | |
13 | |
14 // Distance between left edge of the window and the header icon. | |
15 const int kIconXOffset = 9; | |
16 | |
17 // Height and width of header icon. | |
18 const int kIconSize = 16; | |
19 | |
20 // Space between the title text and the caption buttons. | |
21 const int kTitleLogoSpacing = 5; | |
22 | |
23 // Space between window icon and title text. | |
24 const int kTitleIconOffsetX = 5; | |
25 | |
26 // Space between window edge and title text, when there is no icon. | |
27 const int kTitleNoIconOffsetX = 8; | |
28 | |
29 // In the pre-Ash era the web content area had a frame along the left edge, so | |
30 // user-generated theme images for the new tab page assume they are shifted | |
31 // right relative to the header. Now that we have removed the left edge frame | |
32 // we need to copy the theme image for the window header from a few pixels | |
33 // inset to preserve alignment with the NTP image, or else we'll break a bunch | |
34 // of existing themes. We do something similar on OS X for the same reason. | |
35 const int kThemeFrameImageInsetX = 5; | |
36 | |
37 } // namespace | |
38 | |
39 namespace ash { | |
40 | |
41 // static | |
42 int HeaderMetrics::GetTopCornerRadiusWhenRestored() { | |
43 return kTopCornerRadiusWhenRestored; | |
James Cook
2014/03/10 17:32:30
Optional: Any particular reason these are returned
pkotwicz
2014/03/14 17:56:22
Given that this class is now HeaderPainterUtil, I
| |
44 } | |
45 | |
46 // static | |
47 int HeaderMetrics::GetIconXOffset() { | |
48 return kIconXOffset; | |
49 } | |
50 | |
51 // static | |
52 int HeaderMetrics::GetIconSize() { | |
53 return kIconSize; | |
54 } | |
55 | |
56 // static | |
57 gfx::Rect HeaderMetrics::GetTitleBounds( | |
58 const views::View* icon, | |
59 const views::View* caption_button_container, | |
60 const gfx::FontList& title_font_list) { | |
61 int x = icon ? | |
62 icon->bounds().right() + kTitleIconOffsetX : kTitleNoIconOffsetX; | |
63 int height = title_font_list.GetHeight(); | |
64 int y = std::max( | |
65 0, | |
66 static_cast<int>(std::ceil( | |
67 (caption_button_container->height() - height) / 2.0f))); | |
68 int width = std::max(0, | |
69 caption_button_container->x() - kTitleLogoSpacing - x); | |
70 return gfx::Rect(x, y, width, height); | |
71 } | |
72 | |
73 // static | |
74 int HeaderMetrics::GetThemeBackgroundXInset() { | |
75 return kThemeFrameImageInsetX; | |
76 } | |
77 | |
78 } // namespace ash | |
OLD | NEW |