Commit f59ce13e authored by pkasting@chromium.org's avatar pkasting@chromium.org

Location bar layout changes for M6 theme.

BUG=50107
TEST=none
Review URL: http://codereview.chromium.org/3067011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54048 0039d316-1c4b-4281-b951-d872f2087c98
parent 73caab08
...@@ -222,10 +222,10 @@ void InfoBubbleContentsView::Layout() { ...@@ -222,10 +222,10 @@ void InfoBubbleContentsView::Layout() {
return; return;
gfx::Rect bounds = GetLocalBounds(false); gfx::Rect bounds = GetLocalBounds(false);
// The browser's location bar use a vertical padding that we need to take into // The browser's location bar uses vertical padding that we need to take into
// account to match its height. // account to match its height.
int location_bar_height = int location_bar_height = location_bar_->GetPreferredSize().height() -
location_bar_->GetPreferredSize().height() - LocationBarView::kVertMargin; LocationBarView::kVerticalEdgeThickness;
location_bar_->SetBounds(bounds.x(), bounds.y(), bounds.width(), location_bar_->SetBounds(bounds.x(), bounds.y(), bounds.width(),
location_bar_height); location_bar_height);
int render_y = location_bar_->bounds().bottom() + kNavigationBarBottomPadding; int render_y = location_bar_->bounds().bottom() + kNavigationBarBottomPadding;
......
...@@ -305,13 +305,13 @@ void AutocompleteResultView::Paint(gfx::Canvas* canvas) { ...@@ -305,13 +305,13 @@ void AutocompleteResultView::Paint(gfx::Canvas* canvas) {
} }
void AutocompleteResultView::Layout() { void AutocompleteResultView::Layout() {
icon_bounds_.SetRect(LocationBarView::kItemPadding, icon_bounds_.SetRect(LocationBarView::kEdgeItemPadding,
(height() - icon_size_) / 2, icon_size_, icon_size_); (height() - icon_size_) / 2, icon_size_, icon_size_);
int text_x = icon_bounds_.right() + LocationBarView::kItemPadding; int text_x = icon_bounds_.right() + LocationBarView::kItemPadding;
int font_height = std::max(normal_font_.height(), bold_font_.height()); int font_height = std::max(normal_font_.height(), bold_font_.height());
text_bounds_.SetRect(text_x, std::max(0, (height() - font_height) / 2), text_bounds_.SetRect(text_x, std::max(0, (height() - font_height) / 2),
std::max(0, bounds().width() - text_x - LocationBarView::kItemPadding), std::max(bounds().width() - text_x - LocationBarView::kEdgeItemPadding,
font_height); 0), font_height);
} }
gfx::Size AutocompleteResultView::GetPreferredSize() { gfx::Size AutocompleteResultView::GetPreferredSize() {
...@@ -688,7 +688,8 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() { ...@@ -688,7 +688,8 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() {
// The normal location bar is drawn using a background graphic that includes // The normal location bar is drawn using a background graphic that includes
// the border, so we inset by enough to make the edges line up, and the // the border, so we inset by enough to make the edges line up, and the
// bubble appear at the same height as the Star bubble. // bubble appear at the same height as the Star bubble.
location_bar_bounds.Inset(LocationBarView::kEdgeThickness, 0); location_bar_bounds.Inset(LocationBarView::kNormalHorizontalEdgeThickness,
0);
} }
gfx::Point location_bar_origin(location_bar_bounds.origin()); gfx::Point location_bar_origin(location_bar_bounds.origin());
views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); views::View::ConvertPointToScreen(location_bar_, &location_bar_origin);
......
...@@ -10,14 +10,12 @@ ...@@ -10,14 +10,12 @@
#include "views/controls/image_view.h" #include "views/controls/image_view.h"
#include "views/controls/label.h" #include "views/controls/label.h"
// Amount to offset the image. // Amount of padding at the edges of the bubble.
static const int kImageOffset = 1; static const int kBubbleOuterPadding =
LocationBarView::kEdgeItemPadding - LocationBarView::kBubblePadding;
// Amount to offset the label from the image.
static const int kLabelOffset = 3;
// Amount of padding after the label. // Amount of padding after the label.
static const int kLabelPadding = 4; static const int kLabelPadding = 5;
IconLabelBubbleView::IconLabelBubbleView(const int background_images[], IconLabelBubbleView::IconLabelBubbleView(const int background_images[],
int contained_image, int contained_image,
...@@ -48,10 +46,7 @@ void IconLabelBubbleView::SetImage(const SkBitmap& bitmap) { ...@@ -48,10 +46,7 @@ void IconLabelBubbleView::SetImage(const SkBitmap& bitmap) {
} }
void IconLabelBubbleView::Paint(gfx::Canvas* canvas) { void IconLabelBubbleView::Paint(gfx::Canvas* canvas) {
int y_offset = (GetParent()->height() - height()) / 2;
canvas->TranslateInt(0, y_offset);
background_painter_.Paint(width(), height(), canvas); background_painter_.Paint(width(), height(), canvas);
canvas->TranslateInt(0, -y_offset);
} }
gfx::Size IconLabelBubbleView::GetPreferredSize() { gfx::Size IconLabelBubbleView::GetPreferredSize() {
...@@ -61,12 +56,12 @@ gfx::Size IconLabelBubbleView::GetPreferredSize() { ...@@ -61,12 +56,12 @@ gfx::Size IconLabelBubbleView::GetPreferredSize() {
} }
void IconLabelBubbleView::Layout() { void IconLabelBubbleView::Layout() {
image_->SetBounds(kImageOffset, 0, image_->GetPreferredSize().width(), image_->SetBounds(kBubbleOuterPadding, 0, image_->GetPreferredSize().width(),
height()); height());
const int label_height = label_->GetPreferredSize().height(); const int label_height = label_->GetPreferredSize().height();
label_->SetBounds(image_->x() + image_->width() + kLabelOffset, label_->SetBounds(image_->x() + image_->width() +
(height() - label_height) / 2, width() - GetNonLabelWidth(), LocationBarView::kItemPadding, (height() - label_height) / 2,
label_height); width() - GetNonLabelWidth(), label_height);
} }
void IconLabelBubbleView::SetElideInMiddle(bool elide_in_middle) { void IconLabelBubbleView::SetElideInMiddle(bool elide_in_middle) {
...@@ -78,6 +73,6 @@ gfx::Size IconLabelBubbleView::GetNonLabelSize() { ...@@ -78,6 +73,6 @@ gfx::Size IconLabelBubbleView::GetNonLabelSize() {
} }
int IconLabelBubbleView::GetNonLabelWidth() { int IconLabelBubbleView::GetNonLabelWidth() {
return kImageOffset + image_->GetPreferredSize().width() + kLabelOffset + return kBubbleOuterPadding + image_->GetPreferredSize().width() +
kLabelPadding; LocationBarView::kItemPadding + kBubbleOuterPadding;
} }
...@@ -226,9 +226,16 @@ class LocationBarView : public LocationBar, ...@@ -226,9 +226,16 @@ class LocationBarView : public LocationBar,
// Overridden from TemplateURLModelObserver // Overridden from TemplateURLModelObserver
virtual void OnTemplateURLModelChanged(); virtual void OnTemplateURLModelChanged();
static const int kVertMargin; // Space above and below the edit. // Thickness of the left and right edges of the omnibox, in normal mode.
static const int kEdgeThickness; // Unavailable space at horizontal edges. static const int kNormalHorizontalEdgeThickness;
static const int kItemPadding; // Space between items within the bar. // Thickness of the top and bottom edges of the omnibox.
static const int kVerticalEdgeThickness;
// Space between items in the location bar.
static const int kItemPadding;
// Space between the edges and the items next to them.
static const int kEdgeItemPadding;
// Space between the edge and a bubble.
static const int kBubblePadding;
protected: protected:
void Focus(); void Focus();
...@@ -240,24 +247,20 @@ class LocationBarView : public LocationBar, ...@@ -240,24 +247,20 @@ class LocationBarView : public LocationBar,
friend class PageActionWithBadgeView; friend class PageActionWithBadgeView;
typedef std::vector<PageActionWithBadgeView*> PageActionViews; typedef std::vector<PageActionWithBadgeView*> PageActionViews;
// Returns the height in pixels of the margin at the top of the bar.
int TopMargin() const;
// Returns the amount of horizontal space (in pixels) out of // Returns the amount of horizontal space (in pixels) out of
// |location_bar_width| that is not taken up by the actual text in // |location_bar_width| that is not taken up by the actual text in
// location_entry_. // location_entry_.
int AvailableWidth(int location_bar_width); int AvailableWidth(int location_bar_width);
// Returns whether the |available_width| is large enough to contain a view // If |view| fits in |available_width|, it is made visible and positioned at
// with preferred width |pref_width| at its preferred size. If this returns // the leading or trailing end of |bounds|, which are then shrunk
// true, the preferred size should be used. If this returns false, the // appropriately. Otherwise |view| is made invisible.
// minimum size of the view should be used. // Note: |view| is expected to have already been positioned and sized
bool UsePref(int pref_width, int available_width); // vertically.
void LayoutView(views::View* view,
// If View fits in the specified region, it is made visible and the int padding,
// bounds are adjusted appropriately. If the View does not fit, it is int available_width,
// made invisible. bool leading,
void LayoutView(bool leading, views::View* view, int available_width,
gfx::Rect* bounds); gfx::Rect* bounds);
// Update the visibility state of the Content Blocked icons to reflect what is // Update the visibility state of the Content Blocked icons to reflect what is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment