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

Unified Diff: ui/views/touchui/touch_selection_controller_impl.cc

Issue 138033014: Consistent fading behavior for touch editing handles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fade out handles on destruction by default Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/touchui/touch_selection_controller_impl.cc
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc
index 4f1aac4b1e97826a5a2d5fdc72a5e4c2bc703f25..11868f606cd25895b7aeb85a97477abca5b53436 100644
--- a/ui/views/touchui/touch_selection_controller_impl.cc
+++ b/ui/views/touchui/touch_selection_controller_impl.cc
@@ -16,6 +16,7 @@
#include "ui/gfx/screen.h"
#include "ui/gfx/size.h"
#include "ui/views/corewm/shadow_types.h"
+#include "ui/views/corewm/window_animations.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/public/masked_window_targeter.h"
@@ -57,6 +58,8 @@ const int kSelectionHandleVertPadding = 20;
const int kContextMenuTimoutMs = 200;
+const int kSelectionHandleQuickFadeDurationMs = 50;
+
// Creates a widget to host SelectionHandleView.
views::Widget* CreateTouchSelectionPopupWidget(
gfx::NativeView context,
@@ -154,6 +157,7 @@ class TouchSelectionControllerImpl::EditingHandleView
}
virtual ~EditingHandleView() {
+ SetWidgetVisible(false, false);
}
// Overridden from views::WidgetDelegateView:
@@ -228,13 +232,22 @@ class TouchSelectionControllerImpl::EditingHandleView
return widget_->IsVisible();
}
- void SetWidgetVisible(bool visible) {
+ void SetWidgetVisible(bool visible, bool quick) {
if (widget_->IsVisible() == visible)
return;
- if (visible)
+ if (visible) {
+ corewm::SetWindowShowAnimationDuration(
+ widget_->GetNativeView(),
+ base::TimeDelta::FromMilliseconds(
+ quick ? kSelectionHandleQuickFadeDurationMs : 0));
widget_->Show();
- else
+ } else {
+ corewm::SetWindowHideAnimationDuration(
+ widget_->GetNativeView(),
+ base::TimeDelta::FromMilliseconds(
+ quick ? kSelectionHandleQuickFadeDurationMs : 0));
widget_->Hide();
+ }
}
void SetSelectionRectInScreen(const gfx::Rect& rect) {
@@ -375,13 +388,13 @@ void TouchSelectionControllerImpl::SelectionChanged() {
// Check if there is any selection at all.
if (screen_pos_1 == screen_pos_2) {
- selection_handle_1_->SetWidgetVisible(false);
- selection_handle_2_->SetWidgetVisible(false);
+ selection_handle_1_->SetWidgetVisible(false, false);
+ selection_handle_2_->SetWidgetVisible(false, false);
SetHandleSelectionRect(cursor_handle_.get(), r1, screen_rect_1);
return;
}
- cursor_handle_->SetWidgetVisible(false);
+ cursor_handle_->SetWidgetVisible(false, false);
SetHandleSelectionRect(selection_handle_1_.get(), r1, screen_rect_1);
SetHandleSelectionRect(selection_handle_2_.get(), r2, screen_rect_2);
}
@@ -391,6 +404,12 @@ bool TouchSelectionControllerImpl::IsHandleDragInProgress() {
return !!dragging_handle_;
}
+void TouchSelectionControllerImpl::HideHandles(bool quick) {
+ selection_handle_1_->SetWidgetVisible(false, quick);
+ selection_handle_2_->SetWidgetVisible(false, quick);
+ cursor_handle_->SetWidgetVisible(false, quick);
+}
+
void TouchSelectionControllerImpl::SetDraggingHandle(
EditingHandleView* handle) {
dragging_handle_ = handle;
@@ -440,7 +459,7 @@ void TouchSelectionControllerImpl::SetHandleSelectionRect(
EditingHandleView* handle,
const gfx::Rect& rect,
const gfx::Rect& rect_in_screen) {
- handle->SetWidgetVisible(client_view_->GetBounds().Contains(rect));
+ handle->SetWidgetVisible(client_view_->GetBounds().Contains(rect), false);
if (handle->IsWidgetVisible())
handle->SetSelectionRectInScreen(rect_in_screen);
}
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698