| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_H_ |
| 6 #define CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_H_ | 6 #define CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_H_ |
| 7 | 7 |
| 8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
| 9 #include "app/slide_animation.h" | 9 #include "app/slide_animation.h" |
| 10 #include "chrome/browser/views/tabs/side_tab_strip_model.h" | 10 #include "chrome/browser/views/tabs/side_tab_strip_model.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 #include "views/controls/button/button.h" | 12 #include "views/controls/button/button.h" |
| 13 #include "views/view.h" | 13 #include "views/view.h" |
| 14 | 14 |
| 15 class SideTab; | 15 class SideTab; |
| 16 | 16 |
| 17 class SideTabModel { | 17 class SideTabModel { |
| 18 public: | 18 public: |
| 19 // Returns metadata about the specified |tab|. | 19 // Returns metadata about the specified |tab|. |
| 20 virtual string16 GetTitle(SideTab* tab) const = 0; | 20 virtual string16 GetTitle(SideTab* tab) const = 0; |
| 21 virtual SkBitmap GetIcon(SideTab* tab) const = 0; | 21 virtual SkBitmap GetIcon(SideTab* tab) const = 0; |
| 22 virtual bool IsSelected(SideTab* tab) const = 0; | 22 virtual bool IsSelected(SideTab* tab) const = 0; |
| 23 | 23 |
| 24 // Selects the tab. | 24 // Selects the tab. |
| 25 virtual void SelectTab(SideTab* tab) = 0; | 25 virtual void SelectTab(SideTab* tab) = 0; |
| 26 | 26 |
| 27 // Closes the tab. | 27 // Closes the tab. |
| 28 virtual void CloseTab(SideTab* tab) = 0; | 28 virtual void CloseTab(SideTab* tab) = 0; |
| 29 | |
| 30 // Shows a context menu for the tab at the specified point in screen coords. | |
| 31 virtual void ShowContextMenu(SideTab* tab, const gfx::Point& p) = 0; | |
| 32 }; | 29 }; |
| 33 | 30 |
| 34 class SideTab : public views::View, | 31 class SideTab : public views::View, |
| 35 public views::ContextMenuController, | |
| 36 public views::ButtonListener, | 32 public views::ButtonListener, |
| 37 public AnimationDelegate { | 33 public AnimationDelegate { |
| 38 public: | 34 public: |
| 39 explicit SideTab(SideTabModel* model); | 35 explicit SideTab(SideTabModel* model); |
| 40 virtual ~SideTab(); | 36 virtual ~SideTab(); |
| 41 | 37 |
| 42 // Sets the current network state of the tab. The tab renders different | 38 // Sets the current network state of the tab. The tab renders different |
| 43 // animations in place of the icon when different types of network activity | 39 // animations in place of the icon when different types of network activity |
| 44 // are occurring. | 40 // are occurring. |
| 45 void SetNetworkState(SideTabStripModel::NetworkState state); | 41 void SetNetworkState(SideTabStripModel::NetworkState state); |
| 46 | 42 |
| 47 // AnimationDelegate implementation: | 43 // AnimationDelegate implementation: |
| 48 virtual void AnimationProgressed(const Animation* animation); | 44 virtual void AnimationProgressed(const Animation* animation); |
| 49 virtual void AnimationCanceled(const Animation* animation); | 45 virtual void AnimationCanceled(const Animation* animation); |
| 50 virtual void AnimationEnded(const Animation* animation); | 46 virtual void AnimationEnded(const Animation* animation); |
| 51 | 47 |
| 52 // views::ButtonListener implementation: | 48 // views::ButtonListener implementation: |
| 53 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 49 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 54 | 50 |
| 55 // views::ContextMenuController implementation: | |
| 56 virtual void ShowContextMenu(views::View* source, | |
| 57 const gfx::Point& p, | |
| 58 bool is_mouse_gesture); | |
| 59 | |
| 60 // views::View Overrides: | 51 // views::View Overrides: |
| 61 virtual void Layout(); | 52 virtual void Layout(); |
| 62 virtual void Paint(gfx::Canvas* canvas); | 53 virtual void Paint(gfx::Canvas* canvas); |
| 63 virtual gfx::Size GetPreferredSize(); | 54 virtual gfx::Size GetPreferredSize(); |
| 64 virtual void OnMouseEntered(const views::MouseEvent& event); | 55 virtual void OnMouseEntered(const views::MouseEvent& event); |
| 65 virtual void OnMouseExited(const views::MouseEvent& event); | 56 virtual void OnMouseExited(const views::MouseEvent& event); |
| 66 virtual bool OnMousePressed(const views::MouseEvent& event); | 57 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 67 | 58 |
| 68 private: | 59 private: |
| 69 void FillTabShapePath(gfx::Path* path); | 60 void FillTabShapePath(gfx::Path* path); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 94 // The current network state for this tab. | 85 // The current network state for this tab. |
| 95 SideTabStripModel::NetworkState current_state_; | 86 SideTabStripModel::NetworkState current_state_; |
| 96 | 87 |
| 97 // The current index into the Animation image strip. | 88 // The current index into the Animation image strip. |
| 98 int loading_animation_frame_; | 89 int loading_animation_frame_; |
| 99 | 90 |
| 100 DISALLOW_COPY_AND_ASSIGN(SideTab); | 91 DISALLOW_COPY_AND_ASSIGN(SideTab); |
| 101 }; | 92 }; |
| 102 | 93 |
| 103 #endif // CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_H_ | 94 #endif // CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_H_ |
| OLD | NEW |