ACMX 2.139.0
Dual-Backend Real-Time GPU Video Synthesis
Loading...
Searching...
No Matches
TextEditor Class Reference

Modal shader editor dialog used by ACMX2. More...

#include <editor.hpp>

Inheritance diagram for TextEditor:

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

Detailed Description

Modal shader editor dialog used by ACMX2.

Definition at line 131 of file editor.hpp.

Constructor & Destructor Documentation

◆ TextEditor()

TextEditor::TextEditor ( QWidget * parent = nullptr)
explicit

Member Function Documentation

◆ closeEvent()

void TextEditor::closeEvent ( QCloseEvent * event)
overrideprotected

Definition at line 1732 of file editor.cpp.

References m_fontSize.

Referenced by uniformValueChanged().

◆ customUniformDefines()

QString TextEditor::customUniformDefines ( ) const
private

Definition at line 1136 of file editor.cpp.

References m_uniforms, ShaderEditorUniform::name, and ShaderEditorUniform::slot.

Referenced by init(), and uniformValueChanged().

◆ decreaseFontSize()

void TextEditor::decreaseFontSize ( )
private

Definition at line 1685 of file editor.cpp.

Referenced by init(), and uniformValueChanged().

◆ fileName()

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().

◆ fileSaved

void TextEditor::fileSaved ( const QString & path)
signal

Emitted after the editor successfully writes its contents to disk.

Referenced by MainWindow::openShaderEditor().

◆ findNext()

void TextEditor::findNext ( )
private

Definition at line 1588 of file editor.cpp.

Referenced by init(), and uniformValueChanged().

◆ findPrevious()

void TextEditor::findPrevious ( )
private

Definition at line 1614 of file editor.cpp.

Referenced by init(), and uniformValueChanged().

◆ findText()

void TextEditor::findText ( )
private

Definition at line 1575 of file editor.cpp.

References m_textEdit.

Referenced by init(), and uniformValueChanged().

◆ gotoLine()

void TextEditor::gotoLine ( )
private

Definition at line 1667 of file editor.cpp.

References m_lastSearchText, m_statusBar, and m_textEdit.

Referenced by init(), and uniformValueChanged().

◆ increaseFontSize()

void TextEditor::increaseFontSize ( )
private

Definition at line 1677 of file editor.cpp.

References m_lastSearchText, m_statusBar, and m_textEdit.

Referenced by init(), and uniformValueChanged().

◆ init()

◆ insertSnippet()

void TextEditor::insertSnippet ( const QString & snippet)
private

Definition at line 1147 of file editor.cpp.

References m_statusBar, m_textEdit, and updateCompletionWords().

Referenced by init(), saveContents(), and uniformValueChanged().

◆ keyPressEvent()

void TextEditor::keyPressEvent ( QKeyEvent * event)
overrideprotected

Definition at line 1741 of file editor.cpp.

References acmx2::isCustomStyleEnabled(), and m_fontSize.

Referenced by uniformValueChanged().

◆ maybePromptSave()

bool TextEditor::maybePromptSave ( )
private

Show a Save/Discard/Cancel prompt if the document is modified.

Returns
True if the editor may close, false to cancel the close.

Definition at line 1753 of file editor.cpp.

References m_fontSize.

Referenced by uniformValueChanged().

◆ navigateDiagnostic()

void TextEditor::navigateDiagnostic ( int offset)
private

◆ openFileRequested

void TextEditor::openFileRequested ( const QString & path,
int lineNumber )
signal

◆ openInclude()

void TextEditor::openInclude ( const QString & includeName)
private

Definition at line 991 of file editor.cpp.

References filename, m_libraryDirectory, m_statusBar, and openFileRequested().

Referenced by uniformValueChanged().

◆ parseDiagnostics()

QVector< ShaderDiagnostic > TextEditor::parseDiagnostics ( const QString & compilerOutput) const
private

◆ previewRequested

void TextEditor::previewRequested ( const QString & path,
const QString & source )
signal

◆ rebuildUniformControls()

void TextEditor::rebuildUniformControls ( )
private

◆ replaceText()

void TextEditor::replaceText ( )
private

Definition at line 1639 of file editor.cpp.

References m_lastSearchText, m_statusBar, and m_textEdit.

Referenced by init(), and uniformValueChanged().

◆ requestPreview()

void TextEditor::requestPreview ( )
private

◆ resetFontSize()

void TextEditor::resetFontSize ( )
private

Definition at line 1693 of file editor.cpp.

References m_textEdit.

Referenced by init(), and uniformValueChanged().

◆ revealLocation()

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().

◆ revertContents()

void TextEditor::revertContents ( )
private

Definition at line 1013 of file editor.cpp.

References filename, m_statusBar, and setText().

Referenced by init(), and uniformValueChanged().

◆ saveAs()

void TextEditor::saveAs ( )
private

Definition at line 1563 of file editor.cpp.

Referenced by init(), and uniformValueChanged().

◆ saveContents()

void TextEditor::saveContents ( )
private

Definition at line 1525 of file editor.cpp.

References insertSnippet().

Referenced by init(), and uniformValueChanged().

◆ setCompilePending()

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().

◆ setCompileResult()

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.

◆ setFileName()

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().

◆ setShaderContext()

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().

◆ setText()

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().

◆ setUniformValue()

void TextEditor::setUniformValue ( const QString & name,
double value )

Definition at line 972 of file editor.cpp.

