OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_TAB_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_TAB_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/ui/views/sidebar/sidebar_base_tab.h" |
| 14 #include "gfx/point.h" |
| 15 |
| 16 namespace ui { |
| 17 class SlideAnimation; |
| 18 } // namespace ui |
| 19 |
| 20 // A View that renders a SidebarTab in a SidebarTabStrip. |
| 21 // Does the actual layout and painting, loads the actual image resources. |
| 22 class SidebarTab : public SidebarBaseTab { |
| 23 public: |
| 24 static const char kViewClassName[]; |
| 25 |
| 26 explicit SidebarTab(SidebarTabController* controller); |
| 27 virtual ~SidebarTab(); |
| 28 |
| 29 // SidebarBaseTab overrides: |
| 30 virtual void GetShape(gfx::Path* shape) const; |
| 31 |
| 32 // Returns the minimum possible size of a single unselected tab. |
| 33 static gfx::Size GetMinimumUnselectedSize(); |
| 34 // Returns the minimum possible size of a selected tab. Selected tabs must |
| 35 // always have a larger minimum size than unselected tabs. |
| 36 static gfx::Size GetMinimumSelectedSize(); |
| 37 // Returns the preferred size of a single tab, assuming space is |
| 38 // available. |
| 39 static gfx::Size GetStandardSize(); |
| 40 |
| 41 protected: |
| 42 // SidebarBaseTab overrides: |
| 43 virtual void DataChanged(const SidebarTabRendererData& old_data) OVERRIDE; |
| 44 |
| 45 private: |
| 46 struct TabImage; |
| 47 struct TabImages; |
| 48 |
| 49 // Overridden from views::View: |
| 50 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; |
| 51 virtual void Layout() OVERRIDE; |
| 52 virtual void OnThemeChanged() OVERRIDE; |
| 53 virtual std::string GetClassName() const OVERRIDE { return kViewClassName; } |
| 54 virtual bool HasHitTestMask() const OVERRIDE; |
| 55 virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; |
| 56 virtual bool GetTooltipTextOrigin(const gfx::Point& p, |
| 57 gfx::Point* origin) OVERRIDE; |
| 58 |
| 59 // Returns cached tab background images. |
| 60 static TabImages& tab_images(); |
| 61 |
| 62 // Paint various portions of the tab |
| 63 void PaintTabBackground(gfx::Canvas* canvas); |
| 64 void PaintTabBackgroundImage(gfx::Canvas* canvas, bool as_active); |
| 65 // Paints the icon. Most of the time you'll want to invoke Paint directly, but |
| 66 // in certain situations this invoked outside of Paint. |
| 67 void PaintIcon(gfx::Canvas* canvas); |
| 68 // Paints badge text. |
| 69 void PaintBadge(gfx::Canvas* canvas); |
| 70 |
| 71 // The bounds of the various sections of the display. |
| 72 gfx::Rect icon_bounds_; |
| 73 |
| 74 // Hover animation. |
| 75 scoped_ptr<ui::SlideAnimation> hover_animation_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(SidebarTab); |
| 78 }; |
| 79 |
| 80 #endif // CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_TAB_H_ |
| 81 |
OLD | NEW |