| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/time.h" | 7 #include "base/time/time.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "grit/ui_strings.h" | 9 #include "grit/ui_strings.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 const int kSelectionHandleBarMinHeight = 5; | 65 const int kSelectionHandleBarMinHeight = 5; |
| 66 // Maximum amount that selection handle bar can stick out of client view's | 66 // Maximum amount that selection handle bar can stick out of client view's |
| 67 // boundaries. | 67 // boundaries. |
| 68 const int kSelectionHandleBarBottomAllowance = 3; | 68 const int kSelectionHandleBarBottomAllowance = 3; |
| 69 | 69 |
| 70 // Creates a widget to host SelectionHandleView. | 70 // Creates a widget to host SelectionHandleView. |
| 71 views::Widget* CreateTouchSelectionPopupWidget( | 71 views::Widget* CreateTouchSelectionPopupWidget( |
| 72 gfx::NativeView context, | 72 gfx::NativeView context, |
| 73 views::WidgetDelegate* widget_delegate) { | 73 views::WidgetDelegate* widget_delegate) { |
| 74 views::Widget* widget = new views::Widget; | 74 views::Widget* widget = new views::Widget; |
| 75 views::Widget::InitParams params(views::Widget::InitParams::TYPE_TOOLTIP); | 75 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 76 params.can_activate = false; | 76 params.can_activate = false; |
| 77 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 77 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 78 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 78 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 79 params.context = context; | 79 params.parent = context; |
| 80 params.delegate = widget_delegate; | 80 params.delegate = widget_delegate; |
| 81 widget->Init(params); | 81 widget->Init(params); |
| 82 SetShadowType(widget->GetNativeView(), wm::SHADOW_TYPE_NONE); | 82 SetShadowType(widget->GetNativeView(), wm::SHADOW_TYPE_NONE); |
| 83 return widget; | 83 return widget; |
| 84 } | 84 } |
| 85 | 85 |
| 86 gfx::Image* GetHandleImage() { | 86 gfx::Image* GetHandleImage() { |
| 87 static gfx::Image* handle_image = NULL; | 87 static gfx::Image* handle_image = NULL; |
| 88 if (!handle_image) { | 88 if (!handle_image) { |
| 89 handle_image = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 89 handle_image = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 class TouchSelectionControllerImpl::EditingHandleView | 149 class TouchSelectionControllerImpl::EditingHandleView |
| 150 : public views::WidgetDelegateView { | 150 : public views::WidgetDelegateView { |
| 151 public: | 151 public: |
| 152 EditingHandleView(TouchSelectionControllerImpl* controller, | 152 EditingHandleView(TouchSelectionControllerImpl* controller, |
| 153 gfx::NativeView context) | 153 gfx::NativeView context) |
| 154 : controller_(controller), | 154 : controller_(controller), |
| 155 drag_offset_(0), | 155 drag_offset_(0), |
| 156 draw_invisible_(false) { | 156 draw_invisible_(false) { |
| 157 widget_.reset(CreateTouchSelectionPopupWidget(context, this)); | 157 widget_.reset(CreateTouchSelectionPopupWidget(context, this)); |
| 158 widget_->SetContentsView(this); | 158 widget_->SetContentsView(this); |
| 159 widget_->SetAlwaysOnTop(true); | |
| 160 | 159 |
| 161 aura::Window* window = widget_->GetNativeWindow(); | 160 aura::Window* window = widget_->GetNativeWindow(); |
| 162 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( | 161 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( |
| 163 new TouchHandleWindowTargeter(window, this))); | 162 new TouchHandleWindowTargeter(window, this))); |
| 164 | 163 |
| 165 // We are owned by the TouchSelectionController. | 164 // We are owned by the TouchSelectionController. |
| 166 set_owned_by_client(); | 165 set_owned_by_client(); |
| 167 } | 166 } |
| 168 | 167 |
| 169 virtual ~EditingHandleView() { | 168 virtual ~EditingHandleView() { |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 StartContextMenuTimer(); | 574 StartContextMenuTimer(); |
| 576 } | 575 } |
| 577 | 576 |
| 578 void TouchSelectionControllerImpl::HideContextMenu() { | 577 void TouchSelectionControllerImpl::HideContextMenu() { |
| 579 if (context_menu_) | 578 if (context_menu_) |
| 580 context_menu_->Close(); | 579 context_menu_->Close(); |
| 581 context_menu_ = NULL; | 580 context_menu_ = NULL; |
| 582 context_menu_timer_.Stop(); | 581 context_menu_timer_.Stop(); |
| 583 } | 582 } |
| 584 | 583 |
| 584 gfx::NativeView TouchSelectionControllerImpl::GetCursorHandleNativeView() { |
| 585 return cursor_handle_->GetWidget()->GetNativeView(); |
| 586 } |
| 587 |
| 585 gfx::Point TouchSelectionControllerImpl::GetSelectionHandle1Position() { | 588 gfx::Point TouchSelectionControllerImpl::GetSelectionHandle1Position() { |
| 586 return selection_handle_1_->GetScreenPosition(); | 589 return selection_handle_1_->GetScreenPosition(); |
| 587 } | 590 } |
| 588 | 591 |
| 589 gfx::Point TouchSelectionControllerImpl::GetSelectionHandle2Position() { | 592 gfx::Point TouchSelectionControllerImpl::GetSelectionHandle2Position() { |
| 590 return selection_handle_2_->GetScreenPosition(); | 593 return selection_handle_2_->GetScreenPosition(); |
| 591 } | 594 } |
| 592 | 595 |
| 593 gfx::Point TouchSelectionControllerImpl::GetCursorHandlePosition() { | 596 gfx::Point TouchSelectionControllerImpl::GetCursorHandlePosition() { |
| 594 return cursor_handle_->GetScreenPosition(); | 597 return cursor_handle_->GetScreenPosition(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 610 } | 613 } |
| 611 | 614 |
| 612 ui::TouchSelectionController* ViewsTouchSelectionControllerFactory::create( | 615 ui::TouchSelectionController* ViewsTouchSelectionControllerFactory::create( |
| 613 ui::TouchEditable* client_view) { | 616 ui::TouchEditable* client_view) { |
| 614 if (switches::IsTouchEditingEnabled()) | 617 if (switches::IsTouchEditingEnabled()) |
| 615 return new views::TouchSelectionControllerImpl(client_view); | 618 return new views::TouchSelectionControllerImpl(client_view); |
| 616 return NULL; | 619 return NULL; |
| 617 } | 620 } |
| 618 | 621 |
| 619 } // namespace views | 622 } // namespace views |
| OLD | NEW |