Add context menu for the timeline tracks and change signature for media context menu
This commit is contained in:
@@ -229,8 +229,9 @@ namespace FlaxEditor.GUI.Timeline
|
|||||||
/// Called when showing timeline context menu to the user. Can be used to add custom buttons.
|
/// Called when showing timeline context menu to the user. Can be used to add custom buttons.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="menu">The menu.</param>
|
/// <param name="menu">The menu.</param>
|
||||||
|
/// <param name="time">The time (in seconds) at which context menu is shown (user clicked on a timeline).</param>
|
||||||
/// <param name="controlUnderMouse">The found control under the mouse cursor.</param>
|
/// <param name="controlUnderMouse">The found control under the mouse cursor.</param>
|
||||||
public virtual void OnTimelineShowContextMenu(ContextMenu.ContextMenu menu, Control controlUnderMouse)
|
public virtual void OnTimelineContextMenu(ContextMenu.ContextMenu menu, float time, Control controlUnderMouse)
|
||||||
{
|
{
|
||||||
if (CanDelete && Track.Media.Count > Track.MinMediaCount)
|
if (CanDelete && Track.Media.Count > Track.MinMediaCount)
|
||||||
menu.AddButton("Delete media", Delete);
|
menu.AddButton("Delete media", Delete);
|
||||||
|
|||||||
@@ -1901,6 +1901,9 @@ namespace FlaxEditor.GUI.Timeline
|
|||||||
if (!ContainsFocus)
|
if (!ContainsFocus)
|
||||||
Focus();
|
Focus();
|
||||||
|
|
||||||
|
var timelinePos = MediaPanel.PointFromParent(this, location);
|
||||||
|
var time = (timelinePos.X - StartOffset) / (UnitsPerSecond * Zoom);
|
||||||
|
|
||||||
var controlUnderMouse = GetChildAtRecursive(location);
|
var controlUnderMouse = GetChildAtRecursive(location);
|
||||||
var mediaUnderMouse = controlUnderMouse;
|
var mediaUnderMouse = controlUnderMouse;
|
||||||
while (mediaUnderMouse != null && !(mediaUnderMouse is Media))
|
while (mediaUnderMouse != null && !(mediaUnderMouse is Media))
|
||||||
@@ -1911,12 +1914,23 @@ namespace FlaxEditor.GUI.Timeline
|
|||||||
var menu = new ContextMenu.ContextMenu();
|
var menu = new ContextMenu.ContextMenu();
|
||||||
if (mediaUnderMouse is Media media)
|
if (mediaUnderMouse is Media media)
|
||||||
{
|
{
|
||||||
media.OnTimelineShowContextMenu(menu, controlUnderMouse);
|
media.OnTimelineContextMenu(menu, time, controlUnderMouse);
|
||||||
if (media.PropertiesEditObject != null)
|
if (media.PropertiesEditObject != null)
|
||||||
{
|
{
|
||||||
menu.AddButton("Edit media", () => ShowEditPopup(media.PropertiesEditObject, location, media.Track));
|
menu.AddButton("Edit media", () => ShowEditPopup(media.PropertiesEditObject, location, media.Track));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var track in _tracks)
|
||||||
|
{
|
||||||
|
if (Mathf.IsInRange(timelinePos.Y, track.Top, track.Bottom))
|
||||||
|
{
|
||||||
|
track.OnTimelineContextMenu(menu, time);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (PropertiesEditObject != null)
|
if (PropertiesEditObject != null)
|
||||||
{
|
{
|
||||||
menu.AddButton("Edit timeline", () => ShowEditPopup(PropertiesEditObject, location, this));
|
menu.AddButton("Edit timeline", () => ShowEditPopup(PropertiesEditObject, location, this));
|
||||||
|
|||||||
@@ -1028,6 +1028,15 @@ namespace FlaxEditor.GUI.Timeline
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when showing timeline context menu to the user. Can be used to add custom buttons.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="menu">The menu.</param>
|
||||||
|
/// <param name="time">The time (in seconds) at which context menu is shown (user clicked on a timeline).</param>
|
||||||
|
public virtual void OnTimelineContextMenu(ContextMenu.ContextMenu menu, float time)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when context menu is being prepared to show. Can be used to add custom options.
|
/// Called when context menu is being prepared to show. Can be used to add custom options.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -324,12 +324,12 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnTimelineShowContextMenu(ContextMenu.ContextMenu menu, Control controlUnderMouse)
|
public override void OnTimelineContextMenu(ContextMenu.ContextMenu menu, float time, Control controlUnderMouse)
|
||||||
{
|
{
|
||||||
if (((CameraCutTrack)Track).Camera)
|
if (((CameraCutTrack)Track).Camera)
|
||||||
menu.AddButton("Refresh thumbnails", () => UpdateThumbnails());
|
menu.AddButton("Refresh thumbnails", () => UpdateThumbnails());
|
||||||
|
|
||||||
base.OnTimelineShowContextMenu(menu, controlUnderMouse);
|
base.OnTimelineContextMenu(menu, time, controlUnderMouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnTimelineShowContextMenu(ContextMenu.ContextMenu menu, Control controlUnderMouse)
|
public override void OnTimelineContextMenu(ContextMenu.ContextMenu menu, float time, Control controlUnderMouse)
|
||||||
{
|
{
|
||||||
base.OnTimelineShowContextMenu(menu, controlUnderMouse);
|
base.OnTimelineContextMenu(menu, time, controlUnderMouse);
|
||||||
|
|
||||||
if (controlUnderMouse is GradientEditor.StopControl stop)
|
if (controlUnderMouse is GradientEditor.StopControl stop)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user