Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / ash / system / tray / actionable_view.h
blob0d0f1a1c30a40a906c47766fe4a74ac9b8e01234
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_
6 #define ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "ui/views/view.h"
13 namespace ash {
14 namespace internal {
16 // A focusable view that performs an action when user clicks on it, or presses
17 // enter or space when focused. Note that the action is triggered on mouse-up,
18 // instead of on mouse-down. So if user presses the mouse on the view, then
19 // moves the mouse out of the view and then releases, then the action will not
20 // be performed.
21 // Exported for SystemTray.
22 class ASH_EXPORT ActionableView : public views::View {
23 public:
24 ActionableView();
26 virtual ~ActionableView();
28 void SetAccessibleName(const base::string16& name);
29 const base::string16& accessible_name() const { return accessible_name_; }
31 static const char kViewClassName[];
33 protected:
34 void DrawBorder(gfx::Canvas* canvas, const gfx::Rect& bounds);
36 // Performs an action when user clicks on the view (on mouse-press event), or
37 // presses a key when this view is in focus. Returns true if the event has
38 // been handled and an action was performed. Returns false otherwise.
39 virtual bool PerformAction(const ui::Event& event) = 0;
41 // Overridden from views::View.
42 virtual const char* GetClassName() const OVERRIDE;
43 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
44 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
45 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
46 virtual void OnMouseCaptureLost() OVERRIDE;
47 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
48 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
50 // Overridden from ui::EventHandler.
51 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
53 private:
54 base::string16 accessible_name_;
55 bool has_capture_;
57 DISALLOW_COPY_AND_ASSIGN(ActionableView);
60 } // namespace internal
61 } // namespace ash
63 #endif // ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_