OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "ui/views/window/non_client_view.h" | 5 #include "ui/views/window/non_client_view.h" |
6 | 6 |
7 #include "ui/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
8 #include "ui/base/hit_test.h" | 8 #include "ui/base/hit_test.h" |
9 #include "ui/gfx/geometry/rect_conversions.h" | 9 #include "ui/gfx/geometry/rect_conversions.h" |
10 #include "ui/views/rect_based_targeting_utils.h" | 10 #include "ui/views/rect_based_targeting_utils.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // z-order first and we always want the client view to have first crack at | 27 // z-order first and we always want the client view to have first crack at |
28 // handling mouse messages. | 28 // handling mouse messages. |
29 static const int kFrameViewIndex = 0; | 29 static const int kFrameViewIndex = 0; |
30 static const int kClientViewIndex = 1; | 30 static const int kClientViewIndex = 1; |
31 // The overlay view is always on top (index == child_count() - 1). | 31 // The overlay view is always on top (index == child_count() - 1). |
32 | 32 |
33 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
34 // NonClientView, public: | 34 // NonClientView, public: |
35 | 35 |
36 NonClientView::NonClientView() | 36 NonClientView::NonClientView() |
37 : client_view_(NULL), | 37 : client_view_(nullptr), |
38 overlay_view_(NULL) { | 38 overlay_view_(nullptr) { |
39 SetEventTargeter( | 39 SetEventTargeter( |
40 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 40 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
41 } | 41 } |
42 | 42 |
43 NonClientView::~NonClientView() { | 43 NonClientView::~NonClientView() { |
44 // This value may have been reset before the window hierarchy shuts down, | 44 // This value may have been reset before the window hierarchy shuts down, |
45 // so we need to manually remove it. | 45 // so we need to manually remove it. |
46 RemoveChildView(frame_view_.get()); | 46 RemoveChildView(frame_view_.get()); |
47 } | 47 } |
48 | 48 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return ViewTargeterDelegate::TargetForRect(root, rect); | 234 return ViewTargeterDelegate::TargetForRect(root, rect); |
235 } | 235 } |
236 | 236 |
237 //////////////////////////////////////////////////////////////////////////////// | 237 //////////////////////////////////////////////////////////////////////////////// |
238 // NonClientFrameView, public: | 238 // NonClientFrameView, public: |
239 | 239 |
240 NonClientFrameView::~NonClientFrameView() { | 240 NonClientFrameView::~NonClientFrameView() { |
241 } | 241 } |
242 | 242 |
243 bool NonClientFrameView::ShouldPaintAsActive() const { | 243 bool NonClientFrameView::ShouldPaintAsActive() const { |
244 return GetWidget()->IsAlwaysRenderAsActive() || GetWidget()->IsActive(); | 244 return GetWidget()->IsAlwaysRenderAsActive() || |
| 245 (active_state_override_ ? *active_state_override_ |
| 246 : GetWidget()->IsActive()); |
245 } | 247 } |
246 | 248 |
247 int NonClientFrameView::GetHTComponentForFrame(const gfx::Point& point, | 249 int NonClientFrameView::GetHTComponentForFrame(const gfx::Point& point, |
248 int top_resize_border_height, | 250 int top_resize_border_height, |
249 int resize_border_thickness, | 251 int resize_border_thickness, |
250 int top_resize_corner_height, | 252 int top_resize_corner_height, |
251 int resize_corner_width, | 253 int resize_corner_width, |
252 bool can_resize) { | 254 bool can_resize) { |
253 // Tricky: In XP, native behavior is to return HTTOPLEFT and HTTOPRIGHT for | 255 // Tricky: In XP, native behavior is to return HTTOPLEFT and HTTOPRIGHT for |
254 // a |resize_corner_size|-length strip of both the side and top borders, but | 256 // a |resize_corner_size|-length strip of both the side and top borders, but |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 component = HTBOTTOM; | 288 component = HTBOTTOM; |
287 } else { | 289 } else { |
288 return HTNOWHERE; | 290 return HTNOWHERE; |
289 } | 291 } |
290 | 292 |
291 // If the window can't be resized, there are no resize boundaries, just | 293 // If the window can't be resized, there are no resize boundaries, just |
292 // window borders. | 294 // window borders. |
293 return can_resize ? component : HTBORDER; | 295 return can_resize ? component : HTBORDER; |
294 } | 296 } |
295 | 297 |
| 298 void NonClientFrameView::ActivationChanged(bool active) { |
| 299 } |
| 300 |
296 void NonClientFrameView::GetAccessibleState(ui::AXViewState* state) { | 301 void NonClientFrameView::GetAccessibleState(ui::AXViewState* state) { |
297 state->role = ui::AX_ROLE_CLIENT; | 302 state->role = ui::AX_ROLE_CLIENT; |
298 } | 303 } |
299 | 304 |
300 const char* NonClientFrameView::GetClassName() const { | 305 const char* NonClientFrameView::GetClassName() const { |
301 return kViewClassName; | 306 return kViewClassName; |
302 } | 307 } |
303 | 308 |
304 //////////////////////////////////////////////////////////////////////////////// | 309 //////////////////////////////////////////////////////////////////////////////// |
305 // NonClientFrameView, protected: | 310 // NonClientFrameView, protected: |
306 | 311 |
307 NonClientFrameView::NonClientFrameView() { | 312 NonClientFrameView::NonClientFrameView() |
| 313 : active_state_override_(nullptr) { |
308 SetEventTargeter( | 314 SetEventTargeter( |
309 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 315 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
310 } | 316 } |
311 | 317 |
312 // ViewTargeterDelegate: | 318 // ViewTargeterDelegate: |
313 bool NonClientFrameView::DoesIntersectRect(const View* target, | 319 bool NonClientFrameView::DoesIntersectRect(const View* target, |
314 const gfx::Rect& rect) const { | 320 const gfx::Rect& rect) const { |
315 CHECK_EQ(target, this); | 321 CHECK_EQ(target, this); |
316 | 322 |
317 // For the default case, we assume the non-client frame view never overlaps | 323 // For the default case, we assume the non-client frame view never overlaps |
318 // the client view. | 324 // the client view. |
319 return !GetWidget()->client_view()->bounds().Intersects(rect); | 325 return !GetWidget()->client_view()->bounds().Intersects(rect); |
320 } | 326 } |
321 | 327 |
322 void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 328 void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
323 // Overridden to do nothing. The NonClientView manually calls Layout on the | 329 // Overridden to do nothing. The NonClientView manually calls Layout on the |
324 // FrameView when it is itself laid out, see comment in NonClientView::Layout. | 330 // FrameView when it is itself laid out, see comment in NonClientView::Layout. |
325 } | 331 } |
326 | 332 |
327 } // namespace views | 333 } // namespace views |
OLD | NEW |