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 "ui/aura/client/cursor_client.h" | 8 #include "ui/aura/client/cursor_client.h" |
9 #include "ui/aura/env.h" | 9 #include "ui/aura/env.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.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/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
19 #include "ui/strings/grit/ui_strings.h" | 19 #include "ui/strings/grit/ui_strings.h" |
20 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
21 #include "ui/wm/core/masked_window_targeter.h" | 21 #include "ui/wm/core/masked_window_targeter.h" |
22 #include "ui/wm/core/window_animations.h" | |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 // Constants defining the visual attributes of selection handles | 25 // Constants defining the visual attributes of selection handles |
27 const int kSelectionHandleLineWidth = 1; | 26 const int kSelectionHandleLineWidth = 1; |
28 const SkColor kSelectionHandleLineColor = | 27 const SkColor kSelectionHandleLineColor = |
29 SkColorSetRGB(0x42, 0x81, 0xf4); | 28 SkColorSetRGB(0x42, 0x81, 0xf4); |
30 | 29 |
31 // 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 |
32 // offset vertically to represent the cursor position. This constant specifies | 31 // offset vertically to represent the cursor position. This constant specifies |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 kSelectionHandleVertPadding); | 231 kSelectionHandleVertPadding); |
233 } | 232 } |
234 | 233 |
235 bool IsWidgetVisible() const { | 234 bool IsWidgetVisible() const { |
236 return widget_->IsVisible(); | 235 return widget_->IsVisible(); |
237 } | 236 } |
238 | 237 |
239 void SetWidgetVisible(bool visible, bool quick) { | 238 void SetWidgetVisible(bool visible, bool quick) { |
240 if (widget_->IsVisible() == visible) | 239 if (widget_->IsVisible() == visible) |
241 return; | 240 return; |
242 wm::SetWindowVisibilityAnimationDuration( | 241 widget_->SetVisibilityAnimationDuration( |
243 widget_->GetNativeView(), | |
244 base::TimeDelta::FromMilliseconds( | 242 base::TimeDelta::FromMilliseconds( |
245 quick ? kSelectionHandleQuickFadeDurationMs : 0)); | 243 quick ? kSelectionHandleQuickFadeDurationMs : 0)); |
246 if (visible) | 244 if (visible) |
247 widget_->Show(); | 245 widget_->Show(); |
248 else | 246 else |
249 widget_->Hide(); | 247 widget_->Hide(); |
250 } | 248 } |
251 | 249 |
252 void SetSelectionRectInScreen(const gfx::Rect& rect) { | 250 void SetSelectionRectInScreen(const gfx::Rect& rect) { |
253 gfx::Size image_size = GetHandleImageSize(); | 251 gfx::Size image_size = GetHandleImageSize(); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 618 |
621 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { | 619 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { |
622 return selection_handle_2_->IsWidgetVisible(); | 620 return selection_handle_2_->IsWidgetVisible(); |
623 } | 621 } |
624 | 622 |
625 bool TouchSelectionControllerImpl::IsCursorHandleVisible() { | 623 bool TouchSelectionControllerImpl::IsCursorHandleVisible() { |
626 return cursor_handle_->IsWidgetVisible(); | 624 return cursor_handle_->IsWidgetVisible(); |
627 } | 625 } |
628 | 626 |
629 } // namespace views | 627 } // namespace views |
OLD | NEW |