OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_SHELF_SHELF_BUTTON_HOST_H_ | 5 #ifndef MASH_SHELF_SHELF_BUTTON_HOST_H_ |
6 #define ASH_SHELF_SHELF_BUTTON_HOST_H_ | 6 #define MASH_SHELF_SHELF_BUTTON_HOST_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "mash/shelf/shelf_types.h" |
10 | 11 |
11 namespace ui { | 12 namespace ui { |
12 class LocatedEvent; | 13 class LocatedEvent; |
13 } | 14 } |
14 | 15 |
15 namespace views { | 16 namespace views { |
16 class View; | 17 class View; |
17 } | 18 } |
18 | 19 |
19 namespace ash { | 20 namespace mash { |
| 21 namespace shelf { |
20 | 22 |
| 23 // TODO(msw): Eliminate this abstraction and just pass pointers to ShelfView? |
21 // The shelf buttons communicate back to the host by way of this interface. | 24 // The shelf buttons communicate back to the host by way of this interface. |
22 // This interface is used to enable reordering the items on the shelf. | 25 // This interface is used to enable reordering the items on the shelf. |
23 class ASH_EXPORT ShelfButtonHost { | 26 class ShelfButtonHost { |
24 public: | 27 public: |
25 enum Pointer { | 28 enum Pointer { |
26 NONE, | 29 NONE, |
27 DRAG_AND_DROP, | 30 DRAG_AND_DROP, |
28 MOUSE, | 31 MOUSE, |
29 TOUCH, | 32 TOUCH, |
30 }; | 33 }; |
31 | 34 |
| 35 virtual ShelfAlignment GetAlignment() const = 0; |
| 36 |
| 37 virtual bool IsHorizontalAlignment() const = 0; |
| 38 |
| 39 // Helper function for choosing values specific to the shelf alignment. |
| 40 template<typename T> |
| 41 T PrimaryAxisValue(T horizontal, T vertical) const { |
| 42 return IsHorizontalAlignment() ? horizontal : vertical; |
| 43 } |
| 44 |
| 45 // Helper function for choosing values specific to the shelf alignment. |
| 46 template<typename T> |
| 47 T SelectValueForShelfAlignment(T bottom, T left, T right, T top) const { |
| 48 switch (GetAlignment()) { |
| 49 case SHELF_ALIGNMENT_BOTTOM: return bottom; |
| 50 case SHELF_ALIGNMENT_LEFT: return left; |
| 51 case SHELF_ALIGNMENT_RIGHT: return right; |
| 52 case SHELF_ALIGNMENT_TOP: return top; |
| 53 } |
| 54 NOTREACHED(); |
| 55 return bottom; |
| 56 } |
| 57 |
32 // Invoked when a pointer device is pressed on a view. | 58 // Invoked when a pointer device is pressed on a view. |
33 virtual void PointerPressedOnButton(views::View* view, | 59 virtual void PointerPressedOnButton(views::View* view, |
34 Pointer pointer, | 60 Pointer pointer, |
35 const ui::LocatedEvent& event) = 0; | 61 const ui::LocatedEvent& event) = 0; |
36 | 62 |
37 // Invoked when a pointer device is dragged over a view. | 63 // Invoked when a pointer device is dragged over a view. |
38 virtual void PointerDraggedOnButton(views::View* view, | 64 virtual void PointerDraggedOnButton(views::View* view, |
39 Pointer pointer, | 65 Pointer pointer, |
40 const ui::LocatedEvent& event) = 0; | 66 const ui::LocatedEvent& event) = 0; |
41 | 67 |
(...skipping 11 matching lines...) Expand all Loading... |
53 // Invoked when the mouse exits the item. | 79 // Invoked when the mouse exits the item. |
54 virtual void MouseExitedButton(views::View* view) = 0; | 80 virtual void MouseExitedButton(views::View* view) = 0; |
55 | 81 |
56 // Invoked to get the accessible name of the item. | 82 // Invoked to get the accessible name of the item. |
57 virtual base::string16 GetAccessibleName(const views::View* view) = 0; | 83 virtual base::string16 GetAccessibleName(const views::View* view) = 0; |
58 | 84 |
59 protected: | 85 protected: |
60 virtual ~ShelfButtonHost() {} | 86 virtual ~ShelfButtonHost() {} |
61 }; | 87 }; |
62 | 88 |
63 } // namespace ash | 89 } // namespace shelf |
| 90 } // namespace mash |
64 | 91 |
65 #endif // ASH_SHELF_SHELF_BUTTON_HOST_H_ | 92 #endif // MASH_SHELF_SHELF_BUTTON_HOST_H_ |
OLD | NEW |