summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-10 12:37:51 +0000
committeravayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-10 12:37:51 +0000
commit798eb8d98aebe9e4840c7c85487531c13ec8abc2 (patch)
treec18355c9f3101643c5d58042baf251962e5a3153
parent8c9698118ea2a217d1b62d61ab5426d4369eebb5 (diff)
downloadchromium_src-798eb8d98aebe9e4840c7c85487531c13ec8abc2.zip
chromium_src-798eb8d98aebe9e4840c7c85487531c13ec8abc2.tar.gz
chromium_src-798eb8d98aebe9e4840c7c85487531c13ec8abc2.tar.bz2
Fixed fonts for buttons and labels on picture taking screen.
Button with minimum width for guest user, new user and picture taking views. BUG=chromium-os:8930 TEST=Check that font on buttons and labels on picture screen matches that for login screen. Buttons size should be the same too. Review URL: http://codereview.chromium.org/4684002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65658 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/guest_user_view.cc15
-rw-r--r--chrome/browser/chromeos/login/helper.cc20
-rw-r--r--chrome/browser/chromeos/login/helper.h24
-rw-r--r--chrome/browser/chromeos/login/new_user_view.cc8
-rw-r--r--chrome/browser/chromeos/login/user_image_view.cc6
5 files changed, 52 insertions, 21 deletions
diff --git a/chrome/browser/chromeos/login/guest_user_view.cc b/chrome/browser/chromeos/login/guest_user_view.cc
index 9392c7b..a06e017 100644
--- a/chrome/browser/chromeos/login/guest_user_view.cc
+++ b/chrome/browser/chromeos/login/guest_user_view.cc
@@ -13,11 +13,11 @@
namespace chromeos {
// Button with custom processing for Tab/Shift+Tab to select entries.
-class UserEntryButton : public views::NativeButton {
+class UserEntryButton : public login::WideButton {
public:
UserEntryButton(UserController* controller,
const std::wstring& label)
- : NativeButton(controller, label),
+ : WideButton(controller, label),
controller_(controller) {}
// Overridden from views::View:
@@ -27,13 +27,13 @@ class UserEntryButton : public views::NativeButton {
controller_->SelectUser(index);
return true;
}
- return views::NativeButton::OnKeyPressed(e);
+ return WideButton::OnKeyPressed(e);
}
virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
if (e.GetKeyCode() == app::VKEY_TAB)
return true;
- return views::NativeButton::SkipDefaultKeyEventProcessing(e);
+ return WideButton::SkipDefaultKeyEventProcessing(e);
}
private:
@@ -65,7 +65,6 @@ void GuestUserView::RecreateFields() {
submit_button_ = new UserEntryButton(
user_controller_,
l10n_util::GetString(IDS_ENTER_GUEST_SESSION_BUTTON));
- CorrectNativeButtonFontSize(submit_button_);
AddChildView(submit_button_);
Layout();
SchedulePaint();
@@ -104,13 +103,11 @@ void GuestUserView::OnLocaleChanged() {
void GuestUserView::Layout() {
gfx::Size submit_button_size = submit_button_->GetPreferredSize();
- int submit_button_width = std::max(login::kButtonMinWidth,
- submit_button_size.width());
- int submit_button_x = (width() - submit_button_width) / 2;
+ int submit_button_x = (width() - submit_button_size.width()) / 2;
int submit_button_y = (height() - submit_button_size.height()) / 2;
submit_button_->SetBounds(submit_button_x,
submit_button_y,
- submit_button_width,
+ submit_button_size.width(),
submit_button_size.height());
}
diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc
index dea756f..b3905c0 100644
--- a/chrome/browser/chromeos/login/helper.cc
+++ b/chrome/browser/chromeos/login/helper.cc
@@ -11,6 +11,7 @@
#include "grit/theme_resources.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "views/controls/button/native_button.h"
+#include "views/controls/label.h"
#include "views/controls/textfield/textfield.h"
#include "views/controls/throbber.h"
#include "views/painter.h"
@@ -96,6 +97,11 @@ gfx::Rect CalculateScreenBounds(const gfx::Size& size) {
return bounds;
}
+void CorrectLabelFontSize(views::Label* label) {
+ if (label)
+ label->SetFont(label->font().DeriveFont(kFontSizeCorrectionDelta));
+}
+
void CorrectNativeButtonFontSize(views::NativeButton* button) {
if (button)
button->set_font(button->font().DeriveFont(kFontSizeCorrectionDelta));
@@ -110,5 +116,19 @@ GURL GetAccountRecoveryHelpUrl() {
return google_util::AppendGoogleLocaleParam(GURL(kAccountRecoveryHelpUrl));
}
+namespace login {
+
+// Minimal width for the button.
+const int kButtonMinWidth = 90;
+
+gfx::Size WideButton::GetPreferredSize() {
+ gfx::Size preferred_size = NativeButton::GetPreferredSize();
+ if (preferred_size.width() < kButtonMinWidth)
+ preferred_size.set_width(kButtonMinWidth);
+ return preferred_size;
+}
+
+} // namespace login
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/helper.h b/chrome/browser/chromeos/login/helper.h
index 9713926..58acadd 100644
--- a/chrome/browser/chromeos/login/helper.h
+++ b/chrome/browser/chromeos/login/helper.h
@@ -8,6 +8,7 @@
#define CHROME_BROWSER_CHROMEOS_LOGIN_HELPER_H_
#pragma once
+#include "views/controls/button/native_button.h"
#include "third_party/skia/include/core/SkColor.h"
class GURL;
@@ -18,7 +19,7 @@ class Size;
} // namespace gfx
namespace views {
-class NativeButton;
+class Label;
class Painter;
class Textfield;
class Throbber;
@@ -41,6 +42,9 @@ views::Painter* CreateBackgroundPainter();
gfx::Rect CalculateScreenBounds(const gfx::Size& size);
// Corrects font size for NativeButton control.
+void CorrectLabelFontSize(views::Label* label);
+
+// Corrects font size for NativeButton control.
void CorrectNativeButtonFontSize(views::NativeButton* button);
// Corrects font size for Textfield control.
@@ -58,9 +62,6 @@ enum Command {
SIGN_OUT,
};
-// Minimal width for the button.
-const int kButtonMinWidth = 90;
-
// Gap between edge and image view, and image view and controls.
const int kBorderSize = 6;
@@ -84,6 +85,21 @@ const int kWizardScreenHeight = 450;
const int kScreenCornerRadius = 10;
const int kUserCornerRadius = 5;
+class WideButton : public views::NativeButton {
+ public:
+ WideButton(views::ButtonListener* listener, const std::wstring& text)
+ : NativeButton(listener, text) {
+ CorrectNativeButtonFontSize(this);
+ }
+
+ ~WideButton() {}
+
+ private:
+ virtual gfx::Size GetPreferredSize();
+
+ DISALLOW_COPY_AND_ASSIGN(WideButton);
+};
+
} // namespace login
// Font size correction in points for login/oobe textfields/buttons/title.
diff --git a/chrome/browser/chromeos/login/new_user_view.cc b/chrome/browser/chromeos/login/new_user_view.cc
index 62b63e5..aada4ff 100644
--- a/chrome/browser/chromeos/login/new_user_view.cc
+++ b/chrome/browser/chromeos/login/new_user_view.cc
@@ -30,7 +30,6 @@
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "views/background.h"
-#include "views/controls/button/native_button.h"
#include "views/controls/label.h"
#include "views/controls/throbber.h"
#include "views/widget/widget_gtk.h"
@@ -242,8 +241,7 @@ void NewUserView::RecreatePeculiarControls() {
// There is no way to get native button preferred size after the button was
// sized so delete and recreate the button on text update.
delete sign_in_button_;
- sign_in_button_ = new views::NativeButton(this, std::wstring());
- CorrectNativeButtonFontSize(sign_in_button_);
+ sign_in_button_ = new login::WideButton(this, std::wstring());
UpdateSignInButtonState();
if (!CrosLibrary::Get()->EnsureLoaded())
@@ -438,9 +436,7 @@ void NewUserView::Layout() {
y += setViewBounds(password_field_, x, y, width, true) + kRowPad;
int throbber_y = y;
- int sign_in_button_width =
- std::max(login::kButtonMinWidth,
- sign_in_button_->GetPreferredSize().width());
+ int sign_in_button_width = sign_in_button_->GetPreferredSize().width();
setViewBounds(sign_in_button_, x, y, sign_in_button_width,true);
setViewBounds(throbber_,
x + width - throbber_->GetPreferredSize().width(),
diff --git a/chrome/browser/chromeos/login/user_image_view.cc b/chrome/browser/chromeos/login/user_image_view.cc
index e2bf73b..9b0e2e7 100644
--- a/chrome/browser/chromeos/login/user_image_view.cc
+++ b/chrome/browser/chromeos/login/user_image_view.cc
@@ -68,6 +68,7 @@ class CameraImageView : public views::ImageView {
message_->SetMultiLine(true);
message_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
message_->SetVisible(false);
+ CorrectLabelFontSize(message_);
AddChildView(message_);
}
@@ -171,6 +172,7 @@ void UserImageView::Init() {
new views::Label(l10n_util::GetString(IDS_USER_IMAGE_SCREEN_TITLE));
title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
title_label_->SetMultiLine(true);
+ CorrectLabelFontSize(title_label_);
user_image_ = new CameraImageView();
user_image_->SetImageSize(
@@ -186,10 +188,10 @@ void UserImageView::Init() {
ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_USER_IMAGE_CAPTURE_DISABLED));
- ok_button_ = new views::NativeButton(this, l10n_util::GetString(IDS_OK));
+ ok_button_ = new login::WideButton(this, l10n_util::GetString(IDS_OK));
ok_button_->SetEnabled(!is_capturing_);
- skip_button_ = new views::NativeButton(this, l10n_util::GetString(IDS_SKIP));
+ skip_button_ = new login::WideButton(this, l10n_util::GetString(IDS_SKIP));
skip_button_->SetEnabled(true);
InitLayout();