2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-11-10 14:01:09 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-11-10 14:01:09 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-11-10 14:01:09 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-11-10 14:01:09 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 17:14:20 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-11-10 14:01:09 +01:00
|
|
|
|
|
|
|
|
#ifndef GLSLEDITOR_H
|
|
|
|
|
#define GLSLEDITOR_H
|
|
|
|
|
|
|
|
|
|
#include <texteditor/basetexteditor.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSharedPointer>
|
|
|
|
|
#include <QSet>
|
2010-11-10 14:01:09 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QComboBox;
|
|
|
|
|
class QTimer;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2011-08-18 15:04:13 +02:00
|
|
|
namespace GLSL {
|
|
|
|
|
class Engine;
|
|
|
|
|
class TranslationUnitAST;
|
|
|
|
|
class Scope;
|
2013-08-23 13:56:24 +02:00
|
|
|
} // namespace GLSL
|
2011-08-18 15:04:13 +02:00
|
|
|
|
2010-11-10 14:01:09 +01:00
|
|
|
namespace GLSLEditor {
|
2011-08-18 15:04:13 +02:00
|
|
|
namespace Internal {
|
2013-08-23 13:56:24 +02:00
|
|
|
|
2014-07-30 16:30:31 +02:00
|
|
|
class GlslEditor;
|
|
|
|
|
class GlslEditorWidget;
|
2010-11-29 17:21:47 +01:00
|
|
|
|
2013-08-23 13:56:24 +02:00
|
|
|
class Document
|
2010-11-29 17:21:47 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef QSharedPointer<Document> Ptr;
|
|
|
|
|
|
|
|
|
|
Document();
|
|
|
|
|
~Document();
|
|
|
|
|
|
|
|
|
|
GLSL::Engine *engine() const { return _engine; }
|
|
|
|
|
GLSL::TranslationUnitAST *ast() const { return _ast; }
|
|
|
|
|
GLSL::Scope *globalScope() const { return _globalScope; }
|
|
|
|
|
|
|
|
|
|
GLSL::Scope *scopeAt(int position) const;
|
|
|
|
|
void addRange(const QTextCursor &cursor, GLSL::Scope *scope);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct Range {
|
|
|
|
|
QTextCursor cursor;
|
|
|
|
|
GLSL::Scope *scope;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GLSL::Engine *_engine;
|
|
|
|
|
GLSL::TranslationUnitAST *_ast;
|
|
|
|
|
GLSL::Scope *_globalScope;
|
|
|
|
|
QList<Range> _cursors;
|
|
|
|
|
|
2014-07-30 16:30:31 +02:00
|
|
|
friend class GlslEditorWidget;
|
2010-11-29 17:21:47 +01:00
|
|
|
};
|
2010-11-10 14:01:09 +01:00
|
|
|
|
2014-07-30 16:30:31 +02:00
|
|
|
class GlslEditorWidget : public TextEditor::BaseTextEditorWidget
|
2010-11-10 14:01:09 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2014-07-31 14:44:42 +02:00
|
|
|
GlslEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent);
|
2014-07-30 16:30:31 +02:00
|
|
|
GlslEditorWidget(GlslEditorWidget *other);
|
2010-11-10 14:01:09 +01:00
|
|
|
|
|
|
|
|
int editorRevision() const;
|
|
|
|
|
bool isOutdated() const;
|
|
|
|
|
|
2010-11-19 15:15:12 +01:00
|
|
|
QSet<QString> identifiers() const;
|
|
|
|
|
|
2011-08-02 12:26:00 +02:00
|
|
|
static int languageVariant(const QString &mimeType);
|
2010-11-26 15:14:33 +01:00
|
|
|
|
2011-04-15 16:19:23 +02:00
|
|
|
TextEditor::IAssistInterface *createAssistInterface(TextEditor::AssistKind assistKind,
|
|
|
|
|
TextEditor::AssistReason reason) const;
|
|
|
|
|
|
2010-11-10 14:01:09 +01:00
|
|
|
private slots:
|
|
|
|
|
void updateDocument();
|
|
|
|
|
void updateDocumentNow();
|
|
|
|
|
|
|
|
|
|
protected:
|
2011-02-21 16:02:26 +01:00
|
|
|
TextEditor::BaseTextEditor *createEditor();
|
2010-11-10 14:01:09 +01:00
|
|
|
|
|
|
|
|
private:
|
2014-07-30 16:30:31 +02:00
|
|
|
GlslEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
2014-01-09 18:04:45 +01:00
|
|
|
void ctor();
|
2010-11-10 14:01:09 +01:00
|
|
|
void setSelectedElements();
|
|
|
|
|
QString wordUnderCursor() const;
|
|
|
|
|
|
|
|
|
|
QTimer *m_updateDocumentTimer;
|
|
|
|
|
QComboBox *m_outlineCombo;
|
2010-11-29 17:21:47 +01:00
|
|
|
Document::Ptr m_glslDocument;
|
2010-11-10 14:01:09 +01:00
|
|
|
};
|
|
|
|
|
|
2013-08-23 13:56:24 +02:00
|
|
|
} // namespace Internal
|
2010-11-10 14:01:09 +01:00
|
|
|
} // namespace GLSLEditor
|
|
|
|
|
|
|
|
|
|
#endif // GLSLEDITOR_H
|