| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // A View that displays the text selection handle. | 89 // A View that displays the text selection handle. |
| 90 class TouchSelectionControllerImpl::SelectionHandleView : public View { | 90 class TouchSelectionControllerImpl::SelectionHandleView : public View { |
| 91 public: | 91 public: |
| 92 explicit SelectionHandleView(TouchSelectionControllerImpl* controller) | 92 explicit SelectionHandleView(TouchSelectionControllerImpl* controller) |
| 93 : controller_(controller) { | 93 : controller_(controller) { |
| 94 widget_.reset(CreateTouchSelectionPopupWidget()); | 94 widget_.reset(CreateTouchSelectionPopupWidget()); |
| 95 widget_->SetContentsView(this); | 95 widget_->SetContentsView(this); |
| 96 widget_->SetAlwaysOnTop(true); | 96 widget_->SetAlwaysOnTop(true); |
| 97 | 97 |
| 98 // We are owned by the TouchSelectionController. | 98 // We are owned by the TouchSelectionController. |
| 99 set_parent_owned(false); | 99 set_owned_by_client(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 virtual ~SelectionHandleView() { | 102 virtual ~SelectionHandleView() { |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 105 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
| 106 Circle circle = {kSelectionHandleRadius, gfx::Point(kSelectionHandleRadius, | 106 Circle circle = {kSelectionHandleRadius, gfx::Point(kSelectionHandleRadius, |
| 107 kSelectionHandleRadius + kSelectionHandleCursorHeight), | 107 kSelectionHandleRadius + kSelectionHandleCursorHeight), |
| 108 kSelectionHandleColor}; | 108 kSelectionHandleColor}; |
| 109 PaintCircle(circle, canvas); | 109 PaintCircle(circle, canvas); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 : public ButtonListener, | 200 : public ButtonListener, |
| 201 public View { | 201 public View { |
| 202 public: | 202 public: |
| 203 explicit TouchContextMenuView(TouchSelectionControllerImpl* controller) | 203 explicit TouchContextMenuView(TouchSelectionControllerImpl* controller) |
| 204 : controller_(controller) { | 204 : controller_(controller) { |
| 205 widget_.reset(CreateTouchSelectionPopupWidget()); | 205 widget_.reset(CreateTouchSelectionPopupWidget()); |
| 206 widget_->SetContentsView(this); | 206 widget_->SetContentsView(this); |
| 207 widget_->SetAlwaysOnTop(true); | 207 widget_->SetAlwaysOnTop(true); |
| 208 | 208 |
| 209 // We are owned by the TouchSelectionController. | 209 // We are owned by the TouchSelectionController. |
| 210 set_parent_owned(false); | 210 set_owned_by_client(); |
| 211 SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, kContextMenuPadding, | 211 SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, kContextMenuPadding, |
| 212 kContextMenuPadding, kContextMenuPadding)); | 212 kContextMenuPadding, kContextMenuPadding)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 virtual ~TouchContextMenuView() { | 215 virtual ~TouchContextMenuView() { |
| 216 } | 216 } |
| 217 | 217 |
| 218 virtual void SetVisible(bool visible) OVERRIDE { | 218 virtual void SetVisible(bool visible) OVERRIDE { |
| 219 // We simply show/hide the container widget. | 219 // We simply show/hide the container widget. |
| 220 if (visible != widget_->IsVisible()) { | 220 if (visible != widget_->IsVisible()) { |
| (...skipping 267 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 |