- enhancement: Correctly handle high-precision mouse wheel / touchpad in editors.
This commit is contained in:
parent
fcd086ebb5
commit
9f036d0d70
2
NEWS.md
2
NEWS.md
|
@ -34,8 +34,8 @@ Red Panda C++ Version 2.12
|
||||||
- enhancement: Delay for tooltips.
|
- enhancement: Delay for tooltips.
|
||||||
- enhancement: "Tool tips delay" option in Options/editor/Tooltips
|
- enhancement: "Tool tips delay" option in Options/editor/Tooltips
|
||||||
- change: Remove "Compile & Run" menu item. It's replaced by "Run".
|
- change: Remove "Compile & Run" menu item. It's replaced by "Run".
|
||||||
- enhancement: Limit max speed for mouse scroll (and touch pad?)
|
|
||||||
- enhancement: Show "..." instead of "...}" when folding #if/#endif
|
- enhancement: Show "..." instead of "...}" when folding #if/#endif
|
||||||
|
- enhancement: Correctly handle high-precision mouse wheel / touchpad in editors.
|
||||||
|
|
||||||
Red Panda C++ Version 2.11
|
Red Panda C++ Version 2.11
|
||||||
|
|
||||||
|
|
|
@ -66,25 +66,22 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
const QByteArray& encoding,
|
const QByteArray& encoding,
|
||||||
Project* pProject, bool isNew,
|
Project* pProject, bool isNew,
|
||||||
QTabWidget* parentPageControl):
|
QTabWidget* parentPageControl):
|
||||||
QSynEdit(parent),
|
QSynEdit{parent},
|
||||||
mInited(false),
|
mInited{false},
|
||||||
mEncodingOption(encoding),
|
mEncodingOption{encoding},
|
||||||
mFilename(filename),
|
mFilename{filename},
|
||||||
mParentPageControl(parentPageControl),
|
mParentPageControl{parentPageControl},
|
||||||
mProject(pProject),
|
mProject{pProject},
|
||||||
mIsNew(isNew),
|
mIsNew{isNew},
|
||||||
mSyntaxIssues(),
|
mSyntaxErrorColor{Qt::red},
|
||||||
mSyntaxErrorColor(Qt::red),
|
mSyntaxWarningColor{"orange"},
|
||||||
mSyntaxWarningColor("orange"),
|
mLineCount{0},
|
||||||
mLineCount(0),
|
mActiveBreakpointLine{-1},
|
||||||
mActiveBreakpointLine(-1),
|
mLastIdCharPressed{0},
|
||||||
mLastIdCharPressed(0),
|
mCurrentTipType{TipType::None},
|
||||||
mCurrentWord(),
|
mSaving{false},
|
||||||
mCurrentTipType(TipType::None),
|
mHoverModifiedLine{-1},
|
||||||
mOldHighlightedWord(),
|
mWheelAccumulatedDelta{0}
|
||||||
mCurrentHighlightedWord(),
|
|
||||||
mSaving(false),
|
|
||||||
mHoverModifiedLine(-1)
|
|
||||||
{
|
{
|
||||||
mInited=false;
|
mInited=false;
|
||||||
mBackupFile=nullptr;
|
mBackupFile=nullptr;
|
||||||
|
@ -622,21 +619,23 @@ void Editor::undoSymbolCompletion(int pos)
|
||||||
void Editor::wheelEvent(QWheelEvent *event) {
|
void Editor::wheelEvent(QWheelEvent *event) {
|
||||||
if ( (event->modifiers() & Qt::ControlModifier)!=0) {
|
if ( (event->modifiers() & Qt::ControlModifier)!=0) {
|
||||||
int size = pSettings->editor().fontSize();
|
int size = pSettings->editor().fontSize();
|
||||||
if (event->angleDelta().y()>0) {
|
int oldSize = size;
|
||||||
|
mWheelAccumulatedDelta+=event->angleDelta().y();
|
||||||
|
while (mWheelAccumulatedDelta>=120) {
|
||||||
|
mWheelAccumulatedDelta-=120;
|
||||||
size = std::min(99,size+1);
|
size = std::min(99,size+1);
|
||||||
pSettings->editor().setFontSize(size);
|
|
||||||
pSettings->editor().save();
|
|
||||||
pMainWindow->updateEditorSettings();
|
|
||||||
event->accept();
|
|
||||||
return;
|
|
||||||
} else if (event->angleDelta().y()<0) {
|
|
||||||
size = std::max(2,size-1);
|
|
||||||
pSettings->editor().setFontSize(size);
|
|
||||||
pSettings->editor().save();
|
|
||||||
pMainWindow->updateEditorSettings();
|
|
||||||
event->accept();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
while (mWheelAccumulatedDelta<=-120) {
|
||||||
|
mWheelAccumulatedDelta+=120;
|
||||||
|
size = std::max(2,size-1);
|
||||||
|
}
|
||||||
|
if (size!=oldSize) {
|
||||||
|
pSettings->editor().setFontSize(size);
|
||||||
|
pSettings->editor().save();
|
||||||
|
pMainWindow->updateEditorSettings();
|
||||||
|
}
|
||||||
|
event->accept();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
QSynEdit::wheelEvent(event);
|
QSynEdit::wheelEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,6 +347,7 @@ private:
|
||||||
QTimer mAutoBackupTimer;
|
QTimer mAutoBackupTimer;
|
||||||
QTimer mTooltipTimer;
|
QTimer mTooltipTimer;
|
||||||
int mHoverModifiedLine;
|
int mHoverModifiedLine;
|
||||||
|
int mWheelAccumulatedDelta;
|
||||||
|
|
||||||
static QHash<ParserLanguage,std::weak_ptr<CppParser>> mSharedParsers;
|
static QHash<ParserLanguage,std::weak_ptr<CppParser>> mSharedParsers;
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@
|
||||||
namespace QSynedit {
|
namespace QSynedit {
|
||||||
QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent),
|
QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent),
|
||||||
mDropped{false},
|
mDropped{false},
|
||||||
mLastWheelEventTime{QDateTime::currentMSecsSinceEpoch()},
|
mWheelAccumlatedDeltaX{0},
|
||||||
mWheelEventTimes{0}
|
mWheelAccumlatedDeltaY{0}
|
||||||
{
|
{
|
||||||
mCharWidth=1;
|
mCharWidth=1;
|
||||||
mTextHeight = 1;
|
mTextHeight = 1;
|
||||||
|
@ -6330,37 +6330,28 @@ void QSynEdit::leaveEvent(QEvent *)
|
||||||
|
|
||||||
void QSynEdit::wheelEvent(QWheelEvent *event)
|
void QSynEdit::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
qint64 current=QDateTime::currentMSecsSinceEpoch();
|
|
||||||
if (current-mLastWheelEventTime<=1000) {
|
|
||||||
mWheelEventTimes+=1;
|
|
||||||
if (mWheelEventTimes>30)
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
mWheelEventTimes=0;
|
|
||||||
mLastWheelEventTime=current;
|
|
||||||
}
|
|
||||||
if (event->modifiers() == Qt::ShiftModifier) {
|
if (event->modifiers() == Qt::ShiftModifier) {
|
||||||
if (event->angleDelta().y()>0) {
|
mWheelAccumlatedDeltaX+=event->angleDelta().y();
|
||||||
|
while (mWheelAccumlatedDeltaX>=120) {
|
||||||
|
mWheelAccumlatedDeltaX-=120;
|
||||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);
|
||||||
event->accept();
|
}
|
||||||
return;
|
while (mWheelAccumlatedDeltaX<=-120) {
|
||||||
} else if (event->angleDelta().y()<0) {
|
mWheelAccumlatedDeltaX+=120;
|
||||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed);
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed);
|
||||||
event->accept();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event->angleDelta().y()>0) {
|
mWheelAccumlatedDeltaY+=event->angleDelta().y();
|
||||||
|
while (mWheelAccumlatedDeltaY>=120) {
|
||||||
|
mWheelAccumlatedDeltaY-=120;
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed);
|
verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed);
|
||||||
event->accept();
|
}
|
||||||
return;
|
while (mWheelAccumlatedDeltaY<=-120) {
|
||||||
} else if (event->angleDelta().y()<0) {
|
mWheelAccumlatedDeltaY+=120;
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed);
|
verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed);
|
||||||
event->accept();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QAbstractScrollArea::wheelEvent(event);
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QSynEdit::viewportEvent(QEvent * event)
|
bool QSynEdit::viewportEvent(QEvent * event)
|
||||||
|
|
|
@ -743,8 +743,8 @@ private:
|
||||||
BufferCoord mDragSelBeginSave;
|
BufferCoord mDragSelBeginSave;
|
||||||
BufferCoord mDragSelEndSave;
|
BufferCoord mDragSelEndSave;
|
||||||
bool mDropped;
|
bool mDropped;
|
||||||
qint64 mLastWheelEventTime;
|
int mWheelAccumlatedDeltaX;
|
||||||
int mWheelEventTimes;
|
int mWheelAccumlatedDeltaY;
|
||||||
|
|
||||||
friend class QSynEditPainter;
|
friend class QSynEditPainter;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue