summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 21:46:07 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 21:46:07 +0000
commit8692c5162c9e924f2f5cad18276180d4f6e22f89 (patch)
treec9bfb43a2f20ef3c279086ab245ce1a155f7e236
parentbfb8d8c3cc9486a97efc411bc846f8836f731f21 (diff)
downloadchromium_src-8692c5162c9e924f2f5cad18276180d4f6e22f89.zip
chromium_src-8692c5162c9e924f2f5cad18276180d4f6e22f89.tar.gz
chromium_src-8692c5162c9e924f2f5cad18276180d4f6e22f89.tar.bz2
tweak spacings in infobars per latest specs
BUG=31297 TEST=none. Review URL: http://codereview.chromium.org/555153 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37443 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/infobars/infobars.cc21
-rw-r--r--chrome/browser/views/infobars/infobars.h5
-rw-r--r--chrome/browser/views/infobars/translate_infobars.cc54
-rw-r--r--chrome/browser/views/infobars/translate_infobars.h13
4 files changed, 63 insertions, 30 deletions
diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc
index 3b8df24..fd6437b7 100644
--- a/chrome/browser/views/infobars/infobars.cc
+++ b/chrome/browser/views/infobars/infobars.cc
@@ -22,10 +22,13 @@
#include "views/widget/widget.h"
// static
-const double InfoBar::kTargetHeight = 37.0;
-const int InfoBar::kHorizontalPadding = 3;
-const int InfoBar::kIconLabelSpacing = 5;
-const int InfoBar::kButtonSpacing = 5;
+const double InfoBar::kTargetHeight = 36.0;
+const int InfoBar::kHorizontalPadding = 6;
+const int InfoBar::kIconLabelSpacing = 6;
+const int InfoBar::kButtonButtonSpacing = 10;
+const int InfoBar::kEndOfLabelSpacing = 16;
+const int InfoBar::kCloseButtonSpacing = 12;
+const int InfoBar::kButtonInLabelSpacing = 5;
static const SkColor kInfoBackgroundColorTop = SkColorSetRGB(170, 214, 112);
static const SkColor kInfoBackgroundColorBottom = SkColorSetRGB(146, 205, 114);
@@ -158,7 +161,7 @@ gfx::Size InfoBar::GetPreferredSize() {
void InfoBar::Layout() {
gfx::Size button_ps = close_button_->GetPreferredSize();
- close_button_->SetBounds(width() - kButtonSpacing - button_ps.width(),
+ close_button_->SetBounds(width() - kHorizontalPadding - button_ps.width(),
OffsetY(this, button_ps), button_ps.width(),
button_ps.height());
}
@@ -177,7 +180,7 @@ void InfoBar::ViewHierarchyChanged(bool is_add, views::View* parent,
// InfoBar, protected: ---------------------------------------------------------
int InfoBar::GetAvailableWidth() const {
- return close_button_->x() - kButtonSpacing;
+ return close_button_->x() - kCloseButtonSpacing;
}
void InfoBar::RemoveInfoBar() const {
@@ -452,7 +455,7 @@ void ConfirmInfoBar::Layout() {
cancel_button_->SetBounds(available_width - cancel_button_width,
OffsetY(this, cancel_ps), cancel_ps.width(),
cancel_ps.height());
- int spacing = cancel_button_width > 0 ? kButtonSpacing : 0;
+ int spacing = cancel_button_width > 0 ? kButtonButtonSpacing : 0;
ok_button_->SetBounds(cancel_button_->x() - spacing - ok_button_width,
OffsetY(this, ok_ps), ok_ps.width(), ok_ps.height());
AlertInfoBar::Layout();
@@ -486,9 +489,9 @@ void ConfirmInfoBar::ButtonPressed(
int ConfirmInfoBar::GetAvailableWidth() const {
if (ok_button_)
- return ok_button_->x() - kButtonSpacing;
+ return ok_button_->x() - kEndOfLabelSpacing;
if (cancel_button_)
- return cancel_button_->x() - kButtonSpacing;
+ return cancel_button_->x() - kEndOfLabelSpacing;
return InfoBar::GetAvailableWidth();
}
diff --git a/chrome/browser/views/infobars/infobars.h b/chrome/browser/views/infobars/infobars.h
index aff4928..970b1ab 100644
--- a/chrome/browser/views/infobars/infobars.h
+++ b/chrome/browser/views/infobars/infobars.h
@@ -58,7 +58,10 @@ class InfoBar : public views::View,
static const int kHorizontalPadding;
static const int kIconLabelSpacing;
- static const int kButtonSpacing;
+ static const int kButtonButtonSpacing;
+ static const int kEndOfLabelSpacing;
+ static const int kCloseButtonSpacing;
+ static const int kButtonInLabelSpacing;
// Overridden from views::View:
virtual gfx::Size GetPreferredSize();
diff --git a/chrome/browser/views/infobars/translate_infobars.cc b/chrome/browser/views/infobars/translate_infobars.cc
index ed1034c..e5edffa 100644
--- a/chrome/browser/views/infobars/translate_infobars.cc
+++ b/chrome/browser/views/infobars/translate_infobars.cc
@@ -267,24 +267,28 @@ void TranslateInfoBar::Layout() {
InfoBar::OffsetY(this, label1_ps), text1_width, label1_ps.height());
// Place first language menu button after label_1.
- button1->SetBounds(label_1_->bounds().right() + InfoBar::kButtonSpacing,
- OffsetY(this, button1_ps), button1_ps.width(), button1_ps.height());
+ button1->SetBounds(label_1_->bounds().right() +
+ InfoBar::kButtonInLabelSpacing, OffsetY(this, button1_ps),
+ button1_ps.width(), button1_ps.height());
// Place label_2 after first language menu button.
- label_2_->SetBounds(button1->bounds().right() + InfoBar::kButtonSpacing,
- InfoBar::OffsetY(this, label2_ps), text2_width, label2_ps.height());
+ label_2_->SetBounds(button1->bounds().right() +
+ GetSpacingAfterFirstLanguageButton(), InfoBar::OffsetY(this, label2_ps),
+ text2_width, label2_ps.height());
// If second language menu button is available, place it after label_2.
if (button2) {
gfx::Size button2_ps = button2->GetPreferredSize();
- button2->SetBounds(label_2_->bounds().right() + InfoBar::kButtonSpacing,
- OffsetY(this, button2_ps), button2_ps.width(), button2_ps.height());
+ button2->SetBounds(label_2_->bounds().right() +
+ InfoBar::kButtonInLabelSpacing, OffsetY(this, button2_ps),
+ button2_ps.width(), button2_ps.height());
if (label_3_) {
gfx::Size label3_ps = label_3_->GetPreferredSize();
// Place label_3 after first language menu button.
- label_3_->SetBounds(button2->bounds().right() + InfoBar::kButtonSpacing,
- InfoBar::OffsetY(this, label3_ps), text3_width, label3_ps.height());
+ label_3_->SetBounds(button2->bounds().right() +
+ InfoBar::kButtonInLabelSpacing, InfoBar::OffsetY(this, label3_ps),
+ text3_width, label3_ps.height());
}
}
}
@@ -293,11 +297,25 @@ void TranslateInfoBar::Layout() {
int TranslateInfoBar::GetAvailableWidth() const {
gfx::Size icon_ps = icon_->GetPreferredSize();
+ // For language button, reserve spacing before and after it.
gfx::Size language_ps = original_language_menu_button_->GetPreferredSize();
+ int language_spacing = InfoBar::kButtonInLabelSpacing +
+ GetSpacingAfterFirstLanguageButton();
+ // Options button could come after different types of controls, so we reserve
+ // different spacings for each:
+ // - after label_3 (i.e. this label follows the second language button):
+ // spacing after second language button and for end of sentence
+ // - after second language button (i.e. there's no label_3): spacing for end
+ // of sentence
+ // - all other cases, regular button spacing before options button
gfx::Size options_ps = options_menu_button_->GetPreferredSize();
- return (InfoBar::GetAvailableWidth() - options_ps.width() -
- language_ps.width() - (InfoBar::kButtonSpacing * 3) -
- icon_ps.width() - InfoBar::kIconLabelSpacing);
+ int options_spacing =
+ (label_3_ ? InfoBar::kButtonInLabelSpacing + InfoBar::kEndOfLabelSpacing :
+ (target_language_menu_button() ? InfoBar::kEndOfLabelSpacing :
+ InfoBar::kButtonButtonSpacing));
+ return (InfoBar::GetAvailableWidth() - options_ps.width() - options_spacing -
+ language_ps.width() - language_spacing -
+ icon_->bounds().right() - InfoBar::kIconLabelSpacing);
}
// TranslateInfoBar, views::ViewMenuDelegate implementation: -------------------
@@ -411,7 +429,7 @@ views::MenuButton* TranslateInfoBar::CreateMenuButton(int menu_id,
int TranslateInfoBar::GetAvailableX() const {
return ((label_3_ ? label_3_->bounds().right() : label_2_->bounds().right()) +
- InfoBar::kButtonSpacing);
+ InfoBar::kEndOfLabelSpacing);
}
gfx::Point TranslateInfoBar::DetermineMenuPositionAndAlignment(
@@ -479,8 +497,9 @@ BeforeTranslateInfoBar::~BeforeTranslateInfoBar() {
int BeforeTranslateInfoBar::GetAvailableWidth() const {
gfx::Size accept_ps = accept_button_->GetPreferredSize();
gfx::Size deny_ps = deny_button_->GetPreferredSize();
- return (TranslateInfoBar::GetAvailableWidth() - accept_ps.width() -
- deny_ps.width() - (InfoBar::kButtonSpacing * 2));
+ return (TranslateInfoBar::GetAvailableWidth() -
+ accept_ps.width() - InfoBar::kEndOfLabelSpacing -
+ deny_ps.width() - InfoBar::kButtonButtonSpacing);
}
// BeforeTranslateInfoBar, views::View overrides: ------------------------------
@@ -491,14 +510,13 @@ void BeforeTranslateInfoBar::Layout() {
// Layout accept button.
gfx::Size accept_ps = accept_button_->GetPreferredSize();
- accept_button_->SetBounds(
- TranslateInfoBar::GetAvailableX() + InfoBar::kButtonSpacing,
+ accept_button_->SetBounds(TranslateInfoBar::GetAvailableX(),
OffsetY(this, accept_ps), accept_ps.width(), accept_ps.height());
// Layout deny button.
gfx::Size deny_ps = deny_button_->GetPreferredSize();
deny_button_->SetBounds(
- accept_button_->bounds().right() + InfoBar::kButtonSpacing,
+ accept_button_->bounds().right() + InfoBar::kButtonButtonSpacing,
OffsetY(this, deny_ps), deny_ps.width(), deny_ps.height());
}
@@ -534,7 +552,7 @@ AfterTranslateInfoBar::~AfterTranslateInfoBar() {
int AfterTranslateInfoBar::GetAvailableWidth() const {
gfx::Size target_ps = target_language_menu_button_->GetPreferredSize();
return (TranslateInfoBar::GetAvailableWidth() - target_ps.width() -
- InfoBar::kButtonSpacing);
+ InfoBar::kButtonInLabelSpacing);
}
// AfterTranslateInfoBar, views::ViewMenuDelegate implementation: --------------
diff --git a/chrome/browser/views/infobars/translate_infobars.h b/chrome/browser/views/infobars/translate_infobars.h
index ae2d512..1d0561e 100644
--- a/chrome/browser/views/infobars/translate_infobars.h
+++ b/chrome/browser/views/infobars/translate_infobars.h
@@ -58,10 +58,14 @@ class TranslateInfoBar : public InfoBar,
// Returns the leftmost position that subclasses can position their controls.
virtual int GetAvailableX() const;
- virtual views::MenuButton* target_language_menu_button() {
+ virtual views::MenuButton* target_language_menu_button() const {
return NULL;
}
+ virtual int GetSpacingAfterFirstLanguageButton() const {
+ return InfoBar::kButtonInLabelSpacing;
+ }
+
private:
bool before_translate_;
views::ImageView* icon_;
@@ -95,6 +99,11 @@ class BeforeTranslateInfoBar : public TranslateInfoBar {
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
+ // Overriden from TranslateInfoBar:
+ virtual int GetSpacingAfterFirstLanguageButton() const {
+ return 10;
+ }
+
// Overridden from InfoBar:
virtual int GetAvailableWidth() const;
@@ -120,7 +129,7 @@ class AfterTranslateInfoBar : public TranslateInfoBar {
// Overridden from InfoBar:
virtual int GetAvailableWidth() const;
- virtual views::MenuButton* target_language_menu_button() {
+ virtual views::MenuButton* target_language_menu_button() const {
return target_language_menu_button_;
}