From bcce52ca22ab80bd29b95f7d60dd69df6a68abb8 Mon Sep 17 00:00:00 2001 From: Menotdan <32620310+Menotdan@users.noreply.github.com> Date: Fri, 8 Dec 2023 17:38:58 -0500 Subject: [PATCH] Refactor CurveEditor and KeyframesEditor to use input options. --- Source/Editor/GUI/CurveEditor.cs | 44 +++++++++---------- .../GUI/Timeline/GUI/KeyframesEditor.cs | 42 ++++++++---------- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/Source/Editor/GUI/CurveEditor.cs b/Source/Editor/GUI/CurveEditor.cs index 22deec120..b93aedaf9 100644 --- a/Source/Editor/GUI/CurveEditor.cs +++ b/Source/Editor/GUI/CurveEditor.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.Linq; using FlaxEditor.CustomEditors; using FlaxEditor.GUI.ContextMenu; +using FlaxEditor.Options; using FlaxEngine; using FlaxEngine.GUI; @@ -926,34 +927,29 @@ namespace FlaxEditor.GUI if (base.OnKeyDown(key)) return true; - switch (key) + InputOptions options = Editor.Instance.Options.Options.Input; + if (options.SelectAll.Process(this)) + { + SelectAll(); + UpdateTangents(); + return true; + } + else if (options.Delete.Process(this)) { - case KeyboardKeys.Delete: RemoveKeyframes(); return true; - case KeyboardKeys.A: - if (Root.GetKey(KeyboardKeys.Control)) - { - SelectAll(); - UpdateTangents(); - return true; - } - break; - case KeyboardKeys.C: - if (Root.GetKey(KeyboardKeys.Control)) - { - CopyKeyframes(); - return true; - } - break; - case KeyboardKeys.V: - if (Root.GetKey(KeyboardKeys.Control)) - { - KeyframesEditorUtils.Paste(this); - return true; - } - break; } + else if (options.Copy.Process(this)) + { + CopyKeyframes(); + return true; + } + else if (options.Paste.Process(this)) + { + KeyframesEditorUtils.Paste(this); + return true; + } + return false; } diff --git a/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs b/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs index cb781229f..87bcb9d10 100644 --- a/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs +++ b/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using FlaxEditor.CustomEditors; using FlaxEditor.GUI.ContextMenu; +using FlaxEditor.Options; using FlaxEditor.Scripting; using FlaxEngine; using FlaxEngine.GUI; @@ -1268,33 +1269,28 @@ namespace FlaxEditor.GUI if (base.OnKeyDown(key)) return true; - switch (key) + InputOptions options = Editor.Instance.Options.Options.Input; + if (options.SelectAll.Process(this)) + { + SelectAll(); + return true; + } + else if (options.Delete.Process(this)) { - case KeyboardKeys.Delete: RemoveKeyframes(); return true; - case KeyboardKeys.A: - if (Root.GetKey(KeyboardKeys.Control)) - { - SelectAll(); - return true; - } - break; - case KeyboardKeys.C: - if (Root.GetKey(KeyboardKeys.Control)) - { - CopyKeyframes(); - return true; - } - break; - case KeyboardKeys.V: - if (Root.GetKey(KeyboardKeys.Control)) - { - KeyframesEditorUtils.Paste(this); - return true; - } - break; } + else if (options.Copy.Process(this)) + { + CopyKeyframes(); + return true; + } + else if (options.Paste.Process(this)) + { + KeyframesEditorUtils.Paste(this); + return true; + } + return false; }