summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 04:01:55 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 04:01:55 +0000
commitce1e04c7c514e6c96faa1f30058cefba1511a355 (patch)
tree8f14deaef71a45ad2426c3087d4691d80c963727
parent6acf3dd58505c17b35699b1ec53fbb891a292fc9 (diff)
downloadchromium_src-ce1e04c7c514e6c96faa1f30058cefba1511a355.zip
chromium_src-ce1e04c7c514e6c96faa1f30058cefba1511a355.tar.gz
chromium_src-ce1e04c7c514e6c96faa1f30058cefba1511a355.tar.bz2
Wrapping text to multi-line for the launcher tooltip.
BUG=133620 TEST=manually checked with crbug.com Review URL: https://chromiumcodereview.appspot.com/10612004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143527 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/launcher/launcher_tooltip_manager.cc26
1 files changed, 20 insertions, 6 deletions
diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc
index 4057acd..a9b533c 100644
--- a/ash/launcher/launcher_tooltip_manager.cc
+++ b/ash/launcher/launcher_tooltip_manager.cc
@@ -21,6 +21,10 @@ namespace {
const int kTooltipMargin = 3;
const int kTooltipAppearanceDelay = 200; // msec
+// The maximum width of the tooltip bubble. Borrowed the value from
+// ash/tooltip/tooltip_controller.cc
+const int kTooltipMaxWidth = 400;
+
views::BubbleBorder::ArrowLocation GetArrowLocation(ShelfAlignment alignment) {
switch (alignment) {
case SHELF_ALIGNMENT_LEFT:
@@ -40,10 +44,11 @@ class LauncherTooltipManager::LauncherTooltipBubble
: public views::BubbleDelegateView {
public:
LauncherTooltipBubble(views::View* anchor,
- const string16& text,
views::BubbleBorder::ArrowLocation arrow_location,
LauncherTooltipManager* host);
+ void SetText(const string16& text);
+
private:
// views::View overrides:
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
@@ -52,11 +57,11 @@ class LauncherTooltipManager::LauncherTooltipBubble
virtual void WindowClosing() OVERRIDE;
LauncherTooltipManager* host_;
+ views::Label* label_;
};
LauncherTooltipManager::LauncherTooltipBubble::LauncherTooltipBubble(
views::View* anchor,
- const string16& text,
views::BubbleBorder::ArrowLocation arrow_location,
LauncherTooltipManager* host)
: views::BubbleDelegateView(anchor, arrow_location),
@@ -73,9 +78,17 @@ LauncherTooltipManager::LauncherTooltipBubble::LauncherTooltipBubble(
set_parent_window(ash::Shell::GetInstance()->GetContainer(
root_window, ash::internal::kShellWindowId_SettingBubbleContainer));
}
- views::Label* label = new views::Label(text);
- label->SetHorizontalAlignment(views::Label::ALIGN_CENTER);
- AddChildView(label);
+ label_ = new views::Label;
+ label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ AddChildView(label_);
+}
+
+void LauncherTooltipManager::LauncherTooltipBubble::SetText(
+ const string16& text) {
+ label_->SetText(text);
+ label_->SetMultiLine(true);
+ label_->SizeToFit(kTooltipMaxWidth);
+ SizeToContents();
}
void LauncherTooltipManager::LauncherTooltipBubble::OnMouseExited(
@@ -191,8 +204,9 @@ void LauncherTooltipManager::CreateBubble(views::View* anchor,
anchor_ = anchor;
text_ = text;
view_ = new LauncherTooltipBubble(
- anchor, text, GetArrowLocation(alignment_), this);
+ anchor, GetArrowLocation(alignment_), this);
views::BubbleDelegateView::CreateBubble(view_);
+ view_->SetText(text_);
}
} // namespace internal