Shortcuts.cs
11.9 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
using System;
using JetBrains.Annotations;
using UnityEditor.ShortcutManagement;
using UnityEngine;
namespace UnityEditor.Timeline
{
static class Shortcuts
{
public static class Clip
{
public const string split = "Timeline/Editing/Split";
public const string trimStart = "Timeline/Editing/TrimStart";
public const string trimEnd = "Timeline/Editing/TrimEnd";
[UsedImplicitly, ShortcutManagement.Shortcut(split, typeof(TimelineWindow), KeyCode.S)]
static void Split(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(split, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(trimStart, typeof(TimelineWindow), KeyCode.I)]
static void TrimStart(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(trimStart, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(trimEnd, typeof(TimelineWindow), KeyCode.O)]
static void TrimEnd(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(trimEnd, args.context);
}
}
public static class Timeline
{
public const string play = "Timeline/Play";
public const string previousFrame = "Timeline/PrevFrame";
public const string nextFrame = "Timeline/NextFrame";
public const string frameAll = "Timeline/FrameAll";
public const string previousKey = "Timeline/PrevKey";
public const string nextKey = "Timeline/NextKey";
public const string goToStart = "Timeline/GotoStart";
public const string goToEnd = "Timeline/GotoEnd";
public const string zoomIn = "Timeline/ZoomIn";
public const string zoomOut = "Timeline/ZoomOut";
public const string collapseGroup = "Timeline/CollapseGroup";
public const string unCollapseGroup = "Timeline/UnCollapseGroup";
public const string selectLeftItem = "Timeline/SelectLeftItem";
public const string selectRightItem = "Timeline/SelectRightItem";
public const string selectUpItem = "Timeline/SelectUpItem";
public const string selectUpTrack = "Timeline/SelectUpTrack";
public const string selectDownItem = "Timeline/SelectDownItem";
public const string selectDownTrack = "Timeline/SelectDownTrack";
public const string multiSelectLeft = "Timeline/SelectLeft";
public const string multiSelectRight = "Timeline/SelectRight";
public const string multiSelectUp = "Timeline/SelectUp";
public const string multiSelectDown = "Timeline/SelectDown";
public const string toggleClipTrackArea = "Timeline/ToggleClipTrackArea";
public const string matchContent = "Timeline/MatchContent";
public const string toggleLock = "Timeline/ToggleLock";
public const string toggleMute = "Timeline/ToggleMute";
public const string moveLeft = "Timeline/MoveLeft";
public const string moveRight = "Timeline/MoveRight";
public const string moveUp = "Timeline/MoveUp";
public const string moveDown = "Timeline/MoveDown";
[UsedImplicitly, ShortcutManagement.Shortcut(play, typeof(TimelineWindow), KeyCode.Space)]
static void Play(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(play, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(previousFrame, typeof(TimelineWindow), KeyCode.Comma)]
static void PreviousFrame(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(previousFrame, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(nextFrame, typeof(TimelineWindow), KeyCode.Period)]
static void NextFrame(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(nextFrame, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(frameAll, typeof(TimelineWindow), KeyCode.A)]
static void FrameAll(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(frameAll, args.context);
}
#if UNITY_EDITOR_OSX
[UsedImplicitly, ShortcutManagement.Shortcut(previousKey, typeof(TimelineWindow), KeyCode.Comma, ShortcutModifiers.Action | ShortcutModifiers.Shift)]
#else
[UsedImplicitly, ShortcutManagement.Shortcut(previousKey, typeof(TimelineWindow), KeyCode.Comma, ShortcutModifiers.Action)]
#endif
static void PrevKey(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(previousKey, args.context);
}
#if UNITY_EDITOR_OSX
[UsedImplicitly, ShortcutManagement.Shortcut(nextKey, typeof(TimelineWindow), KeyCode.Period, ShortcutModifiers.Action | ShortcutModifiers.Shift)]
#else
[UsedImplicitly, ShortcutManagement.Shortcut(nextKey, typeof(TimelineWindow), KeyCode.Period, ShortcutModifiers.Action)]
#endif
static void NextKey(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(nextKey, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(goToStart, typeof(TimelineWindow), KeyCode.Comma, ShortcutModifiers.Shift)]
static void GoToStart(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(goToStart, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(goToEnd, typeof(TimelineWindow), KeyCode.Period, ShortcutModifiers.Shift)]
static void GoToEnd(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(goToEnd, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(zoomIn, typeof(TimelineWindow), KeyCode.Equals)]
static void ZoomIn(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(zoomIn, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(zoomOut, typeof(TimelineWindow), KeyCode.Minus)]
static void ZoomOut(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(zoomOut, args.context);
}
[UsedImplicitly]
[ShortcutManagement.Shortcut(moveLeft, typeof(TimelineWindow), KeyCode.LeftArrow)]
static void SelectLeft(ShortcutManagement.ShortcutArguments args)
{
if (KeyboardNavigation.ClipAreaActive())
{
SendEventToInvokeShortcut(selectLeftItem, args.context);
}
else if (KeyboardNavigation.TrackHeadActive())
{
SendEventToInvokeShortcut(collapseGroup, args.context);
}
}
[UsedImplicitly]
[ShortcutManagement.Shortcut(moveRight, typeof(TimelineWindow), KeyCode.RightArrow)]
static void SelectRight(ShortcutManagement.ShortcutArguments args)
{
if (KeyboardNavigation.ClipAreaActive())
{
SendEventToInvokeShortcut(selectRightItem, args.context);
}
else if (KeyboardNavigation.TrackHeadActive())
{
SendEventToInvokeShortcut(unCollapseGroup, args.context);
}
}
[UsedImplicitly]
[ShortcutManagement.Shortcut(moveUp, typeof(TimelineWindow), KeyCode.UpArrow)]
static void SelectUp(ShortcutManagement.ShortcutArguments args)
{
if (KeyboardNavigation.ClipAreaActive())
{
SendEventToInvokeShortcut(selectUpItem, args.context);
}
else if (KeyboardNavigation.TrackHeadActive())
{
SendEventToInvokeShortcut(selectUpTrack, args.context);
}
else
{
KeyboardNavigation.FocusFirstVisibleItem();
}
}
[UsedImplicitly]
[ShortcutManagement.Shortcut(moveDown, typeof(TimelineWindow), KeyCode.DownArrow)]
static void SelectDown(ShortcutManagement.ShortcutArguments args)
{
if (KeyboardNavigation.ClipAreaActive())
{
SendEventToInvokeShortcut(selectDownItem, args.context);
}
else if (KeyboardNavigation.TrackHeadActive())
{
SendEventToInvokeShortcut(selectDownTrack, args.context);
}
else
{
KeyboardNavigation.FocusFirstVisibleItem();
}
}
[UsedImplicitly, ShortcutManagement.Shortcut(multiSelectLeft, typeof(TimelineWindow), KeyCode.LeftArrow, ShortcutModifiers.Shift)]
static void MultiSelectLeft(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(multiSelectLeft, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(multiSelectRight, typeof(TimelineWindow), KeyCode.RightArrow, ShortcutModifiers.Shift)]
static void MultiSelectRight(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(multiSelectRight, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(multiSelectUp , typeof(TimelineWindow), KeyCode.UpArrow, ShortcutModifiers.Shift)]
static void MultiSelectUp(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(multiSelectUp, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(multiSelectDown, typeof(TimelineWindow), KeyCode.DownArrow, ShortcutModifiers.Shift)]
static void MultiSelectDown(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(multiSelectDown, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(toggleClipTrackArea, typeof(TimelineWindow), KeyCode.Tab)]
static void ToggleClipTrackArea(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(toggleClipTrackArea, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(matchContent, typeof(TimelineWindow), KeyCode.C)]
static void Shortcut(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(matchContent, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(toggleLock, typeof(TimelineWindow), KeyCode.L)]
static void Lock(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(toggleLock, args.context);
}
[UsedImplicitly, ShortcutManagement.Shortcut(toggleMute, typeof(TimelineWindow), KeyCode.M)]
static void Mute(ShortcutManagement.ShortcutArguments args)
{
SendEventToInvokeShortcut(toggleMute, args.context);
}
}
static WindowState GetState(ShortcutManagement.ShortcutArguments args)
{
return ((TimelineWindow)args.context).state;
}
static void SendEventToInvokeShortcut(string timelineShortcutId, object context)
{
var e = new Event
{
type = EventType.ExecuteCommand,
commandName = timelineShortcutId
};
(context as EditorWindow).SendEvent(e);
}
}
}