Modal shader editor dialog used by ACMX2. More...
#include <editor.hpp>
Signals | |
| void | fileSaved (const QString &path) |
| Emitted after the editor successfully writes its contents to disk. | |
| void | openFileRequested (const QString &path, int lineNumber) |
| void | previewRequested (const QString &path, const QString &source) |
| void | uniformValueChanged (const QString &name, double value) |
Public Member Functions | |
| QString | fileName () const |
| Return the file currently associated with this editor. | |
| void | revealLocation (int lineNumber, int columnNumber=0, int matchLength=0) |
| Move to a one-based line and select the requested source match. | |
| void | setCompilePending () |
| Mark the associated shader as being compiled. | |
| void | setCompileResult (bool success, const QString &compilerOutput) |
| Show compiler status and source diagnostics for the associated shader. | |
| void | setFileName (const QString &filename) |
| Associate editor with a shader file path. | |
| void | setShaderContext (bool acmxvk, const QVector< ShaderEditorUniform > &uniforms, const QString &libraryDirectory=QString()) |
| Configure ACMXVK completion and snippets from the active manifest. | |
| void | setText (const QString &text) |
| Replace editor contents and reset displayed text. | |
| void | setUniformValue (const QString &name, double value) |
| TextEditor (QWidget *parent=nullptr) | |
Protected Member Functions | |
| void | closeEvent (QCloseEvent *event) override |
| void | keyPressEvent (QKeyEvent *event) override |
Private Member Functions | |
| QString | customUniformDefines () const |
| void | decreaseFontSize () |
| void | findNext () |
| void | findPrevious () |
| void | findText () |
| void | gotoLine () |
| void | increaseFontSize () |
| void | init () |
| void | insertSnippet (const QString &snippet) |
| bool | maybePromptSave () |
| Show a Save/Discard/Cancel prompt if the document is modified. | |
| void | navigateDiagnostic (int offset) |
| void | openInclude (const QString &includeName) |
| QVector< ShaderDiagnostic > | parseDiagnostics (const QString &compilerOutput) const |
| void | rebuildUniformControls () |
| void | replaceText () |
| void | requestPreview () |
| void | resetFontSize () |
| void | revertContents () |
| void | saveAs () |
| void | saveContents () |
| void | updateCompletionWords () |
| void | updateCursorPosition () |
| void | updateDiagnosticActions () |
| void | updateFontSize () |
| void | updateWindowTitle () |
| bool | writeFile (const QString &filePath) |
| Atomically write the document to disk. | |
Private Attributes | |
| QString | filename |
| bool | m_acmxvkContext = false |
| QLabel * | m_compileStatusLabel = nullptr |
| int | m_currentDiagnostic = -1 |
| QVector< ShaderDiagnostic > | m_diagnostics |
| int | m_fontSize = 24 |
| GlslSyntaxHighlighter * | m_highlighter = nullptr |
| QString | m_lastSearchText |
| QString | m_libraryDirectory |
| QLabel * | m_lineColLabel = nullptr |
| QCheckBox * | m_livePreviewCheck = nullptr |
| QCheckBox * | m_loopSafetyCheck = nullptr |
| bool | m_modified = false |
| QAction * | m_nextDiagnosticAction = nullptr |
| QTimer * | m_previewTimer = nullptr |
| QAction * | m_previousDiagnosticAction = nullptr |
| QMenu * | m_snippetsMenu = nullptr |
| QStatusBar * | m_statusBar = nullptr |
| CustomTextEdit * | m_textEdit = nullptr |
| QVBoxLayout * | m_uniformLayout = nullptr |
| QWidget * | m_uniformPanel = nullptr |
| QVector< ShaderEditorUniform > | m_uniforms |
| QScrollArea * | m_uniformScroll = nullptr |
| QHash< QString, QSlider * > | m_uniformSliders |
| QHash< QString, QDoubleSpinBox * > | m_uniformSpins |
Modal shader editor dialog used by ACMX2.
Definition at line 131 of file editor.hpp.
|
explicit |
Definition at line 887 of file editor.cpp.
References init(), m_fontSize, m_highlighter, m_lineColLabel, m_modified, m_statusBar, and m_textEdit.
Referenced by MainWindow::openShaderEditor().
|
overrideprotected |
Definition at line 1732 of file editor.cpp.
References m_fontSize.
Referenced by uniformValueChanged().
|
private |
Definition at line 1136 of file editor.cpp.
References m_uniforms, ShaderEditorUniform::name, and ShaderEditorUniform::slot.
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1685 of file editor.cpp.
Referenced by init(), and uniformValueChanged().
| QString TextEditor::fileName | ( | ) | const |
Return the file currently associated with this editor.
Definition at line 902 of file editor.cpp.
References filename.
Referenced by MainWindow::openShaderEditor().
|
signal |
Emitted after the editor successfully writes its contents to disk.
Referenced by MainWindow::openShaderEditor().
|
private |
Definition at line 1588 of file editor.cpp.
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1614 of file editor.cpp.
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1575 of file editor.cpp.
References m_textEdit.
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1667 of file editor.cpp.
References m_lastSearchText, m_statusBar, and m_textEdit.
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1677 of file editor.cpp.
References m_lastSearchText, m_statusBar, and m_textEdit.
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1241 of file editor.cpp.
References acmx2::applyCustomStyleIfEnabled(), CustomTextEdit::CustomTextEdit(), customUniformDefines(), decreaseFontSize(), CustomTextEdit::duplicateLine(), findNext(), findPrevious(), findText(), GlslSyntaxHighlighter::GlslSyntaxHighlighter(), gotoLine(), increaseFontSize(), CustomTextEdit::indentSelection(), insertSnippet(), m_compileStatusLabel, m_fontSize, m_highlighter, m_lineColLabel, m_livePreviewCheck, m_loopSafetyCheck, m_modified, m_nextDiagnosticAction, m_previewTimer, m_previousDiagnosticAction, m_snippetsMenu, m_statusBar, m_textEdit, m_uniformLayout, m_uniformPanel, m_uniformScroll, CustomTextEdit::moveLineDown(), CustomTextEdit::moveLineUp(), navigateDiagnostic(), replaceText(), requestPreview(), resetFontSize(), revertContents(), saveAs(), saveContents(), GlslSyntaxHighlighter::setEditorPalette(), CustomTextEdit::themeChanged(), CustomTextEdit::toggleComment(), CustomTextEdit::unindentSelection(), updateDiagnosticActions(), and updateFontSize().
Referenced by TextEditor(), and uniformValueChanged().
|
private |
Definition at line 1147 of file editor.cpp.
References m_statusBar, m_textEdit, and updateCompletionWords().
Referenced by init(), saveContents(), and uniformValueChanged().
|
overrideprotected |
Definition at line 1741 of file editor.cpp.
References acmx2::isCustomStyleEnabled(), and m_fontSize.
Referenced by uniformValueChanged().
|
private |
Show a Save/Discard/Cancel prompt if the document is modified.
Definition at line 1753 of file editor.cpp.
References m_fontSize.
Referenced by uniformValueChanged().
|
private |
Definition at line 1212 of file editor.cpp.
References ShaderDiagnostic::column, ShaderDiagnostic::line, m_currentDiagnostic, m_diagnostics, m_statusBar, ShaderDiagnostic::message, and revealLocation().
Referenced by init(), and uniformValueChanged().
|
signal |
Referenced by openInclude(), and MainWindow::openShaderEditor().
|
private |
Definition at line 991 of file editor.cpp.
References filename, m_libraryDirectory, m_statusBar, and openFileRequested().
Referenced by uniformValueChanged().
|
private |
Definition at line 1164 of file editor.cpp.
References ShaderDiagnostic::column, filename, ShaderDiagnostic::line, ShaderDiagnostic::message, Note, ShaderDiagnostic::severity, and Warning.
Referenced by setCompileResult(), and uniformValueChanged().
|
signal |
Referenced by MainWindow::openShaderEditor(), and requestPreview().
|
private |
Definition at line 1025 of file editor.cpp.
References m_acmxvkContext, m_uniformLayout, m_uniformPanel, m_uniforms, m_uniformScroll, m_uniformSliders, m_uniformSpins, and uniformValueChanged().
Referenced by setShaderContext(), and uniformValueChanged().
|
private |
Definition at line 1639 of file editor.cpp.
References m_lastSearchText, m_statusBar, and m_textEdit.
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1004 of file editor.cpp.
References filename, inject_safety_counters(), m_acmxvkContext, m_libraryDirectory, m_loopSafetyCheck, m_textEdit, and previewRequested().
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1693 of file editor.cpp.
References m_textEdit.
Referenced by init(), and uniformValueChanged().
| void TextEditor::revealLocation | ( | int | lineNumber, |
| int | columnNumber = 0, | ||
| int | matchLength = 0 ) |
Move to a one-based line and select the requested source match.
Definition at line 904 of file editor.cpp.
References m_textEdit.
Referenced by navigateDiagnostic(), and MainWindow::openShaderEditor().
|
private |
Definition at line 1013 of file editor.cpp.
References filename, m_statusBar, and setText().
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1563 of file editor.cpp.
Referenced by init(), and uniformValueChanged().
|
private |
Definition at line 1525 of file editor.cpp.
References insertSnippet().
Referenced by init(), and uniformValueChanged().
| void TextEditor::setCompilePending | ( | ) |
Mark the associated shader as being compiled.
Definition at line 922 of file editor.cpp.
References m_compileStatusLabel, m_currentDiagnostic, m_diagnostics, m_textEdit, CustomTextEdit::setDiagnostics(), and updateDiagnosticActions().
| void TextEditor::setCompileResult | ( | bool | success, |
| const QString & | compilerOutput ) |
Show compiler status and source diagnostics for the associated shader.
Definition at line 932 of file editor.cpp.
References Error, m_compileStatusLabel, m_currentDiagnostic, m_diagnostics, m_statusBar, m_textEdit, parseDiagnostics(), CustomTextEdit::setDiagnostics(), updateDiagnosticActions(), and Warning.
| void TextEditor::setFileName | ( | const QString & | filename | ) |
Associate editor with a shader file path.
Definition at line 897 of file editor.cpp.
References filename, and updateWindowTitle().
Referenced by MainWindow::openShaderEditor().
| void TextEditor::setShaderContext | ( | bool | acmxvk, |
| const QVector< ShaderEditorUniform > & | uniforms, | ||
| const QString & | libraryDirectory = QString() ) |
Configure ACMXVK completion and snippets from the active manifest.
Definition at line 961 of file editor.cpp.
References m_acmxvkContext, m_libraryDirectory, m_livePreviewCheck, m_loopSafetyCheck, m_snippetsMenu, m_uniforms, rebuildUniformControls(), and updateCompletionWords().
| void TextEditor::setText | ( | const QString & | text | ) |
Replace editor contents and reset displayed text.
Definition at line 889 of file editor.cpp.
References m_modified, m_textEdit, updateCompletionWords(), and updateWindowTitle().
Referenced by MainWindow::openShaderEditor(), and revertContents().
| void TextEditor::setUniformValue | ( | const QString & | name, |
| double | value ) |
Definition at line 972 of file editor.cpp.
References m_uniforms, m_uniformSliders, and m_uniformSpins.
|
signal |
References closeEvent(), customUniformDefines(), decreaseFontSize(), findNext(), findPrevious(), findText(), gotoLine(), increaseFontSize(), init(), insertSnippet(), keyPressEvent(), maybePromptSave(), navigateDiagnostic(), openInclude(), parseDiagnostics(), rebuildUniformControls(), replaceText(), requestPreview(), resetFontSize(), revertContents(), saveAs(), saveContents(), updateCompletionWords(), updateCursorPosition(), updateDiagnosticActions(), updateFontSize(), updateWindowTitle(), and writeFile().
Referenced by MainWindow::openShaderEditor(), and rebuildUniformControls().
|
private |
Definition at line 1086 of file editor.cpp.
References m_acmxvkContext, m_textEdit, m_uniforms, and CustomTextEdit::setCompletionWords().
Referenced by insertSnippet(), setShaderContext(), setText(), and uniformValueChanged().
|
private |
Definition at line 1722 of file editor.cpp.
References m_fontSize, and updateFontSize().
Referenced by uniformValueChanged().
|
private |
Definition at line 1224 of file editor.cpp.
References m_diagnostics, m_nextDiagnosticAction, and m_previousDiagnosticAction.
Referenced by init(), setCompilePending(), setCompileResult(), and uniformValueChanged().
|
private |
Definition at line 1699 of file editor.cpp.
Referenced by init(), uniformValueChanged(), and updateCursorPosition().
|
private |
Definition at line 1230 of file editor.cpp.
References filename, and m_modified.
Referenced by setFileName(), setText(), and uniformValueChanged().
|
private |
Atomically write the document to disk.
Definition at line 1534 of file editor.cpp.
Referenced by uniformValueChanged().
|
private |
Definition at line 217 of file editor.hpp.
Referenced by fileName(), openInclude(), parseDiagnostics(), requestPreview(), revertContents(), setFileName(), and updateWindowTitle().
|
private |
Definition at line 214 of file editor.hpp.
Referenced by rebuildUniformControls(), requestPreview(), setShaderContext(), and updateCompletionWords().
|
private |
Definition at line 200 of file editor.hpp.
Referenced by init(), setCompilePending(), and setCompileResult().
|
private |
Definition at line 213 of file editor.hpp.
Referenced by navigateDiagnostic(), setCompilePending(), and setCompileResult().
|
private |
Definition at line 212 of file editor.hpp.
Referenced by navigateDiagnostic(), setCompilePending(), setCompileResult(), and updateDiagnosticActions().
|
private |
Definition at line 219 of file editor.hpp.
Referenced by closeEvent(), init(), keyPressEvent(), maybePromptSave(), TextEditor(), and updateCursorPosition().
|
private |
Definition at line 197 of file editor.hpp.
Referenced by init(), and TextEditor().
|
private |
Definition at line 218 of file editor.hpp.
Referenced by gotoLine(), increaseFontSize(), and replaceText().
|
private |
Definition at line 216 of file editor.hpp.
Referenced by openInclude(), requestPreview(), and setShaderContext().
|
private |
Definition at line 199 of file editor.hpp.
Referenced by init(), and TextEditor().
|
private |
Definition at line 207 of file editor.hpp.
Referenced by init(), and setShaderContext().
|
private |
Definition at line 208 of file editor.hpp.
Referenced by init(), requestPreview(), and setShaderContext().
|
private |
Definition at line 195 of file editor.hpp.
Referenced by init(), setText(), TextEditor(), and updateWindowTitle().
|
private |
Definition at line 201 of file editor.hpp.
Referenced by init(), and updateDiagnosticActions().
|
private |
Definition at line 209 of file editor.hpp.
Referenced by init().
|
private |
Definition at line 202 of file editor.hpp.
Referenced by init(), and updateDiagnosticActions().
|
private |
Definition at line 203 of file editor.hpp.
Referenced by init(), and setShaderContext().
|
private |
Definition at line 198 of file editor.hpp.
Referenced by gotoLine(), increaseFontSize(), init(), insertSnippet(), navigateDiagnostic(), openInclude(), replaceText(), revertContents(), setCompileResult(), and TextEditor().
|
private |
Definition at line 196 of file editor.hpp.
Referenced by findText(), gotoLine(), increaseFontSize(), init(), insertSnippet(), replaceText(), requestPreview(), resetFontSize(), revealLocation(), setCompilePending(), setCompileResult(), setText(), TextEditor(), and updateCompletionWords().
|
private |
Definition at line 206 of file editor.hpp.
Referenced by init(), and rebuildUniformControls().
|
private |
Definition at line 204 of file editor.hpp.
Referenced by init(), and rebuildUniformControls().
|
private |
Definition at line 215 of file editor.hpp.
Referenced by customUniformDefines(), rebuildUniformControls(), setShaderContext(), setUniformValue(), and updateCompletionWords().
|
private |
Definition at line 205 of file editor.hpp.
Referenced by init(), and rebuildUniformControls().
|
private |
Definition at line 211 of file editor.hpp.
Referenced by rebuildUniformControls(), and setUniformValue().
|
private |
Definition at line 210 of file editor.hpp.
Referenced by rebuildUniformControls(), and setUniformValue().