Skip to content

Commit

Permalink
Merge pull request #1616 from beru/reduce_flickering_CaretUnderLine
Browse files Browse the repository at this point in the history
メモリDCを利用しない場合はアンダーライン描画を行描画の直後に行う事でちらつきを抑える
  • Loading branch information
beru committed Apr 22, 2021
2 parents b8c3830 + ad890c4 commit b96e322
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion sakura_core/view/CEditView_Paint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,16 @@ void CEditView::OnPaint2( HDC _hdc, PAINTSTRUCT *pPs, BOOL bDrawFromComptibleBmp
// 全部の行を描画 //
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //

/* アクティブペインは、アンダーライン描画 */
const bool bDrawUnderLine = m_pcEditWnd->GetActivePane() == m_nMyIndex;
// カーソル行アンダーライン描画を行描画ループ内で行うかどうか
const bool bDrawUnderLineWithoutDelay =
bDrawUnderLine
&& !bUseMemoryDC // メモリDCを利用しない場合はアンダーライン描画を行描画の直後に行う事でちらつきを抑える
&& !m_pTypeData->m_ColorInfoArr[COLORIDX_CURSORVLINE].m_bDisp // カーソル行より下にあるカーソル位置縦線が消えてしまうので、非表示設定でのみ行う
&& m_pTypeData->m_nLineSpace > 0 // 行間を0以下にすると、カーソル行アンダーラインの位置が一つ下の行に含まれるようになるため、レンダリングの対象行が変わるので、行間が0より大きい場合のみ行う
;

//必要な行を描画する // 2009.03.26 ryoji 行番号のみ描画を通常の行描画と分離(効率化)
if(pPs->rcPaint.right <= GetTextArea().GetAreaLeft()){
while(sPos.GetLayoutLineRef() <= nLayoutLineTo)
Expand All @@ -780,6 +790,7 @@ void CEditView::OnPaint2( HDC _hdc, PAINTSTRUCT *pPs, BOOL bDrawFromComptibleBmp
sPos.ForwardLayoutLineRef(1); //レイアウト行++
}
}else{
auto caretY = GetCaret().GetCaretLayoutPos().GetY2();
SColorStrategyInfo sInfo(gr);
sInfo.m_pDispPos = &sPos;
sInfo.m_pcView = this;
Expand All @@ -788,6 +799,9 @@ void CEditView::OnPaint2( HDC _hdc, PAINTSTRUCT *pPs, BOOL bDrawFromComptibleBmp
//描画X位置リセット
sPos.ResetDrawCol();

//DrawLogicLineを呼ぶと値が変わるので呼ぶ前に取得
auto nCurrLine = sPos.GetLayoutLineRef();

//1行描画
bool bDispResult = DrawLogicLine(
&sInfo,
Expand All @@ -812,6 +826,9 @@ void CEditView::OnPaint2( HDC _hdc, PAINTSTRUCT *pPs, BOOL bDrawFromComptibleBmp
DeleteObject(hdcBgImg);
}
}
if (bDrawUnderLineWithoutDelay && nCurrLine == caretY) {
GetCaret().m_cUnderLine.CaretUnderLineON(true, false);
}
}
}

Expand Down Expand Up @@ -848,7 +865,7 @@ void CEditView::OnPaint2( HDC _hdc, PAINTSTRUCT *pPs, BOOL bDrawFromComptibleBmp

// From Here 2007.09.09 Moca 互換BMPによる画面バッファ
// アンダーライン描画をメモリDCからのコピー前処理から後に移動
if ( m_pcEditWnd->GetActivePane() == m_nMyIndex ){
if ( bDrawUnderLine && !bDrawUnderLineWithoutDelay ){
/* アクティブペインは、アンダーライン描画 */
GetCaret().m_cUnderLine.CaretUnderLineON( true, false );
}
Expand Down

0 comments on commit b96e322

Please sign in to comment.