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

Side by Side Diff: ash/tooltips/tooltip_controller.cc

Issue 9310008: aura: Fix a couple of tooltip related bugs: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | « ash/shell/lock_view.cc ('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 (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 "ash/tooltips/tooltip_controller.h" 5 #include "ash/tooltips/tooltip_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // and applies the adjusted bounds to the label_. 184 // and applies the adjusted bounds to the label_.
185 void SetTooltipBounds(gfx::Point mouse_pos, 185 void SetTooltipBounds(gfx::Point mouse_pos,
186 int tooltip_width, 186 int tooltip_width,
187 int tooltip_height) { 187 int tooltip_height) {
188 gfx::Rect tooltip_rect(mouse_pos.x(), mouse_pos.y(), tooltip_width, 188 gfx::Rect tooltip_rect(mouse_pos.x(), mouse_pos.y(), tooltip_width,
189 tooltip_height); 189 tooltip_height);
190 190
191 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY); 191 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY);
192 gfx::Rect monitor_bounds = 192 gfx::Rect monitor_bounds =
193 gfx::Screen::GetMonitorAreaNearestPoint(tooltip_rect.origin()); 193 gfx::Screen::GetMonitorAreaNearestPoint(tooltip_rect.origin());
194
195 // If tooltip is out of bounds on the x axis, we simply shift it
196 // horizontally by the offset.
197 if (tooltip_rect.right() > monitor_bounds.right()) {
198 int h_offset = tooltip_rect.right() - monitor_bounds.right();
199 tooltip_rect.Offset(-h_offset, 0);
200 }
201
202 // If tooltip is out of bounds on the y axis, we flip it to appear above the
203 // mouse cursor instead of below.
204 if (tooltip_rect.bottom() > monitor_bounds.bottom())
205 tooltip_rect.set_y(mouse_pos.y() - tooltip_height);
206
194 widget_->SetBounds(tooltip_rect.AdjustToFit(monitor_bounds)); 207 widget_->SetBounds(tooltip_rect.AdjustToFit(monitor_bounds));
195 } 208 }
196 209
197 }; 210 };
198 211
199 //////////////////////////////////////////////////////////////////////////////// 212 ////////////////////////////////////////////////////////////////////////////////
200 // TooltipController public: 213 // TooltipController public:
201 214
202 TooltipController::TooltipController() 215 TooltipController::TooltipController()
203 : aura::EventFilter(NULL), 216 : aura::EventFilter(NULL),
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 334 }
322 } 335 }
323 } 336 }
324 337
325 bool TooltipController::IsTooltipVisible() { 338 bool TooltipController::IsTooltipVisible() {
326 return tooltip_->IsVisible(); 339 return tooltip_->IsVisible();
327 } 340 }
328 341
329 } // namespace internal 342 } // namespace internal
330 } // namespace ash 343 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell/lock_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698