LUAEditorBreakpointWidget.hxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #if !defined(Q_MOC_RUN)
  9. #include <AzCore/base.h>
  10. #include <QtWidgets/QWidget>
  11. #include <AzCore/Memory/SystemAllocator.h>
  12. #include <AzCore/std/functional.h>
  13. #include <AzCore/std/containers/unordered_set.h>
  14. #endif
  15. #pragma once
  16. namespace LUAEditor
  17. {
  18. class LUAEditorPlainTextEdit;
  19. //also draws line numbers in addition to breakpoint indicators
  20. class LUAEditorBreakpointWidget : public QWidget
  21. {
  22. Q_OBJECT
  23. static const int c_borderSize = 3;
  24. public:
  25. AZ_CLASS_ALLOCATOR(LUAEditorBreakpointWidget, AZ::SystemAllocator);
  26. LUAEditorBreakpointWidget(QWidget *pParent = nullptr);
  27. virtual ~LUAEditorBreakpointWidget();
  28. //This must be called before textEdit parent widget is destroyed
  29. void PreDestruction();
  30. void SetTextEdit(LUAEditorPlainTextEdit* textEdit) { m_textEdit = textEdit; }
  31. //set to -1 to disable
  32. void SetCurrentlyExecutingLine(int lineNumber) { m_currentExecLine = lineNumber; }
  33. bool HasBreakpoint(int lineNumber) const;
  34. void AddBreakpoint(int lineNumber);
  35. void RemoveBreakpoint(int lineNumber);
  36. void ClearBreakpoints();
  37. void SetFont(QFont font);
  38. signals:
  39. void toggleBreakpoint(int lineNumber);
  40. void breakpointLineMove(int fromLineNumber, int toLineNumber);
  41. void breakpointDelete(int lineNumber);
  42. private:
  43. void paintEvent(QPaintEvent*) override;
  44. void mouseReleaseEvent(QMouseEvent *event) override;
  45. void UpdateSize();
  46. LUAEditorPlainTextEdit* m_textEdit;
  47. AZStd::unordered_set<int> m_breakpoints;
  48. AZStd::vector<int> m_DeletedBreakpoints;
  49. int m_currentExecLine;
  50. QFont m_font{"OpenSans", 10};
  51. int m_numDigits{1};
  52. public slots:
  53. void OnBlockCountChange();
  54. void OnCharsRemoved(int position, int charsRemoved);
  55. };
  56. }