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

Unified Diff: mash/shelf/shelf_button_host.h

Issue 1585363002: Fork a subset of ash/shelf for use in mash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ui/resources dep; comment out unused constants. Created 4 years, 11 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
« no previous file with comments | « mash/shelf/shelf_button.cc ('k') | mash/shelf/shelf_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mash/shelf/shelf_button_host.h
diff --git a/ash/shelf/shelf_button_host.h b/mash/shelf/shelf_button_host.h
similarity index 60%
copy from ash/shelf/shelf_button_host.h
copy to mash/shelf/shelf_button_host.h
index b664c7f407777d18f7cad77671fb379c76f0b8ee..4111fdd2c797ec6c64426805f2e8b3e607d87e4e 100644
--- a/ash/shelf/shelf_button_host.h
+++ b/mash/shelf/shelf_button_host.h
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_SHELF_SHELF_BUTTON_HOST_H_
-#define ASH_SHELF_SHELF_BUTTON_HOST_H_
+#ifndef MASH_SHELF_SHELF_BUTTON_HOST_H_
+#define MASH_SHELF_SHELF_BUTTON_HOST_H_
-#include "ash/ash_export.h"
+#include "base/logging.h"
#include "base/strings/string16.h"
+#include "mash/shelf/shelf_types.h"
namespace ui {
class LocatedEvent;
@@ -16,11 +17,13 @@ namespace views {
class View;
}
-namespace ash {
+namespace mash {
+namespace shelf {
+// TODO(msw): Eliminate this abstraction and just pass pointers to ShelfView?
// The shelf buttons communicate back to the host by way of this interface.
// This interface is used to enable reordering the items on the shelf.
-class ASH_EXPORT ShelfButtonHost {
+class ShelfButtonHost {
public:
enum Pointer {
NONE,
@@ -29,6 +32,29 @@ class ASH_EXPORT ShelfButtonHost {
TOUCH,
};
+ virtual ShelfAlignment GetAlignment() const = 0;
+
+ virtual bool IsHorizontalAlignment() const = 0;
+
+ // Helper function for choosing values specific to the shelf alignment.
+ template<typename T>
+ T PrimaryAxisValue(T horizontal, T vertical) const {
+ return IsHorizontalAlignment() ? horizontal : vertical;
+ }
+
+ // Helper function for choosing values specific to the shelf alignment.
+ template<typename T>
+ T SelectValueForShelfAlignment(T bottom, T left, T right, T top) const {
+ switch (GetAlignment()) {
+ case SHELF_ALIGNMENT_BOTTOM: return bottom;
+ case SHELF_ALIGNMENT_LEFT: return left;
+ case SHELF_ALIGNMENT_RIGHT: return right;
+ case SHELF_ALIGNMENT_TOP: return top;
+ }
+ NOTREACHED();
+ return bottom;
+ }
+
// Invoked when a pointer device is pressed on a view.
virtual void PointerPressedOnButton(views::View* view,
Pointer pointer,
@@ -60,6 +86,7 @@ class ASH_EXPORT ShelfButtonHost {
virtual ~ShelfButtonHost() {}
};
-} // namespace ash
+} // namespace shelf
+} // namespace mash
-#endif // ASH_SHELF_SHELF_BUTTON_HOST_H_
+#endif // MASH_SHELF_SHELF_BUTTON_HOST_H_
« no previous file with comments | « mash/shelf/shelf_button.cc ('k') | mash/shelf/shelf_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698