summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs/tab_overview_grid.h
blob: afb4abaf809ffdc49213028ca542ab5372467d4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_GRID_H_
#define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_GRID_H_

#include "base/scoped_ptr.h"
#include "chrome/browser/views/tabs/grid.h"

class TabOverviewCell;
class TabOverviewController;
class TabOverviewDragController;

// TabOverviewGrid is used to provide a grid view of the contents of a tab
// strip model. Each cell of the grid is a TabOverviewCell. TabOverviewGrids
// primary responsibility is to forward events to TabOverviewDragController.
class TabOverviewGrid : public Grid {
 public:
  explicit TabOverviewGrid(TabOverviewController* controller);
  virtual ~TabOverviewGrid();

  // Returns true if a drag is underway and the drag is in the process of
  // modifying the tab strip model.
  bool modifying_model() const;

  // Returns the TabOverviewCell at the specified index.
  TabOverviewCell* GetTabOverviewCellAt(int index);

  // Cancels the drag. Does nothing if a drag is not underway.
  void CancelDrag();

  // If a drag is under way, this invokes Drag on the DragController with the
  // current position of the mouse.
  void UpdateDragController();

  // View overrides.
  virtual bool OnMousePressed(const views::MouseEvent& event);
  virtual bool OnMouseDragged(const views::MouseEvent& event);
  virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);

  // AnimationDelegate overrides.
  virtual void AnimationEnded(const Animation* animation);
  virtual void AnimationProgressed(const Animation* animation);
  virtual void AnimationCanceled(const Animation* animation);

 private:
  TabOverviewController* controller_;

  scoped_ptr<TabOverviewDragController> drag_controller_;

  DISALLOW_COPY_AND_ASSIGN(TabOverviewGrid);
};

#endif  // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_GRID_H_