LUAEditorStyleMessages.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. #include "LUAEditorStyleMessages.h"
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include "LUAEditorViewMessages.h"
  11. namespace LUAEditor
  12. {
  13. QFont SyntaxStyleSettings::GetFont() const
  14. {
  15. QFont result;
  16. result.setFamily(m_font.c_str());
  17. result.setFixedPitch(true);
  18. result.setStyleHint(QFont::Monospace);
  19. result.setPointSize(m_fontSize);
  20. return result;
  21. }
  22. void SyntaxStyleSettings::Reflect(AZ::ReflectContext* reflection)
  23. {
  24. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflection);
  25. if (serializeContext)
  26. {
  27. serializeContext->Class<SyntaxStyleSettings, AZ::UserSettings >()
  28. ->Version(6)
  29. ->Field("m_font", &SyntaxStyleSettings::m_font)
  30. ->Field("m_fontSize", &SyntaxStyleSettings::m_fontSize)
  31. ->Field("m_tabSize", &SyntaxStyleSettings::m_tabSize)
  32. ->Field("m_useSpacesInsteadOfTabs", &SyntaxStyleSettings::m_useSpacesInsteadOfTabs)
  33. ->Field("m_textColor", &SyntaxStyleSettings::m_textColor)
  34. ->Field("m_textSelectedColor", &SyntaxStyleSettings::m_textSelectedColor)
  35. ->Field("m_textSelectedBackgroundColor", &SyntaxStyleSettings::m_textSelectedBackgroundColor)
  36. ->Field("m_textFocusedBackgroundColor", &SyntaxStyleSettings::m_textFocusedBackgroundColor)
  37. ->Field("m_textUnfocusedBackgroundColor", &SyntaxStyleSettings::m_textUnfocusedBackgroundColor)
  38. ->Field("m_textReadOnlyFocusedBackgroundColor", &SyntaxStyleSettings::m_textReadOnlyFocusedBackgroundColor)
  39. ->Field("m_textReadOnlyUnfocusedBackgroundColor", &SyntaxStyleSettings::m_textReadOnlyUnfocusedBackgroundColor)
  40. ->Field("m_textWhitespaceColor", &SyntaxStyleSettings::m_textWhitespaceColor)
  41. ->Field("m_breakpointFocusedBackgroundColor", &SyntaxStyleSettings::m_breakpointFocusedBackgroundColor)
  42. ->Field("m_breakpointUnocusedBackgroundColor", &SyntaxStyleSettings::m_breakpointUnfocusedBackgroundColor)
  43. ->Field("m_foldingFocusedBackgroundColor", &SyntaxStyleSettings::m_foldingFocusedBackgroundColor)
  44. ->Field("m_foldingUnfocusedBackgroundColor", &SyntaxStyleSettings::m_foldingUnfocusedBackgroundColor)
  45. ->Field("m_currentIdentifierColor", &SyntaxStyleSettings::m_currentIdentifierColor)
  46. ->Field("m_currentLineOutlineColor", &SyntaxStyleSettings::m_currentLineOutlineColor)
  47. ->Field("m_keywordColor", &SyntaxStyleSettings::m_keywordColor)
  48. ->Field("m_commentColor", &SyntaxStyleSettings::m_commentColor)
  49. ->Field("m_stringLiteralColor", &SyntaxStyleSettings::m_stringLiteralColor)
  50. ->Field("m_numberColor", &SyntaxStyleSettings::m_numberColor)
  51. ->Field("m_libraryColor", &SyntaxStyleSettings::m_libraryColor)
  52. ->Field("m_bracketColor", &SyntaxStyleSettings::m_bracketColor)
  53. ->Field("m_unmatchedBracketColor", &SyntaxStyleSettings::m_unmatchedBracketColor)
  54. ->Field("m_foldingColor", &SyntaxStyleSettings::m_foldingColor)
  55. ->Field("m_foldingCurrentColor", &SyntaxStyleSettings::m_foldingCurrentColor)
  56. ->Field("m_foldingLineColor", &SyntaxStyleSettings::m_foldingLineColor)
  57. ->Field("m_findResultsHeaderColor", &SyntaxStyleSettings::m_findResultsHeaderColor)
  58. ->Field("m_findResultsFileColor", &SyntaxStyleSettings::m_findResultsFileColor)
  59. ->Field("m_findResultsMatchColor", &SyntaxStyleSettings::m_findResultsMatchColor)
  60. ;
  61. AZ::EditContext* editContext = serializeContext->GetEditContext();
  62. if (editContext)
  63. {
  64. editContext->Class<SyntaxStyleSettings>("Syntax Colors", "Customize the Lua IDE syntax and interface colors.")
  65. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  66. ->ClassElement(AZ::Edit::ClassElements::Group, "Font")
  67. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  68. ->DataElement(AZ::Edit::UIHandlers::Default, &SyntaxStyleSettings::m_font, "Font", "")
  69. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnFontChange)
  70. ->DataElement(AZ::Edit::UIHandlers::Default, &SyntaxStyleSettings::m_fontSize, "Size", "")
  71. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnFontChange)
  72. ->DataElement(AZ::Edit::UIHandlers::Default, &SyntaxStyleSettings::m_tabSize, "Tab Size", "")
  73. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnFontChange)
  74. ->DataElement(AZ::Edit::UIHandlers::Default, &SyntaxStyleSettings::m_useSpacesInsteadOfTabs, "Use Spaces instead of Tabs", "")
  75. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnFontChange)
  76. ->ClassElement(AZ::Edit::ClassElements::Group, "Editing")
  77. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  78. ->ClassElement(AZ::Edit::ClassElements::Group, "Text")
  79. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_textColor, "Default", "Default text color")
  80. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  81. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_textSelectedColor, "Selected Text", "")
  82. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  83. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_textSelectedBackgroundColor, "Selected Text Background", "")
  84. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  85. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_textFocusedBackgroundColor, "Focused Background Color", "")
  86. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  87. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_textUnfocusedBackgroundColor, "Unfocused Background Color", "")
  88. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  89. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_textReadOnlyFocusedBackgroundColor, "Read Only Focused Background", "")
  90. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  91. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_textReadOnlyUnfocusedBackgroundColor, "Read Only Background", "")
  92. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  93. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_textWhitespaceColor, "Whitespace Color", "")
  94. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  95. ->ClassElement(AZ::Edit::ClassElements::Group, "Interface")
  96. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  97. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_breakpointFocusedBackgroundColor, "Focused Breakpoint Background", "")
  98. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  99. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_breakpointUnfocusedBackgroundColor, "Non Focused Breakpoint Background", "")
  100. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  101. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_foldingFocusedBackgroundColor, "Folding Focused Background", "")
  102. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  103. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_foldingUnfocusedBackgroundColor, "Folding Non Focused Back", "")
  104. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  105. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_currentLineOutlineColor, "Line Outline", "")
  106. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  107. ->ClassElement(AZ::Edit::ClassElements::Group, "LUA Syntax")
  108. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  109. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_currentIdentifierColor, "Current Identifier", "")
  110. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  111. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_keywordColor, "Keyword", "")
  112. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  113. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_commentColor, "Comment", "")
  114. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  115. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_stringLiteralColor, "String Literal", "")
  116. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  117. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_numberColor, "Number", "")
  118. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  119. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_libraryColor, "Library", "")
  120. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  121. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_bracketColor, "Bracket", "")
  122. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  123. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_unmatchedBracketColor, "Unmatched Bracket", "")
  124. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  125. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_foldingColor, "Folding", "")
  126. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  127. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_foldingCurrentColor, "Folding Current", "")
  128. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  129. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_foldingLineColor, "Folding Line", "")
  130. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  131. ->ClassElement(AZ::Edit::ClassElements::Group, "Find Results")
  132. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  133. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_findResultsHeaderColor, "Header", "")
  134. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  135. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_findResultsFileColor, "File", "")
  136. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  137. ->DataElement(AZ::Edit::UIHandlers::Color, &SyntaxStyleSettings::m_findResultsMatchColor, "Match", "")
  138. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SyntaxStyleSettings::OnColorChange)
  139. ;
  140. }
  141. }
  142. }
  143. void SyntaxStyleSettings::OnColorChange()
  144. {
  145. LUAEditorMainWindowMessages::Bus::Broadcast(&LUAEditorMainWindowMessages::Bus::Events::Repaint);
  146. }
  147. void SyntaxStyleSettings::OnFontChange()
  148. {
  149. LUAEditorMainWindowMessages::Bus::Broadcast(&LUAEditorMainWindowMessages::Bus::Events::Repaint);
  150. }
  151. }