window_element.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2017 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. #ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_WINDOW_ELEMENT_H_
  5. #define COMPONENTS_UI_DEVTOOLS_VIEWS_WINDOW_ELEMENT_H_
  6. #include "components/ui_devtools/views/ui_element_with_metadata.h"
  7. #include "ui/aura/window.h"
  8. #include "ui/aura/window_observer.h"
  9. #include "ui/gfx/geometry/rect.h"
  10. #include "ui/gfx/native_widget_types.h"
  11. namespace ui_devtools {
  12. class WindowElement : public aura::WindowObserver,
  13. public UIElementWithMetaData {
  14. public:
  15. WindowElement(aura::Window* window,
  16. UIElementDelegate* ui_element_delegate,
  17. UIElement* parent);
  18. WindowElement(const WindowElement&) = delete;
  19. WindowElement& operator=(const WindowElement&) = delete;
  20. ~WindowElement() override;
  21. aura::Window* window() const { return window_; }
  22. // WindowObserver:
  23. void OnWindowHierarchyChanging(
  24. const aura::WindowObserver::HierarchyChangeParams& params) override;
  25. void OnWindowHierarchyChanged(
  26. const aura::WindowObserver::HierarchyChangeParams& params) override;
  27. void OnWindowStackingChanged(aura::Window* window) override;
  28. void OnWindowBoundsChanged(aura::Window* window,
  29. const gfx::Rect& old_bounds,
  30. const gfx::Rect& new_bounds,
  31. ui::PropertyChangeReason reason) override;
  32. // UIElement:
  33. void GetBounds(gfx::Rect* bounds) const override;
  34. void SetBounds(const gfx::Rect& bounds) override;
  35. void GetVisible(bool* visible) const override;
  36. void SetVisible(bool visible) override;
  37. std::vector<std::string> GetAttributes() const override;
  38. std::pair<gfx::NativeWindow, gfx::Rect> GetNodeWindowAndScreenBounds()
  39. const override;
  40. bool DispatchKeyEvent(protocol::DOM::KeyEvent* event) override;
  41. static aura::Window* From(const UIElement* element);
  42. void InitSources() override;
  43. protected:
  44. ui::metadata::ClassMetaData* GetClassMetaData() const override;
  45. void* GetClassInstance() const override;
  46. ui::Layer* GetLayer() const override;
  47. private:
  48. aura::Window* window_;
  49. };
  50. } // namespace ui_devtools
  51. #endif // COMPONENTS_UI_DEVTOOLS_VIEWS_WINDOW_ELEMENT_H_