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 #ifndef UI_AURA_WINDOW_H_ | 5 #ifndef UI_AURA_WINDOW_H_ |
6 #define UI_AURA_WINDOW_H_ | 6 #define UI_AURA_WINDOW_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
20 #include "ui/aura/aura_export.h" | 20 #include "ui/aura/aura_export.h" |
21 #include "ui/aura/window_observer.h" | 21 #include "ui/aura/window_observer.h" |
22 #include "ui/base/class_property.h" | |
22 #include "ui/compositor/layer_animator.h" | 23 #include "ui/compositor/layer_animator.h" |
23 #include "ui/compositor/layer_delegate.h" | 24 #include "ui/compositor/layer_delegate.h" |
24 #include "ui/compositor/layer_owner.h" | 25 #include "ui/compositor/layer_owner.h" |
25 #include "ui/events/event_constants.h" | 26 #include "ui/events/event_constants.h" |
26 #include "ui/events/event_target.h" | 27 #include "ui/events/event_target.h" |
27 #include "ui/events/event_targeter.h" | 28 #include "ui/events/event_targeter.h" |
28 #include "ui/events/gestures/gesture_types.h" | 29 #include "ui/events/gestures/gesture_types.h" |
29 #include "ui/gfx/geometry/insets.h" | 30 #include "ui/gfx/geometry/insets.h" |
30 #include "ui/gfx/geometry/rect.h" | 31 #include "ui/gfx/geometry/rect.h" |
31 #include "ui/gfx/native_widget_types.h" | 32 #include "ui/gfx/native_widget_types.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
46 namespace aura { | 47 namespace aura { |
47 | 48 |
48 class LayoutManager; | 49 class LayoutManager; |
49 class WindowDelegate; | 50 class WindowDelegate; |
50 class WindowPort; | 51 class WindowPort; |
51 class WindowObserver; | 52 class WindowObserver; |
52 class WindowTreeHost; | 53 class WindowTreeHost; |
53 | 54 |
54 // Defined in window_property.h (which we do not include) | 55 // Defined in window_property.h (which we do not include) |
55 template<typename T> | 56 template<typename T> |
56 struct WindowProperty; | 57 using WindowProperty = ui::ClassProperty<T>; |
57 | 58 |
58 namespace subtle { | 59 namespace subtle { |
59 class PropertyHelper; | 60 class PropertyHelper; |
60 } | 61 } |
61 | 62 |
62 namespace test { | 63 namespace test { |
63 class WindowTestApi; | 64 class WindowTestApi; |
64 } | 65 } |
65 | 66 |
66 // Aura window implementation. Interesting events are sent to the | 67 // Aura window implementation. Interesting events are sent to the |
67 // WindowDelegate. | 68 // WindowDelegate. |
68 // TODO(beng): resolve ownership. | 69 // TODO(beng): resolve ownership. |
69 class AURA_EXPORT Window : public ui::LayerDelegate, | 70 class AURA_EXPORT Window : public ui::LayerDelegate, |
70 public ui::LayerOwner, | 71 public ui::LayerOwner, |
71 public ui::EventTarget, | 72 public ui::EventTarget, |
72 public ui::GestureConsumer { | 73 public ui::GestureConsumer, |
74 public ui::PropertyHandler { | |
73 public: | 75 public: |
74 // Initial value of id() for newly created windows. | 76 // Initial value of id() for newly created windows. |
75 static constexpr int kInitialId = -1; | 77 static constexpr int kInitialId = -1; |
76 | 78 |
77 // Used when stacking windows. | 79 // Used when stacking windows. |
78 enum StackDirection { | 80 enum StackDirection { |
79 STACK_ABOVE, | 81 STACK_ABOVE, |
80 STACK_BELOW | 82 STACK_BELOW |
81 }; | 83 }; |
82 | 84 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 bool HasCapture(); | 290 bool HasCapture(); |
289 | 291 |
290 // Suppresses painting window content by disgarding damaged rect and ignoring | 292 // Suppresses painting window content by disgarding damaged rect and ignoring |
291 // new paint requests. This is a one way operation and there is no way to | 293 // new paint requests. This is a one way operation and there is no way to |
292 // reenable painting. | 294 // reenable painting. |
293 void SuppressPaint(); | 295 void SuppressPaint(); |
294 | 296 |
295 // Sets the |value| of the given window |property|. Setting to the default | 297 // Sets the |value| of the given window |property|. Setting to the default |
296 // value (e.g., NULL) removes the property. The caller is responsible for the | 298 // value (e.g., NULL) removes the property. The caller is responsible for the |
297 // lifetime of any object set as a property on the Window. | 299 // lifetime of any object set as a property on the Window. |
298 template<typename T> | 300 //template<typename T> |
299 void SetProperty(const WindowProperty<T>* property, T value); | 301 //void SetProperty(const WindowProperty<T>* property, T value); |
sky
2017/01/13 20:28:20
Is there a reason you are commenting this out and
kylix_rd
2017/01/13 21:44:59
I'll do a cleanup pass once the substance of these
kylix_rd
2017/01/24 15:14:53
Done.
| |
300 | 302 |
301 // Returns the value of the given window |property|. Returns the | 303 // Returns the value of the given window |property|. Returns the |
302 // property-specific default value if the property was not previously set. | 304 // property-specific default value if the property was not previously set. |
303 template<typename T> | 305 //template<typename T> |
304 T GetProperty(const WindowProperty<T>* property) const; | 306 //T GetProperty(const WindowProperty<T>* property) const; |
305 | 307 |
306 // Sets the |property| to its default value. Useful for avoiding a cast when | 308 // Sets the |property| to its default value. Useful for avoiding a cast when |
307 // setting to NULL. | 309 // setting to NULL. |
308 template<typename T> | 310 //template<typename T> |
309 void ClearProperty(const WindowProperty<T>* property); | 311 //void ClearProperty(const WindowProperty<T>* property); |
310 | 312 |
311 // Returns the value of all properties with a non-default value. | 313 // Returns the value of all properties with a non-default value. |
312 std::set<const void*> GetAllPropertKeys() const; | 314 //std::set<const void*> GetAllPropertKeys() const; |
313 | 315 |
314 // NativeWidget::[GS]etNativeWindowProperty use strings as keys, and this is | 316 // NativeWidget::[GS]etNativeWindowProperty use strings as keys, and this is |
315 // difficult to change while retaining compatibility with other platforms. | 317 // difficult to change while retaining compatibility with other platforms. |
316 // TODO(benrg): Find a better solution. | 318 // TODO(benrg): Find a better solution. |
317 void SetNativeWindowProperty(const char* key, void* value); | 319 void SetNativeWindowProperty(const char* key, void* value); |
318 void* GetNativeWindowProperty(const char* key) const; | 320 void* GetNativeWindowProperty(const char* key) const; |
319 | 321 |
320 // Type of a function to delete a property that this window owns. | 322 // Type of a function to delete a property that this window owns. |
321 typedef void (*PropertyDeallocator)(int64_t value); | 323 //typedef void (*PropertyDeallocator)(int64_t value); |
322 | 324 |
323 // Overridden from ui::LayerDelegate: | 325 // Overridden from ui::LayerDelegate: |
324 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 326 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
325 | 327 |
326 #if !defined(NDEBUG) | 328 #if !defined(NDEBUG) |
327 // These methods are useful when debugging. | 329 // These methods are useful when debugging. |
328 std::string GetDebugInfo() const; | 330 std::string GetDebugInfo() const; |
329 void PrintWindowHierarchy(int depth) const; | 331 void PrintWindowHierarchy(int depth) const; |
330 #endif | 332 #endif |
331 | 333 |
332 // Returns true if there was state needing to be cleaned up. | 334 // Returns true if there was state needing to be cleaned up. |
333 bool CleanupGestureState(); | 335 bool CleanupGestureState(); |
334 | 336 |
335 protected: | 337 protected: |
336 // Deletes (or removes if not owned by parent) all child windows. Intended for | 338 // Deletes (or removes if not owned by parent) all child windows. Intended for |
337 // use from the destructor. | 339 // use from the destructor. |
338 void RemoveOrDestroyChildren(); | 340 void RemoveOrDestroyChildren(); |
339 | 341 |
342 // Overrides from ui::PropertyHandler | |
343 std::unique_ptr<ui::PropertyData> BeforePropertyChange(const void* key) | |
344 override; | |
345 void AfterPropertyChange(const void* key, | |
346 int64_t old_value, | |
347 std::unique_ptr<ui::PropertyData> data) override; | |
340 private: | 348 private: |
341 friend class LayoutManager; | 349 friend class LayoutManager; |
342 friend class PropertyConverter; | 350 friend class PropertyConverter; |
343 friend class WindowPort; | 351 friend class WindowPort; |
344 friend class WindowTargeter; | 352 friend class WindowTargeter; |
345 friend class subtle::PropertyHelper; | 353 //friend class subtle::PropertyHelper; |
346 friend class test::WindowTestApi; | 354 friend class test::WindowTestApi; |
347 | 355 |
348 // Called by the public {Set,Get,Clear}Property functions. | 356 // Called by the public {Set,Get,Clear}Property functions. |
349 int64_t SetPropertyInternal(const void* key, | 357 int64_t SetPropertyInternal(const void* key, |
350 const char* name, | 358 const char* name, |
351 PropertyDeallocator deallocator, | 359 ui::PropertyDeallocator deallocator, |
352 int64_t value, | 360 int64_t value, |
353 int64_t default_value); | 361 int64_t default_value); |
354 int64_t GetPropertyInternal(const void* key, int64_t default_value) const; | 362 int64_t GetPropertyInternal(const void* key, int64_t default_value) const; |
355 | 363 |
356 // Returns true if the mouse pointer at relative-to-this-Window's-origin | 364 // Returns true if the mouse pointer at relative-to-this-Window's-origin |
357 // |local_point| can trigger an event for this Window. | 365 // |local_point| can trigger an event for this Window. |
358 // TODO(beng): A Window can supply a hit-test mask to cause some portions of | 366 // TODO(beng): A Window can supply a hit-test mask to cause some portions of |
359 // itself to not trigger events, causing the events to fall through to the | 367 // itself to not trigger events, causing the events to fall through to the |
360 // Window behind. | 368 // Window behind. |
361 bool HitTest(const gfx::Point& local_point); | 369 bool HitTest(const gfx::Point& local_point); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 bool ignore_events_; | 515 bool ignore_events_; |
508 | 516 |
509 // See set_hit_test_bounds_override_inner(). | 517 // See set_hit_test_bounds_override_inner(). |
510 gfx::Insets hit_test_bounds_override_inner_; | 518 gfx::Insets hit_test_bounds_override_inner_; |
511 | 519 |
512 base::ObserverList<WindowObserver, true> observers_; | 520 base::ObserverList<WindowObserver, true> observers_; |
513 | 521 |
514 // Value struct to keep the name and deallocator for this property. | 522 // Value struct to keep the name and deallocator for this property. |
515 // Key cannot be used for this purpose because it can be char* or | 523 // Key cannot be used for this purpose because it can be char* or |
516 // WindowProperty<>. | 524 // WindowProperty<>. |
517 struct Value { | 525 //struct Value { |
518 const char* name; | 526 // const char* name; |
519 int64_t value; | 527 // int64_t value; |
520 PropertyDeallocator deallocator; | 528 // PropertyDeallocator deallocator; |
521 }; | 529 //}; |
522 | 530 |
523 std::map<const void*, Value> prop_map_; | 531 //std::map<const void*, Value> prop_map_; |
524 | 532 |
525 DISALLOW_COPY_AND_ASSIGN(Window); | 533 DISALLOW_COPY_AND_ASSIGN(Window); |
526 }; | 534 }; |
527 | 535 |
528 } // namespace aura | 536 } // namespace aura |
529 | 537 |
530 #endif // UI_AURA_WINDOW_H_ | 538 #endif // UI_AURA_WINDOW_H_ |
OLD | NEW |