summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 23:32:21 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 23:32:21 +0000
commit448219347191361795210e39ccdca14cfd76a62c (patch)
tree737b978a72876dfad9c958e0c879632a95b4e308 /chrome/browser/views
parent5bc87e02c16ccf68c69bff890af32748dba95142 (diff)
downloadchromium_src-448219347191361795210e39ccdca14cfd76a62c.zip
chromium_src-448219347191361795210e39ccdca14cfd76a62c.tar.gz
chromium_src-448219347191361795210e39ccdca14cfd76a62c.tar.bz2
Changed the status bar size to adapt to the size of the font,
instead of being a const. BUG= http://crbug.com/1275 TEST=Set Windows XP font size to large or extra-large. Open Chrome. Hover over a link to bring up the status bubble. Text should sit comfortably in bubble, without being squeezed. Review URL: http://codereview.chromium.org/113490 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17262 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/frame/browser_view.cc6
-rw-r--r--chrome/browser/views/status_bubble_views.cc58
-rw-r--r--chrome/browser/views/status_bubble_views.h13
3 files changed, 45 insertions, 32 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index b68b2c1..b30d106 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -1441,10 +1441,10 @@ void BrowserView::LayoutStatusBubble(int top) {
// frame.
int overlap = StatusBubbleViews::kShadowThickness +
(IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness);
- gfx::Point origin(-overlap, top - kStatusBubbleHeight + overlap);
+ int height = status_bubble_->GetPreferredSize().height();
+ gfx::Point origin(-overlap, top - height + overlap);
ConvertPointToView(this, GetParent(), &origin);
- status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3,
- kStatusBubbleHeight);
+ status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height);
}
int BrowserView::LayoutExtensionShelf() {
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index ae09cc4..678aa6b 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -492,6 +492,38 @@ void StatusBubbleViews::Init() {
}
}
+void StatusBubbleViews::Reposition() {
+ if (popup_.get()) {
+ gfx::Point top_left;
+ views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left);
+
+ popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
+ top_left.y() + position_.y(),
+ size_.width(), size_.height()));
+ }
+}
+
+gfx::Size StatusBubbleViews::GetPreferredSize() {
+ return gfx::Size(0, ResourceBundle::GetSharedInstance().GetFont(
+ ResourceBundle::BaseFont).height() + kTotalVerticalPadding);
+}
+
+void StatusBubbleViews::SetBounds(int x, int y, int w, int h) {
+ // If the UI layout is RTL, we need to mirror the position of the bubble
+ // relative to the parent.
+ if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
+ gfx::Rect frame_bounds;
+ frame_->GetBounds(&frame_bounds, false);
+ int mirrored_x = frame_bounds.width() - x - w;
+ position_.SetPoint(mirrored_x, y);
+ } else {
+ position_.SetPoint(x, y);
+ }
+
+ size_.SetSize(w, h);
+ Reposition();
+}
+
void StatusBubbleViews::SetStatus(const std::wstring& status_text) {
if (status_text_ == status_text)
return;
@@ -660,29 +692,3 @@ void StatusBubbleViews::AvoidMouse() {
}
}
-void StatusBubbleViews::Reposition() {
- if (popup_.get()) {
- gfx::Point top_left;
- views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left);
-
- popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
- top_left.y() + position_.y(),
- size_.width(), size_.height()));
- }
-}
-
-void StatusBubbleViews::SetBounds(int x, int y, int w, int h) {
- // If the UI layout is RTL, we need to mirror the position of the bubble
- // relative to the parent.
- if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
- gfx::Rect frame_bounds;
- frame_->GetBounds(&frame_bounds, false);
- int mirrored_x = frame_bounds.width() - x - w;
- position_.SetPoint(mirrored_x, y);
- } else {
- position_.SetPoint(x, y);
- }
-
- size_.SetSize(w, h);
- Reposition();
-}
diff --git a/chrome/browser/views/status_bubble_views.h b/chrome/browser/views/status_bubble_views.h
index 0dc90b0..8b8fd9e 100644
--- a/chrome/browser/views/status_bubble_views.h
+++ b/chrome/browser/views/status_bubble_views.h
@@ -23,16 +23,23 @@ class StatusBubbleViews : public StatusBubble {
// How wide the bubble's shadow is.
static const int kShadowThickness;
+ // The combined vertical padding above and below the text.
+ static const int kTotalVerticalPadding = 7;
+
explicit StatusBubbleViews(views::Widget* frame);
~StatusBubbleViews();
- // Set the bounds of the bubble relative to the browser window.
- void SetBounds(int x, int y, int w, int h);
-
// Reposition the bubble - as we are using a WS_POPUP for the bubble,
// we have to manually position it when the browser window moves.
void Reposition();
+ // The bubble only has a preferred height: the sum of the height of
+ // the font and kTotalVerticalPadding.
+ gfx::Size GetPreferredSize();
+
+ // Set the bounds of the bubble relative to the browser window.
+ void SetBounds(int x, int y, int w, int h);
+
// Overridden from StatusBubble:
virtual void SetStatus(const std::wstring& status);
virtual void SetURL(const GURL& url, const std::wstring& languages);