| 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 17 matching lines...) Expand all Loading... |
| 28 class ASH_EXPORT FrameCaptionButtonContainerView | 28 class ASH_EXPORT FrameCaptionButtonContainerView |
| 29 : public views::View, | 29 : public views::View, |
| 30 public views::ButtonListener, | 30 public views::ButtonListener, |
| 31 public FrameSizeButtonDelegate, | 31 public FrameSizeButtonDelegate, |
| 32 public gfx::AnimationDelegate { | 32 public gfx::AnimationDelegate { |
| 33 public: | 33 public: |
| 34 static const char kViewClassName[]; | 34 static const char kViewClassName[]; |
| 35 | 35 |
| 36 // |frame| is the views::Widget that the caption buttons act on. | 36 // |frame| is the views::Widget that the caption buttons act on. |
| 37 explicit FrameCaptionButtonContainerView(views::Widget* frame); | 37 explicit FrameCaptionButtonContainerView(views::Widget* frame); |
| 38 virtual ~FrameCaptionButtonContainerView(); | 38 ~FrameCaptionButtonContainerView() override; |
| 39 | 39 |
| 40 // For testing. | 40 // For testing. |
| 41 class ASH_EXPORT TestApi { | 41 class ASH_EXPORT TestApi { |
| 42 public: | 42 public: |
| 43 explicit TestApi(FrameCaptionButtonContainerView* container_view) | 43 explicit TestApi(FrameCaptionButtonContainerView* container_view) |
| 44 : container_view_(container_view) { | 44 : container_view_(container_view) { |
| 45 } | 45 } |
| 46 | 46 |
| 47 void EndAnimations(); | 47 void EndAnimations(); |
| 48 | 48 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // HTNOWHERE if |point| is not over any of the caption buttons. |point| must | 84 // HTNOWHERE if |point| is not over any of the caption buttons. |point| must |
| 85 // be in the coordinates of the FrameCaptionButtonContainerView. | 85 // be in the coordinates of the FrameCaptionButtonContainerView. |
| 86 int NonClientHitTest(const gfx::Point& point) const; | 86 int NonClientHitTest(const gfx::Point& point) const; |
| 87 | 87 |
| 88 // Updates the size button's visibility based on whether |frame_| can be | 88 // 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 | 89 // maximized and if maximize mode is enabled. A parent view should relayout |
| 90 // to reflect the change in visibility. | 90 // to reflect the change in visibility. |
| 91 void UpdateSizeButtonVisibility(); | 91 void UpdateSizeButtonVisibility(); |
| 92 | 92 |
| 93 // views::View: | 93 // views::View: |
| 94 virtual gfx::Size GetPreferredSize() const override; | 94 gfx::Size GetPreferredSize() const override; |
| 95 virtual void Layout() override; | 95 void Layout() override; |
| 96 virtual const char* GetClassName() const override; | 96 const char* GetClassName() const override; |
| 97 | 97 |
| 98 // Overridden from gfx::AnimationDelegate: | 98 // Overridden from gfx::AnimationDelegate: |
| 99 virtual void AnimationEnded(const gfx::Animation* animation) override; | 99 void AnimationEnded(const gfx::Animation* animation) override; |
| 100 virtual 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 { | 105 struct ButtonIconIds { |
| 106 ButtonIconIds(); | 106 ButtonIconIds(); |
| 107 ButtonIconIds(int icon_id, | 107 ButtonIconIds(int icon_id, |
| 108 int inactive_icon_id, | 108 int inactive_icon_id, |
| 109 int hovered_background_id, | 109 int hovered_background_id, |
| 110 int pressed_background_id); | 110 int pressed_background_id); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 122 // end. | 122 // end. |
| 123 void SetButtonIcon(FrameCaptionButton* button, | 123 void SetButtonIcon(FrameCaptionButton* button, |
| 124 CaptionButtonIcon icon, | 124 CaptionButtonIcon icon, |
| 125 Animate animate); | 125 Animate animate); |
| 126 | 126 |
| 127 // Returns true if maximize mode is not enabled, and |frame_| widget delegate | 127 // Returns true if maximize mode is not enabled, and |frame_| widget delegate |
| 128 // can be maximized. | 128 // can be maximized. |
| 129 bool ShouldSizeButtonBeVisible() const; | 129 bool ShouldSizeButtonBeVisible() const; |
| 130 | 130 |
| 131 // views::ButtonListener: | 131 // views::ButtonListener: |
| 132 virtual void ButtonPressed(views::Button* sender, | 132 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 133 const ui::Event& event) override; | |
| 134 | 133 |
| 135 // FrameSizeButtonDelegate: | 134 // FrameSizeButtonDelegate: |
| 136 virtual bool IsMinimizeButtonVisible() const override; | 135 bool IsMinimizeButtonVisible() const override; |
| 137 virtual void SetButtonsToNormal(Animate animate) override; | 136 void SetButtonsToNormal(Animate animate) override; |
| 138 virtual void SetButtonIcons(CaptionButtonIcon minimize_button_icon, | 137 void SetButtonIcons(CaptionButtonIcon minimize_button_icon, |
| 139 CaptionButtonIcon close_button_icon, | 138 CaptionButtonIcon close_button_icon, |
| 140 Animate animate) override; | 139 Animate animate) override; |
| 141 virtual const FrameCaptionButton* GetButtonClosestTo( | 140 const FrameCaptionButton* GetButtonClosestTo( |
| 142 const gfx::Point& position_in_screen) const override; | 141 const gfx::Point& position_in_screen) const override; |
| 143 virtual void SetHoveredAndPressedButtons( | 142 void SetHoveredAndPressedButtons(const FrameCaptionButton* to_hover, |
| 144 const FrameCaptionButton* to_hover, | 143 const FrameCaptionButton* to_press) override; |
| 145 const FrameCaptionButton* to_press) override; | |
| 146 | 144 |
| 147 // The widget that the buttons act on. | 145 // The widget that the buttons act on. |
| 148 views::Widget* frame_; | 146 views::Widget* frame_; |
| 149 | 147 |
| 150 // The buttons. In the normal button style, at most one of |minimize_button_| | 148 // The buttons. In the normal button style, at most one of |minimize_button_| |
| 151 // and |size_button_| is visible. | 149 // and |size_button_| is visible. |
| 152 FrameCaptionButton* minimize_button_; | 150 FrameCaptionButton* minimize_button_; |
| 153 FrameCaptionButton* size_button_; | 151 FrameCaptionButton* size_button_; |
| 154 FrameCaptionButton* close_button_; | 152 FrameCaptionButton* close_button_; |
| 155 | 153 |
| 156 // Mapping of the images needed to paint a button for each of the values of | 154 // Mapping of the images needed to paint a button for each of the values of |
| 157 // CaptionButtonIcon. | 155 // CaptionButtonIcon. |
| 158 std::map<CaptionButtonIcon, ButtonIconIds> button_icon_id_map_; | 156 std::map<CaptionButtonIcon, ButtonIconIds> button_icon_id_map_; |
| 159 | 157 |
| 160 // Animation that affects the position of |minimize_button_| and the | 158 // Animation that affects the position of |minimize_button_| and the |
| 161 // visibility of |size_button_|. | 159 // visibility of |size_button_|. |
| 162 scoped_ptr<gfx::SlideAnimation> maximize_mode_animation_; | 160 scoped_ptr<gfx::SlideAnimation> maximize_mode_animation_; |
| 163 | 161 |
| 164 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); | 162 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); |
| 165 }; | 163 }; |
| 166 | 164 |
| 167 } // namespace ash | 165 } // namespace ash |
| 168 | 166 |
| 169 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 167 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| OLD | NEW |