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

Unified Diff: ash/wm/header_metrics.cc

Issue 189463013: [Refactor] Move code for painting the window header for browser windows out of ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/header_metrics.cc
diff --git a/ash/wm/header_metrics.cc b/ash/wm/header_metrics.cc
new file mode 100644
index 0000000000000000000000000000000000000000..784c89f793ffb49b0323d058b137cedeffd1528b
--- /dev/null
+++ b/ash/wm/header_metrics.cc
@@ -0,0 +1,78 @@
+#include "ash/wm/header_metrics.h"
James Cook 2014/03/10 17:32:30 needs copyright
+
+#include <algorithm>
+
+#include "ui/gfx/font_list.h"
+#include "ui/gfx/rect.h"
+#include "ui/views/view.h"
+
+namespace {
+
+// Radius of the header's top corners when the window is restored.
+const int kTopCornerRadiusWhenRestored = 2;
+
+// Distance between left edge of the window and the header icon.
+const int kIconXOffset = 9;
+
+// Height and width of header icon.
+const int kIconSize = 16;
+
+// Space between the title text and the caption buttons.
+const int kTitleLogoSpacing = 5;
+
+// Space between window icon and title text.
+const int kTitleIconOffsetX = 5;
+
+// Space between window edge and title text, when there is no icon.
+const int kTitleNoIconOffsetX = 8;
+
+// In the pre-Ash era the web content area had a frame along the left edge, so
+// user-generated theme images for the new tab page assume they are shifted
+// right relative to the header. Now that we have removed the left edge frame
+// we need to copy the theme image for the window header from a few pixels
+// inset to preserve alignment with the NTP image, or else we'll break a bunch
+// of existing themes. We do something similar on OS X for the same reason.
+const int kThemeFrameImageInsetX = 5;
+
+} // namespace
+
+namespace ash {
+
+// static
+int HeaderMetrics::GetTopCornerRadiusWhenRestored() {
+ 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
+}
+
+// static
+int HeaderMetrics::GetIconXOffset() {
+ return kIconXOffset;
+}
+
+// static
+int HeaderMetrics::GetIconSize() {
+ return kIconSize;
+}
+
+// static
+gfx::Rect HeaderMetrics::GetTitleBounds(
+ const views::View* icon,
+ const views::View* caption_button_container,
+ const gfx::FontList& title_font_list) {
+ int x = icon ?
+ icon->bounds().right() + kTitleIconOffsetX : kTitleNoIconOffsetX;
+ int height = title_font_list.GetHeight();
+ int y = std::max(
+ 0,
+ static_cast<int>(std::ceil(
+ (caption_button_container->height() - height) / 2.0f)));
+ int width = std::max(0,
+ caption_button_container->x() - kTitleLogoSpacing - x);
+ return gfx::Rect(x, y, width, height);
+}
+
+// static
+int HeaderMetrics::GetThemeBackgroundXInset() {
+ return kThemeFrameImageInsetX;
+}
+
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698