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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
ash / system / time / calendar_event_list_item_view.h [blame]
// 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_SYSTEM_TIME_CALENDAR_EVENT_LIST_ITEM_VIEW_H_
#define ASH_SYSTEM_TIME_CALENDAR_EVENT_LIST_ITEM_VIEW_H_
#include "ash/ash_export.h"
#include "base/memory/raw_ptr.h"
#include "google_apis/calendar/calendar_api_response_types.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/controls/button/button.h"
#include "url/gurl.h"
namespace ui {
class Event;
} // namespace ui
namespace gfx {
class RoundedCornersF;
}
namespace ash {
// View ID's.
constexpr int kSummaryLabelID = 100;
constexpr int kTimeLabelID = 101;
constexpr int kEventListItemDotID = 102;
constexpr int kJoinButtonID = 103;
constexpr int kEventListMultiDayEventsContainer = 104;
constexpr int kEventListSameDayEventsContainer = 105;
class CalendarViewController;
struct SelectedDateParams {
base::Time selected_date;
base::Time selected_date_midnight;
base::Time selected_date_midnight_utc;
};
struct UIParams {
bool round_top_corners = false;
bool round_bottom_corners = false;
// If this view is for `CalendarUpNextView`. `CalendarUpNextView` event list
// item has a different focus ring rounded corner radius.
bool is_up_next_event_list_item = false;
// Show the calendar indicator dots which show the event colors. If
// false this piece of UI is not added to the view hierarchy.
bool show_event_list_dot = false;
// Used in `Label::SizeToFit()` to fix the width of this view. If 0, no
// fixed width is enforced.
int fixed_width = 0;
};
// The index of the event in the event list. Used for the accessibility
// description to show "Event n of n".
struct EventListItemIndex {
int item_index;
int total_count_of_events;
};
// This view displays a calendar event entry.
class ASH_EXPORT CalendarEventListItemView : public views::Button {
METADATA_HEADER(CalendarEventListItemView, views::Button)
public:
CalendarEventListItemView(CalendarViewController* calendar_view_controller,
SelectedDateParams selected_date_params,
google_apis::calendar::CalendarEvent event,
UIParams ui_params,
EventListItemIndex event_list_item_index);
CalendarEventListItemView(const CalendarEventListItemView& other) = delete;
CalendarEventListItemView& operator=(const CalendarEventListItemView& other) =
delete;
~CalendarEventListItemView() override;
// views::View:
void OnThemeChanged() override;
void PerformAction(const ui::Event& event);
// Sets up a custom highlight path for when the
// `CalendarEventListItemView` view is focused. Conditionally follows the
// same corner rounding as the view.
void SetUpFocusHighlight(const gfx::RoundedCornersF& item_corner_radius);
void OnJoinMeetingButtonPressed(const ui::Event& event);
bool is_current_or_next_single_day_event() const {
return is_current_or_next_single_day_event_;
}
private:
friend class CalendarViewEventListViewTest;
// Unowned.
const raw_ptr<CalendarViewController, DanglingUntriaged>
calendar_view_controller_;
const SelectedDateParams selected_date_params_;
// The URL for the meeting event.
const GURL event_url_;
const GURL video_conference_url_;
// Whether this item which is not an all-day or multi-day event is the current
// or next event. Used for auto scroll in the `CalendarEventListView`.
bool is_current_or_next_single_day_event_ = false;
// Whether this event has ended by now.
bool is_past_event_ = false;
base::WeakPtrFactory<CalendarEventListItemView> weak_ptr_factory_{this};
};
} // namespace ash
#endif // ASH_SYSTEM_TIME_CALENDAR_EVENT_LIST_ITEM_VIEW_H_