summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/views/controls/button/label_button.cc15
-rw-r--r--ui/views/controls/label.cc1
2 files changed, 6 insertions, 10 deletions
diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
index 75e6c4f..a408240 100644
--- a/ui/views/controls/button/label_button.cc
+++ b/ui/views/controls/button/label_button.cc
@@ -45,7 +45,6 @@ LabelButton::LabelButton(ButtonListener* listener, const string16& text)
AddChildView(label_);
label_->SetAutoColorReadabilityEnabled(false);
label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- label_->SetElideBehavior(Label::ELIDE_AT_END);
// Initialize the colors, border, and layout for a Views-themed button.
SetNativeTheme(false);
@@ -143,9 +142,6 @@ void LabelButton::StateChanged() {
gfx::Size LabelButton::GetPreferredSize() {
gfx::Size size(label_->GetPreferredSize());
- // TODO(msw): Multi-line labels are cut off at their preferred bounds.
- // This apparent bug in CanvasSkia requires investigation.
- size.set_width(size.width() * (GetTextMultiLine() ? 2 : 1));
const gfx::Size image_size(image_->GetPreferredSize());
if (image_size.width() > 0 && size.width() > 0)
size.Enlarge(kSpacing, 0);
@@ -173,16 +169,15 @@ void LabelButton::Layout() {
image_size.set_width(std::min(image_size.width(), child_area.width()));
image_size.set_height(std::min(image_size.height(), child_area.height()));
- // The label takes any remaining width after sizing the image.
+ // The label takes any remaining width after sizing the image, unless both
+ // views are centered. In that case, using the tighter preferred label width
+ // avoids wasted space within the label that would look like awkward padding.
gfx::Size label_size(child_area.size());
if (!image_size.IsEmpty() && !label_size.IsEmpty()) {
label_size.set_width(child_area.width() - image_size.width() - kSpacing);
if (GetHorizontalAlignment() == Label::ALIGN_CENTER) {
- gfx::Size preferred(label_->GetPreferredSize());
- // TODO(msw): Multi-line labels are cut off at their preferred bounds.
- // This apparent bug in CanvasSkia requires investigation.
- preferred.set_width(preferred.width() * (GetTextMultiLine() ? 2 : 1));
- label_size.set_width(std::min(label_size.width(), preferred.width()));
+ label_size.set_width(std::min(label_size.width(),
+ label_->GetPreferredSize().width()));
}
}
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index a9a9abe..f4af0a2 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -480,6 +480,7 @@ void Label::CalculateDrawStringParams(string16* paint_text,
int* flags) const {
DCHECK(paint_text && text_bounds && flags);
+ // TODO(msw): Use ElideRectangleText to support eliding multi-line text.
if (is_email_) {
*paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width());
} else if (elide_behavior_ == ELIDE_IN_MIDDLE) {