OLD | NEW |
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if (tooltip_rect.right() > display_bounds.right()) { | 172 if (tooltip_rect.right() > display_bounds.right()) { |
173 int h_offset = tooltip_rect.right() - display_bounds.right(); | 173 int h_offset = tooltip_rect.right() - display_bounds.right(); |
174 tooltip_rect.Offset(-h_offset, 0); | 174 tooltip_rect.Offset(-h_offset, 0); |
175 } | 175 } |
176 | 176 |
177 // If tooltip is out of bounds on the y axis, we flip it to appear above the | 177 // If tooltip is out of bounds on the y axis, we flip it to appear above the |
178 // mouse cursor instead of below. | 178 // mouse cursor instead of below. |
179 if (tooltip_rect.bottom() > display_bounds.bottom()) | 179 if (tooltip_rect.bottom() > display_bounds.bottom()) |
180 tooltip_rect.set_y(mouse_pos.y() - tooltip_height); | 180 tooltip_rect.set_y(mouse_pos.y() - tooltip_height); |
181 | 181 |
182 GetWidget()->SetBounds(tooltip_rect.AdjustToFit(display_bounds)); | 182 tooltip_rect.AdjustToFit(display_bounds); |
| 183 GetWidget()->SetBounds(tooltip_rect); |
183 } | 184 } |
184 | 185 |
185 views::Widget* GetWidget() { | 186 views::Widget* GetWidget() { |
186 if (!widget_) { | 187 if (!widget_) { |
187 widget_ = CreateTooltip(); | 188 widget_ = CreateTooltip(); |
188 widget_->SetContentsView(&label_); | 189 widget_->SetContentsView(&label_); |
189 widget_->AddObserver(this); | 190 widget_->AddObserver(this); |
190 } | 191 } |
191 return widget_; | 192 return widget_; |
192 } | 193 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 471 } |
471 | 472 |
472 TooltipController::Tooltip* TooltipController::GetTooltip() { | 473 TooltipController::Tooltip* TooltipController::GetTooltip() { |
473 if (!tooltip_.get()) | 474 if (!tooltip_.get()) |
474 tooltip_.reset(new Tooltip); | 475 tooltip_.reset(new Tooltip); |
475 return tooltip_.get(); | 476 return tooltip_.get(); |
476 } | 477 } |
477 | 478 |
478 } // namespace internal | 479 } // namespace internal |
479 } // namespace ash | 480 } // namespace ash |
OLD | NEW |