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

Side by Side Diff: ui/views/controls/button/text_button.cc

Issue 14322007: Add line height setting to views::Label & use it for notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/message_center/views/notification_view.cc ('k') | ui/views/controls/label.h » ('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/button/text_button.h" 5 #include "ui/views/controls/button/text_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 } 370 }
371 371
372 void TextButtonBase::CalculateTextSize(gfx::Size* text_size, int max_width) { 372 void TextButtonBase::CalculateTextSize(gfx::Size* text_size, int max_width) {
373 int h = font_.GetHeight(); 373 int h = font_.GetHeight();
374 int w = multi_line_ ? max_width : 0; 374 int w = multi_line_ ? max_width : 0;
375 int flags = ComputeCanvasStringFlags(); 375 int flags = ComputeCanvasStringFlags();
376 if (!multi_line_) 376 if (!multi_line_)
377 flags |= gfx::Canvas::NO_ELLIPSIS; 377 flags |= gfx::Canvas::NO_ELLIPSIS;
378 378
379 gfx::Canvas::SizeStringInt(text_, font_, &w, &h, flags); 379 gfx::Canvas::SizeStringInt(text_, font_, &w, &h, 0, flags);
380 text_size->SetSize(w, h); 380 text_size->SetSize(w, h);
381 } 381 }
382 382
383 int TextButtonBase::ComputeCanvasStringFlags() const { 383 int TextButtonBase::ComputeCanvasStringFlags() const {
384 if (!multi_line_) 384 if (!multi_line_)
385 return 0; 385 return 0;
386 386
387 int flags = gfx::Canvas::MULTI_LINE; 387 int flags = gfx::Canvas::MULTI_LINE;
388 switch (alignment_) { 388 switch (alignment_) {
389 case ALIGN_LEFT: 389 case ALIGN_LEFT:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 draw_string_flags); 491 draw_string_flags);
492 #endif 492 #endif
493 } else { 493 } else {
494 gfx::ShadowValues shadows; 494 gfx::ShadowValues shadows;
495 if (has_text_shadow_) { 495 if (has_text_shadow_) {
496 SkColor color = GetWidget()->IsActive() ? active_text_shadow_color_ : 496 SkColor color = GetWidget()->IsActive() ? active_text_shadow_color_ :
497 inactive_text_shadow_color_; 497 inactive_text_shadow_color_;
498 shadows.push_back(gfx::ShadowValue(text_shadow_offset_, 0, color)); 498 shadows.push_back(gfx::ShadowValue(text_shadow_offset_, 0, color));
499 } 499 }
500 canvas->DrawStringWithShadows(text_, font_, text_color, text_bounds, 500 canvas->DrawStringWithShadows(text_, font_, text_color, text_bounds,
501 draw_string_flags, shadows); 501 0, draw_string_flags, shadows);
502 } 502 }
503 } 503 }
504 } 504 }
505 505
506 //////////////////////////////////////////////////////////////////////////////// 506 ////////////////////////////////////////////////////////////////////////////////
507 // TextButtonBase, View overrides: 507 // TextButtonBase, View overrides:
508 508
509 gfx::Size TextButtonBase::GetMinimumSize() { 509 gfx::Size TextButtonBase::GetMinimumSize() {
510 return max_text_size_; 510 return max_text_size_;
511 } 511 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // when not using NativeThemeWin. 812 // when not using NativeThemeWin.
813 #if defined(OS_WIN) 813 #if defined(OS_WIN)
814 if (GetNativeTheme() == ui::NativeThemeWin::instance()) 814 if (GetNativeTheme() == ui::NativeThemeWin::instance())
815 return; 815 return;
816 #endif 816 #endif
817 params->button.is_focused = HasFocus() && 817 params->button.is_focused = HasFocus() &&
818 (focusable() || IsAccessibilityFocusable()); 818 (focusable() || IsAccessibilityFocusable());
819 } 819 }
820 820
821 } // namespace views 821 } // namespace views
OLDNEW
« no previous file with comments | « ui/message_center/views/notification_view.cc ('k') | ui/views/controls/label.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698