summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authoryukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-03 05:23:28 +0000
committeryukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-03 05:23:28 +0000
commit4809dd48dbbf27917833fca9944d4437e000c447 (patch)
treea96c6423ba55a095673c9121d21664bd6c04ebe0 /ui
parent8fe854f49da44c6d7f89fbd107f7ebce34e3ecee (diff)
downloadchromium_src-4809dd48dbbf27917833fca9944d4437e000c447.zip
chromium_src-4809dd48dbbf27917833fca9944d4437e000c447.tar.gz
chromium_src-4809dd48dbbf27917833fca9944d4437e000c447.tar.bz2
Refactor: Makes views::TreeView use gfx::FontList instead of gfx::Font.
As part of effort to support multiple fonts, this CL changes methods which are now taking gfx::Font so they will take gfx::FontList instead. BUG=265485 TEST=Run unit_tests, ui_unittests, views_unittests Review URL: https://codereview.chromium.org/98253010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/controls/tree/tree_view.cc23
-rw-r--r--ui/views/controls/tree/tree_view.h10
2 files changed, 20 insertions, 13 deletions
diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc
index 3bed127..62c0fa9 100644
--- a/ui/views/controls/tree/tree_view.cc
+++ b/ui/views/controls/tree/tree_view.cc
@@ -14,6 +14,7 @@
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/skia_util.h"
@@ -79,7 +80,7 @@ TreeView::TreeView()
controller_(NULL),
root_shown_(true),
has_custom_icons_(false),
- row_height_(font_.GetHeight() + kTextVerticalPadding * 2) {
+ row_height_(font_list_.GetHeight() + kTextVerticalPadding * 2) {
SetFocusable(true);
closed_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
(base::i18n::IsRTL() ? IDR_FOLDER_CLOSED_RTL
@@ -158,7 +159,7 @@ void TreeView::StartEditing(TreeModelNode* node) {
// Add the editor immediately as GetPreferredSize returns the wrong thing if
// not parented.
AddChildView(editor_);
- editor_->SetFont(font_);
+ editor_->SetFontList(font_list_);
empty_editor_size_ = editor_->GetPreferredSize();
editor_->SetController(this);
}
@@ -694,7 +695,7 @@ void TreeView::ConfigureInternalNode(TreeModelNode* model_node,
void TreeView::UpdateNodeTextWidth(InternalNode* node) {
int width = 0, height = 0;
- gfx::Canvas::SizeStringInt(node->model_node()->GetTitle(), font_,
+ gfx::Canvas::SizeStringInt(node->model_node()->GetTitle(), font_list_,
&width, &height, 0, gfx::Canvas::NO_ELLIPSIS);
node->set_text_width(width);
}
@@ -729,7 +730,7 @@ void TreeView::LayoutEditor() {
row_bounds.set_width(row_bounds.width() - text_offset_);
row_bounds.Inset(kTextHorizontalPadding, kTextVerticalPadding);
row_bounds.Inset(-empty_editor_size_.width() / 2,
- -(empty_editor_size_.height() - font_.GetHeight()) / 2);
+ -(empty_editor_size_.height() - font_list_.GetHeight()) / 2);
// Give a little extra space for editing.
row_bounds.set_width(row_bounds.width() + 50);
editor_->SetBoundsRect(row_bounds);
@@ -803,12 +804,14 @@ void TreeView::PaintRow(gfx::Canvas* canvas,
}
const ui::NativeTheme::ColorId color_id =
text_color_id(HasFocus(), node == selected_node_);
- canvas->DrawStringInt(node->model_node()->GetTitle(), font_,
- GetNativeTheme()->GetSystemColor(color_id),
- text_bounds.x() + kTextHorizontalPadding,
- text_bounds.y() + kTextVerticalPadding,
- text_bounds.width() - kTextHorizontalPadding * 2,
- text_bounds.height() - kTextVerticalPadding * 2);
+ const gfx::Rect internal_bounds(
+ text_bounds.x() + kTextHorizontalPadding,
+ text_bounds.y() + kTextVerticalPadding,
+ text_bounds.width() - kTextHorizontalPadding * 2,
+ text_bounds.height() - kTextVerticalPadding * 2);
+ canvas->DrawStringRect(node->model_node()->GetTitle(), font_list_,
+ GetNativeTheme()->GetSystemColor(color_id),
+ internal_bounds);
}
}
diff --git a/ui/views/controls/tree/tree_view.h b/ui/views/controls/tree/tree_view.h
index b7a4eca..1e5db32d 100644
--- a/ui/views/controls/tree/tree_view.h
+++ b/ui/views/controls/tree/tree_view.h
@@ -11,13 +11,17 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "ui/base/models/tree_node_model.h"
-#include "ui/gfx/font.h"
+#include "ui/gfx/font_list.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/controls/prefix_delegate.h"
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/view.h"
+namespace gfx {
+class Rect;
+} // namespace gfx
+
namespace views {
class Textfield;
@@ -376,8 +380,8 @@ class VIEWS_EXPORT TreeView : public ui::TreeModelObserver,
// Cached preferred size.
gfx::Size preferred_size_;
- // Font used to display text.
- gfx::Font font_;
+ // Font list used to display text.
+ gfx::FontList font_list_;
// Height of each row. Based on font and some padding.
int row_height_;