Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: ui/views/controls/label.cc

Issue 1689623004: Start removing enum ui::ResourceBundle::FontStyle, fix MacViews font sizes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix transcription error Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | ui/views/controls/tabbed_pane/tabbed_pane.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <limits> 11 #include <limits>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/profiler/scoped_tracker.h" 17 #include "base/profiler/scoped_tracker.h"
18 #include "base/strings/string_split.h" 18 #include "base/strings/string_split.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "ui/accessibility/ax_view_state.h" 20 #include "ui/accessibility/ax_view_state.h"
21 #include "ui/base/default_style.h"
22 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/color_utils.h" 24 #include "ui/gfx/color_utils.h"
23 #include "ui/gfx/geometry/insets.h" 25 #include "ui/gfx/geometry/insets.h"
24 #include "ui/gfx/text_elider.h" 26 #include "ui/gfx/text_elider.h"
25 #include "ui/native_theme/native_theme.h" 27 #include "ui/native_theme/native_theme.h"
26 28
27 namespace views { 29 namespace views {
30 namespace {
31
32 const gfx::FontList& GetDefaultFontList() {
33 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
34 return rb.GetFontListWithDelta(ui::kLabelFontSizeDelta);
35 }
36
37 } // namespace
28 38
29 // static 39 // static
30 const char Label::kViewClassName[] = "Label"; 40 const char Label::kViewClassName[] = "Label";
31 const int Label::kFocusBorderPadding = 1; 41 const int Label::kFocusBorderPadding = 1;
32 42
33 Label::Label() { 43 Label::Label() : Label(base::string16()) {
34 Init(base::string16(), gfx::FontList());
35 } 44 }
36 45
37 Label::Label(const base::string16& text) { 46 Label::Label(const base::string16& text) : Label(text, GetDefaultFontList()) {
38 Init(text, gfx::FontList());
39 } 47 }
40 48
41 Label::Label(const base::string16& text, const gfx::FontList& font_list) { 49 Label::Label(const base::string16& text, const gfx::FontList& font_list) {
42 Init(text, font_list); 50 Init(text, font_list);
43 } 51 }
44 52
45 Label::~Label() { 53 Label::~Label() {
46 } 54 }
47 55
48 void Label::SetFontList(const gfx::FontList& font_list) { 56 void Label::SetFontList(const gfx::FontList& font_list) {
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 585 }
578 586
579 bool Label::ShouldShowDefaultTooltip() const { 587 bool Label::ShouldShowDefaultTooltip() const {
580 const gfx::Size text_size = GetTextSize(); 588 const gfx::Size text_size = GetTextSize();
581 const gfx::Size size = GetContentsBounds().size(); 589 const gfx::Size size = GetContentsBounds().size();
582 return !obscured() && (text_size.width() > size.width() || 590 return !obscured() && (text_size.width() > size.width() ||
583 (multi_line() && text_size.height() > size.height())); 591 (multi_line() && text_size.height() > size.height()));
584 } 592 }
585 593
586 } // namespace views 594 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | ui/views/controls/tabbed_pane/tabbed_pane.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698