#include "ui/aura/window_tracker.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/display_observer.h"
+#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/wm/public/activation_change_observer.h"
namespace aura {
class LocatedEvent;
}
+namespace views {
+class Textfield;
+class Widget;
+}
+
namespace ash {
class WindowSelectorDelegate;
class WindowSelectorItem;
// The WindowSelector shows a grid of all of your windows, allowing to select
// one by clicking or tapping on it.
class ASH_EXPORT WindowSelector
- : public ui::EventHandler,
- public gfx::DisplayObserver,
+ : public gfx::DisplayObserver,
public aura::WindowObserver,
- public aura::client::ActivationChangeObserver {
+ public aura::client::ActivationChangeObserver,
+ public views::TextfieldController {
public:
+ // The distance between the top edge of the screen and the bottom edge of
+ // the text filtering textfield.
+ static const int kTextFilterBottomEdge;
+
enum Direction {
LEFT,
UP,
// Called when the last window selector item from a grid is deleted.
void OnGridEmpty(WindowGrid* grid);
- // ui::EventHandler:
- virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
-
// gfx::DisplayObserver:
virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
aura::Window* request_active,
aura::Window* actual_active) OVERRIDE;
+ // views::TextfieldController:
+ virtual void ContentsChanged(views::Textfield* sender,
+ const base::string16& new_contents) OVERRIDE;
+ virtual bool HandleKeyEvent(views::Textfield* sender,
+ const ui::KeyEvent& key_event) OVERRIDE;
+
private:
friend class WindowSelectorTest;
// Helper function that moves the selection widget to |direction| on the
// corresponding window grid.
- void Move(Direction direction);
+ void Move(Direction direction, bool animate);
// Tracks observed windows.
std::set<aura::Window*> observed_windows_;
// The number of items in the overview.
size_t num_items_;
+ // Indicates if we are showing the selection widget.
+ bool showing_selection_widget_;
+
+ // Window text filter widget. As the user writes on it, we filter the items
+ // in the overview. It is also responsible for handling overview key events,
+ // such as enter key to select.
+ scoped_ptr<views::Widget> text_filter_widget_;
+
+ // The current length of the string entered into the text filtering textfield.
+ size_t text_filter_string_length_;
+
+ // The number of times the text filtering textfield has been cleared of text
+ // during this overview mode session.
+ size_t num_times_textfield_cleared_;
+
DISALLOW_COPY_AND_ASSIGN(WindowSelector);
};