InspectableFieldStyleInfo.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. /// <summary>
  58. /// Specifies that a <see cref="Color"/> is allowed to have a value outside of the [0, 1] range.
  59. /// </summary>
  60. HDR = 1 << 9
  61. }
  62. /// <summary>
  63. /// Contains all the information about a field style.
  64. /// </summary>
  65. public class InspectableFieldStyleInfo
  66. {
  67. /// <summary>
  68. /// Information about the field range.
  69. /// </summary>
  70. public InspectableFieldRangeStyle RangeStyle;
  71. /// <summary>
  72. /// Information about the field stepping.
  73. /// </summary>
  74. public InspectableFieldStepStyle StepStyle;
  75. /// <summary>
  76. /// Determines the category to place the field in. If null field will be placed in the default category.
  77. /// </summary>
  78. public InspectableFieldCategoryStyle CategoryStyle;
  79. /// <summary>
  80. /// Determines the order of the field displayed in the inspector, relative to other fields.
  81. /// </summary>
  82. public InspectableFieldOrderStyle OrderStyle;
  83. /// <summary>
  84. /// Boolean information about the field.
  85. /// </summary>
  86. public InspectableFieldStyleFlags StyleFlags;
  87. /// <summary>
  88. /// Creates an empty set of information about a field style.
  89. /// </summary>
  90. public InspectableFieldStyleInfo()
  91. {
  92. }
  93. /// <summary>
  94. /// Makes a deep copy of this object.
  95. /// </summary>
  96. public InspectableFieldStyleInfo Clone()
  97. {
  98. InspectableFieldStyleInfo style = new InspectableFieldStyleInfo();
  99. style.StyleFlags = StyleFlags;
  100. if(RangeStyle != null)
  101. style.RangeStyle = new InspectableFieldRangeStyle(RangeStyle.Min, RangeStyle.Max, RangeStyle.Slider);
  102. if(StepStyle != null)
  103. style.StepStyle = new InspectableFieldStepStyle(StepStyle.Step);
  104. if(CategoryStyle != null)
  105. style.CategoryStyle = new InspectableFieldCategoryStyle(CategoryStyle.Category);
  106. if(OrderStyle != null)
  107. style.OrderStyle = new InspectableFieldOrderStyle(OrderStyle.Index);
  108. return style;
  109. }
  110. }
  111. }