Handle.cs 2.1 KB

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