References m_uniforms, m_uniformSliders, and m_uniformSpins.

◆ uniformValueChanged

◆ updateCompletionWords()

void TextEditor::updateCompletionWords ( )
private

◆ updateCursorPosition()

void TextEditor::updateCursorPosition ( )
private

Definition at line 1722 of file editor.cpp.

References m_fontSize, and updateFontSize().

Referenced by uniformValueChanged().

◆ updateDiagnosticActions()

void TextEditor::updateDiagnosticActions ( )
private

◆ updateFontSize()

void TextEditor::updateFontSize ( )
private

Definition at line 1699 of file editor.cpp.

Referenced by init(), uniformValueChanged(), and updateCursorPosition().

◆ updateWindowTitle()

void TextEditor::updateWindowTitle ( )
private

Definition at line 1230 of file editor.cpp.

References filename, and m_modified.

Referenced by setFileName(), setText(), and uniformValueChanged().

◆ writeFile()

bool TextEditor::writeFile ( const QString & filePath)
private

Atomically write the document to disk.

Returns
True when the file was committed successfully.

Definition at line 1534 of file editor.cpp.

Referenced by uniformValueChanged().

Member Data Documentation

◆ filename

QString TextEditor::filename
private

◆ m_acmxvkContext

bool TextEditor::m_acmxvkContext = false
private

◆ m_compileStatusLabel

QLabel* TextEditor::m_compileStatusLabel = nullptr
private

Definition at line 200 of file editor.hpp.

Referenced by init(), setCompilePending(), and setCompileResult().

◆ m_currentDiagnostic

int TextEditor::m_currentDiagnostic = -1
private

Definition at line 213 of file editor.hpp.

Referenced by navigateDiagnostic(), setCompilePending(), and setCompileResult().

◆ m_diagnostics

QVector<ShaderDiagnostic> TextEditor::m_diagnostics
private

◆ m_fontSize

int TextEditor::m_fontSize = 24
private

◆ m_highlighter

GlslSyntaxHighlighter* TextEditor::m_highlighter = nullptr
private

Definition at line 197 of file editor.hpp.

Referenced by init(), and TextEditor().

◆ m_lastSearchText

QString TextEditor::m_lastSearchText
private

Definition at line 218 of file editor.hpp.

Referenced by gotoLine(), increaseFontSize(), and replaceText().

◆ m_libraryDirectory

QString TextEditor::m_libraryDirectory
private

Definition at line 216 of file editor.hpp.

Referenced by openInclude(), requestPreview(), and setShaderContext().

◆ m_lineColLabel

QLabel* TextEditor::m_lineColLabel = nullptr
private

Definition at line 199 of file editor.hpp.

Referenced by init(), and TextEditor().

◆ m_livePreviewCheck

QCheckBox* TextEditor::m_livePreviewCheck = nullptr
private

Definition at line 207 of file editor.hpp.

Referenced by init(), and setShaderContext().

◆ m_loopSafetyCheck

QCheckBox* TextEditor::m_loopSafetyCheck = nullptr
private

Definition at line 208 of file editor.hpp.

Referenced by init(), requestPreview(), and setShaderContext().

◆ m_modified

bool TextEditor::m_modified = false
private

Definition at line 195 of file editor.hpp.

Referenced by init(), setText(), TextEditor(), and updateWindowTitle().

◆ m_nextDiagnosticAction

QAction* TextEditor::m_nextDiagnosticAction = nullptr
private

Definition at line 201 of file editor.hpp.

Referenced by init(), and updateDiagnosticActions().

◆ m_previewTimer

QTimer* TextEditor::m_previewTimer = nullptr
private

Definition at line 209 of file editor.hpp.

Referenced by init().

◆ m_previousDiagnosticAction

QAction* TextEditor::m_previousDiagnosticAction = nullptr
private

Definition at line 202 of file editor.hpp.

Referenced by init(), and updateDiagnosticActions().

◆ m_snippetsMenu

QMenu* TextEditor::m_snippetsMenu = nullptr
private

Definition at line 203 of file editor.hpp.

Referenced by init(), and setShaderContext().

◆ m_statusBar

QStatusBar* TextEditor::m_statusBar = nullptr
private

◆ m_textEdit

◆ m_uniformLayout

QVBoxLayout* TextEditor::m_uniformLayout = nullptr
private

Definition at line 206 of file editor.hpp.

Referenced by init(), and rebuildUniformControls().

◆ m_uniformPanel

QWidget* TextEditor::m_uniformPanel = nullptr
private

Definition at line 204 of file editor.hpp.

Referenced by init(), and rebuildUniformControls().

◆ m_uniforms

QVector<ShaderEditorUniform> TextEditor::m_uniforms
private

◆ m_uniformScroll

QScrollArea* TextEditor::m_uniformScroll = nullptr
private

Definition at line 205 of file editor.hpp.

Referenced by init(), and rebuildUniformControls().

◆ m_uniformSliders

QHash<QString, QSlider *> TextEditor::m_uniformSliders
private

Definition at line 211 of file editor.hpp.

Referenced by rebuildUniformControls(), and setUniformValue().

◆ m_uniformSpins

QHash<QString, QDoubleSpinBox *> TextEditor::m_uniformSpins
private

Definition at line 210 of file editor.hpp.

Referenced by rebuildUniformControls(), and setUniformValue().


The documentation for this class was generated from the following files: