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