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.

79 lines
3.2KB

  1. #include "PluginSelectorState.h"
  2. namespace {
  3. const char* XML_SORT_COLUMN_ID_STR {"sortColumnId"};
  4. const char* XML_SORT_FORWARDS_STR {"sortForwards"};
  5. const char* XML_SORT_INCLUDE_VST_STR {"includeVST"};
  6. const char* XML_SORT_INCLUDE_VST3_STR {"includeVST3"};
  7. const char* XML_SORT_INCLUDE_AU_STR {"includeAU"};
  8. const char* XML_SORT_FILTER_STRING_STR {"filterString"};
  9. const char* XML_SORT_BOUNDS_STR {"bounds"};
  10. const char* XML_SORT_SCROLL_POSITION_STR {"scrollPosition"};
  11. }
  12. void PluginSelectorState::restoreFromXml(juce::XmlElement* element) {
  13. if (element->hasAttribute(XML_SORT_COLUMN_ID_STR)) {
  14. sortColumnId = element->getIntAttribute(XML_SORT_COLUMN_ID_STR);
  15. } else {
  16. juce::Logger::writeToLog("Missing attribute " + juce::String(XML_SORT_COLUMN_ID_STR));
  17. }
  18. if (element->hasAttribute(XML_SORT_FORWARDS_STR)) {
  19. sortForwards = element->getBoolAttribute(XML_SORT_FORWARDS_STR);
  20. } else {
  21. juce::Logger::writeToLog("Missing attribute " + juce::String(XML_SORT_FORWARDS_STR));
  22. }
  23. if (element->hasAttribute(XML_SORT_INCLUDE_VST_STR)) {
  24. includeVST = element->getBoolAttribute(XML_SORT_INCLUDE_VST_STR);
  25. } else {
  26. juce::Logger::writeToLog("Missing attribute " + juce::String(XML_SORT_INCLUDE_VST_STR));
  27. }
  28. if (element->hasAttribute(XML_SORT_INCLUDE_VST3_STR)) {
  29. includeVST3 = element->getBoolAttribute(XML_SORT_INCLUDE_VST3_STR);
  30. } else {
  31. juce::Logger::writeToLog("Missing attribute " + juce::String(XML_SORT_INCLUDE_VST3_STR));
  32. }
  33. if (element->hasAttribute(XML_SORT_INCLUDE_AU_STR)) {
  34. includeAU = element->getBoolAttribute(XML_SORT_INCLUDE_AU_STR);
  35. } else {
  36. juce::Logger::writeToLog("Missing attribute " + juce::String(XML_SORT_INCLUDE_AU_STR));
  37. }
  38. if (element->hasAttribute(XML_SORT_FILTER_STRING_STR)) {
  39. filterString = element->getStringAttribute(XML_SORT_FILTER_STRING_STR);
  40. } else {
  41. juce::Logger::writeToLog("Missing attribute " + juce::String(XML_SORT_FILTER_STRING_STR));
  42. }
  43. if (element->hasAttribute(XML_SORT_BOUNDS_STR)) {
  44. juce::String boundsStr = element->getStringAttribute(XML_SORT_BOUNDS_STR);
  45. bounds = juce::Rectangle<int>::fromString(boundsStr);
  46. } else {
  47. juce::Logger::writeToLog("Missing attribute " + juce::String(XML_SORT_BOUNDS_STR));
  48. }
  49. if (element->hasAttribute(XML_SORT_SCROLL_POSITION_STR)) {
  50. scrollPosition = element->getDoubleAttribute(XML_SORT_SCROLL_POSITION_STR);
  51. } else {
  52. juce::Logger::writeToLog("Missing attribute " + juce::String(XML_SORT_SCROLL_POSITION_STR));
  53. }
  54. }
  55. void PluginSelectorState::writeToXml(juce::XmlElement* element) const {
  56. element->setAttribute(XML_SORT_COLUMN_ID_STR, sortColumnId);
  57. element->setAttribute(XML_SORT_FORWARDS_STR, sortForwards);
  58. element->setAttribute(XML_SORT_INCLUDE_VST_STR, includeVST);
  59. element->setAttribute(XML_SORT_INCLUDE_VST3_STR, includeVST3);
  60. element->setAttribute(XML_SORT_INCLUDE_AU_STR, includeAU);
  61. element->setAttribute(XML_SORT_FILTER_STRING_STR, filterString);
  62. if (bounds.has_value()) {
  63. element->setAttribute(XML_SORT_BOUNDS_STR, bounds->toString());
  64. }
  65. element->setAttribute(XML_SORT_SCROLL_POSITION_STR, scrollPosition);
  66. }