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

Unified Diff: ash/shelf/shelf.h

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ash/shelf/shelf_widget.cc for browser_tests crash... Created 4 years, 10 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 | « ash/shelf/overflow_button.cc ('k') | ash/shelf/shelf.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf.h
diff --git a/ash/shelf/shelf.h b/ash/shelf/shelf.h
index 59cb0099ed30c6b1940734042f17fdf1e162b3de..c00895f204b9b5581f529b10eb13b89edb92ac65 100644
--- a/ash/shelf/shelf.h
+++ b/ash/shelf/shelf.h
@@ -8,6 +8,7 @@
#include "ash/ash_export.h"
#include "ash/shelf/shelf_constants.h"
#include "ash/shelf/shelf_types.h"
+#include "ash/shelf/shelf_widget.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/geometry/size.h"
@@ -35,13 +36,11 @@ class ShelfDelegate;
class ShelfIconObserver;
class ShelfModel;
class ShelfView;
-class ShelfWidget;
namespace test {
class ShelfTestAPI;
}
-
class ASH_EXPORT Shelf {
public:
static const char kNativeViewName[];
@@ -53,12 +52,36 @@ class ASH_EXPORT Shelf {
static Shelf* ForPrimaryDisplay();
// Return the shelf for the display that |window| is currently on, or a shelf
- // on primary display if the shelf per display feature is disabled. NULL if
- // no user is logged in yet.
- static Shelf* ForWindow(aura::Window* window);
+ // on primary display if the shelf per display feature is disabled. NULL if no
+ // user is logged in yet.
+ static Shelf* ForWindow(const aura::Window* window);
void SetAlignment(ShelfAlignment alignment);
ShelfAlignment alignment() const { return alignment_; }
+ bool IsHorizontalAlignment() const;
+
+ // A helper functions that chooses values specific to a shelf alignment.
+ template <typename T>
+ T SelectValueForShelfAlignment(T bottom, T left, T right, T top) const {
+ switch (alignment_) {
+ 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 right;
+ }
+
+ // A helper functions that chooses values specific to a shelf alignment type.
+ template <typename T>
+ T PrimaryAxisValue(T horizontal, T vertical) const {
+ return IsHorizontalAlignment() ? horizontal : vertical;
+ }
// Returns the screen bounds of the item for the specified window. If there is
// no item for the specified window an empty rect is returned.
@@ -96,6 +119,11 @@ class ASH_EXPORT Shelf {
ShelfWidget* shelf_widget() { return shelf_widget_; }
+ // TODO(msw): ShelfLayoutManager should not be accessed externally.
+ ShelfLayoutManager* shelf_layout_manager() {
+ return shelf_widget_->shelf_layout_manager();
+ }
+
// Set the bounds of the shelf view.
void SetShelfViewBounds(gfx::Rect bounds);
gfx::Rect GetShelfViewBounds() const;
« no previous file with comments | « ash/shelf/overflow_button.cc ('k') | ash/shelf/shelf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698