summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-13 19:56:42 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-13 19:56:42 +0000
commita562cb7d8304af4d5d04a6d8e63e455e5077d3cd (patch)
tree4b04f108588386e4754af750bd4a9e1d0b042929 /chrome
parentdbb8211ed7a2a52da822cd5304096cea366c1fb6 (diff)
downloadchromium_src-a562cb7d8304af4d5d04a6d8e63e455e5077d3cd.zip
chromium_src-a562cb7d8304af4d5d04a6d8e63e455e5077d3cd.tar.gz
chromium_src-a562cb7d8304af4d5d04a6d8e63e455e5077d3cd.tar.bz2
Use system title bar font for app windows, detached popups, constrained popups.
http://crbug.com/3376 Review URL: http://codereview.chromium.org/7274 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/constrained_window_impl.cc8
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc18
-rw-r--r--chrome/common/win_util.cc7
-rw-r--r--chrome/common/win_util.h4
-rw-r--r--chrome/views/custom_frame_window.cc12
5 files changed, 42 insertions, 7 deletions
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 8cb16f8..76e3eb1 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -603,6 +603,12 @@ void ConstrainedWindowNonClientView::Layout() {
int title_left = icon_bounds_.right() + spacing;
title_bounds_.SetRect(title_left, kTitleTopOffset,
title_right - title_left, title_font_.height());
+
+ // Center the icon within the vertical bounds of the title if the title
+ // is taller.
+ int delta_y = title_bounds_.height() - icon_bounds_.height();
+ if (delta_y > 0)
+ icon_bounds_.set_y(title_bounds_.y() + static_cast<int>(delta_y / 2));
}
}
@@ -770,6 +776,8 @@ void ConstrainedWindowNonClientView::InitClass() {
throbber_frame_count_ =
throbber_frames_.width() / throbber_frames_.height();
+ title_font_ = win_util::GetWindowTitleFont();
+
initialized = true;
}
}
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index 19628c8..f3b3afa 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -11,6 +11,7 @@
#include "chrome/common/gfx/path.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/resource_bundle.h"
+#include "chrome/common/win_util.h"
#include "chrome/views/root_view.h"
#include "chrome/views/window_resources.h"
#include "chromium_strings.h"
@@ -306,7 +307,7 @@ static const int kWindowIconLeftOffset = 5;
static const int kWindowIconTopOffset = 5;
// The distance between the window icon and the window title when a title-bar
// is showing.
-static const int kWindowIconTitleSpacing = 3;
+static const int kWindowIconTitleSpacing = 4;
// The distance between the top of the window and the title text when a
// title-bar is showing.
static const int kTitleTopOffset = 6;
@@ -985,8 +986,6 @@ void OpaqueNonClientView::LayoutTitleBar() {
icon_bounds_.SetRect(kWindowIconLeftOffset, kWindowIconLeftOffset,
show_icon ? kWindowIconSize : 0,
show_icon ? kWindowIconSize : 0);
- if (window_icon_)
- window_icon_->SetBounds(icon_bounds_.ToRECT());
// Size the title, if visible.
if (d->ShouldShowWindowTitle()) {
@@ -997,7 +996,17 @@ void OpaqueNonClientView::LayoutTitleBar() {
title_bounds_.SetRect(title_left, kTitleTopOffset + top_offset,
std::max(0, static_cast<int>(title_right - icon_right)),
title_font_.height());
+
+ // Adjust the Y-position of the icon to be vertically centered within
+ // the bounds of the title text.
+ int delta_y = title_bounds_.height() - icon_bounds_.height();
+ if (delta_y > 0)
+ icon_bounds_.set_y(title_bounds_.y() + static_cast<int>(delta_y / 2));
}
+
+ // Do this last, after the icon has been moved.
+ if (window_icon_)
+ window_icon_->SetBounds(icon_bounds_.ToRECT());
}
void OpaqueNonClientView::LayoutClientView() {
@@ -1030,8 +1039,7 @@ void OpaqueNonClientView::InitClass() {
void OpaqueNonClientView::InitAppWindowResources() {
static bool initialized = false;
if (!initialized) {
- title_font_ = ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont).DeriveFont(1, ChromeFont::BOLD);
+ title_font_ = win_util::GetWindowTitleFont();
initialized = true;
}
}
diff --git a/chrome/common/win_util.cc b/chrome/common/win_util.cc
index 9b51220..fc0e055 100644
--- a/chrome/common/win_util.cc
+++ b/chrome/common/win_util.cc
@@ -805,5 +805,12 @@ int MessageBox(HWND hwnd,
return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags);
}
+ChromeFont GetWindowTitleFont() {
+ NONCLIENTMETRICS ncm;
+ win_util::GetNonClientMetrics(&ncm);
+ ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
+ return ChromeFont::CreateFont(caption_font);
+}
+
} // namespace win_util
diff --git a/chrome/common/win_util.h b/chrome/common/win_util.h
index 6c88a12..6688892 100644
--- a/chrome/common/win_util.h
+++ b/chrome/common/win_util.h
@@ -13,6 +13,7 @@
#include "base/fix_wp64.h"
#include "base/gfx/rect.h"
#include "base/scoped_handle.h"
+#include "chrome/common/gfx/chrome_font.h"
namespace win_util {
@@ -228,6 +229,9 @@ int MessageBox(HWND hwnd,
const std::wstring& caption,
UINT flags);
+// Returns the system set window title font.
+ChromeFont GetWindowTitleFont();
+
} // namespace win_util
#endif // WIN_COMMON_WIN_UTIL_H__
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc
index b93882e..018a188 100644
--- a/chrome/views/custom_frame_window.cc
+++ b/chrome/views/custom_frame_window.cc
@@ -802,6 +802,15 @@ void DefaultNonClientView::LayoutTitleBar() {
// DefaultNonClientView subclass to use a ChromeView::Label as a child View
// instead of drawing the title's text directly on the canvas).
title_bounds_.set_x(MirroredLeftPointForRect(title_bounds_));
+
+ // Center the icon within the height of the title if the title is taller.
+ int delta_y = title_bounds_.height() - system_menu_button_->height();
+ if (delta_y > 0) {
+ int new_y = title_bounds_.y() + static_cast<int>(delta_y / 2);
+ system_menu_button_->SetBounds(system_menu_button_->x(), new_y,
+ system_menu_button_->width(),
+ system_menu_button_->height());
+ }
}
}
@@ -817,8 +826,7 @@ void DefaultNonClientView::InitClass() {
if (!initialized) {
active_resources_ = new ActiveWindowResources;
inactive_resources_ = new InactiveWindowResources;
- title_font_ = ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont).DeriveFont(1, ChromeFont::BOLD);
+ title_font_ = win_util::GetWindowTitleFont();
initialized = true;
}
}