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