| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure | 58 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure |
| 59 // out a way to merge. | 59 // out a way to merge. |
| 60 return ui::ResourceBundle::GetSharedInstance().GetFont( | 60 return ui::ResourceBundle::GetSharedInstance().GetFont( |
| 61 ui::ResourceBundle::BaseFont); | 61 ui::ResourceBundle::BaseFont); |
| 62 } | 62 } |
| 63 | 63 |
| 64 int GetMaxWidth(int x, int y) { | 64 int GetMaxWidth(int x, int y) { |
| 65 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure | 65 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure |
| 66 // out a way to merge. | 66 // out a way to merge. |
| 67 gfx::Rect monitor_bounds = | 67 gfx::Rect monitor_bounds = |
| 68 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point(x, y)); | 68 gfx::Screen::GetMonitorNearestPoint(gfx::Point(x, y)).bounds(); |
| 69 return (monitor_bounds.width() + 1) / 2; | 69 return (monitor_bounds.width() + 1) / 2; |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Creates a widget of type TYPE_TOOLTIP | 72 // Creates a widget of type TYPE_TOOLTIP |
| 73 views::Widget* CreateTooltip() { | 73 views::Widget* CreateTooltip() { |
| 74 views::Widget* widget = new views::Widget; | 74 views::Widget* widget = new views::Widget; |
| 75 views::Widget::InitParams params; | 75 views::Widget::InitParams params; |
| 76 // For aura, since we set the type to TOOLTIP_TYPE, the widget will get | 76 // For aura, since we set the type to TOOLTIP_TYPE, the widget will get |
| 77 // auto-parented to the MenuAndTooltipsContainer. | 77 // auto-parented to the MenuAndTooltipsContainer. |
| 78 params.type = views::Widget::InitParams::TYPE_TOOLTIP; | 78 params.type = views::Widget::InitParams::TYPE_TOOLTIP; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Adjusts the bounds given by the arguments to fit inside the desktop | 148 // Adjusts the bounds given by the arguments to fit inside the desktop |
| 149 // and applies the adjusted bounds to the label_. | 149 // and applies the adjusted bounds to the label_. |
| 150 void SetTooltipBounds(gfx::Point mouse_pos, | 150 void SetTooltipBounds(gfx::Point mouse_pos, |
| 151 int tooltip_width, | 151 int tooltip_width, |
| 152 int tooltip_height) { | 152 int tooltip_height) { |
| 153 gfx::Rect tooltip_rect(mouse_pos.x(), mouse_pos.y(), tooltip_width, | 153 gfx::Rect tooltip_rect(mouse_pos.x(), mouse_pos.y(), tooltip_width, |
| 154 tooltip_height); | 154 tooltip_height); |
| 155 | 155 |
| 156 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY); | 156 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY); |
| 157 gfx::Rect monitor_bounds = | 157 gfx::Rect monitor_bounds = |
| 158 gfx::Screen::GetMonitorAreaNearestPoint(tooltip_rect.origin()); | 158 gfx::Screen::GetMonitorNearestPoint(tooltip_rect.origin()).bounds(); |
| 159 | 159 |
| 160 // If tooltip is out of bounds on the x axis, we simply shift it | 160 // If tooltip is out of bounds on the x axis, we simply shift it |
| 161 // horizontally by the offset. | 161 // horizontally by the offset. |
| 162 if (tooltip_rect.right() > monitor_bounds.right()) { | 162 if (tooltip_rect.right() > monitor_bounds.right()) { |
| 163 int h_offset = tooltip_rect.right() - monitor_bounds.right(); | 163 int h_offset = tooltip_rect.right() - monitor_bounds.right(); |
| 164 tooltip_rect.Offset(-h_offset, 0); | 164 tooltip_rect.Offset(-h_offset, 0); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // If tooltip is out of bounds on the y axis, we flip it to appear above the | 167 // If tooltip is out of bounds on the y axis, we flip it to appear above the |
| 168 // mouse cursor instead of below. | 168 // mouse cursor instead of below. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 bool TooltipController::IsDragDropInProgress() { | 420 bool TooltipController::IsDragDropInProgress() { |
| 421 aura::client::DragDropClient* client = aura::client::GetDragDropClient( | 421 aura::client::DragDropClient* client = aura::client::GetDragDropClient( |
| 422 Shell::GetRootWindow()); | 422 Shell::GetRootWindow()); |
| 423 if (client) | 423 if (client) |
| 424 return client->IsDragDropInProgress(); | 424 return client->IsDragDropInProgress(); |
| 425 return false; | 425 return false; |
| 426 } | 426 } |
| 427 | 427 |
| 428 } // namespace internal | 428 } // namespace internal |
| 429 } // namespace ash | 429 } // namespace ash |
| OLD | NEW |