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

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

Issue 613753003: Fix TooltipAura initial sizing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« 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 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
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
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
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