| 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_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 5 #ifndef ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| 6 #define ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 6 #define ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/wm/caption_buttons/alternate_frame_size_button_delegate.h" | 9 #include "ash/wm/caption_buttons/alternate_frame_size_button_delegate.h" |
| 10 #include "ui/gfx/image/image_skia.h" | |
| 11 #include "ui/views/controls/button/button.h" | 10 #include "ui/views/controls/button/button.h" |
| 12 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 13 | 12 |
| 14 namespace views { | 13 namespace views { |
| 15 class Widget; | 14 class Widget; |
| 16 } | 15 } |
| 17 | 16 |
| 18 namespace ash { | 17 namespace ash { |
| 19 class FrameCaptionButton; | 18 class FrameCaptionButton; |
| 20 class FrameMaximizeButton; | 19 class FrameMaximizeButton; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 }; | 67 }; |
| 69 | 68 |
| 70 // Returns the size button if using the old caption button style, returns NULL | 69 // Returns the size button if using the old caption button style, returns NULL |
| 71 // otherwise. | 70 // otherwise. |
| 72 FrameMaximizeButton* GetOldStyleSizeButton(); | 71 FrameMaximizeButton* GetOldStyleSizeButton(); |
| 73 | 72 |
| 74 // Sets the resource ids of the images to paint the button for |icon|. The | 73 // Sets the resource ids of the images to paint the button for |icon|. The |
| 75 // FrameCaptionButtonContainerView will keep track of the images to use for | 74 // FrameCaptionButtonContainerView will keep track of the images to use for |
| 76 // |icon| even if none of the buttons currently use |icon|. | 75 // |icon| even if none of the buttons currently use |icon|. |
| 77 void SetButtonImages(CaptionButtonIcon icon, | 76 void SetButtonImages(CaptionButtonIcon icon, |
| 78 int normal_image_id, | 77 int icon_image_id, |
| 79 int hovered_image_id, | 78 int inactive_icon_image_id, |
| 80 int pressed_image_id); | 79 int hovered_background_image_id, |
| 80 int pressed_background_image_id); |
| 81 |
| 82 // Sets whether the buttons should be painted as active. Does not schedule |
| 83 // a repaint. |
| 84 void SetPaintAsActive(bool paint_as_active); |
| 81 | 85 |
| 82 // Tell the window controls to reset themselves to the normal state. | 86 // Tell the window controls to reset themselves to the normal state. |
| 83 void ResetWindowControls(); | 87 void ResetWindowControls(); |
| 84 | 88 |
| 85 // Determines the window HT* code for the caption button at |point|. Returns | 89 // Determines the window HT* code for the caption button at |point|. Returns |
| 86 // HTNOWHERE if |point| is not over any of the caption buttons. |point| must | 90 // HTNOWHERE if |point| is not over any of the caption buttons. |point| must |
| 87 // be in the coordinates of the FrameCaptionButtonContainerView. | 91 // be in the coordinates of the FrameCaptionButtonContainerView. |
| 88 int NonClientHitTest(const gfx::Point& point) const; | 92 int NonClientHitTest(const gfx::Point& point) const; |
| 89 | 93 |
| 90 // views::View overrides: | 94 // views::View overrides: |
| 91 virtual gfx::Size GetPreferredSize() OVERRIDE; | 95 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 92 virtual void Layout() OVERRIDE; | 96 virtual void Layout() OVERRIDE; |
| 93 virtual const char* GetClassName() const OVERRIDE; | 97 virtual const char* GetClassName() const OVERRIDE; |
| 94 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
| 95 | 98 |
| 96 private: | 99 private: |
| 97 friend class FrameCaptionButtonContainerViewTest; | 100 friend class FrameCaptionButtonContainerViewTest; |
| 98 | 101 |
| 99 struct ButtonIconIds { | 102 struct ButtonIconIds { |
| 100 ButtonIconIds(); | 103 ButtonIconIds(); |
| 101 ButtonIconIds(int normal_id, int hovered_id, int pressed_id); | 104 ButtonIconIds(int icon_id, |
| 105 int inactive_icon_id, |
| 106 int hovered_background_id, |
| 107 int pressed_background_id); |
| 102 ~ButtonIconIds(); | 108 ~ButtonIconIds(); |
| 103 | 109 |
| 104 int normal_image_id; | 110 int icon_image_id; |
| 105 int hovered_image_id; | 111 int inactive_icon_image_id; |
| 106 int pressed_image_id; | 112 int hovered_background_image_id; |
| 113 int pressed_background_image_id; |
| 107 }; | 114 }; |
| 108 | 115 |
| 109 // Sets |button|'s icon to |icon|. If |animate| is ANIMATE_YES, the button | 116 // Sets |button|'s icon to |icon|. If |animate| is ANIMATE_YES, the button |
| 110 // will crossfade to the new icon. If |animate| is ANIMATE_NO and | 117 // will crossfade to the new icon. If |animate| is ANIMATE_NO and |
| 111 // |icon| == |button|->icon(), the crossfade animation is progressed to the | 118 // |icon| == |button|->icon(), the crossfade animation is progressed to the |
| 112 // end. | 119 // end. |
| 113 void SetButtonIcon(FrameCaptionButton* button, | 120 void SetButtonIcon(FrameCaptionButton* button, |
| 114 CaptionButtonIcon icon, | 121 CaptionButtonIcon icon, |
| 115 Animate animate); | 122 Animate animate); |
| 116 | 123 |
| 117 // views::ButtonListener override: | 124 // views::ButtonListener override: |
| 118 virtual void ButtonPressed(views::Button* sender, | 125 virtual void ButtonPressed(views::Button* sender, |
| 119 const ui::Event& event) OVERRIDE; | 126 const ui::Event& event) OVERRIDE; |
| 120 | 127 |
| 121 // AlternateFrameSizeButton::Delegate overrides: | 128 // AlternateFrameSizeButton::Delegate overrides: |
| 122 virtual bool IsMinimizeButtonVisible() const OVERRIDE; | 129 virtual bool IsMinimizeButtonVisible() const OVERRIDE; |
| 123 virtual void SetButtonsToNormal(Animate animate) OVERRIDE; | 130 virtual void SetButtonsToNormal(Animate animate) OVERRIDE; |
| 124 virtual void SetButtonIcons(CaptionButtonIcon minimize_button_icon, | 131 virtual void SetButtonIcons(CaptionButtonIcon minimize_button_icon, |
| 125 CaptionButtonIcon close_button_icon, | 132 CaptionButtonIcon close_button_icon, |
| 126 Animate animate) OVERRIDE; | 133 Animate animate) OVERRIDE; |
| 127 virtual const FrameCaptionButton* GetButtonClosestTo( | 134 virtual const FrameCaptionButton* GetButtonClosestTo( |
| 128 const gfx::Point& position_in_screen) const OVERRIDE; | 135 const gfx::Point& position_in_screen) const OVERRIDE; |
| 129 virtual void SetHoveredAndPressedButtons( | 136 virtual void SetHoveredAndPressedButtons( |
| 130 const FrameCaptionButton* to_hover, | 137 const FrameCaptionButton* to_hover, |
| 131 const FrameCaptionButton* to_press) OVERRIDE; | 138 const FrameCaptionButton* to_press) OVERRIDE; |
| 132 | 139 |
| 133 // The widget that the buttons act on. | 140 // The widget that the buttons act on. |
| 134 views::Widget* frame_; | 141 views::Widget* frame_; |
| 135 | 142 |
| 136 // The close button separator. | |
| 137 gfx::ImageSkia button_separator_; | |
| 138 | |
| 139 // The buttons. In the normal button style, at most one of |minimize_button_| | 143 // The buttons. In the normal button style, at most one of |minimize_button_| |
| 140 // and |size_button_| is visible. | 144 // and |size_button_| is visible. |
| 141 FrameCaptionButton* minimize_button_; | 145 FrameCaptionButton* minimize_button_; |
| 142 FrameCaptionButton* size_button_; | 146 FrameCaptionButton* size_button_; |
| 143 FrameCaptionButton* close_button_; | 147 FrameCaptionButton* close_button_; |
| 144 | 148 |
| 145 // Mapping of the images needed to paint a button for each of the values of | 149 // Mapping of the images needed to paint a button for each of the values of |
| 146 // CaptionButtonIcon. | 150 // CaptionButtonIcon. |
| 147 std::map<CaptionButtonIcon, ButtonIconIds> button_icon_id_map_; | 151 std::map<CaptionButtonIcon, ButtonIconIds> button_icon_id_map_; |
| 148 | 152 |
| 149 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); | 153 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); |
| 150 }; | 154 }; |
| 151 | 155 |
| 152 } // namesapace ash | 156 } // namesapace ash |
| 153 | 157 |
| 154 #endif // ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ | 158 #endif // ASH_WM_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_ |
| OLD | NEW |