Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: ash/wm/workspace/frame_caption_button_container_view.h

Issue 23498031: Move code related to the window controls to ash/wm/caption_buttons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef ASH_WM_WORKSPACE_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_
6 #define ASH_WM_WORKSPACE_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_
7
8 #include "ash/ash_export.h"
9 #include "ui/gfx/image/image_skia.h"
10 #include "ui/views/controls/button/button.h"
11 #include "ui/views/view.h"
12
13 namespace views {
14 class CustomButton;
15 class NonClientFrameView;
16 class Widget;
17 }
18
19 namespace ash {
20
21 // Container view for the frame caption buttons. It performs the appropriate
22 // action when a caption button is clicked.
23 class ASH_EXPORT FrameCaptionButtonContainerView
24 : public views::View,
25 public views::ButtonListener {
26 public:
27 static const char kViewClassName[];
28
29 // Whether the frame can be minimized (either via the maximize/restore button
30 // or via a dedicated button).
31 enum MinimizeAllowed {
32 MINIMIZE_ALLOWED,
33 MINIMIZE_DISALLOWED
34 };
35 enum HeaderStyle {
36 // Dialogs, panels, packaged apps, tabbed maximized/fullscreen browser
37 // windows.
38 HEADER_STYLE_SHORT,
39
40 // Restored tabbed browser windows, popups for browser windows, restored
41 // hosted app windows, popups for hosted app windows.
42 HEADER_STYLE_TALL,
43
44 // AppNonClientFrameViewAsh.
45 HEADER_STYLE_MAXIMIZED_HOSTED_APP
46 };
47
48 // |frame_view| and |frame| are the NonClientFrameView and the views::Widget
49 // that the caption buttons act on.
50 // |minimize_allowed| indicates whether the frame can be minimized (either via
51 // the maximize/restore button or via a dedicated button).
52 // TODO(pkotwicz): Remove the |frame_view| parameter once FrameMaximizeButton
53 // is refactored to take in a views::Widget instead.
54 FrameCaptionButtonContainerView(views::NonClientFrameView* frame_view,
55 views::Widget* frame,
56 MinimizeAllowed minimize_allowed);
57 virtual ~FrameCaptionButtonContainerView();
58
59 // For testing.
60 class TestApi {
61 public:
62 explicit TestApi(FrameCaptionButtonContainerView* container_view)
63 : container_view_(container_view) {
64 }
65
66 views::CustomButton* minimize_button() const {
67 return container_view_->minimize_button_;
68 }
69
70 views::CustomButton* size_button() const {
71 return container_view_->size_button_;
72 }
73
74 views::CustomButton* close_button() const {
75 return container_view_->close_button_;
76 }
77
78 private:
79 FrameCaptionButtonContainerView* container_view_;
80
81 DISALLOW_COPY_AND_ASSIGN(TestApi);
82 };
83
84 // Tell the window controls to reset themselves to the normal state.
85 void ResetWindowControls();
86
87 // Determines the window HT* code for the caption button at |point|. Returns
88 // HTNOWHERE if |point| is not over any of the caption buttons. |point| must
89 // be in the coordinates of the FrameCaptionButtonContainerView.
90 int NonClientHitTest(const gfx::Point& point) const;
91
92 // Sets the header style.
93 void set_header_style(HeaderStyle header_style) {
94 header_style_ = header_style;
95 }
96
97 // views::View overrides:
98 virtual gfx::Size GetPreferredSize() OVERRIDE;
99 virtual void Layout() OVERRIDE;
100 virtual const char* GetClassName() const OVERRIDE;
101 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
102
103 private:
104 friend class FrameCaptionButtonContainerViewTest;
105
106 // Returns the distance between buttons which are next to each other. A
107 // negative value is returned if the buttons overlap.
108 int GetDistanceBetweenButtons() const;
109
110 // Returns the inset of the leftmost visible button from the view's border
111 // (if any).
112 int GetLeftInset() const;
113
114 // Returns the inset of the rightmost visible button from the view's border
115 // (if any).
116 int GetRightInset() const;
117
118 // views::ButtonListener override:
119 virtual void ButtonPressed(views::Button* sender,
120 const ui::Event& event) OVERRIDE;
121
122 // Methods specific to normal button style -----------------------------------
123 //
124 // Sets the images for a button based on the given ids.
125 void SetButtonImages(views::CustomButton* button,
126 int normal_image_id,
127 int hot_image_id,
128 int pushed_image_id);
129
130 // The widget that the buttons act on.
131 views::Widget* frame_;
132
133 // The close button separator.
134 gfx::ImageSkia button_separator_;
135
136 HeaderStyle header_style_;
137
138 // The buttons. In the normal button style, at most one of |minimize_button_|
139 // and |size_button_| is visible.
140 views::CustomButton* minimize_button_;
141 views::CustomButton* size_button_;
142 views::CustomButton* close_button_;
143
144 DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView);
145 };
146
147 } // namesapace ash
148
149 #endif // ASH_WM_WORKSPACE_FRAME_CAPTION_BUTTON_CONTAINER_VIEW_H_
OLDNEW
« no previous file with comments | « ash/wm/workspace/alternate_frame_caption_button.cc ('k') | ash/wm/workspace/frame_caption_button_container_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698