InspectableFieldStyleInfo.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. namespace bs.Editor
  5. {
  6. /// <summary>
  7. /// Contains boolean information about a field style.
  8. /// </summary>
  9. [Flags]
  10. public enum InspectableFieldStyleFlags
  11. {
  12. None = 0,
  13. /// <summary>
  14. /// Floating point field should be represented as a slider rather than a plain input field.
  15. /// </summary>
  16. AsSlider = 1 << 0,
  17. /// <summary>
  18. /// Integer field should be represented as a layer mask drop down instead of a plain integer input field.
  19. /// </summary>
  20. AsLayerMask = 1 << 1,
  21. /// <summary>
  22. /// Object accessed by the inspectable field is passed as a copy. This means modifications to the object returned by
  23. /// the property getter will not be registered until the object is re-assigned to the property. Similarly,
  24. /// modifications to the object passed to the setter, after the setter has been called, will not be registered by
  25. /// the field. Only relevant if a field type is a reference type.
  26. /// </summary>
  27. CopiedAsValue = 1 << 2,
  28. /// <summary>
  29. /// Object returned by the inspectable field will never be null, and null should never be passed to the field. Only
  30. /// relevant if a field type is a reference type.
  31. /// </summary>
  32. NotNull = 1 << 3,
  33. /// <summary>
  34. /// Field represents a property that wraps a native object. Getters and setters of such a property issue calls into
  35. /// native code to update the native object.
  36. /// </summary>
  37. NativeWrapper = 1 << 4,
  38. /// <summary>
  39. /// When a field changes those changes need to be applied to the parent object by calling the field setter. Only
  40. /// applicable to properties containing reference types.
  41. /// </summary>
  42. ApplyOnDirty = 1 << 5,
  43. /// <summary>
  44. /// When a quaternion is displayed in the inspector, by default it will be displayed as converted into euler angles.
  45. /// Use this flag to force it to be displayed as a quaternion (4D value) with no conversion instead.
  46. /// </summary>
  47. AsQuaternion = 1 << 6,
  48. /// <summary>
  49. /// Singifies that the field containing a class/struct should display the child fields of that objects as if they
  50. /// were part of the parent class in the inspector.
  51. /// </summary>
  52. Inline = 1 << 7,
  53. /// <summary>
  54. /// Signifies that a <see cref="RRef{T}"/> should be loaded when assigned to field through the inspector.
  55. /// </summary>
  56. LoadOnAssign = 1 << 8
  57. }
  58. /// <summary>
  59. /// Contains all the information about a field style.
  60. /// </summary>
  61. public class InspectableFieldStyleInfo
  62. {
  63. /// <summary>
  64. /// Information about the field range.
  65. /// </summary>
  66. public InspectableFieldRangeStyle RangeStyle;
  67. /// <summary>
  68. /// Information about the field stepping.
  69. /// </summary>
  70. public InspectableFieldStepStyle StepStyle;
  71. /// <summary>
  72. /// Determines the category to place the field in. If null field will be placed in the default category.
  73. /// </summary>
  74. public InspectableFieldCategoryStyle CategoryStyle;
  75. /// <summary>
  76. /// Determines the order of the field displayed in the inspector, relative to other fields.
  77. /// </summary>
  78. public InspectableFieldOrderStyle OrderStyle;
  79. /// <summary>
  80. /// Boolean information about the field.
  81. /// </summary>
  82. public InspectableFieldStyleFlags StyleFlags;
  83. /// <summary>
  84. /// Creates an empty set of information about a field style.
  85. /// </summary>
  86. public InspectableFieldStyleInfo()
  87. {
  88. }
  89. /// <summary>
  90. /// Makes a deep copy of this object.
  91. /// </summary>
  92. public InspectableFieldStyleInfo Clone()
  93. {
  94. InspectableFieldStyleInfo style = new InspectableFieldStyleInfo();
  95. style.StyleFlags = StyleFlags;
  96. if(RangeStyle != null)
  97. style.RangeStyle = new InspectableFieldRangeStyle(RangeStyle.Min, RangeStyle.Max, RangeStyle.Slider);
  98. if(StepStyle != null)
  99. style.StepStyle = new InspectableFieldStepStyle(StepStyle.Step);
  100. if(CategoryStyle != null)
  101. style.CategoryStyle = new InspectableFieldCategoryStyle(CategoryStyle.Category);
  102. if(OrderStyle != null)
  103. style.OrderStyle = new InspectableFieldOrderStyle(OrderStyle.Index);
  104. return style;
  105. }
  106. }
  107. }