[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / ui / views / window / non_client_view.h
blob9466afa6e47225aad1ca7c1a2d73efc995c9d27a
1 // Copyright (c) 2012 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 UI_VIEWS_WINDOW_NON_CLIENT_VIEW_H_
6 #define UI_VIEWS_WINDOW_NON_CLIENT_VIEW_H_
8 #include "ui/views/view.h"
9 #include "ui/views/view_targeter_delegate.h"
11 namespace gfx {
12 class Path;
15 namespace views {
17 class ClientView;
19 ////////////////////////////////////////////////////////////////////////////////
20 // NonClientFrameView
22 // An object that subclasses NonClientFrameView is a View that renders and
23 // responds to events within the frame portions of the non-client area of a
24 // window. This view does _not_ contain the ClientView, but rather is a sibling
25 // of it.
26 class VIEWS_EXPORT NonClientFrameView : public View,
27 public ViewTargeterDelegate {
28 public:
29 // Internal class name.
30 static const char kViewClassName[];
32 enum {
33 // Various edges of the frame border have a 1 px shadow along their edges;
34 // in a few cases we shift elements based on this amount for visual appeal.
35 kFrameShadowThickness = 1,
37 // In restored mode, we draw a 1 px edge around the content area inside the
38 // frame border.
39 kClientEdgeThickness = 1,
42 virtual ~NonClientFrameView();
44 // Sets whether the window should be rendered as active regardless of the
45 // actual active state. Used when bubbles become active to make their parent
46 // appear active. A value of true makes the window render as active always,
47 // false gives normal behavior.
48 void SetInactiveRenderingDisabled(bool disable);
50 // Used to determine if the frame should be painted as active. Keyed off the
51 // window's actual active state and |inactive_rendering_disabled_|.
52 bool ShouldPaintAsActive() const;
54 // Helper for non-client view implementations to determine which area of the
55 // window border the specified |point| falls within. The other parameters are
56 // the size of the sizing edges, and whether or not the window can be
57 // resized.
58 int GetHTComponentForFrame(const gfx::Point& point,
59 int top_resize_border_height,
60 int resize_border_thickness,
61 int top_resize_corner_height,
62 int resize_corner_width,
63 bool can_resize);
65 // Returns the bounds (in this View's parent's coordinates) that the client
66 // view should be laid out within.
67 virtual gfx::Rect GetBoundsForClientView() const = 0;
69 virtual gfx::Rect GetWindowBoundsForClientBounds(
70 const gfx::Rect& client_bounds) const = 0;
72 // This function must ask the ClientView to do a hittest. We don't do this in
73 // the parent NonClientView because that makes it more difficult to calculate
74 // hittests for regions that are partially obscured by the ClientView, e.g.
75 // HTSYSMENU.
76 virtual int NonClientHitTest(const gfx::Point& point) = 0;
77 virtual void GetWindowMask(const gfx::Size& size,
78 gfx::Path* window_mask) = 0;
79 virtual void ResetWindowControls() = 0;
80 virtual void UpdateWindowIcon() = 0;
81 virtual void UpdateWindowTitle() = 0;
83 // View:
84 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
85 virtual const char* GetClassName() const OVERRIDE;
87 protected:
88 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
90 NonClientFrameView();
92 private:
93 // ViewTargeterDelegate:
94 virtual bool DoesIntersectRect(const View* target,
95 const gfx::Rect& rect) const OVERRIDE;
97 // Prevents the non-client frame view from being rendered as inactive when
98 // true.
99 bool inactive_rendering_disabled_;
102 ////////////////////////////////////////////////////////////////////////////////
103 // NonClientView
105 // The NonClientView is the logical root of all Views contained within a
106 // Window, except for the RootView which is its parent and of which it is the
107 // sole child. The NonClientView has two children, the NonClientFrameView which
108 // is responsible for painting and responding to events from the non-client
109 // portions of the window, and the ClientView, which is responsible for the
110 // same for the client area of the window:
112 // +- views::Widget ------------------------------------+
113 // | +- views::RootView ------------------------------+ |
114 // | | +- views::NonClientView ---------------------+ | |
115 // | | | +- views::NonClientFrameView subclass ---+ | | |
116 // | | | | | | | |
117 // | | | | << all painting and event receiving >> | | | |
118 // | | | | << of the non-client areas of a >> | | | |
119 // | | | | << views::Widget. >> | | | |
120 // | | | | | | | |
121 // | | | +----------------------------------------+ | | |
122 // | | | +- views::ClientView or subclass --------+ | | |
123 // | | | | | | | |
124 // | | | | << all painting and event receiving >> | | | |
125 // | | | | << of the client areas of a >> | | | |
126 // | | | | << views::Widget. >> | | | |
127 // | | | | | | | |
128 // | | | +----------------------------------------+ | | |
129 // | | +--------------------------------------------+ | |
130 // | +------------------------------------------------+ |
131 // +----------------------------------------------------+
133 // The NonClientFrameView and ClientView are siblings because due to theme
134 // changes the NonClientFrameView may be replaced with different
135 // implementations (e.g. during the switch from DWM/Aero-Glass to Vista Basic/
136 // Classic rendering).
138 class VIEWS_EXPORT NonClientView : public View {
139 public:
140 // Internal class name.
141 static const char kViewClassName[];
143 NonClientView();
144 virtual ~NonClientView();
146 // Returns the current NonClientFrameView instance, or NULL if
147 // it does not exist.
148 NonClientFrameView* frame_view() const { return frame_view_.get(); }
150 // Replaces the current NonClientFrameView (if any) with the specified one.
151 void SetFrameView(NonClientFrameView* frame_view);
153 // Replaces the current |overlay_view_| (if any) with the specified one.
154 void SetOverlayView(View* view);
156 // Returns true if the ClientView determines that the containing window can be
157 // closed, false otherwise.
158 bool CanClose();
160 // Called by the containing Window when it is closed.
161 void WindowClosing();
163 // Replaces the frame view with a new one. Used when switching window theme
164 // or frame style.
165 void UpdateFrame();
167 // Prevents the window from being rendered as deactivated when |disable| is
168 // true, until called with |disable| false. Used when a sub-window is to be
169 // shown that shouldn't visually de-activate the window.
170 void SetInactiveRenderingDisabled(bool disable);
172 // Returns the bounds of the window required to display the content area at
173 // the specified bounds.
174 gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect client_bounds) const;
176 // Determines the windows HT* code when the mouse cursor is at the
177 // specified point, in window coordinates.
178 int NonClientHitTest(const gfx::Point& point);
180 // Returns a mask to be used to clip the top level window for the given
181 // size. This is used to create the non-rectangular window shape.
182 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask);
184 // Tells the window controls as rendered by the NonClientView to reset
185 // themselves to a normal state. This happens in situations where the
186 // containing window does not receive a normal sequences of messages that
187 // would lead to the controls returning to this normal state naturally, e.g.
188 // when the window is maximized, minimized or restored.
189 void ResetWindowControls();
191 // Tells the NonClientView to invalidate the NonClientFrameView's window icon.
192 void UpdateWindowIcon();
194 // Tells the NonClientView to invalidate the NonClientFrameView's window
195 // title.
196 void UpdateWindowTitle();
198 // Get/Set client_view property.
199 ClientView* client_view() const { return client_view_; }
200 void set_client_view(ClientView* client_view) {
201 client_view_ = client_view;
204 // Layout just the frame view. This is necessary on Windows when non-client
205 // metrics such as the position of the window controls changes independently
206 // of a window resize message.
207 void LayoutFrameView();
209 // Set the accessible name of this view.
210 void SetAccessibleName(const base::string16& name);
212 // NonClientView, View overrides:
213 virtual gfx::Size GetPreferredSize() const OVERRIDE;
214 virtual gfx::Size GetMinimumSize() const OVERRIDE;
215 virtual gfx::Size GetMaximumSize() const OVERRIDE;
216 virtual void Layout() OVERRIDE;
217 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
218 virtual const char* GetClassName() const OVERRIDE;
220 virtual views::View* GetEventHandlerForRect(const gfx::Rect& rect) OVERRIDE;
221 virtual views::View* GetTooltipHandlerForPoint(
222 const gfx::Point& point) OVERRIDE;
224 protected:
225 // NonClientView, View overrides:
226 virtual void ViewHierarchyChanged(
227 const ViewHierarchyChangedDetails& details) OVERRIDE;
229 private:
230 // A ClientView object or subclass, responsible for sizing the contents view
231 // of the window, hit testing and perhaps other tasks depending on the
232 // implementation.
233 ClientView* client_view_;
235 // The NonClientFrameView that renders the non-client portions of the window.
236 // This object is not owned by the view hierarchy because it can be replaced
237 // dynamically as the system settings change.
238 scoped_ptr<NonClientFrameView> frame_view_;
240 // The overlay view, when non-NULL and visible, takes up the entire widget and
241 // is placed on top of the ClientView and NonClientFrameView.
242 View* overlay_view_;
244 // The accessible name of this view.
245 base::string16 accessible_name_;
247 DISALLOW_COPY_AND_ASSIGN(NonClientView);
250 } // namespace views
252 #endif // UI_VIEWS_WINDOW_NON_CLIENT_VIEW_H_