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

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

Issue 2982453002: New AppListView Scroll Behavior. (Closed)
Patch Set: Removed unintended edit. 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
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | ui/app_list/views/search_box_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c73cf31091026913f9a4ae182e3e72a99e818535..9d9a5bb4b5c00c8ca39b5166df0896f7ba0e3c36 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;
@@ -687,6 +691,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;
+ case ui::ET_SCROLL:
+ case ui::ET_SCROLL_FLING_START: {
+ if (fabs(event->AsScrollEvent()->y_offset()) >
+ kAppListMinScrollToSwitchStates) {
+ SetState(event->AsScrollEvent()->y_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) {
@@ -720,6 +749,20 @@ 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))
+ return;
+
+ event->SetHandled();
+ event->StopPropagation();
+}
+
void AppListView::OnMouseEvent(ui::MouseEvent* event) {
if (!is_fullscreen_app_list_enabled_)
return;
@@ -729,6 +772,10 @@ void AppListView::OnMouseEvent(ui::MouseEvent* event) {
event->SetHandled();
HandleClickOrTap();
break;
+ case ui::ET_MOUSEWHEEL:
+ if (HandleScroll(event))
+ event->SetHandled();
+ break;
default:
break;
}
@@ -764,6 +811,11 @@ void AppListView::OnGestureEvent(ui::GestureEvent* event) {
EndDrag(event->location());
event->SetHandled();
break;
+ case ui::ET_MOUSEWHEEL: {
+ if (HandleScroll(event))
+ event->SetHandled();
+ break;
+ }
default:
break;
}
@@ -791,8 +843,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(),
@@ -974,8 +1026,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();
}
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | ui/app_list/views/search_box_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698