TVCustomizeTrackColorsDlg.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. // Description : A dialog for customizing track colors
  9. #ifndef CRYINCLUDE_EDITOR_TRACKVIEW_TVCUSTOMIZETRACKCOLORSDLG_H
  10. #define CRYINCLUDE_EDITOR_TRACKVIEW_TVCUSTOMIZETRACKCOLORSDLG_H
  11. #pragma once
  12. #if !defined(Q_MOC_RUN)
  13. #include <QDialog>
  14. #endif
  15. namespace Ui
  16. {
  17. class TVCustomizeTrackColorsDialog;
  18. }
  19. class QLabel;
  20. class ColorButton;
  21. class CTVCustomizeTrackColorsDlg
  22. : public QDialog
  23. {
  24. Q_OBJECT
  25. friend class CTrackViewDialog;
  26. public:
  27. CTVCustomizeTrackColorsDlg(QWidget* pParent = nullptr);
  28. virtual ~CTVCustomizeTrackColorsDlg();
  29. static QColor GetTrackColor(CAnimParamType paramType)
  30. {
  31. auto itr = s_trackColors.find(paramType);
  32. if (itr != end(s_trackColors))
  33. {
  34. return itr->second;
  35. }
  36. else
  37. {
  38. return s_colorForOthers;
  39. }
  40. }
  41. static QColor GetColorForDisabledTracks()
  42. { return s_colorForDisabled; }
  43. static QColor GetColorForMutedTracks()
  44. { return s_colorForMuted; }
  45. private:
  46. inline void GetQColorFromXmlNode(QColor& colorOut, const XmlNodeRef& xmlNode) const
  47. {
  48. QRgb rgb = std::numeric_limits<unsigned int>::max();
  49. xmlNode->getAttr("color", rgb);
  50. colorOut.setRgb(rgb);
  51. };
  52. virtual void OnInitDialog();
  53. void OnApply();
  54. void OnResetAll();
  55. void OnExport();
  56. void OnImport();
  57. void accept() override;
  58. void Export(const QString& fullPath) const;
  59. bool Import(const QString& fullPath);
  60. static void SaveColors(const char* sectionName);
  61. static void LoadColors(const char* sectionName);
  62. QVector<QLabel*> m_aLabels;
  63. QVector<ColorButton*> m_colorButtons;
  64. QScopedPointer<Ui::TVCustomizeTrackColorsDialog> m_ui;
  65. static std::map<CAnimParamType, QColor> s_trackColors;
  66. static QColor s_colorForDisabled;
  67. static QColor s_colorForMuted;
  68. static QColor s_colorForOthers;
  69. };
  70. #endif // CRYINCLUDE_EDITOR_TRACKVIEW_TVCUSTOMIZETRACKCOLORSDLG_H