LUAEditorStyleMessages.cpp 14 KB

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