- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / detachable_toolbar_view.h
1 // Copyright (c) 2012 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_DETACHABLE_TOOLBAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_DETACHABLE_TOOLBAR_VIEW_H_
7
8 #include "chrome/browser/ui/host_desktop.h"
9 #include "ui/views/accessible_pane_view.h"
10
11 struct SkRect;
12
13 // DetachableToolbarView contains functionality common to views that can detach
14 // from the Chrome frame, such as the BookmarkBarView and the Extension shelf.
15 class DetachableToolbarView : public views::AccessiblePaneView {
16  public:
17   // The color gradient start value close to the edge of the divider.
18   static const SkColor kEdgeDividerColor;
19   // The color gradient value for the middle of the divider.
20   static const SkColor kMiddleDividerColor;
21
22   DetachableToolbarView() {}
23   virtual ~DetachableToolbarView() {}
24
25   // Whether the view is currently detached from the Chrome frame.
26   virtual bool IsDetached() const = 0;
27
28   // Gets the current state of the resize animation (show/hide).
29   virtual double GetAnimationValue() const = 0;
30
31   // Gets the current amount of overlap atop the browser toolbar.
32   virtual int GetToolbarOverlap() const = 0;
33
34   // Paints the background (including the theme image behind content area) for
35   // the bar/shelf when it is attached to the top toolbar into |bounds|.
36   // |background_origin| is the origin to use for painting the theme image.
37   static void PaintBackgroundAttachedMode(
38       gfx::Canvas* canvas,
39       ui::ThemeProvider* theme_provider,
40       const gfx::Rect& bounds,
41       const gfx::Point& background_origin,
42      chrome::HostDesktopType host_desktop_type);
43
44   // Calculate the rect for the content area of the bar/shelf. This is only
45   // needed when the bar/shelf is detached from the Chrome frame (otherwise the
46   // content area is the whole area of the bar/shelf. When detached, however,
47   // only a small round rectangle is for drawing our content on. This calculates
48   // how big this area is, where it is located within the shelf and how round
49   // the edges should be.
50   static void CalculateContentArea(double animation_state,
51                                    double horizontal_padding,
52                                    double vertical_padding,
53                                    SkRect* rect,
54                                    double* roundness,
55                                    views::View* view);
56
57   // Paint the horizontal border separating the shelf/bar from the toolbar or
58   // page content according to |at_top| with |color|.
59   static void PaintHorizontalBorder(gfx::Canvas* canvas,
60                                     DetachableToolbarView* view,
61                                     bool at_top,
62                                     SkColor color);
63
64   // Paint the background of the content area (the surface behind the
65   // bookmarks). |rect| is the rectangle to paint the background within.
66   // |roundness| describes the roundness of the corners.
67   static void PaintContentAreaBackground(gfx::Canvas* canvas,
68                                          ui::ThemeProvider* theme_provider,
69                                          const SkRect& rect,
70                                          double roundness);
71   // Paint the border around the content area (when in detached mode).
72   static void PaintContentAreaBorder(gfx::Canvas* canvas,
73                                      ui::ThemeProvider* theme_provider,
74                                      const SkRect& rect,
75                                      double roundness);
76
77   // Paint a themed gradient divider at location |x|. |height| is the full
78   // height of the view you want to paint the divider into, not the height of
79   // the divider. The height of the divider will become:
80   //   |height| - 2 * |vertical_padding|.
81   // The color of the divider is a gradient starting with |top_color| at the
82   // top, and changing into |middle_color| and then over to |bottom_color| as
83   // you go further down.
84   static void PaintVerticalDivider(gfx::Canvas* canvas,
85                                    int x,
86                                    int height,
87                                    int vertical_padding,
88                                    SkColor top_color,
89                                    SkColor middle_color,
90                                    SkColor bottom_color);
91
92  private:
93   DISALLOW_COPY_AND_ASSIGN(DetachableToolbarView);
94 };
95
96 #endif  // CHROME_BROWSER_UI_VIEWS_DETACHABLE_TOOLBAR_VIEW_H_