recording_overlay_controller.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2021 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 ASH_CAPTURE_MODE_RECORDING_OVERLAY_CONTROLLER_H_
  5. #define ASH_CAPTURE_MODE_RECORDING_OVERLAY_CONTROLLER_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ui/views/widget/unique_widget_ptr.h"
  9. #include "ui/views/widget/widget.h"
  10. namespace aura {
  11. class Window;
  12. } // namespace aura
  13. namespace ash {
  14. class RecordingOverlayView;
  15. // Constructs and owns the widget that will be used as an overlay on top of the
  16. // recorded surface, to host contents, such as the Projector mode's annotations,
  17. // which are meant to be shown as part of the recording.
  18. class ASH_EXPORT RecordingOverlayController {
  19. public:
  20. // Constructs the overlay widget, and adds it as a child of
  21. // |window_being_recorded| with the initial bounds provided.
  22. // |initial_bounds_in_parent| should be relative to the parent
  23. // |window_being_recorded|.
  24. RecordingOverlayController(aura::Window* window_being_recorded,
  25. const gfx::Rect& initial_bounds_in_parent);
  26. RecordingOverlayController(const RecordingOverlayController&) = delete;
  27. RecordingOverlayController& operator=(const RecordingOverlayController&) =
  28. delete;
  29. ~RecordingOverlayController() = default;
  30. bool is_enabled() const { return is_enabled_; }
  31. // Toggles the overlay on or off.
  32. void Toggle();
  33. // Sets the bounds of the overlay widget. The given bounds should be relative
  34. // to the parent |window_being_recorded|.
  35. void SetBounds(const gfx::Rect& bounds_in_parent);
  36. // Gets the underlying window of |overlay_widget_|.
  37. aura::Window* GetOverlayNativeWindow();
  38. private:
  39. // Starts or stops showing the overlay on top of the recorded surface.
  40. void Start();
  41. void Stop();
  42. // Updates the z-order of the |overlay_widget_|'s native window.
  43. void UpdateWidgetStacking();
  44. // The overlay widget and its contents view.
  45. views::UniqueWidgetPtr overlay_widget_ = std::make_unique<views::Widget>();
  46. RecordingOverlayView* recording_overlay_view_ = nullptr;
  47. // Whether the overlay is currently enabled and showing on top of the recorded
  48. // surface.
  49. bool is_enabled_ = false;
  50. };
  51. } // namespace ash
  52. #endif // ASH_CAPTURE_MODE_RECORDING_OVERLAY_CONTROLLER_H_