OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_aura.h" | 5 #include "ui/views/corewm/tooltip_aura.h" |
6 | 6 |
7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
9 #include "ui/aura/window_tree_host.h" | 9 #include "ui/aura/window_tree_host.h" |
10 #include "ui/gfx/screen.h" | 10 #include "ui/gfx/screen.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 void TooltipAura::SetText(aura::Window* window, | 183 void TooltipAura::SetText(aura::Window* window, |
184 const base::string16& tooltip_text, | 184 const base::string16& tooltip_text, |
185 const gfx::Point& location) { | 185 const gfx::Point& location) { |
186 tooltip_window_ = window; | 186 tooltip_window_ = window; |
187 int max_width = 0; | 187 int max_width = 0; |
188 int line_count = 0; | 188 int line_count = 0; |
189 base::string16 trimmed_text(tooltip_text); | 189 base::string16 trimmed_text(tooltip_text); |
190 TrimTooltipToFit(label_.font_list(), GetMaxWidth(location), &trimmed_text, | 190 TrimTooltipToFit(label_.font_list(), GetMaxWidth(location), &trimmed_text, |
191 &max_width, &line_count); | 191 &max_width, &line_count); |
192 label_.SetText(trimmed_text); | 192 label_.SetText(trimmed_text); |
193 label_.SizeToFit(max_width + label_.GetInsets().width()); | |
194 | 193 |
195 if (!widget_) { | 194 if (!widget_) { |
196 widget_ = CreateTooltipWidget(tooltip_window_); | 195 widget_ = CreateTooltipWidget(tooltip_window_); |
197 widget_->SetContentsView(&label_); | 196 widget_->SetContentsView(&label_); |
198 widget_->AddObserver(this); | 197 widget_->AddObserver(this); |
199 } | 198 } |
200 | 199 |
| 200 label_.SizeToFit(max_width + label_.GetInsets().width()); |
201 SetTooltipBounds(location, label_.size()); | 201 SetTooltipBounds(location, label_.size()); |
202 | 202 |
203 ui::NativeTheme* native_theme = widget_->GetNativeTheme(); | 203 ui::NativeTheme* native_theme = widget_->GetNativeTheme(); |
204 label_.set_background( | 204 label_.set_background( |
205 views::Background::CreateSolidBackground( | 205 views::Background::CreateSolidBackground( |
206 native_theme->GetSystemColor( | 206 native_theme->GetSystemColor( |
207 ui::NativeTheme::kColorId_TooltipBackground))); | 207 ui::NativeTheme::kColorId_TooltipBackground))); |
208 | 208 |
209 label_.SetAutoColorReadabilityEnabled(false); | 209 label_.SetAutoColorReadabilityEnabled(false); |
210 label_.SetEnabledColor(native_theme->GetSystemColor( | 210 label_.SetEnabledColor(native_theme->GetSystemColor( |
(...skipping 18 matching lines...) Expand all Loading... |
229 } | 229 } |
230 | 230 |
231 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { | 231 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { |
232 DCHECK_EQ(widget_, widget); | 232 DCHECK_EQ(widget_, widget); |
233 widget_ = NULL; | 233 widget_ = NULL; |
234 tooltip_window_ = NULL; | 234 tooltip_window_ = NULL; |
235 } | 235 } |
236 | 236 |
237 } // namespace corewm | 237 } // namespace corewm |
238 } // namespace views | 238 } // namespace views |
OLD | NEW |