Skip to content

Commit

Permalink
Merge pull request sakura-editor#1066 from berryzplus/feature/DispNot…
Browse files Browse the repository at this point in the history
…eLines

ノート線描画を少し分かりやすくする
  • Loading branch information
berryzplus authored Oct 6, 2019
2 parents b85172a + 866f1c9 commit dd18298
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 30 deletions.
12 changes: 5 additions & 7 deletions sakura_core/view/CEditView_Paint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,13 +821,11 @@ void CEditView::OnPaint2( HDC _hdc, PAINTSTRUCT *pPs, BOOL bDrawFromComptibleBmp

// ノート線描画
if( !m_bMiniMap ){
GetTextDrawer().DispNoteLine(
pInfo->m_gr,
y0,
y1,
GetTextArea().GetAreaLeft(),
GetTextArea().GetAreaRight()
);
LONG left = GetTextArea().GetAreaLeft();
LONG top = y0;
LONG right = GetTextArea().GetAreaRight();
LONG bottom = y1;
GetTextDrawer().DispNoteLines( pInfo->m_gr, left, top, right, bottom );
}

// 指定桁縦線描画
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/view/CEditView_Paint_Bracket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void CEditView::DrawBracketPair( bool bDraw )
DispPos sPos(nWidth, nHeight);
sPos.InitDrawPos(CMyPoint(nLeft, nTop));
GetTextDrawer().DispText(gr, &sPos, 0, &pLine[OutputX], 1, bTrans);
GetTextDrawer().DispNoteLine(gr, nTop, nTop + nHeight, nLeft, nLeft + (Int)charsWidth * nWidth);
GetTextDrawer().DispNoteLines(gr, nLeft, nTop, nLeft + (Int)charsWidth * nWidth, nTop + nHeight);
// 2006.04.30 Moca 対括弧の縦線対応
GetTextDrawer().DispVerticalLines(gr, nTop, nTop + nHeight, ptColLine.x, ptColLine.x + charsWidth); //※括弧が全角幅である場合を考慮
cTextType.RewindGraphicsState(gr);
Expand Down
45 changes: 24 additions & 21 deletions sakura_core/view/CTextDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,35 +281,38 @@ void CTextDrawer::DispVerticalLines(
}
}

void CTextDrawer::DispNoteLine(
void CTextDrawer::DispNoteLines(
CGraphics& gr, //!< 作画するウィンドウのDC
int nTop, //!< 線を引く上端のクライアント座標y
int nBottom, //!< 線を引く下端のクライアント座標y
int nLeft, //!< 線を引く左端
int nRight //!< 線を引く右端
LONG left, //!< ノート線を引く領域の左端のクライアント座標x
LONG top, //!< ノート線を引く領域の上端のクライアント座標y
LONG right, //!< ノート線を引く領域の右端のクライアント座標x
LONG bottom //!< ノート線を引く領域の下端のクライアント座標y
) const
{
const CEditView* pView=m_pEditView;

CTypeSupport cNoteLine(pView, COLORIDX_NOTELINE);
if( cNoteLine.IsDisp() ){
gr.SetPen( cNoteLine.GetTextColor() );
const int nLineHeight = pView->GetTextMetrics().GetHankakuDy();
const int left = nLeft;
const int right = nRight;
int userOffset = pView->m_pTypeData->m_nNoteLineOffset;
int offset = pView->GetTextArea().GetAreaTop() + userOffset - 1;
const LONG nLineHeight = pView->GetTextMetrics().GetHankakuDy();
const LONG userOffset = pView->m_pTypeData->m_nNoteLineOffset;
LONG offset = pView->GetTextArea().GetAreaTop() + userOffset - 1;
while( offset < 0 ){
offset += nLineHeight;
}
int offsetMod = offset % nLineHeight;
int y = ((nTop - offset) / nLineHeight * nLineHeight) + offsetMod;
for( ; y < nBottom; y += nLineHeight ){
if( nTop <= y ){
::MoveToEx( gr, left, y, NULL );
::LineTo( gr, right, y );

std::vector<CMyPoint> vLineEnds;
LONG offsetMod = offset % nLineHeight;
LONG y = ((top - offset) / nLineHeight * nLineHeight) + offsetMod;
for( ; y < bottom; y += nLineHeight ){
if( top <= y ){
vLineEnds.push_back(CMyPoint(left, y));
vLineEnds.push_back(CMyPoint(right, y));
}
}

std::vector<DWORD> vNumPts(vLineEnds.size() / 2, 2);
::PolyPolyline(gr, vLineEnds.data(), vNumPts.data(), static_cast<DWORD>(vNumPts.size()));
}
}

Expand Down Expand Up @@ -569,11 +572,11 @@ void CTextDrawer::DispLineNumber(

// 行番号部分のノート線描画
if( !pView->m_bMiniMap ){
int left = bDispLineNumTrans ? 0 : rcLineNum.right;
int right = pView->GetTextArea().GetAreaLeft();
int top = y;
int bottom = y + nLineHeight;
DispNoteLine( gr, top, bottom, left, right );
LONG left = bDispLineNumTrans ? 0 : rcLineNum.right;
LONG top = y;
LONG right = pView->GetTextArea().GetAreaLeft();
LONG bottom = y + nLineHeight;
DispNoteLines( gr, left, top, right, bottom );
}
}

2 changes: 1 addition & 1 deletion sakura_core/view/CTextDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CTextDrawer{
void DispText( HDC hdc, DispPos* pDispPos, int marginy, const wchar_t* pData, int nLength, bool bTransparent = false ) const; // テキスト表示

//! ノート線描画
void DispNoteLine( CGraphics& gr, int nTop, int nBottom, int nLeft, int nRight ) const;
void DispNoteLines( CGraphics& gr, LONG left, LONG top, LONG right, LONG bottom ) const;

// -- -- 指定桁縦線描画 -- -- //
//! 指定桁縦線描画関数 // 2005.11.08 Moca
Expand Down

0 comments on commit dd18298

Please sign in to comment.