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
ash / wm / system_panel_view.h [blame]
// Copyright 2024 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_WM_SYSTEM_PANEL_VIEW_H_
#define ASH_WM_SYSTEM_PANEL_VIEW_H_
#include "ash/ash_export.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/view.h"
namespace ui {
class LocatedEvent;
} // namespace ui
namespace ash {
// `SystemPanelView` is a movable panel that can be dragged from any point
// within the view itself. Other drag behavior, e.g. for text selection, may be
// handled by the panel's child views.
class ASH_EXPORT SystemPanelView : public views::View {
METADATA_HEADER(SystemPanelView, views::View)
public:
// Handles logic for dragging to reposition the `SystemPanelView`.
class DragController {
public:
DragController() = default;
DragController(const DragController&) = delete;
DragController& operator=(const DragController&) = delete;
~DragController() = default;
// Handles mouse or gesture drag events to reposition `widget`. Events
// that are not part of a drag event sequence are ignored.
void OnLocatedPanelEvent(views::Widget* const widget,
ui::LocatedEvent* event);
private:
// Whether a drag is currently in progress.
bool is_dragging_ = false;
// The start coordinates of the most recent press or drag begin event
// handled by the controller, in screen coordinates.
gfx::Point start_dragging_event_location_;
// The initial bounds of the panel of the most recent press or drag begin
// event handled by the controller, in screen coordinates.
gfx::Rect panel_widget_initial_bounds_;
};
SystemPanelView();
SystemPanelView(const SystemPanelView&) = delete;
SystemPanelView& operator=(const SystemPanelView&) = delete;
~SystemPanelView() override;
// views::View:
void OnMouseEvent(ui::MouseEvent* event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
private:
// Handles drag events to reposition the panel. Events that are not part of a
// drag event sequence are ignored.
void HandleDragEventIfNeeded(ui::LocatedEvent* event);
DragController drag_controller_;
};
} // namespace ash
#endif // ASH_WM_SYSTEM_PANEL_VIEW_H_