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

Side by Side Diff: ui/views/controls/menu/menu_item_view.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix round-down problems 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/menu/menu_item_view.h" 5 #include "ui/views/controls/menu/menu_item_view.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 delegate->GetHorizontalIconMargins(command_, 969 delegate->GetHorizontalIconMargins(command_,
970 icon_area_width_, 970 icon_area_width_,
971 &left_icon_margin_, 971 &left_icon_margin_,
972 &right_icon_margin_); 972 &right_icon_margin_);
973 } else { 973 } else {
974 left_icon_margin_ = 0; 974 left_icon_margin_ = 0;
975 right_icon_margin_ = 0; 975 right_icon_margin_ = 0;
976 } 976 }
977 int label_start = GetLabelStartForThisItem(); 977 int label_start = GetLabelStartForThisItem();
978 978
979 int string_width = font.GetStringWidth(title_); 979 float string_width = font.GetStringWidth(title_);
980 if (!subtitle_.empty()) 980 if (!subtitle_.empty())
981 string_width = std::max(string_width, font.GetStringWidth(subtitle_)); 981 string_width = std::max(string_width, font.GetStringWidth(subtitle_));
982 982
983 dimensions.standard_width = string_width + label_start + 983 dimensions.standard_width = std::ceil(string_width + label_start +
984 item_right_margin_; 984 item_right_margin_);
985 // Determine the length of the right-side text. 985 // Determine the length of the right-side text.
986 string16 minor_text = GetMinorText(); 986 string16 minor_text = GetMinorText();
987 dimensions.minor_text_width = 987 dimensions.minor_text_width =
988 minor_text.empty() ? 0 : GetFont().GetStringWidth(minor_text); 988 minor_text.empty() ? 0 : GetFont().GetStringWidth(minor_text);
989 989
990 // Determine the height to use. 990 // Determine the height to use.
991 dimensions.height = std::max(dimensions.height, 991 dimensions.height = std::max(dimensions.height,
992 (subtitle_.empty() ? 0 : font.GetHeight()) + 992 (subtitle_.empty() ? 0 : font.GetHeight()) +
993 font.GetHeight() + GetBottomMargin() + GetTopMargin()); 993 font.GetHeight() + GetBottomMargin() + GetTopMargin());
994 dimensions.height = std::max(dimensions.height, 994 dimensions.height = std::max(dimensions.height,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 } else { 1061 } else {
1062 const Type& type = menu_item->GetType(); 1062 const Type& type = menu_item->GetType();
1063 if (type == CHECKBOX || type == RADIO) 1063 if (type == CHECKBOX || type == RADIO)
1064 return true; 1064 return true;
1065 } 1065 }
1066 } 1066 }
1067 return false; 1067 return false;
1068 } 1068 }
1069 1069
1070 } // namespace views 1070 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698