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

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

Issue 263533003: Revert of Linux Aura: get tooltip background color from theme (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « ui/native_theme/native_theme.h ('k') | 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/aura/window_tree_host.h" 10 #include "ui/aura/window_tree_host.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/screen.h" 12 #include "ui/gfx/screen.h"
13 #include "ui/gfx/text_elider.h" 13 #include "ui/gfx/text_elider.h"
14 #include "ui/gfx/text_utils.h" 14 #include "ui/gfx/text_utils.h"
15 #include "ui/native_theme/native_theme.h"
16 #include "ui/views/background.h" 15 #include "ui/views/background.h"
17 #include "ui/views/border.h" 16 #include "ui/views/border.h"
18 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
19 18
20 namespace { 19 namespace {
21 20
21 const SkColor kTooltipBackground = 0xFFFFFFCC;
22 const int kTooltipHorizontalPadding = 3; 22 const int kTooltipHorizontalPadding = 3;
23 23
24 // Max visual tooltip width. If a tooltip is greater than this width, it will 24 // Max visual tooltip width. If a tooltip is greater than this width, it will
25 // be wrapped. 25 // be wrapped.
26 const int kTooltipMaxWidthPixels = 400; 26 const int kTooltipMaxWidthPixels = 400;
27 27
28 const size_t kMaxLines = 10; 28 const size_t kMaxLines = 10;
29 29
30 // TODO(derat): This padding is needed on Chrome OS devices but seems excessive 30 // TODO(derat): This padding is needed on Chrome OS devices but seems excessive
31 // when running the same binary on a Linux workstation; presumably there's a 31 // when running the same binary on a Linux workstation; presumably there's a
(...skipping 21 matching lines...) Expand all
53 53
54 } // namespace 54 } // namespace
55 55
56 namespace views { 56 namespace views {
57 namespace corewm { 57 namespace corewm {
58 58
59 TooltipAura::TooltipAura(gfx::ScreenType screen_type) 59 TooltipAura::TooltipAura(gfx::ScreenType screen_type)
60 : screen_type_(screen_type), 60 : screen_type_(screen_type),
61 widget_(NULL), 61 widget_(NULL),
62 tooltip_window_(NULL) { 62 tooltip_window_(NULL) {
63 label_.set_background(
64 views::Background::CreateSolidBackground(kTooltipBackground));
63 label_.set_owned_by_client(); 65 label_.set_owned_by_client();
64 label_.SetMultiLine(true); 66 label_.SetMultiLine(true);
65 } 67 }
66 68
67 TooltipAura::~TooltipAura() { 69 TooltipAura::~TooltipAura() {
68 DestroyWidget(); 70 DestroyWidget();
69 } 71 }
70 72
71 // static 73 // static
72 void TooltipAura::TrimTooltipToFit(const gfx::FontList& font_list, 74 void TooltipAura::TrimTooltipToFit(const gfx::FontList& font_list,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 base::string16 trimmed_text(tooltip_text); 227 base::string16 trimmed_text(tooltip_text);
226 TrimTooltipToFit(label_.font_list(), GetMaxWidth(location), &trimmed_text, 228 TrimTooltipToFit(label_.font_list(), GetMaxWidth(location), &trimmed_text,
227 &max_width, &line_count); 229 &max_width, &line_count);
228 label_.SetText(trimmed_text); 230 label_.SetText(trimmed_text);
229 231
230 int width = max_width + 2 * kTooltipHorizontalPadding; 232 int width = max_width + 2 * kTooltipHorizontalPadding;
231 int height = label_.GetHeightForWidth(max_width) + 233 int height = label_.GetHeightForWidth(max_width) +
232 2 * kTooltipVerticalPadding; 234 2 * kTooltipVerticalPadding;
233 CreateWidget(); 235 CreateWidget();
234 SetTooltipBounds(location, width, height); 236 SetTooltipBounds(location, width, height);
235
236 label_.set_background(
237 views::Background::CreateSolidBackground(
238 widget_->GetNativeTheme()->GetSystemColor(
239 ui::NativeTheme::kColorId_TooltipBackground)));
240 } 237 }
241 238
242 void TooltipAura::Show() { 239 void TooltipAura::Show() {
243 if (widget_) 240 if (widget_)
244 widget_->Show(); 241 widget_->Show();
245 } 242 }
246 243
247 void TooltipAura::Hide() { 244 void TooltipAura::Hide() {
248 tooltip_window_ = NULL; 245 tooltip_window_ = NULL;
249 if (widget_) 246 if (widget_)
250 widget_->Hide(); 247 widget_->Hide();
251 } 248 }
252 249
253 bool TooltipAura::IsVisible() { 250 bool TooltipAura::IsVisible() {
254 return widget_ && widget_->IsVisible(); 251 return widget_ && widget_->IsVisible();
255 } 252 }
256 253
257 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { 254 void TooltipAura::OnWidgetDestroying(views::Widget* widget) {
258 DCHECK_EQ(widget_, widget); 255 DCHECK_EQ(widget_, widget);
259 widget_ = NULL; 256 widget_ = NULL;
260 tooltip_window_ = NULL; 257 tooltip_window_ = NULL;
261 } 258 }
262 259
263 } // namespace corewm 260 } // namespace corewm
264 } // namespace views 261 } // namespace views
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698