| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 5 #ifndef ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| 6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 FrameCaptionButton* close_button() const { | 58 FrameCaptionButton* close_button() const { |
| 59 return container_view_->close_button_; | 59 return container_view_->close_button_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 FrameCaptionButtonContainerView* container_view_; | 63 FrameCaptionButtonContainerView* container_view_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(TestApi); | 65 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // Sets the resource ids of the images to paint the button for |icon|. The | 68 // Sets the resource id of the image to paint the button for |icon|. The |
| 69 // FrameCaptionButtonContainerView will keep track of the images to use for | 69 // FrameCaptionButtonContainerView will keep track of the image to use for |
| 70 // |icon| even if none of the buttons currently use |icon|. | 70 // |icon| even if none of the buttons currently use |icon|. |
| 71 void SetButtonImages(CaptionButtonIcon icon, | 71 void SetButtonImage(CaptionButtonIcon icon, int icon_image_id); |
| 72 int icon_image_id, | |
| 73 int hovered_background_image_id, | |
| 74 int pressed_background_image_id); | |
| 75 | 72 |
| 76 // Sets whether the buttons should be painted as active. Does not schedule | 73 // Sets whether the buttons should be painted as active. Does not schedule |
| 77 // a repaint. | 74 // a repaint. |
| 78 void SetPaintAsActive(bool paint_as_active); | 75 void SetPaintAsActive(bool paint_as_active); |
| 79 | 76 |
| 80 // Tell the window controls to reset themselves to the normal state. | 77 // Tell the window controls to reset themselves to the normal state. |
| 81 void ResetWindowControls(); | 78 void ResetWindowControls(); |
| 82 | 79 |
| 83 // Determines the window HT* code for the caption button at |point|. Returns | 80 // Determines the window HT* code for the caption button at |point|. Returns |
| 84 // HTNOWHERE if |point| is not over any of the caption buttons. |point| must | 81 // HTNOWHERE if |point| is not over any of the caption buttons. |point| must |
| 85 // be in the coordinates of the FrameCaptionButtonContainerView. | 82 // be in the coordinates of the FrameCaptionButtonContainerView. |
| 86 int NonClientHitTest(const gfx::Point& point) const; | 83 int NonClientHitTest(const gfx::Point& point) const; |
| 87 | 84 |
| 88 // Updates the size button's visibility based on whether |frame_| can be | 85 // Updates the size button's visibility based on whether |frame_| can be |
| 89 // maximized and if maximize mode is enabled. A parent view should relayout | 86 // maximized and if maximize mode is enabled. A parent view should relayout |
| 90 // to reflect the change in visibility. | 87 // to reflect the change in visibility. |
| 91 void UpdateSizeButtonVisibility(); | 88 void UpdateSizeButtonVisibility(); |
| 92 | 89 |
| 90 // Sets the size of the buttons in this container. |
| 91 void SetButtonSize(const gfx::Size& size); |
| 92 |
| 93 // views::View: | 93 // views::View: |
| 94 gfx::Size GetPreferredSize() const override; | 94 gfx::Size GetPreferredSize() const override; |
| 95 void Layout() override; | 95 void Layout() override; |
| 96 const char* GetClassName() const override; | 96 const char* GetClassName() const override; |
| 97 | 97 |
| 98 // Overridden from gfx::AnimationDelegate: | 98 // gfx::AnimationDelegate: |
| 99 void AnimationEnded(const gfx::Animation* animation) override; | 99 void AnimationEnded(const gfx::Animation* animation) override; |
| 100 void AnimationProgressed(const gfx::Animation* animation) override; | 100 void AnimationProgressed(const gfx::Animation* animation) override; |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 friend class FrameCaptionButtonContainerViewTest; | 103 friend class FrameCaptionButtonContainerViewTest; |
| 104 | 104 |
| 105 struct ButtonIconIds { | |
| 106 ButtonIconIds(); | |
| 107 ButtonIconIds(int icon_id, | |
| 108 int hovered_background_id, | |
| 109 int pressed_background_id); | |
| 110 ~ButtonIconIds(); | |
| 111 | |
| 112 int icon_image_id; | |
| 113 int hovered_background_image_id; | |
| 114 int pressed_background_image_id; | |
| 115 }; | |
| 116 | |
| 117 // Sets |button|'s icon to |icon|. If |animate| is ANIMATE_YES, the button | 105 // Sets |button|'s icon to |icon|. If |animate| is ANIMATE_YES, the button |
| 118 // will crossfade to the new icon. If |animate| is ANIMATE_NO and | 106 // will crossfade to the new icon. If |animate| is ANIMATE_NO and |
| 119 // |icon| == |button|->icon(), the crossfade animation is progressed to the | 107 // |icon| == |button|->icon(), the crossfade animation is progressed to the |
| 120 // end. | 108 // end. |
| 121 void SetButtonIcon(FrameCaptionButton* button, | 109 void SetButtonIcon(FrameCaptionButton* button, |
| 122 CaptionButtonIcon icon, | 110 CaptionButtonIcon icon, |
| 123 Animate animate); | 111 Animate animate); |
| 124 | 112 |
| 125 // Returns true if maximize mode is not enabled, and |frame_| widget delegate | 113 // Returns true if maximize mode is not enabled, and |frame_| widget delegate |
| 126 // can be maximized. | 114 // can be maximized. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 142 | 130 |
| 143 // The widget that the buttons act on. | 131 // The widget that the buttons act on. |
| 144 views::Widget* frame_; | 132 views::Widget* frame_; |
| 145 | 133 |
| 146 // The buttons. In the normal button style, at most one of |minimize_button_| | 134 // The buttons. In the normal button style, at most one of |minimize_button_| |
| 147 // and |size_button_| is visible. | 135 // and |size_button_| is visible. |
| 148 FrameCaptionButton* minimize_button_; | 136 FrameCaptionButton* minimize_button_; |
| 149 FrameCaptionButton* size_button_; | 137 FrameCaptionButton* size_button_; |
| 150 FrameCaptionButton* close_button_; | 138 FrameCaptionButton* close_button_; |
| 151 | 139 |
| 152 // Mapping of the images needed to paint a button for each of the values of | 140 // Mapping of the image ID needed to paint a button for each of the values of |
| 153 // CaptionButtonIcon. | 141 // CaptionButtonIcon. |
| 154 std::map<CaptionButtonIcon, ButtonIconIds> button_icon_id_map_; | 142 std::map<CaptionButtonIcon, int> button_icon_id_map_; |
| 155 | 143 |
| 156 // Animation that affects the position of |minimize_button_| and the | 144 // Animation that affects the position of |minimize_button_| and the |
| 157 // visibility of |size_button_|. | 145 // visibility of |size_button_|. |
| 158 scoped_ptr<gfx::SlideAnimation> maximize_mode_animation_; | 146 scoped_ptr<gfx::SlideAnimation> maximize_mode_animation_; |
| 159 | 147 |
| 160 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); | 148 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); |
| 161 }; | 149 }; |
| 162 | 150 |
| 163 } // namespace ash | 151 } // namespace ash |
| 164 | 152 |
| 165 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 153 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| OLD | NEW |