Handle.cs 2.1 KB

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