tweak displays

This commit is contained in:
Roy Qu 2024-03-23 10:24:59 +08:00
parent b485e18e04
commit 79274d786a
4 changed files with 17 additions and 19 deletions

View File

@ -781,17 +781,6 @@ void Editor::keyPressEvent(QKeyEvent *event)
insertString.append(QString(" * @return ")+USER_CODE_IN_INSERT_POS); insertString.append(QString(" * @return ")+USER_CODE_IN_INSERT_POS);
} }
insertString.append(" */"); insertString.append(" */");
// } else if (caretY()==1) { /* file header */
// insertString.append(QString(" * @file %1<SOURCEPATH>%2")
// .arg(USER_CODE_IN_REPL_POS_BEGIN)
// .arg(USER_CODE_IN_REPL_POS_END));
// insertString.append(QString(" * @brief: ")+ USER_CODE_IN_INSERT_POS);
// insertString.append(QString(" * @version: ")+ USER_CODE_IN_INSERT_POS);
// insertString.append(QString(" * @copyright: ")+ USER_CODE_IN_INSERT_POS);
// insertString.append(QString(" * @author: ")+ USER_CODE_IN_INSERT_POS);
// insertString.append(" * @date: <DATETIME>");
// insertString.append(" * ");
// insertString.append(" **/");
} else { } else {
insertString.append(QString(" * ")+USER_CODE_IN_INSERT_POS); insertString.append(QString(" * ")+USER_CODE_IN_INSERT_POS);
insertString.append(" */"); insertString.append(" */");

View File

@ -520,6 +520,9 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList)
pen.setWidth(penWidth); pen.setWidth(penWidth);
mPainter->setPen(pen); mPainter->setPen(pen);
mPainter->setBrush(Qt::NoBrush); mPainter->setBrush(Qt::NoBrush);
int lineHeight = rc.height();
int fontHeight = mPainter->fontMetrics().descent() + mPainter->fontMetrics().ascent();
int linePadding = (lineHeight - fontHeight) / 2;
switch(p->type) { switch(p->type) {
case EditingAreaType::eatRectangleBorder: case EditingAreaType::eatRectangleBorder:
rc.setTop(rc.top()+penWidth/2); rc.setTop(rc.top()+penWidth/2);
@ -527,17 +530,14 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList)
rc.setBottom(rc.bottom()-penWidth/2); rc.setBottom(rc.bottom()-penWidth/2);
mPainter->drawRect(rc); mPainter->drawRect(rc);
break; break;
case EditingAreaType::eatUnderLine: { case EditingAreaType::eatUnderLine:
int lineHeight = rc.height();
int fontHeight = mPainter->fontMetrics().descent() + mPainter->fontMetrics().ascent();
int linePadding = (lineHeight - fontHeight) / 2;
mPainter->drawLine(rc.left(),rc.bottom()-linePadding-pen.width(),rc.right(),rc.bottom()-linePadding-pen.width()); mPainter->drawLine(rc.left(),rc.bottom()-linePadding-pen.width(),rc.right(),rc.bottom()-linePadding-pen.width());
}
break; break;
case EditingAreaType::eatWaveUnderLine: { case EditingAreaType::eatWaveUnderLine: {
int lineHeight = rc.height(); if (linePadding>mPainter->fontMetrics().descent())
int fontHeight = mPainter->fontMetrics().descent() + mPainter->fontMetrics().ascent(); linePadding -= mPainter->fontMetrics().descent();
int linePadding = (lineHeight - fontHeight) / 2; else
linePadding = 0;
int maxOffset = std::min(3*penWidth, mPainter->fontMetrics().descent()); int maxOffset = std::min(3*penWidth, mPainter->fontMetrics().descent());
maxOffset = std::max(3, maxOffset); maxOffset = std::max(3, maxOffset);
int offset = maxOffset; int offset = maxOffset;

View File

@ -6069,6 +6069,7 @@ void QSynEdit::mousePressEvent(QMouseEvent *event)
bool bStartDrag = false; bool bStartDrag = false;
mMouseMoved = false; mMouseMoved = false;
mMouseOrigin = event->pos(); mMouseOrigin = event->pos();
mMouseScrollOldTop = topPos();
Qt::MouseButton button = event->button(); Qt::MouseButton button = event->button();
int X=event->pos().x(); int X=event->pos().x();
int Y=event->pos().y(); int Y=event->pos().y();
@ -6143,6 +6144,13 @@ void QSynEdit::mouseReleaseEvent(QMouseEvent *event)
mStateFlags.setFlag(StateFlag::sfWaitForDragging, false); mStateFlags.setFlag(StateFlag::sfWaitForDragging, false);
} }
mStateFlags.setFlag(StateFlag::sfDblClicked,false); mStateFlags.setFlag(StateFlag::sfDblClicked,false);
if (mMouseScrollOldTop > topPos()) {
if (topPos() % mTextHeight !=0)
setTopPos(topPos()/mTextHeight * mTextHeight);
} else if (mMouseScrollOldTop < topPos()) {
if (topPos() % mTextHeight !=0)
setTopPos( (topPos()/mTextHeight + 1) * mTextHeight);
}
if (oldCaret!=caretXY()) { if (oldCaret!=caretXY()) {
if (mOptions.testFlag(EditorOption::eoGroupUndo)) if (mOptions.testFlag(EditorOption::eoGroupUndo))
mUndoList->addGroupBreak(); mUndoList->addGroupBreak();

View File

@ -689,6 +689,7 @@ private:
QFont mFontForNonAscii; QFont mFontForNonAscii;
bool mMouseMoved; bool mMouseMoved;
QPoint mMouseOrigin; QPoint mMouseOrigin;
int mMouseScrollOldTop;
bool mInserting; bool mInserting;
bool mPainting; bool mPainting;