| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_UI_VIEWS_DETACHABLE_TOOLBAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DETACHABLE_TOOLBAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_DETACHABLE_TOOLBAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DETACHABLE_TOOLBAR_VIEW_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/host_desktop.h" | 8 #include "chrome/browser/ui/host_desktop.h" |
| 9 #include "ui/views/accessible_pane_view.h" | 9 #include "ui/views/accessible_pane_view.h" |
| 10 | 10 |
| 11 struct SkRect; | 11 struct SkRect; |
| 12 | 12 |
| 13 // DetachableToolbarView contains functionality common to views that can detach | 13 // DetachableToolbarView contains functionality common to views that can detach |
| 14 // from the Chrome frame, such as the BookmarkBarView and the Extension shelf. | 14 // from the Chrome frame, such as the BookmarkBarView and the Extension shelf. |
| 15 class DetachableToolbarView : public views::AccessiblePaneView { | 15 class DetachableToolbarView : public views::AccessiblePaneView { |
| 16 public: | 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() {} | 17 DetachableToolbarView() {} |
| 23 ~DetachableToolbarView() override {} | 18 ~DetachableToolbarView() override {} |
| 24 | 19 |
| 25 // Whether the view is currently detached from the Chrome frame. | 20 // Whether the view is currently detached from the Chrome frame. |
| 26 virtual bool IsDetached() const = 0; | 21 virtual bool IsDetached() const = 0; |
| 27 | 22 |
| 28 // Gets the current state of the resize animation (show/hide). | 23 // Gets the current state of the resize animation (show/hide). |
| 29 virtual double GetAnimationValue() const = 0; | 24 virtual double GetAnimationValue() const = 0; |
| 30 | 25 |
| 31 // Gets the current amount of overlap atop the browser toolbar. | 26 // Gets the current amount of overlap atop the browser toolbar. |
| 32 virtual int GetToolbarOverlap() const = 0; | 27 virtual int GetToolbarOverlap() const = 0; |
| 33 | 28 |
| 34 // Paints the background (including the theme image behind content area) for | 29 // 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|. | 30 // 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. | 31 // |background_origin| is the origin to use for painting the theme image. |
| 37 static void PaintBackgroundAttachedMode( | 32 static void PaintBackgroundAttachedMode( |
| 38 gfx::Canvas* canvas, | 33 gfx::Canvas* canvas, |
| 39 ui::ThemeProvider* theme_provider, | 34 ui::ThemeProvider* theme_provider, |
| 40 const gfx::Rect& bounds, | 35 const gfx::Rect& bounds, |
| 41 const gfx::Point& background_origin, | 36 const gfx::Point& background_origin, |
| 42 chrome::HostDesktopType host_desktop_type); | 37 chrome::HostDesktopType host_desktop_type); |
| 43 | 38 |
| 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 | 39 // Paint the horizontal border separating the shelf/bar from the toolbar or |
| 58 // page content according to |at_top| with |color|. | 40 // page content according to |at_top| with |color|. |
| 59 static void PaintHorizontalBorder(gfx::Canvas* canvas, | 41 static void PaintHorizontalBorder(gfx::Canvas* canvas, |
| 60 DetachableToolbarView* view, | 42 DetachableToolbarView* view, |
| 61 bool at_top, | 43 bool at_top, |
| 62 SkColor color); | 44 SkColor color); |
| 63 | 45 |
| 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 | 46 // 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 | 47 // 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: | 48 // the divider. The height of the divider will become: |
| 80 // |height| - 2 * |vertical_padding|. | 49 // |height| - 2 * |vertical_padding|. |
| 81 // The color of the divider is a gradient starting with |top_color| at the | 50 // 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 | 51 // top, and changing into |middle_color| and then over to |bottom_color| as |
| 83 // you go further down. | 52 // you go further down. |
| 84 static void PaintVerticalDivider(gfx::Canvas* canvas, | 53 static void PaintVerticalDivider(gfx::Canvas* canvas, |
| 85 int x, | 54 int x, |
| 86 int height, | 55 int height, |
| 87 int vertical_padding, | 56 int vertical_padding, |
| 88 SkColor top_color, | 57 SkColor top_color, |
| 89 SkColor middle_color, | 58 SkColor middle_color, |
| 90 SkColor bottom_color); | 59 SkColor bottom_color); |
| 91 | 60 |
| 92 private: | 61 private: |
| 93 DISALLOW_COPY_AND_ASSIGN(DetachableToolbarView); | 62 DISALLOW_COPY_AND_ASSIGN(DetachableToolbarView); |
| 94 }; | 63 }; |
| 95 | 64 |
| 96 #endif // CHROME_BROWSER_UI_VIEWS_DETACHABLE_TOOLBAR_VIEW_H_ | 65 #endif // CHROME_BROWSER_UI_VIEWS_DETACHABLE_TOOLBAR_VIEW_H_ |
| OLD | NEW |