| 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_DROPDOWN_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_VIEW_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/views/dropdown_bar_host.h" | 8 #include "chrome/browser/ui/views/dropdown_bar_host.h" |
| 9 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" | 9 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" |
| 10 #include "ui/views/accessible_pane_view.h" | 10 #include "ui/views/accessible_pane_view.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 class Canvas; | 13 class Canvas; |
| 14 class ImageSkia; | 14 class ImageSkia; |
| 15 } // namespace gfx | 15 } // namespace gfx |
| 16 | 16 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
| 18 // | 18 // |
| 19 // The DropdownBarView is an abstract view to draw the UI controls of the | 19 // The DropdownBarView is an abstract view to draw the UI controls of the |
| 20 // DropdownBarHost. | 20 // DropdownBarHost. |
| 21 // | 21 // |
| 22 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 23 class DropdownBarView : public views::AccessiblePaneView, | 23 class DropdownBarView : public views::AccessiblePaneView, |
| 24 public DropdownBarHostDelegate { | 24 public DropdownBarHostDelegate { |
| 25 public: | 25 public: |
| 26 explicit DropdownBarView(DropdownBarHost* host); | 26 explicit DropdownBarView(DropdownBarHost* host); |
| 27 ~DropdownBarView() override; | 27 ~DropdownBarView() override; |
| 28 | 28 |
| 29 // Updates the view to let it know where the host is clipping the | |
| 30 // dropdown widget (while animating the opening or closing of the widget). | |
| 31 void SetAnimationOffset(int offset) override; | |
| 32 | |
| 33 // Returns the offset used while animating. | |
| 34 int animation_offset() const { return animation_offset_; } | |
| 35 | |
| 36 protected: | 29 protected: |
| 37 // views::View: | |
| 38 void OnPaint(gfx::Canvas* canvas) override; | |
| 39 | |
| 40 // Returns the DropdownBarHost that manages this view. | 30 // Returns the DropdownBarHost that manages this view. |
| 41 DropdownBarHost* host() const { return host_; } | 31 DropdownBarHost* host() const { return host_; } |
| 42 | 32 |
| 43 void SetBackground(const gfx::ImageSkia* left_alpha_mask, | 33 void SetBackground(const gfx::ImageSkia* left_alpha_mask, |
| 44 const gfx::ImageSkia* right_alpha_mask); | 34 const gfx::ImageSkia* right_alpha_mask); |
| 45 void SetBorderFromIds(int left_border_image_id, | 35 void SetBorderFromIds(int left_border_image_id, |
| 46 int middle_border_image_id, | 36 int middle_border_image_id, |
| 47 int right_border_image_id); | 37 int right_border_image_id); |
| 48 | 38 |
| 49 private: | 39 private: |
| 50 // The dropdown bar host that controls this view. | 40 // The dropdown bar host that controls this view. |
| 51 DropdownBarHost* host_; | 41 DropdownBarHost* host_; |
| 52 | 42 |
| 53 // While animating, the host clips the widget and draws only the bottom | |
| 54 // part of it. The view needs to know the pixel offset at which we are drawing | |
| 55 // the widget so that we can draw the curved edges that attach to the toolbar | |
| 56 // in the right location. | |
| 57 int animation_offset_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(DropdownBarView); | 43 DISALLOW_COPY_AND_ASSIGN(DropdownBarView); |
| 60 }; | 44 }; |
| 61 #endif // CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_VIEW_H_ | 45 #endif // CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_VIEW_H_ |
| OLD | NEW |