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

Unified Diff: ui/app_list/views/app_list_view.cc

Issue 2982453002: New AppListView Scroll Behavior. (Closed)
Patch Set: Created 3 years, 5 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
Index: ui/app_list/views/app_list_view.cc
diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc
index 48a26d9691f3574d9d65d1e07384ba03e8c7dac8..eacbaff4d695c7ba1dda6a384105dd6503af1ec2 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -35,6 +35,7 @@
#include "ui/display/screen.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
+#include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/path.h"
#include "ui/gfx/skia_util.h"
@@ -72,6 +73,9 @@ constexpr int kAppListThresholdDenominator = 3;
// state, measured in DIPs/event.
constexpr int kAppListDragVelocityThreshold = 25;
+// The scroll offset in order to transition from PEEKING to FULLSCREEN
+constexpr int kAppListMinScrollToSwitchStates = 20;
+
// The DIP distance from the bezel that a drag event must end within to transfer
// the |app_list_state_|.
constexpr int kAppListBezelMargin = 50;
@@ -664,6 +668,31 @@ void AppListView::OnMaximizeModeChanged(bool started) {
}
}
+bool AppListView::HandleScroll(const ui::Event* event) {
+ if (app_list_state_ != PEEKING)
+ return false;
+
+ switch (event->type()) {
+ case ui::ET_MOUSEWHEEL:
+ SetState(event->AsMouseWheelEvent()->y_offset() < 0 ? FULLSCREEN_ALL_APPS
+ : CLOSED);
+ return true;
+ break;
vadimt 2017/07/11 23:32:56 No need to break after unconditional return.
newcomer 2017/07/12 16:56:00 Done.
+ case ui::ET_SCROLL:
+ case ui::ET_SCROLL_FLING_START: {
+ int offset = event->AsScrollEvent()->y_offset();
+ if (abs(offset) > kAppListMinScrollToSwitchStates) {
+ SetState(offset < 0 ? FULLSCREEN_ALL_APPS : CLOSED);
+ return true;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return false;
+}
+
void AppListView::OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
views::Widget* widget) const {
if (!params->native_widget) {
@@ -697,6 +726,19 @@ void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const {
mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds()));
}
+void AppListView::OnScrollEvent(ui::ScrollEvent* event) {
+ if (!is_fullscreen_app_list_enabled_)
+ return;
+
+ if (event->type() == ui::ET_SCROLL_FLING_CANCEL)
+ return;
+
+ if (HandleScroll(event)) {
+ event->SetHandled();
+ event->StopPropagation();
+ }
+}
+
void AppListView::OnMouseEvent(ui::MouseEvent* event) {
if (!is_fullscreen_app_list_enabled_)
return;
@@ -714,6 +756,11 @@ void AppListView::OnMouseEvent(ui::MouseEvent* event) {
EndDrag(event->location());
event->SetHandled();
break;
+ case ui::ET_MOUSEWHEEL: {
+ if (HandleScroll(event))
+ event->SetHandled();
+ break;
+ }
default:
break;
}
@@ -765,8 +812,8 @@ bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
void AppListView::Layout() {
const gfx::Rect contents_bounds = GetContentsBounds();
- // Make sure to layout |app_list_main_view_| and |speech_view_| at the center
- // of the widget.
+ // Make sure to layout |app_list_main_view_| and |speech_view_| at the
+ // center of the widget.
gfx::Rect centered_bounds = contents_bounds;
centered_bounds.ClampToCenteredSize(gfx::Size(
app_list_main_view_->contents_view()->GetDefaultContentsBounds().width(),
@@ -948,8 +995,9 @@ void AppListView::OnSpeechRecognitionStateChanged(
} else {
app_list_main_view_->SetVisible(true);
// Refocus the search box. However, if the app list widget does not have
- // focus, it means another window has already taken focus, and we *must not*
- // focus the search box (or we would steal focus back into the app list).
+ // focus, it means another window has already taken focus, and we *must
+ // not* focus the search box (or we would steal focus back into the app
+ // list).
if (GetWidget()->IsActive())
search_box_view_->search_box()->RequestFocus();
}

Powered by Google App Engine
This is Rietveld 408576698