Handle.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections.Generic;
  2. using BansheeEngine;
  3. namespace BansheeEditor
  4. {
  5. /// <summary>
  6. /// Base class for handle implementations. Handles provide tools that the user can interact with in the scene view.
  7. /// This includes traditional handles like move, rotate or scale, but also custom user defined handles. Custom handles
  8. /// need to implement this class and also specify a <see cref="CustomHandle"/> attribute.
  9. /// </summary>
  10. public abstract class Handle
  11. {
  12. private List<HandleSlider> sliders = new List<HandleSlider>();
  13. /// <summary>
  14. /// Called every frame before handle input is processed. Allows handle transforms to be updated before input.
  15. /// </summary>
  16. protected internal abstract void PreInput();
  17. /// <summary>
  18. /// Called every frame after handle input is processed. Active handle sliders should contain values signals if and
  19. /// how much they were dragged.
  20. /// </summary>
  21. protected internal abstract void PostInput();
  22. /// <summary>
  23. /// Called every frame after <see cref="PostInput"/>. Allows handles graphics to be drawn. This is the only
  24. /// method that draw methods <see cref="Handles"/> may be called.
  25. /// </summary>
  26. protected internal abstract void Draw();
  27. /// <summary>
  28. /// Registers a new handle slider used by this handle.
  29. /// </summary>
  30. /// <param name="slider">Slider used by the handle.</param>
  31. internal void RegisterSlider(HandleSlider slider)
  32. {
  33. sliders.Add(slider);
  34. }
  35. /// <summary>
  36. /// Destroys the handle, removing it from the scene.
  37. /// </summary>
  38. public void Destroy()
  39. {
  40. foreach (var slider in sliders)
  41. slider.Destroy();
  42. }
  43. }
  44. }