Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

マウスドラッグ時のスクロール速度を制限する #1853

Merged
merged 4 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions sakura_core/view/CCaret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,38 @@ CLayoutInt CCaret::MoveCursor(
}
// To Here 2007.07.28 じゅうじ
if( bScroll ){
if( abs( (Int)nScrollRowNum ) < 7 &&
( m_pEditView->GetSelectionInfo().IsMouseSelecting() || m_pEditView->m_bDragMode )){
struct ScrollRowRecord{
Int nScrollRowNum;
DWORD dwTime;
};
static std::array<ScrollRowRecord, 512> s_records{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4倍の根拠 = 試してみて値が大きいほうがいい感じだったから。

static size_t s_recordPos = 0;
DWORD dwNow = GetTickCount();
Int nScrollRowsPerTiming = 0;
DWORD dwPerTiming = 80;
if( nScrollRowNum > 0 && m_pEditView->m_bDragMode ){
dwPerTiming = 30;
}

std::for_each(s_records.begin(), s_records.end(),
[ dwNow, dwPerTiming, &nScrollRowsPerTiming ]( ScrollRowRecord rec ){
if( ( dwNow - rec.dwTime ) <= dwPerTiming ){
nScrollRowsPerTiming += rec.nScrollRowNum;
}
});
if( abs( nScrollRowsPerTiming ) >= 1 ){
nScrollRowNum = 0;
}
auto& rec = s_records[s_recordPos];
rec.dwTime = dwNow;
rec.nScrollRowNum = nScrollRowNum;
++s_recordPos;
if( s_recordPos >= s_records.size() ){
s_recordPos = 0;
}
}
/* スクロール */
if( t_abs( nScrollColNum ) >= m_pEditView->GetTextArea().m_nViewColNum ||
t_abs( nScrollRowNum ) >= m_pEditView->GetTextArea().m_nViewRowNum ){
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/view/CEditView_Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ void CEditView::OnMOUSEMOVE( WPARAM fwKeys, int xPos_, int yPos_ )
}
}
}else{
GetCaret().MoveCursorToClientPoint( ptMouse, true, &ptNewCursor );
GetCaret().MoveCursorToClientPoint( ptMouse, false, &ptNewCursor );
}
GetSelectionInfo().m_ptMouseRollPosOld = ptMouse; // マウス範囲選択前回位置(XY座標)

Expand Down