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 "ui/views/touchui/touch_selection_controller_impl.h" | 5 #include "ui/views/touchui/touch_selection_controller_impl.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "grit/ui_strings.h" | 9 #include "grit/ui_strings.h" |
10 #include "third_party/skia/include/effects/SkGradientShader.h" | 10 #include "third_party/skia/include/effects/SkGradientShader.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 | 148 |
149 void SetScreenPosition(const gfx::Point& position) { | 149 void SetScreenPosition(const gfx::Point& position) { |
150 gfx::Rect widget_bounds(position.x() - kSelectionHandleRadius, position.y(), | 150 gfx::Rect widget_bounds(position.x() - kSelectionHandleRadius, position.y(), |
151 2 * kSelectionHandleRadius, | 151 2 * kSelectionHandleRadius, |
152 2 * kSelectionHandleRadius + kSelectionHandleCursorHeight); | 152 2 * kSelectionHandleRadius + kSelectionHandleCursorHeight); |
153 widget_->SetBounds(widget_bounds); | 153 widget_->SetBounds(widget_bounds); |
154 } | 154 } |
155 | 155 |
156 gfx::Point GetScreenPosition() { | 156 gfx::Point GetScreenPosition() { |
157 return widget_->GetClientAreaScreenBounds().origin(); | 157 return widget_->GetClientAreaBoundsInScreen().origin(); |
158 } | 158 } |
159 | 159 |
160 private: | 160 private: |
161 scoped_ptr<Widget> widget_; | 161 scoped_ptr<Widget> widget_; |
162 TouchSelectionControllerImpl* controller_; | 162 TouchSelectionControllerImpl* controller_; |
163 | 163 |
164 DISALLOW_COPY_AND_ASSIGN(SelectionHandleView); | 164 DISALLOW_COPY_AND_ASSIGN(SelectionHandleView); |
165 }; | 165 }; |
166 | 166 |
167 class ContextMenuButtonBackground : public Background { | 167 class ContextMenuButtonBackground : public Background { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 widget_->Hide(); | 224 widget_->Hide(); |
225 } | 225 } |
226 View::SetVisible(visible); | 226 View::SetVisible(visible); |
227 } | 227 } |
228 | 228 |
229 void SetScreenPosition(const gfx::Point& position) { | 229 void SetScreenPosition(const gfx::Point& position) { |
230 RefreshButtonsAndSetWidgetPosition(position); | 230 RefreshButtonsAndSetWidgetPosition(position); |
231 } | 231 } |
232 | 232 |
233 gfx::Point GetScreenPosition() { | 233 gfx::Point GetScreenPosition() { |
234 return widget_->GetClientAreaScreenBounds().origin(); | 234 return widget_->GetClientAreaBoundsInScreen().origin(); |
235 } | 235 } |
236 | 236 |
237 void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE { | 237 void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE { |
238 // TODO(varunjain): the following color scheme is copied from | 238 // TODO(varunjain): the following color scheme is copied from |
239 // menu_scroll_view_container.cc. Figure out how to consolidate the two | 239 // menu_scroll_view_container.cc. Figure out how to consolidate the two |
240 // pieces of code. | 240 // pieces of code. |
241 #if defined(OS_CHROMEOS) | 241 #if defined(OS_CHROMEOS) |
242 static const SkColor kGradientColors[2] = { | 242 static const SkColor kGradientColors[2] = { |
243 SK_ColorWHITE, | 243 SK_ColorWHITE, |
244 SkColorSetRGB(0xF0, 0xF0, 0xF0) | 244 SkColorSetRGB(0xF0, 0xF0, 0xF0) |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 // Instruct client_view to select the region between p1 and p2. The position | 406 // Instruct client_view to select the region between p1 and p2. The position |
407 // of |fixed_handle| is the start and that of |dragging_handle| is the end | 407 // of |fixed_handle| is the start and that of |dragging_handle| is the end |
408 // of selection. | 408 // of selection. |
409 client_view_->SelectRect(p2, p1); | 409 client_view_->SelectRect(p2, p1); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 void TouchSelectionControllerImpl::ConvertPointToClientView( | 413 void TouchSelectionControllerImpl::ConvertPointToClientView( |
414 SelectionHandleView* source, gfx::Point* point) { | 414 SelectionHandleView* source, gfx::Point* point) { |
415 View::ConvertPointToScreen(source, point); | 415 View::ConvertPointToScreen(source, point); |
416 gfx::Rect r = client_view_->GetWidget()->GetClientAreaScreenBounds(); | 416 gfx::Rect r = client_view_->GetWidget()->GetClientAreaBoundsInScreen(); |
417 point->SetPoint(point->x() - r.x(), point->y() - r.y()); | 417 point->SetPoint(point->x() - r.x(), point->y() - r.y()); |
418 View::ConvertPointFromWidget(client_view_, point); | 418 View::ConvertPointFromWidget(client_view_, point); |
419 } | 419 } |
420 | 420 |
421 bool TouchSelectionControllerImpl::IsCommandIdEnabled(int command_id) const { | 421 bool TouchSelectionControllerImpl::IsCommandIdEnabled(int command_id) const { |
422 return client_view_->IsCommandIdEnabled(command_id); | 422 return client_view_->IsCommandIdEnabled(command_id); |
423 } | 423 } |
424 | 424 |
425 void TouchSelectionControllerImpl::ExecuteCommand(int command_id) { | 425 void TouchSelectionControllerImpl::ExecuteCommand(int command_id) { |
426 HideContextMenu(); | 426 HideContextMenu(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { | 488 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { |
489 return selection_handle_2_->visible(); | 489 return selection_handle_2_->visible(); |
490 } | 490 } |
491 | 491 |
492 TouchSelectionController* TouchSelectionController::create( | 492 TouchSelectionController* TouchSelectionController::create( |
493 TouchSelectionClientView* client_view) { | 493 TouchSelectionClientView* client_view) { |
494 return new TouchSelectionControllerImpl(client_view); | 494 return new TouchSelectionControllerImpl(client_view); |
495 } | 495 } |
496 | 496 |
497 } // namespace views | 497 } // namespace views |
OLD | NEW |