diff options
author | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-26 07:05:17 +0000 |
---|---|---|
committer | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-26 07:05:17 +0000 |
commit | 0af059171ce1156f75ff11191fe0bdebe70f1039 (patch) | |
tree | acba11fb19f6f24bd225ccd6a45346857545caa5 /ui/app_list | |
parent | 1b8c1f82462f850b3ff0afef5a4ba88fbe9a26f8 (diff) | |
download | chromium_src-0af059171ce1156f75ff11191fe0bdebe70f1039.zip chromium_src-0af059171ce1156f75ff11191fe0bdebe70f1039.tar.gz chromium_src-0af059171ce1156f75ff11191fe0bdebe70f1039.tar.bz2 |
Clean-up: Replaces gfx::Font with gfx::FontList in ui/app_list.
As a part of effort to support multiple fonts, this CL changes methods to take gfx::FontList instead of gfx::Font, and to use new methods.
See https://docs.google.com/a/chromium.org/document/d/1D_25fp9B8b9aZJORfAjDIFq61NWvUquZ5xmKH-VcC4k/view
BUG=265485
TEST=Run views_unittests, ui_unittests and unit_tests.
Review URL: https://codereview.chromium.org/119963002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242518 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list')
-rw-r--r-- | ui/app_list/views/app_list_item_view.cc | 8 | ||||
-rw-r--r-- | ui/app_list/views/search_result_actions_view.cc | 2 | ||||
-rw-r--r-- | ui/app_list/views/signin_view.cc | 36 | ||||
-rw-r--r-- | ui/app_list/views/signin_view.h | 8 |
4 files changed, 26 insertions, 28 deletions
diff --git a/ui/app_list/views/app_list_item_view.cc b/ui/app_list/views/app_list_item_view.cc index 1e70e42..525b729 100644 --- a/ui/app_list/views/app_list_item_view.cc +++ b/ui/app_list/views/app_list_item_view.cc @@ -20,7 +20,7 @@ #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/animation/throb_animation.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/font.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/point.h" #include "ui/gfx/transform_util.h" @@ -70,7 +70,7 @@ AppListItemView::AppListItemView(AppsGridView* apps_grid_view, title_->SetBackgroundColor(0); title_->SetAutoColorReadabilityEnabled(false); title_->SetEnabledColor(kGridTitleColor); - title_->SetFont(rb.GetFont(kItemTextFontStyle)); + title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); title_->SetVisible(!model_->is_installing()); title_->Invalidate(); @@ -261,8 +261,8 @@ const char* AppListItemView::GetClassName() const { void AppListItemView::Layout() { gfx::Rect rect(GetContentsBounds()); - const int left_right_padding = kLeftRightPaddingChars * - title_->font().GetAverageCharacterWidth(); + const int left_right_padding = + title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); const int y = rect.y(); diff --git a/ui/app_list/views/search_result_actions_view.cc b/ui/app_list/views/search_result_actions_view.cc index 2c6abcf..691e264 100644 --- a/ui/app_list/views/search_result_actions_view.cc +++ b/ui/app_list/views/search_result_actions_view.cc @@ -78,7 +78,7 @@ void SearchResultActionsView::CreateBlueButton( views::BlueButton* button = new views::BlueButton(this, action.label_text); button->SetAccessibleName(action.label_text); button->SetTooltipText(action.tooltip_text); - button->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont( + button->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( ui::ResourceBundle::SmallBoldFont)); button->SetFocusable(false); AddChildView(button); diff --git a/ui/app_list/views/signin_view.cc b/ui/app_list/views/signin_view.cc index 74724e7..90a67e4 100644 --- a/ui/app_list/views/signin_view.cc +++ b/ui/app_list/views/signin_view.cc @@ -5,8 +5,7 @@ #include "ui/app_list/views/signin_view.h" #include "ui/app_list/signin_delegate.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/font.h" +#include "ui/gfx/font_list.h" #include "ui/views/background.h" #include "ui/views/controls/button/blue_button.h" #include "ui/views/controls/label.h" @@ -35,14 +34,21 @@ SigninView::SigninView(SigninDelegate* delegate, int width) if (!delegate_) return; - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); - title_font_.reset(new gfx::Font(base_font.GetFontName(), kTitleFontSize)); - text_font_.reset(new gfx::Font(base_font.GetFontName(), kTextFontSize)); - button_font_.reset(new gfx::Font(base_font.GetFontName(), kButtonFontSize)); - - int title_descender = title_font_->GetHeight() - title_font_->GetBaseline(); - int text_descender = text_font_->GetHeight() - text_font_->GetBaseline(); + const gfx::FontList base_font_list; + const gfx::FontList& title_font_list = + base_font_list.DeriveFontListWithSizeDelta( + kTitleFontSize - base_font_list.GetFontSize()); + const gfx::FontList& text_font_list = + base_font_list.DeriveFontListWithSizeDelta( + kTextFontSize - base_font_list.GetFontSize()); + const gfx::FontList& button_font_list = + base_font_list.DeriveFontListWithSizeDelta( + kButtonFontSize - base_font_list.GetFontSize()); + + int title_descender = + title_font_list.GetHeight() - title_font_list.GetBaseline(); + int text_descender = + text_font_list.GetHeight() - text_font_list.GetBaseline(); views::GridLayout* layout = new views::GridLayout(this); layout->SetInsets(kTopPadding, kLeftPadding, kBottomPadding - text_descender, @@ -68,14 +74,14 @@ SigninView::SigninView(SigninDelegate* delegate, int width) 0); views::Label* heading = new views::Label(delegate_->GetSigninHeading()); - heading->SetFont(*title_font_); + heading->SetFontList(title_font_list); heading->SetHorizontalAlignment(gfx::ALIGN_LEFT); layout->StartRow(0, kNormalSetId); layout->AddView(heading); views::Label* text = new views::Label(delegate_->GetSigninText()); - text->SetFont(*text_font_); + text->SetFontList(text_font_list); text->SetMultiLine(true); text->SetHorizontalAlignment(gfx::ALIGN_LEFT); layout->StartRowWithPadding(0, kNormalSetId, 0, @@ -85,7 +91,7 @@ SigninView::SigninView(SigninDelegate* delegate, int width) views::BlueButton* signin_button = new views::BlueButton( this, delegate_->GetSigninButtonText()); - signin_button->SetFont(*button_font_); + signin_button->SetFontList(button_font_list); layout->StartRowWithPadding(0, kButtonSetId, 0, kButtonPadding - text_descender); layout->AddView(signin_button); @@ -93,7 +99,7 @@ SigninView::SigninView(SigninDelegate* delegate, int width) layout->StartRow(1, kNormalSetId); learn_more_link_ = new views::Link(delegate_->GetLearnMoreLinkText()); learn_more_link_->set_listener(this); - learn_more_link_->SetFont(*text_font_); + learn_more_link_->SetFontList(text_font_list); learn_more_link_->SetUnderline(false); layout->AddView(learn_more_link_, 1, @@ -104,7 +110,7 @@ SigninView::SigninView(SigninDelegate* delegate, int width) layout->StartRow(0, kNormalSetId); settings_link_ = new views::Link(delegate_->GetSettingsLinkText()); settings_link_->set_listener(this); - settings_link_->SetFont(*text_font_); + settings_link_->SetFontList(text_font_list); settings_link_->SetUnderline(false); layout->AddView(settings_link_, 1, diff --git a/ui/app_list/views/signin_view.h b/ui/app_list/views/signin_view.h index 47a107b..b4bb989 100644 --- a/ui/app_list/views/signin_view.h +++ b/ui/app_list/views/signin_view.h @@ -7,15 +7,10 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/link_listener.h" #include "ui/views/view.h" -namespace gfx { -class Font; -} - namespace app_list { class SigninDelegate; @@ -38,9 +33,6 @@ class SigninView : public views::View, views::Link* learn_more_link_; views::Link* settings_link_; - scoped_ptr<gfx::Font> title_font_; - scoped_ptr<gfx::Font> text_font_; - scoped_ptr<gfx::Font> button_font_; SigninDelegate* delegate_; |