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

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

Issue 2588103004: Apply new WM shadows to app list. (Closed)
Patch Set: stop building app list on other platforms Created 4 years 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 893d005bc7e824f35954000a67ff7d4c783266e1..b55c9c3f36c4189eea2a9aeb479fb27e2c3c30ab 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -18,7 +18,6 @@
#include "ui/app_list/app_list_switches.h"
#include "ui/app_list/app_list_view_delegate.h"
#include "ui/app_list/speech_ui_model.h"
-#include "ui/app_list/views/app_list_background.h"
#include "ui/app_list/views/app_list_folder_view.h"
#include "ui/app_list/views/app_list_main_view.h"
#include "ui/app_list/views/app_list_view_observer.h"
@@ -28,6 +27,8 @@
#include "ui/app_list/views/search_box_view.h"
#include "ui/app_list/views/speech_view.h"
#include "ui/app_list/views/start_page_view.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
@@ -39,21 +40,13 @@
#include "ui/gfx/skia_util.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/views/bubble/bubble_frame_view.h"
+#include "ui/views/bubble/bubble_window_targeter.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
-
-#if defined(USE_AURA)
-#include "ui/aura/window.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/views/bubble/bubble_window_targeter.h"
#include "ui/wm/core/masked_window_targeter.h"
-#if !defined(OS_CHROMEOS)
-#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
-#endif
-#endif // defined(USE_AURA)
namespace app_list {
@@ -65,18 +58,6 @@ const int kSpeechUIMargin = 12;
// The vertical position for the appearing animation of the speech UI.
const float kSpeechUIAppearingPosition = 12;
-// The distance between the arrow tip and edge of the anchor view.
-const int kArrowOffset = 10;
-
-// Determines whether the current environment supports shadows bubble borders.
-bool SupportsShadow() {
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- // Shadows are not supported on (non-ChromeOS) Linux.
- return false;
-#endif
- return true;
-}
-
// This view forwards the focus to the search box widget by providing it as a
// FocusTraversable when a focus search is provided.
class SearchBoxFocusHost : public views::View {
@@ -123,7 +104,6 @@ class AppListOverlayView : public views::View {
DISALLOW_COPY_AND_ASSIGN(AppListOverlayView);
};
-#if defined(USE_AURA)
// An event targeter for the search box widget which will ignore events that
// are on the search box's shadow.
class SearchBoxWindowTargeter : public wm::MaskedWindowTargeter {
@@ -144,7 +124,6 @@ class SearchBoxWindowTargeter : public wm::MaskedWindowTargeter {
DISALLOW_COPY_AND_ASSIGN(SearchBoxWindowTargeter);
};
-#endif
} // namespace
@@ -212,21 +191,46 @@ AppListView::~AppListView() {
RemoveAllChildViews(true);
}
-void AppListView::InitAsBubbleAtFixedLocation(
- gfx::NativeView parent,
- int initial_apps_page,
- const gfx::Point& anchor_point_in_screen,
- views::BubbleBorder::Arrow arrow,
- bool border_accepts_events) {
- SetAnchorRect(gfx::Rect(anchor_point_in_screen, gfx::Size()));
- // TODO(mgiuca): Inline InitAsBubbleInternal, since there is only one caller.
- InitAsBubbleInternal(
- parent, initial_apps_page, arrow, border_accepts_events, gfx::Vector2d());
+void AppListView::InitAsBubble(gfx::NativeView parent, int initial_apps_page) {
+ base::Time start_time = base::Time::Now();
+
+ InitContents(parent, initial_apps_page);
+
+ AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
+ set_margins(gfx::Insets());
+ set_parent_window(parent);
+ set_close_on_deactivate(false);
+ set_shadow(views::BubbleBorder::NO_ASSETS);
+ set_color(kContentsBackgroundColor);
+ // This creates the app list widget. (Before this, child widgets cannot be
+ // created.)
+ views::BubbleDialogDelegateView::CreateBubble(this);
+
+ SetBubbleArrow(views::BubbleBorder::FLOAT);
+ // We can now create the internal widgets.
+ InitChildWidgets();
+
+ aura::Window* window = GetWidget()->GetNativeWindow();
+ window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>(
tapted 2016/12/21 22:39:58 nit: MakeUnique?
Evan Stade 2016/12/29 17:23:12 Done.
+ new views::BubbleWindowTargeter(this)));
+
+ const int kOverlayCornerRadius =
+ GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius();
+ overlay_view_ = new AppListOverlayView(kOverlayCornerRadius);
+ overlay_view_->SetBoundsRect(GetContentsBounds());
+ AddChildView(overlay_view_);
+
+ if (delegate_)
+ delegate_->ViewInitialized();
+
+ UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime",
+ base::Time::Now() - start_time);
}
void AppListView::InitAsFramelessWindow(gfx::NativeView parent,
int initial_apps_page,
gfx::Rect bounds) {
+ set_color(kContentsBackgroundColor);
InitContents(parent, initial_apps_page);
overlay_view_ = new AppListOverlayView(0 /* no corners */);
AddChildView(overlay_view_);
@@ -238,11 +242,6 @@ void AppListView::InitAsFramelessWindow(gfx::NativeView parent,
params.delegate = this;
widget->Init(params);
widget->SetBounds(bounds);
- // This needs to be set *after* Widget::Init() because
- // BubbleDialogDelegateView sets its own background at OnNativeThemeChanged(),
- // which is called in View::AddChildView() which is called at
- // Widget::SetContentsView() to build the views hierarchy in the widget.
- set_background(new AppListBackground(0));
InitChildWidgets();
}
@@ -294,7 +293,7 @@ void AppListView::SetAppListOverlayVisible(bool visible) {
settings.AddObserver(animation_observer_.get());
}
- const float kOverlayFadeInMilliseconds = 125;
+ const float kOverlayFadeInMilliseconds = 1250;
msw 2016/12/20 19:16:10 Revert this
Evan Stade 2016/12/29 17:23:12 Done.
settings.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kOverlayFadeInMilliseconds));
@@ -351,14 +350,6 @@ void AppListView::SetProfileByPath(const base::FilePath& profile_path) {
app_list_main_view_->ModelChanged();
}
-void AppListView::AddObserver(AppListViewObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void AppListView::RemoveObserver(AppListViewObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
PaginationModel* AppListView::GetAppsPaginationModel() {
return app_list_main_view_->contents_view()
->apps_container_view()
@@ -437,93 +428,14 @@ void AppListView::InitChildWidgets() {
search_box_widget_->SetFocusTraversableParent(
GetWidget()->GetFocusTraversable());
-#if defined(USE_AURA)
// Mouse events on the search box shadow should not be captured.
aura::Window* window = search_box_widget_->GetNativeWindow();
- window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>(
- new SearchBoxWindowTargeter(search_box_view_)));
-#endif
+ window->SetEventTargeter(
+ base::MakeUnique<SearchBoxWindowTargeter>(search_box_view_));
app_list_main_view_->contents_view()->Layout();
}
-void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
- int initial_apps_page,
- views::BubbleBorder::Arrow arrow,
- bool border_accepts_events,
- const gfx::Vector2d& anchor_offset) {
- base::Time start_time = base::Time::Now();
-
- InitContents(parent, initial_apps_page);
-
- AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
- set_color(kContentsBackgroundColor);
- set_margins(gfx::Insets());
- set_parent_window(parent);
- set_close_on_deactivate(false);
- set_anchor_view_insets(gfx::Insets(kArrowOffset + anchor_offset.y(),
- kArrowOffset + anchor_offset.x(),
- kArrowOffset - anchor_offset.y(),
- kArrowOffset - anchor_offset.x()));
- set_border_accepts_events(border_accepts_events);
- set_shadow(SupportsShadow() ? views::BubbleBorder::BIG_SHADOW
- : views::BubbleBorder::NO_SHADOW_OPAQUE_BORDER);
-
- {
- // TODO(tapted): Remove ScopedTracker below once crbug.com/431326 is fixed.
- tracked_objects::ScopedTracker tracking_profile(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "431326 views::BubbleDialogDelegateView::CreateBubble()"));
-
- // This creates the app list widget. (Before this, child widgets cannot be
- // created.)
- views::BubbleDialogDelegateView::CreateBubble(this);
- }
-
- SetBubbleArrow(arrow);
-
- // We can now create the internal widgets.
- InitChildWidgets();
-
-#if defined(USE_AURA)
- aura::Window* window = GetWidget()->GetNativeWindow();
- window->layer()->SetMasksToBounds(true);
- GetBubbleFrameView()->set_background(new AppListBackground(
- GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius()));
- set_background(NULL);
- window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>(
- new views::BubbleWindowTargeter(this)));
-#else
- set_background(new AppListBackground(
- GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius()));
-
- // On non-aura the bubble has two widgets, and it's possible for the border
- // to be shown independently in odd situations. Explicitly hide the bubble
- // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the
- // window manager do not have the SWP_SHOWWINDOW flag set which would cause
- // the border to be shown. See http://crbug.com/231687 .
- GetWidget()->Hide();
-#endif
-
- // On platforms that don't support a shadow, the rounded border of the app
- // list is constructed _inside_ the view, so a rectangular background goes
- // over the border in the rounded corners. To fix this, give the background a
- // corner radius 1px smaller than the outer border, so it just reaches but
- // doesn't cover it.
- const int kOverlayCornerRadius =
- GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius();
- overlay_view_ =
- new AppListOverlayView(kOverlayCornerRadius - (SupportsShadow() ? 0 : 1));
- overlay_view_->SetBoundsRect(GetContentsBounds());
- AddChildView(overlay_view_);
-
- if (delegate_)
- delegate_->ViewInitialized();
-
- UMA_HISTOGRAM_TIMES("Apps.AppListCreationTime",
- base::Time::Now() - start_time);
-}
-
void AppListView::OnBeforeBubbleWidgetInit(
views::Widget::InitParams* params,
views::Widget* widget) const {
@@ -534,18 +446,8 @@ void AppListView::OnBeforeBubbleWidgetInit(
views_delegate->native_widget_factory().Run(*params, widget);
}
}
-#if defined(USE_AURA) && !defined(OS_CHROMEOS)
- if (!params->native_widget && delegate_ && delegate_->ForceNativeDesktop())
- params->native_widget = new views::DesktopNativeWidgetAura(widget);
-#endif
-#if defined(OS_LINUX)
- // Set up a custom WM_CLASS for the app launcher window. This allows task
- // switchers in X11 environments to distinguish it from main browser windows.
- params->wm_class_name = kAppListWMClass;
- // Show the window in the taskbar, even though it is a bubble, which would not
- // normally be shown.
- params->force_show_in_taskbar = true;
-#endif
+ // Apply a WM-provided shadow (see ui/wm/core/).
+ params->shadow_type = views::Widget::InitParams::SHADOW_TYPE_DROP;
}
int AppListView::GetDialogButtons() const {
@@ -617,16 +519,6 @@ void AppListView::OnWidgetDestroying(views::Widget* widget) {
delegate_->ViewClosing();
}
-void AppListView::OnWidgetActivationChanged(views::Widget* widget,
- bool active) {
- // Do not called inherited function as the bubble delegate auto close
tapted 2016/12/21 22:39:58 So long as you've checked that clicking outside th
Evan Stade 2016/12/29 17:23:12 it does still close. Not the easiest thing to trac
- // functionality is not used.
- if (widget == GetWidget()) {
- for (auto& observer : observers_)
- observer.OnActivationChanged(widget, active);
- }
-}
-
void AppListView::OnWidgetVisibilityChanged(views::Widget* widget,
bool visible) {
BubbleDialogDelegateView::OnWidgetVisibilityChanged(widget, visible);

Powered by Google App Engine
This is Rietveld 408576698