File: capture_button_view.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (85 lines) | stat: -rw-r--r-- 3,476 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_CAPTURE_MODE_CAPTURE_BUTTON_VIEW_H_
#define ASH_CAPTURE_MODE_CAPTURE_BUTTON_VIEW_H_

#include "ash/capture_mode/capture_mode_session_focus_cycler.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"

namespace views {
class ImageButton;
class LabelButton;
class Separator;
}  // namespace views

namespace ash {

class CaptureModeBehavior;

// Defines a view that will host the capture button which when pressed, the
// screen capture operation will be performed. In the case of video recording,
// if multiple recording formats are supported, it will display a drop down
// button which when pressed will open the recording type selection menu.
class CaptureButtonView : public views::View {
  METADATA_HEADER(CaptureButtonView, views::View)

 public:
  CaptureButtonView(views::Button::PressedCallback on_capture_button_pressed,
                    views::Button::PressedCallback on_drop_down_pressed,
                    CaptureModeBehavior* active_behavior);
  CaptureButtonView(const CaptureButtonView&) = delete;
  CaptureButtonView& operator=(const CaptureButtonView&) = delete;
  ~CaptureButtonView() override = default;

  views::LabelButton* capture_button() { return capture_button_; }
  views::ImageButton* drop_down_button() { return drop_down_button_; }

  // Updates the icon and text of `capture_button_`, as well as the visibility
  // of the `separator_` and `drop_down_button_` depending on the current type
  // of capture. It also updates the shape of the focus ring of the
  // `capture_button_` as it can switch from being fully rounded to half rounded
  // when the visibility of the separator changes. This should only be called
  // when this view is visible.
  void UpdateViewVisuals();

  // Returns the list of avaibale buttons that can be highlighted while
  // navigating with keyboard.
  std::vector<CaptureModeSessionFocusCycler::HighlightableView*>
  GetHighlightableItems() const;

  // views::View:
  void OnThemeChanged() override;

 private:
  // Sets up the given `button`'s ink drop style and focus behavior.
  void SetupButton(views::Button* button);

  // Bound to callbacks that will create a path generator for both the capture
  // and the drop down buttons. If `use_zero_insets` is true, no insets will be
  // added to the resulting path generator. This is useful when using the path
  // generator for the ink drop highlight which should not have any insets,
  // unlike the focus ring which should be insetted a little to be drawn within
  // the bounds of the view.
  std::unique_ptr<views::HighlightPathGenerator> CreateFocusRingPath(
      views::View* view,
      bool use_zero_insets);

  // The button which when pressed, screen capture will be performed.
  const raw_ptr<views::LabelButton> capture_button_;

  // Optional views that are created only, when multiple (i.e. more than one)
  // recording formats (e.g. webm, gif, .. etc.) are supported. They're visible
  // only if the current capture type is video recording.
  raw_ptr<views::Separator> separator_ = nullptr;
  raw_ptr<views::ImageButton> drop_down_button_ = nullptr;
};

}  // namespace ash

#endif  // ASH_CAPTURE_MODE_CAPTURE_BUTTON_VIEW_H_