diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-12 18:57:03 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-12 18:57:03 +0000 |
commit | a2b35465c42e3bb3f85c22a869e0dce74b5d8a4c (patch) | |
tree | e800a3fd638bda7b597b8fd0b76af50d3d049ea5 /views/controls | |
parent | 5e49b2ce1dc358328ab732520b17414b44081712 (diff) | |
download | chromium_src-a2b35465c42e3bb3f85c22a869e0dce74b5d8a4c.zip chromium_src-a2b35465c42e3bb3f85c22a869e0dce74b5d8a4c.tar.gz chromium_src-a2b35465c42e3bb3f85c22a869e0dce74b5d8a4c.tar.bz2 |
Shift omnibox dropdown in and up on Windows, and square off the top, so it connects to the location bar. Also fix info bubble positioning against location bar icons to put the arrow "up against the icon edge" (fixes the arrow overlapping some page action icons).
Remove BubblePositioner, which is now no longer needed.
BUG=27570,40730
TEST=Omnibox dropdown should line up with editable area edges, icons and text should line up with icon and text in the omnibox. Info bubbles should still be positioned correctly
Review URL: http://codereview.chromium.org/1578021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44268 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/image_view.cc | 76 | ||||
-rw-r--r-- | views/controls/image_view.h | 8 |
2 files changed, 34 insertions, 50 deletions
diff --git a/views/controls/image_view.cc b/views/controls/image_view.cc index d35585e..9728332 100644 --- a/views/controls/image_view.cc +++ b/views/controls/image_view.cc @@ -49,6 +49,12 @@ bool ImageView::GetImageSize(gfx::Size* image_size) { return image_size_set_; } +gfx::Rect ImageView::GetImageBounds() const { + gfx::Size image_size(image_size_set_ ? + image_size_ : gfx::Size(image_.width(), image_.height())); + return gfx::Rect(ComputeImageOrigin(image_size), image_size); +} + void ImageView::ResetImageSize() { image_size_set_ = false; } @@ -65,74 +71,52 @@ gfx::Size ImageView::GetPreferredSize() { image_.height() + insets.height()); } -void ImageView::ComputeImageOrigin(int image_width, int image_height, - int *x, int *y) { +gfx::Point ImageView::ComputeImageOrigin(const gfx::Size& image_size) const { + gfx::Insets insets = GetInsets(); + + int x; // In order to properly handle alignment of images in RTL locales, we need // to flip the meaning of trailing and leading. For example, if the // horizontal alignment is set to trailing, then we'll use left alignment for // the image instead of right alignment if the UI layout is RTL. Alignment actual_horiz_alignment = horiz_alignment_; - if (UILayoutIsRightToLeft()) { - if (horiz_alignment_ == TRAILING) - actual_horiz_alignment = LEADING; - if (horiz_alignment_ == LEADING) - actual_horiz_alignment = TRAILING; - } - - gfx::Insets insets = GetInsets(); - + if (UILayoutIsRightToLeft() && (horiz_alignment_ != CENTER)) + actual_horiz_alignment = (horiz_alignment_ == LEADING) ? TRAILING : LEADING; switch (actual_horiz_alignment) { - case LEADING: - *x = insets.left(); - break; - case TRAILING: - *x = width() - insets.right() - image_width; - break; - case CENTER: - *x = (width() - image_width) / 2; - break; - default: - NOTREACHED(); + case LEADING: x = insets.left(); break; + case TRAILING: x = width() - insets.right() - image_size.width(); break; + case CENTER: x = (width() - image_size.width()) / 2; break; + default: NOTREACHED(); x = 0; break; } + int y; switch (vert_alignment_) { - case LEADING: - *y = insets.top(); - break; - case TRAILING: - *y = height() - insets.bottom() - image_height; - break; - case CENTER: - *y = (height() - image_height) / 2; - break; - default: - NOTREACHED(); + case LEADING: y = insets.top(); break; + case TRAILING: y = height() - insets.bottom() - image_size.height(); break; + case CENTER: y = (height() - image_size.height()) / 2; break; + default: NOTREACHED(); y = 0; break; } + + return gfx::Point(x, y); } void ImageView::Paint(gfx::Canvas* canvas) { View::Paint(canvas); - int image_width = image_.width(); - int image_height = image_.height(); - if (image_width == 0 || image_height == 0) + gfx::Rect image_bounds(GetImageBounds()); + if (image_bounds.IsEmpty()) return; - int x, y; - if (image_size_set_ && - (image_size_.width() != image_width || - image_size_.width() != image_height)) { + if (image_bounds.size() != gfx::Size(image_.width(), image_.height())) { // Resize case image_.buildMipMap(false); - ComputeImageOrigin(image_size_.width(), image_size_.height(), &x, &y); SkPaint paint; paint.setFilterBitmap(true); - canvas->DrawBitmapInt(image_, 0, 0, image_width, image_height, - x, y, image_size_.width(), image_size_.height(), - true, paint); + canvas->DrawBitmapInt(image_, 0, 0, image_.width(), image_.height(), + image_bounds.x(), image_bounds.y(), image_bounds.width(), + image_bounds.height(), true, paint); } else { - ComputeImageOrigin(image_width, image_height, &x, &y); - canvas->DrawBitmapInt(image_, x, y); + canvas->DrawBitmapInt(image_, image_bounds.x(), image_bounds.y()); } } diff --git a/views/controls/image_view.h b/views/controls/image_view.h index 46cbb00..45eeecd 100644 --- a/views/controls/image_view.h +++ b/views/controls/image_view.h @@ -55,6 +55,9 @@ class ImageView : public View { // size. bool GetImageSize(gfx::Size* image_size); + // Returns the actual bounds of the visible image inside the view. + gfx::Rect GetImageBounds() const; + // Reset the image size to the current image dimensions. void ResetImageSize(); @@ -70,19 +73,16 @@ class ImageView : public View { void SetTooltipText(const std::wstring& tooltip); std::wstring GetTooltipText(); - // Return whether the image should be centered inside the view. // Overriden from View virtual gfx::Size GetPreferredSize(); virtual void Paint(gfx::Canvas* canvas); virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); - - // Overriden from View. virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); private: // Compute the image origin given the desired size and the receiver alignment // properties. - void ComputeImageOrigin(int image_width, int image_height, int *x, int *y); + gfx::Point ComputeImageOrigin(const gfx::Size& image_size) const; // Whether the image size is set. bool image_size_set_; |