| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MASH_WM_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| 6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 6 #define MASH_WM_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 "base/macros.h" |
| 11 #include "ash/frame/caption_buttons/frame_size_button_delegate.h" | 11 #include "mash/wm/frame/caption_buttons/caption_button_types.h" |
| 12 #include "ui/gfx/animation/animation_delegate.h" | 12 #include "ui/gfx/animation/animation_delegate.h" |
| 13 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
| 14 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 class SlideAnimation; | 17 class SlideAnimation; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 class Widget; | 21 class Widget; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace ash { | 24 namespace mash { |
| 25 namespace wm { |
| 26 |
| 27 class FrameCaptionButton; |
| 25 | 28 |
| 26 // Container view for the frame caption buttons. It performs the appropriate | 29 // Container view for the frame caption buttons. It performs the appropriate |
| 27 // action when a caption button is clicked. | 30 // action when a caption button is clicked. |
| 28 class ASH_EXPORT FrameCaptionButtonContainerView | 31 class FrameCaptionButtonContainerView : public views::View, |
| 29 : public views::View, | 32 public views::ButtonListener, |
| 30 public views::ButtonListener, | 33 public gfx::AnimationDelegate { |
| 31 public FrameSizeButtonDelegate, | |
| 32 public gfx::AnimationDelegate { | |
| 33 public: | 34 public: |
| 35 enum Animate { ANIMATE_YES, ANIMATE_NO }; |
| 36 |
| 34 static const char kViewClassName[]; | 37 static const char kViewClassName[]; |
| 35 | 38 |
| 36 // |frame| is the views::Widget that the caption buttons act on. | 39 // |frame| is the views::Widget that the caption buttons act on. |
| 37 explicit FrameCaptionButtonContainerView(views::Widget* frame); | 40 explicit FrameCaptionButtonContainerView(views::Widget* frame); |
| 38 ~FrameCaptionButtonContainerView() override; | 41 ~FrameCaptionButtonContainerView() override; |
| 39 | 42 |
| 40 // For testing. | |
| 41 class ASH_EXPORT TestApi { | |
| 42 public: | |
| 43 explicit TestApi(FrameCaptionButtonContainerView* container_view) | |
| 44 : container_view_(container_view) { | |
| 45 } | |
| 46 | |
| 47 void EndAnimations(); | |
| 48 | |
| 49 FrameCaptionButton* minimize_button() const { | |
| 50 return container_view_->minimize_button_; | |
| 51 } | |
| 52 | |
| 53 FrameCaptionButton* size_button() const { | |
| 54 return container_view_->size_button_; | |
| 55 } | |
| 56 | |
| 57 FrameCaptionButton* close_button() const { | |
| 58 return container_view_->close_button_; | |
| 59 } | |
| 60 | |
| 61 private: | |
| 62 FrameCaptionButtonContainerView* container_view_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(TestApi); | |
| 65 }; | |
| 66 | |
| 67 // Sets the resource ids of the images to paint the button for |icon|. The | 43 // Sets the resource ids of the images to paint the button for |icon|. The |
| 68 // FrameCaptionButtonContainerView will keep track of the images to use for | 44 // FrameCaptionButtonContainerView will keep track of the images to use for |
| 69 // |icon| even if none of the buttons currently use |icon|. | 45 // |icon| even if none of the buttons currently use |icon|. |
| 70 void SetButtonImages(CaptionButtonIcon icon, | 46 void SetButtonImages(CaptionButtonIcon icon, |
| 71 int icon_image_id, | 47 int icon_image_id, |
| 72 int hovered_background_image_id, | 48 int hovered_background_image_id, |
| 73 int pressed_background_image_id); | 49 int pressed_background_image_id); |
| 74 | 50 |
| 75 // Sets whether the buttons should be painted as active. Does not schedule | 51 // Sets whether the buttons should be painted as active. Does not schedule |
| 76 // a repaint. | 52 // a repaint. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // |icon| == |button|->icon(), the crossfade animation is progressed to the | 94 // |icon| == |button|->icon(), the crossfade animation is progressed to the |
| 119 // end. | 95 // end. |
| 120 void SetButtonIcon(FrameCaptionButton* button, | 96 void SetButtonIcon(FrameCaptionButton* button, |
| 121 CaptionButtonIcon icon, | 97 CaptionButtonIcon icon, |
| 122 Animate animate); | 98 Animate animate); |
| 123 | 99 |
| 124 // Returns true if maximize mode is not enabled, and |frame_| widget delegate | 100 // Returns true if maximize mode is not enabled, and |frame_| widget delegate |
| 125 // can be maximized. | 101 // can be maximized. |
| 126 bool ShouldSizeButtonBeVisible() const; | 102 bool ShouldSizeButtonBeVisible() const; |
| 127 | 103 |
| 104 void SetButtonsToNormal(Animate animate); |
| 105 void SetButtonIcons(CaptionButtonIcon minimize_button_icon, |
| 106 CaptionButtonIcon close_button_icon, |
| 107 Animate animate); |
| 108 |
| 128 // views::ButtonListener: | 109 // views::ButtonListener: |
| 129 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 110 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 130 | 111 |
| 131 // FrameSizeButtonDelegate: | |
| 132 bool IsMinimizeButtonVisible() const override; | |
| 133 void SetButtonsToNormal(Animate animate) override; | |
| 134 void SetButtonIcons(CaptionButtonIcon minimize_button_icon, | |
| 135 CaptionButtonIcon close_button_icon, | |
| 136 Animate animate) override; | |
| 137 const FrameCaptionButton* GetButtonClosestTo( | |
| 138 const gfx::Point& position_in_screen) const override; | |
| 139 void SetHoveredAndPressedButtons(const FrameCaptionButton* to_hover, | |
| 140 const FrameCaptionButton* to_press) override; | |
| 141 | |
| 142 // The widget that the buttons act on. | 112 // The widget that the buttons act on. |
| 143 views::Widget* frame_; | 113 views::Widget* frame_; |
| 144 | 114 |
| 145 // The buttons. In the normal button style, at most one of |minimize_button_| | 115 // The buttons. In the normal button style, at most one of |minimize_button_| |
| 146 // and |size_button_| is visible. | 116 // and |size_button_| is visible. |
| 147 FrameCaptionButton* minimize_button_; | 117 FrameCaptionButton* minimize_button_; |
| 148 FrameCaptionButton* size_button_; | 118 FrameCaptionButton* size_button_; |
| 149 FrameCaptionButton* close_button_; | 119 FrameCaptionButton* close_button_; |
| 150 | 120 |
| 151 // Mapping of the images needed to paint a button for each of the values of | 121 // Mapping of the images needed to paint a button for each of the values of |
| 152 // CaptionButtonIcon. | 122 // CaptionButtonIcon. |
| 153 std::map<CaptionButtonIcon, ButtonIconIds> button_icon_id_map_; | 123 std::map<CaptionButtonIcon, ButtonIconIds> button_icon_id_map_; |
| 154 | 124 |
| 155 // Animation that affects the position of |minimize_button_| and the | 125 // Animation that affects the position of |minimize_button_| and the |
| 156 // visibility of |size_button_|. | 126 // visibility of |size_button_|. |
| 157 scoped_ptr<gfx::SlideAnimation> maximize_mode_animation_; | 127 scoped_ptr<gfx::SlideAnimation> maximize_mode_animation_; |
| 158 | 128 |
| 159 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); | 129 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); |
| 160 }; | 130 }; |
| 161 | 131 |
| 162 } // namespace ash | 132 } // namespace wm |
| 133 } // namespace mash |
| 163 | 134 |
| 164 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 135 #endif // MASH_WM_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| OLD | NEW |