Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
321dbba5
Commit
321dbba5
authored
Sep 23, 2009
by
mae
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed artefact of animated parentheses when the text is modified.
Bug-number: QTCREATOR-154
parent
76d1de0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
src/plugins/texteditor/basetexteditor.cpp
src/plugins/texteditor/basetexteditor.cpp
+13
-5
src/plugins/texteditor/basetexteditor.h
src/plugins/texteditor/basetexteditor.h
+7
-5
No files found.
src/plugins/texteditor/basetexteditor.cpp
View file @
321dbba5
...
...
@@ -589,6 +589,9 @@ Core::IFile *BaseTextEditor::file()
void
BaseTextEditor
::
editorContentsChange
(
int
position
,
int
charsRemoved
,
int
charsAdded
)
{
if
(
d
->
m_animator
)
d
->
m_animator
->
finish
();
d
->
m_contentsChanged
=
true
;
// Keep the line numbers and the block information for the text marks updated
...
...
@@ -2689,7 +2692,8 @@ void BaseTextEditor::slotCursorPositionChanged()
if
(
d
->
m_parenthesesMatchingEnabled
)
{
// Delay update when no matching is displayed yet, to avoid flicker
if
(
extraSelections
(
ParenthesesMatchingSelection
).
isEmpty
())
{
if
(
extraSelections
(
ParenthesesMatchingSelection
).
isEmpty
()
&&
d
->
m_animator
==
0
)
{
d
->
m_parenthesesMatchingTimer
->
start
(
50
);
}
else
{
// use 0-timer, not direct call, to give the syntax highlighter a chance
...
...
@@ -3747,11 +3751,13 @@ void BaseTextEditor::setFindScope(const QTextCursor &scope)
}
}
void
BaseTextEditor
::
_q_animateUpdate
(
int
position
,
QRectF
rect
)
void
BaseTextEditor
::
_q_animateUpdate
(
int
position
,
QPointF
lastPos
,
QRectF
rect
)
{
QTextCursor
cursor
(
textCursor
());
cursor
.
setPosition
(
position
);
viewport
()
->
update
(
QRectF
(
cursorRect
(
cursor
).
topLeft
()
+
rect
.
topLeft
(),
rect
.
size
()).
toAlignedRect
());
if
(
!
lastPos
.
isNull
())
viewport
()
->
update
(
QRectF
(
lastPos
+
rect
.
topLeft
(),
rect
.
size
()).
toAlignedRect
());
}
...
...
@@ -3778,6 +3784,7 @@ void BaseTextEditorAnimator::setData(QFont f, QPalette pal, const QString &text)
void
BaseTextEditorAnimator
::
draw
(
QPainter
*
p
,
const
QPointF
&
pos
)
{
m_lastDrawPos
=
pos
;
p
->
setPen
(
m_palette
.
text
().
color
());
QFont
f
=
m_font
;
f
.
setPointSizeF
(
f
.
pointSizeF
()
*
(
1.0
+
m_value
/
2
));
...
...
@@ -3809,11 +3816,12 @@ void BaseTextEditorAnimator::step(qreal v)
QRectF
before
=
rect
();
m_value
=
v
;
QRectF
after
=
rect
();
emit
updateRequest
(
m_position
,
before
.
united
(
after
));
emit
updateRequest
(
m_position
,
m_lastDrawPos
,
before
.
united
(
after
));
}
void
BaseTextEditorAnimator
::
finish
()
{
m_timeline
->
stop
();
step
(
0
);
deleteLater
();
}
...
...
@@ -3912,8 +3920,8 @@ void BaseTextEditor::_q_matchParentheses()
pal
.
setBrush
(
QPalette
::
Text
,
d
->
m_matchFormat
.
foreground
());
pal
.
setBrush
(
QPalette
::
Base
,
d
->
m_rangeFormat
.
background
());
d
->
m_animator
->
setData
(
font
(),
pal
,
characterAt
(
d
->
m_animator
->
position
()));
connect
(
d
->
m_animator
,
SIGNAL
(
updateRequest
(
int
,
QRectF
)),
this
,
SLOT
(
_q_animateUpdate
(
int
,
QRectF
)));
connect
(
d
->
m_animator
,
SIGNAL
(
updateRequest
(
int
,
QPointF
,
QRectF
)),
this
,
SLOT
(
_q_animateUpdate
(
int
,
QPointF
,
QRectF
)));
}
setExtraSelections
(
ParenthesesMatchingSelection
,
extraSelections
);
...
...
src/plugins/texteditor/basetexteditor.h
View file @
321dbba5
...
...
@@ -242,22 +242,23 @@ class TEXTEDITOR_EXPORT BaseTextEditorAnimator : public QObject
public:
BaseTextEditorAnimator
(
QObject
*
parent
);
void
setPosition
(
int
position
)
{
m_position
=
position
;
}
int
position
()
const
{
return
m_position
;
}
inline
void
setPosition
(
int
position
)
{
m_position
=
position
;
}
inline
int
position
()
const
{
return
m_position
;
}
void
setData
(
QFont
f
,
QPalette
pal
,
const
QString
&
text
);
void
draw
(
QPainter
*
p
,
const
QPointF
&
pos
);
QRectF
rect
()
const
;
qreal
value
()
const
{
return
m_value
;
}
inline
qreal
value
()
const
{
return
m_value
;
}
inline
QPointF
lastDrawPos
()
const
{
return
m_lastDrawPos
;
}
void
finish
();
bool
isRunning
()
const
;
signals:
void
updateRequest
(
int
position
,
QRectF
rect
);
void
updateRequest
(
int
position
,
QPointF
lastPos
,
QRectF
rect
);
private
slots
:
...
...
@@ -267,6 +268,7 @@ private:
QTimeLine
*
m_timeline
;
qreal
m_value
;
int
m_position
;
QPointF
m_lastDrawPos
;
QFont
m_font
;
QPalette
m_palette
;
QString
m_text
;
...
...
@@ -599,7 +601,7 @@ private slots:
void
_q_matchParentheses
();
void
_q_highlightBlocks
();
void
slotSelectionChanged
();
void
_q_animateUpdate
(
int
position
,
QRectF
rect
);
void
_q_animateUpdate
(
int
position
,
QPointF
lastPos
,
QRectF
rect
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment