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

Unified Diff: ash/wm/overview/window_selector.cc

Issue 403493006: Visual improvements to text filtering in Ash overview mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« ash/wm/overview/window_grid.cc ('K') | « ash/wm/overview/window_selector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/overview/window_selector.cc
diff --git a/ash/wm/overview/window_selector.cc b/ash/wm/overview/window_selector.cc
index a8cef585f2013eaa114f794a6a2dde1086d9e5cf..4f6b77034bc9e1e38085b873a9ceae1a2d08fb74 100644
--- a/ash/wm/overview/window_selector.cc
+++ b/ash/wm/overview/window_selector.cc
@@ -25,11 +25,14 @@
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_observer.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/events/event.h"
#include "ui/gfx/screen.h"
+#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/layout/box_layout.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"
@@ -38,10 +41,14 @@ namespace ash {
namespace {
// The proportion of screen width that the text filter takes.
-const float kTextFilterScreenProportion = 0.5;
+const float kTextFilterScreenProportion = 0.25;
-// The height of the text filter.
-const int kTextFilterHeight = 50;
+// The amount of padding surrounding the text in the text filtering textbox.
+const int kTextFilterPadding = 3;
+
+// The font style used for text filtering.
+static const ::ui::ResourceBundle::FontStyle kTextFilterFontStyle =
+ ::ui::ResourceBundle::FontStyle::BaseFont;
// Solid shadow length from the text filter.
const int kVerticalShadowOffset = 1;
@@ -51,6 +58,7 @@ const int kShadowBlur = 10;
// Text filter shadow color.
const SkColor kTextFilterShadow = 0xB0000000;
+const unsigned char kTextFilterOpacity = 128;
tdanderson 2014/07/17 19:45:26 Admittedly a copy of WindowGrid::kWindowOverviewSe
flackr 2014/07/18 13:41:51 As a static class var (like kTransitionMillisecond
// A comparator for locating a grid with a given root window.
struct RootWindowGridComparator
@@ -105,42 +113,6 @@ void UpdateShelfVisibility() {
}
}
-// Initializes the text filter on the top of the main root window and requests
-// focus on its textfield.
-views::Widget* CreateTextFilter(views::TextfieldController* controller,
- aura::Window* root_window) {
- views::Widget* widget = new views::Widget;
- views::Widget::InitParams params;
- params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
- params.parent =
- Shell::GetContainer(root_window, ash::kShellWindowId_OverlayContainer);
- params.accept_events = true;
- params.bounds = gfx::Rect(
- root_window->bounds().width() / 2 * (1 - kTextFilterScreenProportion), 0,
- root_window->bounds().width() * kTextFilterScreenProportion,
- kTextFilterHeight);
- widget->Init(params);
-
- views::Textfield* textfield = new views::Textfield;
- textfield->set_controller(controller);
- textfield->SetBackgroundColor(SK_ColorTRANSPARENT);
- textfield->SetBorder(views::Border::NullBorder());
- textfield->SetTextColor(SK_ColorWHITE);
- textfield->SetShadows(gfx::ShadowValues(1, gfx::ShadowValue(
- gfx::Point(0, kVerticalShadowOffset), kShadowBlur, kTextFilterShadow)));
- widget->SetContentsView(textfield);
-
- gfx::Transform transform;
- transform.Translate(0, -kTextFilterHeight);
- widget->GetNativeWindow()->SetTransform(transform);
- widget->Show();
- textfield->RequestFocus();
-
- return widget;
-}
-
} // namespace
WindowSelector::WindowSelector(const WindowList& windows,
@@ -153,11 +125,16 @@ WindowSelector::WindowSelector(const WindowList& windows,
overview_start_time_(base::Time::Now()),
num_key_presses_(0),
num_items_(0),
- showing_selection_widget_(false) {
+ showing_selection_widget_(false),
+ text_height_(0) {
DCHECK(delegate_);
Shell* shell = Shell::GetInstance();
shell->OnOverviewModeStarting();
+ // Compute and store the height of the text used in text filtering.
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ text_height_ = bundle.GetFontList(kTextFilterFontStyle).GetHeight();
+
if (restore_focus_window_)
restore_focus_window_->AddObserver(this);
@@ -253,6 +230,11 @@ WindowSelector::~WindowSelector() {
UpdateShelfVisibility();
}
+int WindowSelector::TextFilterHeight() const {
flackr 2014/07/18 13:41:51 Can this be in anonymous namespace and use a stati
tdanderson 2014/08/07 20:13:07 This is gone in the next patch set.
+ DCHECK(text_height_ > 0);
+ return text_height_ + 2 * kTextFilterPadding;
+}
+
void WindowSelector::CancelSelection() {
delegate_->OnSelectionEnded();
}
@@ -402,7 +384,7 @@ void WindowSelector::ContentsChanged(views::Textfield* sender,
if (should_show_selection_widget)
transform.Translate(0, 0);
else
- transform.Translate(0, -kTextFilterHeight);
+ transform.Translate(0, -TextFilterHeight());
text_filter_widget_->GetNativeWindow()->SetTransform(transform);
showing_selection_widget_ = should_show_selection_widget;
@@ -493,4 +475,53 @@ void WindowSelector::Move(Direction direction, bool animate) {
}
}
+views::Widget* WindowSelector::CreateTextFilter(
+ views::TextfieldController* controller,
+ aura::Window* root_window) {
flackr 2014/07/18 13:41:51 Seems like this could still be in the anonymous na
tdanderson 2014/08/07 20:13:07 Done.
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params;
+ params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
+ params.parent =
+ Shell::GetContainer(root_window, ash::kShellWindowId_OverlayContainer);
+ params.accept_events = true;
+ params.bounds = gfx::Rect(
+ root_window->bounds().width() / 2 * (1 - kTextFilterScreenProportion), 0,
+ root_window->bounds().width() * kTextFilterScreenProportion,
+ TextFilterHeight());
+ widget->Init(params);
+
+ views::View* container = new views::View;
+ container->set_background(
+ views::Background::CreateSolidBackground(SK_ColorBLACK));
+ container->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
+ kTextFilterPadding,
+ kTextFilterPadding,
+ kTextFilterPadding));
+
+ views::Textfield* textfield = new views::Textfield;
+ textfield->set_controller(controller);
+ textfield->SetBackgroundColor(SK_ColorTRANSPARENT);
+ textfield->SetBorder(views::Border::NullBorder());
+ textfield->SetTextColor(SK_ColorWHITE);
+ textfield->SetShadows(gfx::ShadowValues(1, gfx::ShadowValue(
+ gfx::Point(0, kVerticalShadowOffset), kShadowBlur, kTextFilterShadow)));
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ textfield->SetFontList(bundle.GetFontList(kTextFilterFontStyle));
+
+ container->AddChildView(textfield);
+ widget->SetContentsView(container);
+
+ gfx::Transform transform;
+ transform.Translate(0, -TextFilterHeight());
+ widget->GetNativeWindow()->SetTransform(transform);
+ widget->SetOpacity(kTextFilterOpacity);
+
+ widget->Show();
+ textfield->RequestFocus();
+
+ return widget;
+}
+
} // namespace ash
« ash/wm/overview/window_grid.cc ('K') | « ash/wm/overview/window_selector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698