Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ATTRIBUTEWIDGETFACTORY_H
  7. #define ATTRIBUTEWIDGETFACTORY_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier0/platform.h"
  12. //-----------------------------------------------------------------------------
  13. // Forward declarations
  14. //-----------------------------------------------------------------------------
  15. class CDmElement;
  16. class CMovieDoc;
  17. class IDmNotify;
  18. class CDmeEditorAttributeInfo;
  19. class CDmeEditorTypeDictionary;
  20. class CDmAttribute;
  21. namespace vgui
  22. {
  23. class EditablePanel;
  24. class Panel;
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Info about the attribute being edited, and how the editor should look
  28. //-----------------------------------------------------------------------------
  29. struct AttributeWidgetInfo_t
  30. {
  31. AttributeWidgetInfo_t()
  32. {
  33. m_nArrayIndex = -1;
  34. }
  35. CDmElement *m_pElement;
  36. const char *m_pAttributeName;
  37. int m_nArrayIndex;
  38. CDmeEditorTypeDictionary *m_pEditorTypeDictionary;
  39. CDmeEditorAttributeInfo *m_pEditorInfo;
  40. IDmNotify *m_pNotify;
  41. bool m_bAutoApply;
  42. bool m_bShowMemoryUsage;
  43. };
  44. //-----------------------------------------------------------------------------
  45. // Interface used to create an attribute widget
  46. //-----------------------------------------------------------------------------
  47. class IAttributeWidgetFactory
  48. {
  49. public:
  50. virtual vgui::Panel *Create( vgui::Panel *pParent, const AttributeWidgetInfo_t &info ) = 0;
  51. };
  52. //-----------------------------------------------------------------------------
  53. // Templatized class used to create widget factories
  54. //-----------------------------------------------------------------------------
  55. class IAttributeWidgetFactoryList
  56. {
  57. public:
  58. // Returns a named widget factory
  59. virtual IAttributeWidgetFactory *GetWidgetFactory( const char *pWidgetName ) = 0;
  60. // Returns a factory used to create widget for the attribute passed in
  61. virtual IAttributeWidgetFactory *GetWidgetFactory( CDmElement *object, CDmAttribute *pAttribute, CDmeEditorTypeDictionary *pTypeDictionary ) = 0;
  62. // Returns a factory used to create widgets for entries in an attribute array
  63. virtual IAttributeWidgetFactory *GetArrayWidgetFactory( CDmElement *object, CDmAttribute *pAttribute, CDmeEditorTypeDictionary *pTypeDictionary ) = 0;
  64. // Applies changes to a widget
  65. virtual void ApplyChanges( vgui::Panel *pWidget, vgui::Panel *pSender = NULL ) = 0;
  66. // Refreshes a widget when attributes change
  67. virtual void Refresh( vgui::Panel *pWidget, vgui::Panel *pSender = NULL ) = 0;
  68. };
  69. extern IAttributeWidgetFactoryList *attributewidgetfactorylist;
  70. #endif // ATTRIBUTEWIDGETFACTORY_H