Implement listing tests to a JSON file for iOS gtest test launcher
[chromium-blink-merge.git] / ash / frame / caption_buttons / frame_caption_button_container_view.h
blob1d915943ae37d09012e1c243ca5f719ce9ba9096
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
3 // found in the LICENSE file.
5 #ifndef ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_
6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_
8 #include <map>
10 #include "ash/ash_export.h"
11 #include "ash/frame/caption_buttons/frame_size_button_delegate.h"
12 #include "ui/gfx/animation/animation_delegate.h"
13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/view.h"
16 namespace gfx {
17 class SlideAnimation;
20 namespace views {
21 class Widget;
24 namespace ash {
26 // Container view for the frame caption buttons. It performs the appropriate
27 // action when a caption button is clicked.
28 class ASH_EXPORT FrameCaptionButtonContainerView
29 : public views::View,
30 public views::ButtonListener,
31 public FrameSizeButtonDelegate,
32 public gfx::AnimationDelegate {
33 public:
34 static const char kViewClassName[];
36 // |frame| is the views::Widget that the caption buttons act on.
37 explicit FrameCaptionButtonContainerView(views::Widget* frame);
38 ~FrameCaptionButtonContainerView() override;
40 // For testing.
41 class ASH_EXPORT TestApi {
42 public:
43 explicit TestApi(FrameCaptionButtonContainerView* container_view)
44 : container_view_(container_view) {
47 void EndAnimations();
49 FrameCaptionButton* minimize_button() const {
50 return container_view_->minimize_button_;
53 FrameCaptionButton* size_button() const {
54 return container_view_->size_button_;
57 FrameCaptionButton* close_button() const {
58 return container_view_->close_button_;
61 private:
62 FrameCaptionButtonContainerView* container_view_;
64 DISALLOW_COPY_AND_ASSIGN(TestApi);
67 // 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
69 // |icon| even if none of the buttons currently use |icon|.
70 void SetButtonImages(CaptionButtonIcon icon,
71 int icon_image_id,
72 int inactive_icon_image_id,
73 int hovered_background_image_id,
74 int pressed_background_image_id);
76 // Sets whether the buttons should be painted as active. Does not schedule
77 // a repaint.
78 void SetPaintAsActive(bool paint_as_active);
80 // Tell the window controls to reset themselves to the normal state.
81 void ResetWindowControls();
83 // 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
85 // be in the coordinates of the FrameCaptionButtonContainerView.
86 int NonClientHitTest(const gfx::Point& point) const;
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
90 // to reflect the change in visibility.
91 void UpdateSizeButtonVisibility();
93 // views::View:
94 gfx::Size GetPreferredSize() const override;
95 void Layout() override;
96 const char* GetClassName() const override;
98 // Overridden from gfx::AnimationDelegate:
99 void AnimationEnded(const gfx::Animation* animation) override;
100 void AnimationProgressed(const gfx::Animation* animation) override;
102 private:
103 friend class FrameCaptionButtonContainerViewTest;
105 struct ButtonIconIds {
106 ButtonIconIds();
107 ButtonIconIds(int icon_id,
108 int inactive_icon_id,
109 int hovered_background_id,
110 int pressed_background_id);
111 ~ButtonIconIds();
113 int icon_image_id;
114 int inactive_icon_image_id;
115 int hovered_background_image_id;
116 int pressed_background_image_id;
119 // Sets |button|'s icon to |icon|. If |animate| is ANIMATE_YES, the button
120 // will crossfade to the new icon. If |animate| is ANIMATE_NO and
121 // |icon| == |button|->icon(), the crossfade animation is progressed to the
122 // end.
123 void SetButtonIcon(FrameCaptionButton* button,
124 CaptionButtonIcon icon,
125 Animate animate);
127 // Returns true if maximize mode is not enabled, and |frame_| widget delegate
128 // can be maximized.
129 bool ShouldSizeButtonBeVisible() const;
131 // views::ButtonListener:
132 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
134 // FrameSizeButtonDelegate:
135 bool IsMinimizeButtonVisible() const override;
136 void SetButtonsToNormal(Animate animate) override;
137 void SetButtonIcons(CaptionButtonIcon minimize_button_icon,
138 CaptionButtonIcon close_button_icon,
139 Animate animate) override;
140 const FrameCaptionButton* GetButtonClosestTo(
141 const gfx::Point& position_in_screen) const override;
142 void SetHoveredAndPressedButtons(const FrameCaptionButton* to_hover,
143 const FrameCaptionButton* to_press) override;
145 // The widget that the buttons act on.
146 views::Widget* frame_;
148 // The buttons. In the normal button style, at most one of |minimize_button_|
149 // and |size_button_| is visible.
150 FrameCaptionButton* minimize_button_;
151 FrameCaptionButton* size_button_;
152 FrameCaptionButton* close_button_;
154 // Mapping of the images needed to paint a button for each of the values of
155 // CaptionButtonIcon.
156 std::map<CaptionButtonIcon, ButtonIconIds> button_icon_id_map_;
158 // Animation that affects the position of |minimize_button_| and the
159 // visibility of |size_button_|.
160 scoped_ptr<gfx::SlideAnimation> maximize_mode_animation_;
162 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView);
165 } // namespace ash
167 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_