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

Side by Side Diff: ui/views/corewm/tooltip_controller.cc

Issue 15772002: views::Label displaying the tooltip should not elide. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 7 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 | « no previous file | no next file » | 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/corewm/tooltip_controller.h" 5 #include "ui/views/corewm/tooltip_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 : controller_(controller), 91 : controller_(controller),
92 widget_(NULL) { 92 widget_(NULL) {
93 label_.set_background( 93 label_.set_background(
94 views::Background::CreateSolidBackground(kTooltipBackground)); 94 views::Background::CreateSolidBackground(kTooltipBackground));
95 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoDropShadows)) { 95 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoDropShadows)) {
96 label_.set_border( 96 label_.set_border(
97 views::Border::CreateSolidBorder(kTooltipBorderWidth, 97 views::Border::CreateSolidBorder(kTooltipBorderWidth,
98 kTooltipBorder)); 98 kTooltipBorder));
99 } 99 }
100 label_.set_owned_by_client(); 100 label_.set_owned_by_client();
101 label_.SetMultiLine(true);
101 } 102 }
102 103
103 virtual ~Tooltip() { 104 virtual ~Tooltip() {
104 if (widget_) { 105 if (widget_) {
105 widget_->RemoveObserver(this); 106 widget_->RemoveObserver(this);
106 widget_->Close(); 107 widget_->Close();
107 } 108 }
108 } 109 }
109 110
110 // Updates the text on the tooltip and resizes to fit. 111 // Updates the text on the tooltip and resizes to fit.
111 void SetText(aura::Window* window, 112 void SetText(aura::Window* window,
112 const string16& tooltip_text, 113 const string16& tooltip_text,
113 const gfx::Point& location) { 114 const gfx::Point& location) {
114 int max_width, line_count; 115 int max_width, line_count;
115 string16 trimmed_text(tooltip_text); 116 string16 trimmed_text(tooltip_text);
116 controller_->TrimTooltipToFit( 117 controller_->TrimTooltipToFit(
117 controller_->GetMaxWidth(location), &trimmed_text, &max_width, 118 controller_->GetMaxWidth(location), &trimmed_text, &max_width,
118 &line_count); 119 &line_count);
119 label_.SetText(trimmed_text); 120 label_.SetText(trimmed_text);
120 121
121 int width = max_width + 2 * kTooltipHorizontalPadding; 122 int width = max_width + 2 * kTooltipHorizontalPadding;
122 int height = label_.GetPreferredSize().height() + 123 int height = label_.GetHeightForWidth(max_width) +
123 2 * kTooltipVerticalPadding; 124 2 * kTooltipVerticalPadding;
124 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoDropShadows)) { 125 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoDropShadows)) {
125 width += 2 * kTooltipBorderWidth; 126 width += 2 * kTooltipBorderWidth;
126 height += 2 * kTooltipBorderWidth; 127 height += 2 * kTooltipBorderWidth;
127 } 128 }
128 CreateWidgetIfNecessary(window); 129 CreateWidgetIfNecessary(window);
129 SetTooltipBounds(location, width, height); 130 SetTooltipBounds(location, width, height);
130 } 131 }
131 132
132 // Shows the tooltip. 133 // Shows the tooltip.
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 if (!root) 511 if (!root)
511 return false; 512 return false;
512 aura::client::CursorClient* cursor_client = 513 aura::client::CursorClient* cursor_client =
513 aura::client::GetCursorClient(root); 514 aura::client::GetCursorClient(root);
514 // |cursor_client| may be NULL in tests, treat NULL as always visible. 515 // |cursor_client| may be NULL in tests, treat NULL as always visible.
515 return !cursor_client || cursor_client->IsCursorVisible(); 516 return !cursor_client || cursor_client->IsCursorVisible();
516 } 517 }
517 518
518 } // namespace corewm 519 } // namespace corewm
519 } // namespace views 520 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698