| 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" |
| 11 #include "ui/base/ui_base_switches_util.h" | 11 #include "ui/base/ui_base_switches_util.h" |
| 12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
| 13 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
| 14 #include "ui/gfx/path.h" | 14 #include "ui/gfx/path.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
| 17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 19 #include "ui/wm/core/masked_window_targeter.h" |
| 19 #include "ui/wm/core/shadow_types.h" | 20 #include "ui/wm/core/shadow_types.h" |
| 20 #include "ui/wm/core/window_animations.h" | 21 #include "ui/wm/core/window_animations.h" |
| 21 #include "ui/wm/public/masked_window_targeter.h" | |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Constants defining the visual attributes of selection handles | 25 // Constants defining the visual attributes of selection handles |
| 26 const int kSelectionHandleLineWidth = 1; | 26 const int kSelectionHandleLineWidth = 1; |
| 27 const SkColor kSelectionHandleLineColor = | 27 const SkColor kSelectionHandleLineColor = |
| 28 SkColorSetRGB(0x42, 0x81, 0xf4); | 28 SkColorSetRGB(0x42, 0x81, 0xf4); |
| 29 | 29 |
| 30 // When a handle is dragged, the drag position reported to the client view is | 30 // When a handle is dragged, the drag position reported to the client view is |
| 31 // offset vertically to represent the cursor position. This constant specifies | 31 // offset vertically to represent the cursor position. This constant specifies |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_TOOLTIP); |
| 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.context = 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(), wm::SHADOW_TYPE_NONE); |
| 76 return widget; | 76 return widget; |
| 77 } | 77 } |
| 78 | 78 |
| 79 gfx::Image* GetHandleImage() { | 79 gfx::Image* GetHandleImage() { |
| 80 static gfx::Image* handle_image = NULL; | 80 static gfx::Image* handle_image = NULL; |
| 81 if (!handle_image) { | 81 if (!handle_image) { |
| 82 handle_image = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 82 handle_image = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 83 IDR_TEXT_SELECTION_HANDLE); | 83 IDR_TEXT_SELECTION_HANDLE); |
| 84 } | 84 } |
| 85 return handle_image; | 85 return handle_image; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 kSelectionHandleVertPadding); | 226 kSelectionHandleVertPadding); |
| 227 } | 227 } |
| 228 | 228 |
| 229 bool IsWidgetVisible() const { | 229 bool IsWidgetVisible() const { |
| 230 return widget_->IsVisible(); | 230 return widget_->IsVisible(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void SetWidgetVisible(bool visible, bool quick) { | 233 void SetWidgetVisible(bool visible, bool quick) { |
| 234 if (widget_->IsVisible() == visible) | 234 if (widget_->IsVisible() == visible) |
| 235 return; | 235 return; |
| 236 corewm::SetWindowVisibilityAnimationDuration( | 236 wm::SetWindowVisibilityAnimationDuration( |
| 237 widget_->GetNativeView(), | 237 widget_->GetNativeView(), |
| 238 base::TimeDelta::FromMilliseconds( | 238 base::TimeDelta::FromMilliseconds( |
| 239 quick ? kSelectionHandleQuickFadeDurationMs : 0)); | 239 quick ? kSelectionHandleQuickFadeDurationMs : 0)); |
| 240 if (visible) | 240 if (visible) |
| 241 widget_->Show(); | 241 widget_->Show(); |
| 242 else | 242 else |
| 243 widget_->Hide(); | 243 widget_->Hide(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void SetSelectionRectInScreen(const gfx::Rect& rect) { | 246 void SetSelectionRectInScreen(const gfx::Rect& rect) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 582 } |
| 583 | 583 |
| 584 ui::TouchSelectionController* ViewsTouchSelectionControllerFactory::create( | 584 ui::TouchSelectionController* ViewsTouchSelectionControllerFactory::create( |
| 585 ui::TouchEditable* client_view) { | 585 ui::TouchEditable* client_view) { |
| 586 if (switches::IsTouchEditingEnabled()) | 586 if (switches::IsTouchEditingEnabled()) |
| 587 return new views::TouchSelectionControllerImpl(client_view); | 587 return new views::TouchSelectionControllerImpl(client_view); |
| 588 return NULL; | 588 return NULL; |
| 589 } | 589 } |
| 590 | 590 |
| 591 } // namespace views | 591 } // namespace views |
| OLD | NEW |