group.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUI_INSPECTOR_GROUP_H_
  23. #define _GUI_INSPECTOR_GROUP_H_
  24. #include "gui/core/guiCanvas.h"
  25. #include "gui/controls/guiTextEditCtrl.h"
  26. #include "gui/buttons/guiBitmapButtonCtrl.h"
  27. #include "gui/containers/guiRolloutCtrl.h"
  28. // Forward refs
  29. class GuiInspector;
  30. class GuiInspectorField;
  31. /// The GuiInspectorGroup control is a helper control that the inspector
  32. /// makes use of which houses a collapsible pane type control for separating
  33. /// inspected objects fields into groups. The content of the inspector is
  34. /// made up of zero or more GuiInspectorGroup controls inside of a GuiStackControl
  35. ///
  36. class GuiInspectorGroup : public GuiRolloutCtrl
  37. {
  38. private:
  39. typedef GuiRolloutCtrl Parent;
  40. public:
  41. // Members
  42. SimObjectPtr<GuiInspector> mParent;
  43. Vector<GuiInspectorField*> mChildren;
  44. GuiStackControl* mStack;
  45. Vector<GuiRolloutCtrl*> mArrayCtrls;
  46. S32 mForcedArrayIndex; /// This is a special behavior variable that, when set, changes
  47. /// the presented behavior for arrays. Instead of showing sub-rollouts
  48. /// it instead forces showing ONLY the fields of the specific index, removing
  49. /// the presented array controls. This is useful for wanting to edit an associated
  50. /// 'set' of fields that are commonly arrayed, like material layers
  51. // Constructor/Destructor/Conobject Declaration
  52. GuiInspectorGroup();
  53. GuiInspectorGroup( const String& groupName, SimObjectPtr<GuiInspector> parent );
  54. virtual ~GuiInspectorGroup();
  55. DECLARE_CONOBJECT(GuiInspectorGroup);
  56. DECLARE_CATEGORY( "Gui Editor" );
  57. virtual GuiInspectorField* constructField( S32 fieldType );
  58. virtual GuiInspectorField* findField( const char *fieldName );
  59. // Publicly Accessible Information about this group
  60. const String& getGroupName() const { return mCaption; };
  61. SimObjectPtr<GuiInspector> getInspector() { return mParent; };
  62. bool onAdd() override;
  63. virtual bool inspectGroup();
  64. virtual void animateToContents();
  65. void clearFields();
  66. virtual bool updateFieldValue( StringTableEntry fieldName, const char *arrayIdx );
  67. virtual void updateAllFields();
  68. U32 getNumFields() const { return mChildren.size(); }
  69. GuiInspectorField* createInspectorField();
  70. void addInspectorField(StringTableEntry name, StringTableEntry typeName, const char* description, const char* callbackName);
  71. void addInspectorField(GuiInspectorField* field);
  72. void removeInspectorField(StringTableEntry name);
  73. void hideInspectorField(StringTableEntry fieldName, bool setHidden);
  74. void setForcedArrayIndex(const S32& arrayIndex = -1)
  75. {
  76. mForcedArrayIndex = arrayIndex;
  77. }
  78. protected:
  79. // overridable method that creates our inner controls.
  80. virtual bool createContent();
  81. /// Determine the class that is a common ancestor to all inspected objects.
  82. AbstractClassRep* findCommonAncestorClass();
  83. };
  84. #endif // _GUI_INSPECTOR_GROUP_H_