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

Side by Side Diff: ui/views/touchui/touch_selection_controller_impl.cc

Issue 177173007: Change type of touch selection handles to POPUP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 9 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
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 const int kContextMenuTimoutMs = 200; 59 const int kContextMenuTimoutMs = 200;
60 60
61 const int kSelectionHandleQuickFadeDurationMs = 50; 61 const int kSelectionHandleQuickFadeDurationMs = 50;
62 62
63 // Creates a widget to host SelectionHandleView. 63 // Creates a widget to host SelectionHandleView.
64 views::Widget* CreateTouchSelectionPopupWidget( 64 views::Widget* CreateTouchSelectionPopupWidget(
65 gfx::NativeView context, 65 gfx::NativeView context,
66 views::WidgetDelegate* widget_delegate) { 66 views::WidgetDelegate* widget_delegate) {
67 views::Widget* widget = new views::Widget; 67 views::Widget* widget = new views::Widget;
68 views::Widget::InitParams params(views::Widget::InitParams::TYPE_TOOLTIP); 68 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
69 params.can_activate = false; 69 params.can_activate = false;
70 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 70 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
71 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 71 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
72 params.context = context; 72 params.parent = context;
73 params.delegate = widget_delegate; 73 params.delegate = widget_delegate;
74 widget->Init(params); 74 widget->Init(params);
75 SetShadowType(widget->GetNativeView(), views::corewm::SHADOW_TYPE_NONE); 75 SetShadowType(widget->GetNativeView(), views::corewm::SHADOW_TYPE_NONE);
76 // A transient child is not stacked above its parent upon creation; so, we
77 // do it manually here.
78 // TODO(mohsen): Remove after the above bug is fixed in the transient window
79 // management: crbug.com/352371.
80 widget->GetNativeView()->parent()->StackChildAbove(widget->GetNativeView(),
81 context);
76 return widget; 82 return widget;
77 } 83 }
78 84
79 gfx::Image* GetHandleImage() { 85 gfx::Image* GetHandleImage() {
80 static gfx::Image* handle_image = NULL; 86 static gfx::Image* handle_image = NULL;
81 if (!handle_image) { 87 if (!handle_image) {
82 handle_image = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 88 handle_image = &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
83 IDR_TEXT_SELECTION_HANDLE); 89 IDR_TEXT_SELECTION_HANDLE);
84 } 90 }
85 return handle_image; 91 return handle_image;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 class TouchSelectionControllerImpl::EditingHandleView 143 class TouchSelectionControllerImpl::EditingHandleView
138 : public views::WidgetDelegateView { 144 : public views::WidgetDelegateView {
139 public: 145 public:
140 EditingHandleView(TouchSelectionControllerImpl* controller, 146 EditingHandleView(TouchSelectionControllerImpl* controller,
141 gfx::NativeView context) 147 gfx::NativeView context)
142 : controller_(controller), 148 : controller_(controller),
143 drag_offset_(0), 149 drag_offset_(0),
144 draw_invisible_(false) { 150 draw_invisible_(false) {
145 widget_.reset(CreateTouchSelectionPopupWidget(context, this)); 151 widget_.reset(CreateTouchSelectionPopupWidget(context, this));
146 widget_->SetContentsView(this); 152 widget_->SetContentsView(this);
147 widget_->SetAlwaysOnTop(true);
148 153
149 aura::Window* window = widget_->GetNativeWindow(); 154 aura::Window* window = widget_->GetNativeWindow();
150 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( 155 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
151 new TouchHandleWindowTargeter(window, this))); 156 new TouchHandleWindowTargeter(window, this)));
152 157
153 // We are owned by the TouchSelectionController. 158 // We are owned by the TouchSelectionController.
154 set_owned_by_client(); 159 set_owned_by_client();
155 } 160 }
156 161
157 virtual ~EditingHandleView() { 162 virtual ~EditingHandleView() {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 StartContextMenuTimer(); 552 StartContextMenuTimer();
548 } 553 }
549 554
550 void TouchSelectionControllerImpl::HideContextMenu() { 555 void TouchSelectionControllerImpl::HideContextMenu() {
551 if (context_menu_) 556 if (context_menu_)
552 context_menu_->Close(); 557 context_menu_->Close();
553 context_menu_ = NULL; 558 context_menu_ = NULL;
554 context_menu_timer_.Stop(); 559 context_menu_timer_.Stop();
555 } 560 }
556 561
562 gfx::NativeView TouchSelectionControllerImpl::GetCursorHandleNativeView() {
563 return cursor_handle_->GetWidget()->GetNativeView();
564 }
565
557 gfx::Point TouchSelectionControllerImpl::GetSelectionHandle1Position() { 566 gfx::Point TouchSelectionControllerImpl::GetSelectionHandle1Position() {
558 return selection_handle_1_->GetScreenPosition(); 567 return selection_handle_1_->GetScreenPosition();
559 } 568 }
560 569
561 gfx::Point TouchSelectionControllerImpl::GetSelectionHandle2Position() { 570 gfx::Point TouchSelectionControllerImpl::GetSelectionHandle2Position() {
562 return selection_handle_2_->GetScreenPosition(); 571 return selection_handle_2_->GetScreenPosition();
563 } 572 }
564 573
565 gfx::Point TouchSelectionControllerImpl::GetCursorHandlePosition() { 574 gfx::Point TouchSelectionControllerImpl::GetCursorHandlePosition() {
566 return cursor_handle_->GetScreenPosition(); 575 return cursor_handle_->GetScreenPosition();
(...skipping 15 matching lines...) Expand all
582 } 591 }
583 592
584 ui::TouchSelectionController* ViewsTouchSelectionControllerFactory::create( 593 ui::TouchSelectionController* ViewsTouchSelectionControllerFactory::create(
585 ui::TouchEditable* client_view) { 594 ui::TouchEditable* client_view) {
586 if (switches::IsTouchEditingEnabled()) 595 if (switches::IsTouchEditingEnabled())
587 return new views::TouchSelectionControllerImpl(client_view); 596 return new views::TouchSelectionControllerImpl(client_view);
588 return NULL; 597 return NULL;
589 } 598 }
590 599
591 } // namespace views 600 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698