Commit f86476e7 authored by Kevin Strohbehn's avatar Kevin Strohbehn Committed by Commit Bot

Move Fullscreen Widget up to prevent overlap with search box

Bug: 860119
Change-Id: I1545e820cd53d46ef6a20b6d923d33f727070901
Reviewed-on: https://chromium-review.googlesource.com/1195897Reviewed-by: default avatarWeidong Guo <weidongg@chromium.org>
Commit-Queue: Kevin Strohbehn <ginko@google.com>
Cr-Commit-Position: refs/heads/master@{#587793}
parent 15716860
...@@ -594,26 +594,37 @@ void AppListFolderView::UpdatePreferredBounds() { ...@@ -594,26 +594,37 @@ void AppListFolderView::UpdatePreferredBounds() {
0, 0); 0, 0);
preferred_bounds_.AdjustToFit(container_bounds); preferred_bounds_.AdjustToFit(container_bounds);
auto* const keyboard_controller = keyboard::KeyboardController::Get();
if (keyboard_controller->enabled()) {
// This view should be on top of on-screen keyboard to prevent the folder
// title from being blocked.
const gfx::Rect occluded_bounds =
keyboard_controller->GetWorkspaceOccludedBounds();
if (!occluded_bounds.IsEmpty()) {
gfx::Point keyboard_top_right = occluded_bounds.top_right();
ConvertPointFromScreen(parent(), &keyboard_top_right);
int y_offset = keyboard_top_right.y() - kOnscreenKeyboardTopPadding -
preferred_bounds_.bottom();
preferred_bounds_.Offset(0, std::min(0, y_offset));
}
}
// Calculate the folder icon's bounds relative to this view. // Calculate the folder icon's bounds relative to this view.
folder_item_icon_bounds_ = folder_item_icon_bounds_ =
icon_bounds_in_container - preferred_bounds_.OffsetFromOrigin(); icon_bounds_in_container - preferred_bounds_.OffsetFromOrigin();
} }
int AppListFolderView::GetYOffsetForFolder() {
auto* const keyboard_controller = keyboard::KeyboardController::Get();
if (!keyboard_controller->enabled())
return 0;
// This view should be on top of on-screen keyboard to prevent the folder
// title from being blocked.
const gfx::Rect occluded_bounds =
keyboard_controller->GetWorkspaceOccludedBounds();
if (!occluded_bounds.IsEmpty()) {
gfx::Point keyboard_top_right = occluded_bounds.top_right();
ConvertPointFromScreen(parent(), &keyboard_top_right);
// Our final Y-Offset is determined by combining the space from the bottom
// of the folder to the top of the keyboard, and the padding that should
// exist between the keyboard and the folder bottom.
// std::min() is used so that positive offsets are ignored.
return std::min(keyboard_top_right.y() - kOnscreenKeyboardTopPadding -
preferred_bounds_.bottom(),
0);
}
// If no offset is calculated above, then we need none.
return 0;
}
bool AppListFolderView::IsAnimationRunning() const { bool AppListFolderView::IsAnimationRunning() const {
return top_icon_animation_ && top_icon_animation_->IsAnimationRunning(); return top_icon_animation_ && top_icon_animation_->IsAnimationRunning();
} }
......
...@@ -75,6 +75,10 @@ class APP_LIST_EXPORT AppListFolderView : public views::View, ...@@ -75,6 +75,10 @@ class APP_LIST_EXPORT AppListFolderView : public views::View,
// icon's bounds. // icon's bounds.
void UpdatePreferredBounds(); void UpdatePreferredBounds();
// Returns the Y-offset that would move a folder out from under a visible
// Virtual keyboard
int GetYOffsetForFolder();
// Returns true if this view's child views are in animation for opening or // Returns true if this view's child views are in animation for opening or
// closing the folder. // closing the folder.
bool IsAnimationRunning() const; bool IsAnimationRunning() const;
......
...@@ -1420,6 +1420,13 @@ void AppListView::UpdateYPositionAndOpacity(int y_position_in_screen, ...@@ -1420,6 +1420,13 @@ void AppListView::UpdateYPositionAndOpacity(int y_position_in_screen,
DraggingLayout(); DraggingLayout();
} }
void AppListView::OffsetYPositionOfAppList(int offset) {
gfx::NativeView native_view = fullscreen_widget_->GetNativeView();
gfx::Transform transform;
transform.Translate(0, offset);
native_view->SetTransform(transform);
}
PaginationModel* AppListView::GetAppsPaginationModel() { PaginationModel* AppListView::GetAppsPaginationModel() {
return GetRootAppsGridView()->pagination_model(); return GetRootAppsGridView()->pagination_model();
} }
...@@ -1541,13 +1548,16 @@ void AppListView::OnScreenKeyboardShown(bool shown) { ...@@ -1541,13 +1548,16 @@ void AppListView::OnScreenKeyboardShown(bool shown) {
return; return;
onscreen_keyboard_shown_ = shown; onscreen_keyboard_shown_ = shown;
if (!GetAppsContainerView()->IsInFolderView()) if (shown && GetAppsContainerView()->IsInFolderView()) {
return; // Move the app list up to prevent folders being blocked by the
// Update the folder's bounds to avoid being blocked by the on-screen // on-screen keyboard.
// keyboard. OffsetYPositionOfAppList(
GetAppsContainerView()->app_list_folder_view()->UpdatePreferredBounds(); GetAppsContainerView()->app_list_folder_view()->GetYOffsetForFolder());
GetAppsContainerView()->Layout(); } else {
GetAppsContainerView()->SchedulePaint(); // If the keyboard is closing or a folder isn't being shown, reset
// the app list's position
OffsetYPositionOfAppList(0);
}
} }
void AppListView::OnDisplayMetricsChanged(const display::Display& display, void AppListView::OnDisplayMetricsChanged(const display::Display& display,
......
...@@ -180,6 +180,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -180,6 +180,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
void UpdateYPositionAndOpacity(int y_position_in_screen, void UpdateYPositionAndOpacity(int y_position_in_screen,
float background_opacity); float background_opacity);
// Offsets the y position of the app list (above the screen)
void OffsetYPositionOfAppList(int offset);
// Layouts the app list during dragging. // Layouts the app list during dragging.
void DraggingLayout(); void DraggingLayout();
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ash/app_list/views/folder_background_view.h" #include "ash/app_list/views/folder_background_view.h"
#include "ash/app_list/views/app_list_folder_view.h" #include "ash/app_list/views/app_list_folder_view.h"
#include "ui/keyboard/keyboard_controller.h"
namespace app_list { namespace app_list {
...@@ -28,6 +29,15 @@ void FolderBackgroundView::OnGestureEvent(ui::GestureEvent* event) { ...@@ -28,6 +29,15 @@ void FolderBackgroundView::OnGestureEvent(ui::GestureEvent* event) {
} }
void FolderBackgroundView::HandleClickOrTap() { void FolderBackgroundView::HandleClickOrTap() {
// If the virtual keyboard is visible, dismiss the keyboard and return early
auto* const keyboard_controller = keyboard::KeyboardController::Get();
if (keyboard_controller->enabled() &&
keyboard_controller->IsKeyboardVisible()) {
keyboard_controller->HideKeyboardByUser();
return;
}
// TODO(ginko): make the first tap close the keyboard only, and the second tap
// close the folder. Bug: https://crbug.com/879329
folder_view_->CloseFolderPage(); folder_view_->CloseFolderPage();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment