LUAEditorFoldingWidget.hxx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/Memory/SystemAllocator.h>
  10. #include <AzCore/base.h>
  11. #include <QtWidgets/QWidget>
  12. #include <Source/LUA/LUAEditorPlainTextEdit.hxx>
  13. #endif
  14. #pragma once
  15. namespace LUAEditor
  16. {
  17. class FoldingWidget : public QWidget
  18. {
  19. Q_OBJECT
  20. static const int c_borderSize{3};
  21. public:
  22. AZ_CLASS_ALLOCATOR(FoldingWidget, AZ::SystemAllocator);
  23. FoldingWidget(QWidget *pParent = nullptr);
  24. virtual ~FoldingWidget();
  25. void SetTextEdit(LUAEditorPlainTextEdit* textEdit) { m_textEdit = textEdit; }
  26. void OnContentChanged(int from, int charsRemoved, int charsAdded);
  27. void FoldAll();
  28. void UnfoldAll();
  29. void SetFont(QFont font);
  30. signals:
  31. void TextBlockFoldingChanged();
  32. private:
  33. void paintEvent(QPaintEvent*) override;
  34. void mouseReleaseEvent(QMouseEvent* event) override;
  35. LUAEditorPlainTextEdit* m_textEdit;
  36. int m_singleSize{10}; //square size for folding widget, of a single line in editor
  37. };
  38. }