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

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

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/tabbed_pane/tabbed_pane.h" 5 #include "ui/views/controls/tabbed_pane/tabbed_pane.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "third_party/skia/include/core/SkPaint.h" 9 #include "third_party/skia/include/core/SkPaint.h"
10 #include "third_party/skia/include/core/SkPath.h" 10 #include "third_party/skia/include/core/SkPath.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace { 22 namespace {
23 23
24 // TODO(markusheintz|msw): Use NativeTheme colors. 24 // TODO(markusheintz|msw): Use NativeTheme colors.
25 const SkColor kTabTitleColor_Inactive = SkColorSetRGB(0x64, 0x64, 0x64); 25 const SkColor kTabTitleColor_Inactive = SkColorSetRGB(0x64, 0x64, 0x64);
26 const SkColor kTabTitleColor_Active = SK_ColorBLACK; 26 const SkColor kTabTitleColor_Active = SK_ColorBLACK;
27 const SkColor kTabTitleColor_Hovered = SK_ColorBLACK; 27 const SkColor kTabTitleColor_Hovered = SK_ColorBLACK;
28 const SkColor kTabBorderColor = SkColorSetRGB(0xC8, 0xC8, 0xC8); 28 const SkColor kTabBorderColor = SkColorSetRGB(0xC8, 0xC8, 0xC8);
29 const SkScalar kTabBorderThickness = 1.0f; 29 const SkScalar kTabBorderThickness = 1.0f;
30 30
31 const gfx::Font::FontStyle kHoverStyle = gfx::Font::NORMAL; 31 const gfx::Font::FontWeight kHoverWeight = gfx::Font::WEIGHT_NORMAL;
32 const gfx::Font::FontStyle kActiveStyle = gfx::Font::BOLD; 32 const gfx::Font::FontWeight kActiveWeight = gfx::Font::WEIGHT_BOLD;
33 const gfx::Font::FontStyle kInactiveStyle = gfx::Font::NORMAL; 33 const gfx::Font::FontWeight kInactiveWeight = gfx::Font::WEIGHT_NORMAL;
34 34
35 } // namespace 35 } // namespace
36 36
37 namespace views { 37 namespace views {
38 38
39 // static 39 // static
40 const char TabbedPane::kViewClassName[] = "TabbedPane"; 40 const char TabbedPane::kViewClassName[] = "TabbedPane";
41 41
42 // The tab view shown in the tab strip. 42 // The tab view shown in the tab strip.
43 class Tab : public View { 43 class Tab : public View {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 // static 105 // static
106 const char Tab::kViewClassName[] = "Tab"; 106 const char Tab::kViewClassName[] = "Tab";
107 107
108 Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents) 108 Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents)
109 : tabbed_pane_(tabbed_pane), 109 : tabbed_pane_(tabbed_pane),
110 title_(new Label( 110 title_(new Label(
111 title, 111 title,
112 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( 112 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
113 ui::kLabelFontSizeDelta, 113 ui::kLabelFontSizeDelta,
114 kActiveStyle))), 114 gfx::Font::NORMAL,
115 kInactiveWeight))),
msw 2016/03/22 01:53:44 Shouldn't this be kActiveWeight to match the old b
Mikus 2016/03/22 14:19:52 Done.
115 tab_state_(TAB_ACTIVE), 116 tab_state_(TAB_ACTIVE),
116 contents_(contents) { 117 contents_(contents) {
117 // Calculate this now while the font list is guaranteed to be bold. 118 // Calculate this now while the font list is guaranteed to be bold.
118 preferred_title_size_ = title_->GetPreferredSize(); 119 preferred_title_size_ = title_->GetPreferredSize();
119 120
120 SetState(TAB_INACTIVE); 121 SetState(TAB_INACTIVE);
121 AddChildView(title_); 122 AddChildView(title_);
122 } 123 }
123 124
124 Tab::~Tab() {} 125 Tab::~Tab() {}
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 183
183 void Tab::SetState(TabState tab_state) { 184 void Tab::SetState(TabState tab_state) {
184 if (tab_state == tab_state_) 185 if (tab_state == tab_state_)
185 return; 186 return;
186 tab_state_ = tab_state; 187 tab_state_ = tab_state;
187 188
188 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 189 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
189 switch (tab_state) { 190 switch (tab_state) {
190 case TAB_INACTIVE: 191 case TAB_INACTIVE:
191 title_->SetEnabledColor(kTabTitleColor_Inactive); 192 title_->SetEnabledColor(kTabTitleColor_Inactive);
192 title_->SetFontList( 193 title_->SetFontList(rb.GetFontListWithDelta(
193 rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, kInactiveStyle)); 194 ui::kLabelFontSizeDelta, gfx::Font::NORMAL, kInactiveWeight));
194 break; 195 break;
195 case TAB_ACTIVE: 196 case TAB_ACTIVE:
196 title_->SetEnabledColor(kTabTitleColor_Active); 197 title_->SetEnabledColor(kTabTitleColor_Active);
197 title_->SetFontList( 198 title_->SetFontList(rb.GetFontListWithDelta(
198 rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, kActiveStyle)); 199 ui::kLabelFontSizeDelta, gfx::Font::NORMAL, kActiveWeight));
199 break; 200 break;
200 case TAB_HOVERED: 201 case TAB_HOVERED:
201 title_->SetEnabledColor(kTabTitleColor_Hovered); 202 title_->SetEnabledColor(kTabTitleColor_Hovered);
202 title_->SetFontList( 203 title_->SetFontList(rb.GetFontListWithDelta(
203 rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, kHoverStyle)); 204 ui::kLabelFontSizeDelta, gfx::Font::NORMAL, kHoverWeight));
204 break; 205 break;
205 } 206 }
206 SchedulePaint(); 207 SchedulePaint();
207 } 208 }
208 209
209 // static 210 // static
210 const char TabStrip::kViewClassName[] = "TabStrip"; 211 const char TabStrip::kViewClassName[] = "TabStrip";
211 212
212 TabStrip::TabStrip(TabbedPane* tabbed_pane) : tabbed_pane_(tabbed_pane) {} 213 TabStrip::TabStrip(TabbedPane* tabbed_pane) : tabbed_pane_(tabbed_pane) {}
213 214
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 selected_tab->NotifyAccessibilityEvent( 402 selected_tab->NotifyAccessibilityEvent(
402 ui::AX_EVENT_FOCUS, true); 403 ui::AX_EVENT_FOCUS, true);
403 } 404 }
404 } 405 }
405 406
406 void TabbedPane::GetAccessibleState(ui::AXViewState* state) { 407 void TabbedPane::GetAccessibleState(ui::AXViewState* state) {
407 state->role = ui::AX_ROLE_TAB_LIST; 408 state->role = ui::AX_ROLE_TAB_LIST;
408 } 409 }
409 410
410 } // namespace views 411 } // namespace views
OLDNEW
« ui/views/controls/button/label_button.cc ('K') | « ui/views/controls/styled_label_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698