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

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

Issue 10675011: Rename the remaining usage of Monitor to Display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 5 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/test/ash_test_base.cc ('k') | ash/wm/base_layout_manager.h » ('j') | 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 gfx::Font GetDefaultFont() { 59 gfx::Font GetDefaultFont() {
60 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure 60 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure
61 // out a way to merge. 61 // out a way to merge.
62 return ui::ResourceBundle::GetSharedInstance().GetFont( 62 return ui::ResourceBundle::GetSharedInstance().GetFont(
63 ui::ResourceBundle::BaseFont); 63 ui::ResourceBundle::BaseFont);
64 } 64 }
65 65
66 int GetMaxWidth(int x, int y) { 66 int GetMaxWidth(int x, int y) {
67 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure 67 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure
68 // out a way to merge. 68 // out a way to merge.
69 gfx::Rect monitor_bounds = 69 gfx::Rect display_bounds =
70 gfx::Screen::GetDisplayNearestPoint(gfx::Point(x, y)).bounds(); 70 gfx::Screen::GetDisplayNearestPoint(gfx::Point(x, y)).bounds();
71 return (monitor_bounds.width() + 1) / 2; 71 return (display_bounds.width() + 1) / 2;
72 } 72 }
73 73
74 // Creates a widget of type TYPE_TOOLTIP 74 // Creates a widget of type TYPE_TOOLTIP
75 views::Widget* CreateTooltip() { 75 views::Widget* CreateTooltip() {
76 views::Widget* widget = new views::Widget; 76 views::Widget* widget = new views::Widget;
77 views::Widget::InitParams params; 77 views::Widget::InitParams params;
78 // For aura, since we set the type to TOOLTIP_TYPE, the widget will get 78 // For aura, since we set the type to TOOLTIP_TYPE, the widget will get
79 // auto-parented to the MenuAndTooltipsContainer. 79 // auto-parented to the MenuAndTooltipsContainer.
80 params.type = views::Widget::InitParams::TYPE_TOOLTIP; 80 params.type = views::Widget::InitParams::TYPE_TOOLTIP;
81 params.keep_on_top = true; 81 params.keep_on_top = true;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // Adjusts the bounds given by the arguments to fit inside the desktop 149 // Adjusts the bounds given by the arguments to fit inside the desktop
150 // and applies the adjusted bounds to the label_. 150 // and applies the adjusted bounds to the label_.
151 void SetTooltipBounds(gfx::Point mouse_pos, 151 void SetTooltipBounds(gfx::Point mouse_pos,
152 int tooltip_width, 152 int tooltip_width,
153 int tooltip_height) { 153 int tooltip_height) {
154 gfx::Rect tooltip_rect(mouse_pos.x(), mouse_pos.y(), tooltip_width, 154 gfx::Rect tooltip_rect(mouse_pos.x(), mouse_pos.y(), tooltip_width,
155 tooltip_height); 155 tooltip_height);
156 156
157 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY); 157 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY);
158 gfx::Rect monitor_bounds = 158 gfx::Rect display_bounds =
159 gfx::Screen::GetDisplayNearestPoint(tooltip_rect.origin()).bounds(); 159 gfx::Screen::GetDisplayNearestPoint(tooltip_rect.origin()).bounds();
160 160
161 // If tooltip is out of bounds on the x axis, we simply shift it 161 // If tooltip is out of bounds on the x axis, we simply shift it
162 // horizontally by the offset. 162 // horizontally by the offset.
163 if (tooltip_rect.right() > monitor_bounds.right()) { 163 if (tooltip_rect.right() > display_bounds.right()) {
164 int h_offset = tooltip_rect.right() - monitor_bounds.right(); 164 int h_offset = tooltip_rect.right() - display_bounds.right();
165 tooltip_rect.Offset(-h_offset, 0); 165 tooltip_rect.Offset(-h_offset, 0);
166 } 166 }
167 167
168 // If tooltip is out of bounds on the y axis, we flip it to appear above the 168 // If tooltip is out of bounds on the y axis, we flip it to appear above the
169 // mouse cursor instead of below. 169 // mouse cursor instead of below.
170 if (tooltip_rect.bottom() > monitor_bounds.bottom()) 170 if (tooltip_rect.bottom() > display_bounds.bottom())
171 tooltip_rect.set_y(mouse_pos.y() - tooltip_height); 171 tooltip_rect.set_y(mouse_pos.y() - tooltip_height);
172 172
173 widget_->SetBounds(tooltip_rect.AdjustToFit(monitor_bounds)); 173 widget_->SetBounds(tooltip_rect.AdjustToFit(display_bounds));
174 } 174 }
175 175
176 }; 176 };
177 177
178 //////////////////////////////////////////////////////////////////////////////// 178 ////////////////////////////////////////////////////////////////////////////////
179 // TooltipController public: 179 // TooltipController public:
180 180
181 TooltipController::TooltipController( 181 TooltipController::TooltipController(
182 aura::client::DragDropClient* drag_drop_client) 182 aura::client::DragDropClient* drag_drop_client)
183 : drag_drop_client_(drag_drop_client), 183 : drag_drop_client_(drag_drop_client),
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 bool TooltipController::IsTooltipVisible() { 419 bool TooltipController::IsTooltipVisible() {
420 return tooltip_->IsVisible(); 420 return tooltip_->IsVisible();
421 } 421 }
422 422
423 bool TooltipController::IsDragDropInProgress() { 423 bool TooltipController::IsDragDropInProgress() {
424 return drag_drop_client_->IsDragDropInProgress(); 424 return drag_drop_client_->IsDragDropInProgress();
425 } 425 }
426 426
427 } // namespace internal 427 } // namespace internal
428 } // namespace ash 428 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/ash_test_base.cc ('k') | ash/wm/base_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698