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

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

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 7 years, 2 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
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // again once width() changes. 367 // again once width() changes.
368 if (!multi_line_ || text_width != 0) { 368 if (!multi_line_ || text_width != 0) {
369 max_text_size_.SetSize(std::max(max_text_size_.width(), text_size_.width()), 369 max_text_size_.SetSize(std::max(max_text_size_.width(), text_size_.width()),
370 std::max(max_text_size_.height(), 370 std::max(max_text_size_.height(),
371 text_size_.height())); 371 text_size_.height()));
372 PreferredSizeChanged(); 372 PreferredSizeChanged();
373 } 373 }
374 } 374 }
375 375
376 void TextButtonBase::CalculateTextSize(gfx::Size* text_size, int max_width) { 376 void TextButtonBase::CalculateTextSize(gfx::Size* text_size, int max_width) {
377 int h = font_.GetHeight(); 377 float h = font_.GetHeight();
378 int w = multi_line_ ? max_width : 0; 378 float w = multi_line_ ? max_width : 0;
379 int flags = ComputeCanvasStringFlags(); 379 int flags = ComputeCanvasStringFlags();
380 if (!multi_line_) 380 if (!multi_line_)
381 flags |= gfx::Canvas::NO_ELLIPSIS; 381 flags |= gfx::Canvas::NO_ELLIPSIS;
382 382
383 gfx::Canvas::SizeStringInt(text_, font_, &w, &h, 0, flags); 383 gfx::Canvas::SizeStringInt(text_, font_, &w, &h, 0, flags);
384 text_size->SetSize(w, h); 384 text_size->SetSize(w, h);
385 } 385 }
386 386
387 int TextButtonBase::ComputeCanvasStringFlags() const { 387 int TextButtonBase::ComputeCanvasStringFlags() const {
388 if (!multi_line_) 388 if (!multi_line_)
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 if (show_multiple_icon_states_) { 735 if (show_multiple_icon_states_) {
736 if (has_hover_icon_ && (state() == STATE_HOVERED)) 736 if (has_hover_icon_ && (state() == STATE_HOVERED))
737 return icon_hover_; 737 return icon_hover_;
738 if (has_pushed_icon_ && (state() == STATE_PRESSED)) 738 if (has_pushed_icon_ && (state() == STATE_PRESSED))
739 return icon_pushed_; 739 return icon_pushed_;
740 } 740 }
741 return icon_; 741 return icon_;
742 } 742 }
743 743
744 } // namespace views 744 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698