Refactor painting of editor gutter
This commit is contained in:
parent
e082a5731d
commit
a5563949e5
7 changed files with 188 additions and 85 deletions
38
pglab/codeeditor/GutterPainter.h
Normal file
38
pglab/codeeditor/GutterPainter.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include <QPainter>
|
||||
#include <QTextBlock>
|
||||
|
||||
#pragma once
|
||||
|
||||
class CodeEditor;
|
||||
class QPaintEvent;
|
||||
|
||||
class GutterPainter
|
||||
{
|
||||
public:
|
||||
GutterPainter(CodeEditor *editor, QPaintEvent *event);
|
||||
|
||||
void Paint();
|
||||
private:
|
||||
CodeEditor *editor;
|
||||
QPainter painter;
|
||||
QPaintEvent *event;
|
||||
QFontMetrics fontMetrics;
|
||||
|
||||
// Loop state
|
||||
struct LoopState {
|
||||
CodeEditor *editor;
|
||||
QTextBlock block;
|
||||
int top;
|
||||
int bottom;
|
||||
|
||||
LoopState(CodeEditor *editor);
|
||||
|
||||
int blockNumber() const;
|
||||
|
||||
void advanceToNextLine();
|
||||
};
|
||||
|
||||
void drawLineNumber(const LoopState &loopState);
|
||||
|
||||
void drawGutterErrorMarker(const LoopState &loopState);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue