capture_mode_bar_view.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright 2020 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_CAPTURE_MODE_BAR_VIEW_H_
  5. #define ASH_CAPTURE_MODE_CAPTURE_MODE_BAR_VIEW_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/capture_mode/capture_mode_types.h"
  8. #include "ui/base/metadata/metadata_header_macros.h"
  9. #include "ui/views/view.h"
  10. namespace views {
  11. class Separator;
  12. } // namespace views
  13. namespace ash {
  14. class CaptureModeButton;
  15. class CaptureModeSourceView;
  16. class CaptureModeToggleButton;
  17. class CaptureModeTypeView;
  18. class SystemShadow;
  19. // A view that acts as the content view of the capture mode bar widget.
  20. // It has a set of buttons to toggle between image and video capture, and
  21. // another set of buttons to toggle between fullscreen, region, and window
  22. // capture sources. It also contains a settings button. The structure looks like
  23. // this:
  24. //
  25. // +---------------------------------------------------------------+
  26. // | +----------------+ | | |
  27. // | | +---+ +---+ | | +---+ +---+ +---+ | +---+ +---+ |
  28. // | | | | | | | | | | | | | | | | | | | |
  29. // | | +---+ +---+ | | +---+ +---+ +---+ | +---+ +---+ |
  30. // | +----------------+ | ^ ^ | ^ ^ |
  31. // +--^----------------------|-----------------|-----|------|------+
  32. // ^ | +-----------------+ | |
  33. // | | | | CaptureModeButton
  34. // | | | |
  35. // | | | CaptureModeToggleButton
  36. // | | CaptureModeSourceView
  37. // | CaptureModeTypeView
  38. // |
  39. // CaptureModeBarView
  40. //
  41. class ASH_EXPORT CaptureModeBarView : public views::View {
  42. public:
  43. METADATA_HEADER(CaptureModeBarView);
  44. // |projector_mode| is true when the current session was started through the
  45. // projector workflow.
  46. explicit CaptureModeBarView(bool projector_mode);
  47. CaptureModeBarView(const CaptureModeBarView&) = delete;
  48. CaptureModeBarView& operator=(const CaptureModeBarView&) = delete;
  49. ~CaptureModeBarView() override;
  50. CaptureModeTypeView* capture_type_view() const { return capture_type_view_; }
  51. CaptureModeSourceView* capture_source_view() const {
  52. return capture_source_view_;
  53. }
  54. CaptureModeToggleButton* settings_button() const { return settings_button_; }
  55. CaptureModeButton* close_button() const { return close_button_; }
  56. // Gets the ideal bounds in screen coordinates of the bar of widget on the
  57. // given `root` window. The `image_toggle_button` will not be shown in the bar
  58. // if `is_in_projector_mode` is true, which means the width of the bar will be
  59. // different.
  60. static gfx::Rect GetBounds(aura::Window* root, bool is_in_projector_mode);
  61. // Called when either the capture mode source or type changes.
  62. void OnCaptureSourceChanged(CaptureModeSource new_source);
  63. void OnCaptureTypeChanged(CaptureModeType new_type);
  64. // Called when settings is toggled on or off.
  65. void SetSettingsMenuShown(bool shown);
  66. private:
  67. void OnSettingsButtonPressed();
  68. void OnCloseButtonPressed();
  69. // Owned by the views hierarchy.
  70. CaptureModeTypeView* capture_type_view_;
  71. views::Separator* separator_1_;
  72. CaptureModeSourceView* capture_source_view_;
  73. views::Separator* separator_2_;
  74. CaptureModeToggleButton* settings_button_;
  75. CaptureModeButton* close_button_;
  76. std::unique_ptr<SystemShadow> shadow_;
  77. };
  78. } // namespace ash
  79. #endif // ASH_CAPTURE_MODE_CAPTURE_MODE_BAR_VIEW_H_