Adjust the method of drawing rounded borders
Signed-off-by: jiajia_deng <2894220@gmail.com>
This commit is contained in:
parent
ad9ef19e01
commit
bb82e1cb93
@ -52,5 +52,5 @@ Enter the `NIM_Duilib_Framework/samples` directory,Open `samples.sln` with Vis
|
||||
## Communication
|
||||
|
||||
- Question: Read the [Documentation](docs/SUMMARY.md) and [Samples code](samples/README.md) to help you.
|
||||
- Report: File a bug in GitHub issues
|
||||
- Report: File a bug in GitHub issues.
|
||||
- Suggestion: Request a new feature in Github issues.
|
||||
|
@ -34,12 +34,10 @@
|
||||
<Option class="circle_option_2" group="option_group" text="option3" margin="0,3,0,10"/>
|
||||
</VBox>
|
||||
<!-- List -->
|
||||
<VListBox class="list" name="list" padding="5,3,5,3" bordersize="1" bordercolor="red" borderround="5,5">
|
||||
|
||||
<VListBox class="list" name="list" padding="5,3,5,3">
|
||||
</VListBox>
|
||||
<!-- TreeView -->
|
||||
<TreeView class="list" name="tree" padding="5,3,5,3" margin="20">
|
||||
|
||||
</TreeView>
|
||||
</HBox>
|
||||
<Control class="splitline_hor_level1"/>
|
||||
|
@ -207,9 +207,6 @@
|
||||
<Project>{0149ba6e-3c0a-426d-aa0a-0b9ec7742f19}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\bin\resources.zip" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
@ -55,7 +55,4 @@
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\bin\resources.zip" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1429,25 +1429,6 @@ void Control::PaintBorder(IRenderContext* pRender)
|
||||
}
|
||||
|
||||
if (dwBorderColor != 0) {
|
||||
//判断是否需要画圆角矩阵
|
||||
if ((m_cxyBorderRound.cx > 0 || m_cxyBorderRound.cy > 0) && m_nBorderSize > 0)
|
||||
{
|
||||
UiRect rcDraw = m_rcItem;
|
||||
int nDeltaValue = m_nBorderSize / 2;
|
||||
rcDraw.top += nDeltaValue;
|
||||
rcDraw.bottom -= nDeltaValue;
|
||||
if (m_nBorderSize % 2 != 0) {
|
||||
rcDraw.bottom -= 1;
|
||||
}
|
||||
rcDraw.left += nDeltaValue;
|
||||
rcDraw.right -= nDeltaValue;
|
||||
if (m_nBorderSize % 2 != 0) {
|
||||
rcDraw.right -= 1;
|
||||
}
|
||||
pRender->DrawRoundRect(rcDraw, m_cxyBorderRound, m_nBorderSize, dwBorderColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_rcBorderSize.left > 0 || m_rcBorderSize.top > 0 || m_rcBorderSize.right > 0 || m_rcBorderSize.bottom > 0) {
|
||||
UiRect rcBorder;
|
||||
if (m_rcBorderSize.left > 0) {
|
||||
@ -1496,11 +1477,14 @@ void Control::PaintBorder(IRenderContext* pRender)
|
||||
if (m_nBorderSize % 2 != 0) {
|
||||
rcDraw.right -= 1;
|
||||
}
|
||||
|
||||
if (m_cxyBorderRound.cx > 0 || m_cxyBorderRound.cy > 0)
|
||||
pRender->DrawRoundRect(rcDraw, m_cxyBorderRound, m_nBorderSize, dwBorderColor);
|
||||
else
|
||||
pRender->DrawRect(rcDraw, m_nBorderSize, dwBorderColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Control::SetAlpha(int alpha)
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ public:
|
||||
virtual void DrawLine(const IPen* pen, int x1, int y1, int x2, int y2) = 0;
|
||||
virtual void DrawBezier(const IPen* pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) = 0;
|
||||
virtual void DrawRect(const UiRect& rc, int nSize, DWORD dwPenColor) = 0;
|
||||
virtual void DrawRoundRect(const UiRect& rc, const SIZE& round, int nSize, DWORD dwPenColor) = 0;
|
||||
virtual void DrawRoundRect(const UiRect& rc, const CSize& roundSize, int nSize, DWORD dwPenColor) = 0;
|
||||
|
||||
virtual void DrawText(const UiRect& rc, const std::wstring& strText, DWORD dwTextColor, const std::wstring& strFontId, UINT uStyle, BYTE uFade = 255, bool bLineLimit = false) = 0;
|
||||
|
||||
|
@ -471,30 +471,27 @@ void RenderContext_GdiPlus::DrawRect(const UiRect& rc, int nSize, DWORD dwPenCol
|
||||
}
|
||||
|
||||
|
||||
void RenderContext_GdiPlus::DrawRoundRect(const UiRect& rc, const SIZE& round, int nSize, DWORD dwPenColor)
|
||||
void RenderContext_GdiPlus::DrawRoundRect(const UiRect& rc, const CSize& roundSize, int nSize, DWORD dwPenColor)
|
||||
{
|
||||
Gdiplus::Graphics graphics(m_hDC);
|
||||
graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
|
||||
Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize);
|
||||
|
||||
// 裁剪区域不能作画,导致边框有时不全,往里收缩一个像素
|
||||
UiRect _rc = rc;
|
||||
_rc.left += 1;
|
||||
_rc.top += 1;
|
||||
_rc.right -= 1;
|
||||
_rc.bottom -= 1;
|
||||
//͸Ã÷»Ë¢
|
||||
Gdiplus::SolidBrush brShadow(Gdiplus::Color(0,0, 0, 0));
|
||||
// UiRect rcInflate = rc;
|
||||
// rcInflate.Inflate({ -1, -1, -1, -1 });
|
||||
|
||||
Gdiplus::GraphicsPath pPath;
|
||||
pPath.AddArc(_rc.left, _rc.top, round.cx, round.cy, 180, 90);
|
||||
pPath.AddLine(_rc.left + round.cx, _rc.top, _rc.right - round.cx, _rc.top);
|
||||
pPath.AddArc(_rc.right - round.cx, _rc.top, round.cx, round.cy, 270, 90);
|
||||
pPath.AddLine(_rc.right, _rc.top + round.cy, _rc.right, _rc.bottom - round.cy);
|
||||
pPath.AddArc(_rc.right - round.cx, _rc.bottom - round.cy, round.cx, round.cy, 0, 90);
|
||||
pPath.AddLine(_rc.right - round.cx, _rc.bottom, _rc.left + round.cx, _rc.bottom);
|
||||
pPath.AddArc(_rc.left, _rc.bottom - round.cy, round.cx, round.cy, 90, 90);
|
||||
pPath.AddLine(_rc.left, _rc.bottom - round.cy, _rc.left, _rc.top + round.cy);
|
||||
pPath.AddArc(rc.left, rc.top, roundSize.cx, roundSize.cy, 180, 90);
|
||||
pPath.AddLine(rc.left + roundSize.cx, rc.top, rc.right - roundSize.cx, rc.top);
|
||||
pPath.AddArc(rc.right - roundSize.cx, rc.top, roundSize.cx, roundSize.cy, 270, 90);
|
||||
pPath.AddLine(rc.right, rc.top + roundSize.cy, rc.right, rc.bottom - roundSize.cy);
|
||||
pPath.AddArc(rc.right - roundSize.cx, rc.bottom - roundSize.cy, roundSize.cx, roundSize.cy, 0, 90);
|
||||
pPath.AddLine(rc.right - roundSize.cx, rc.bottom, rc.left + roundSize.cx, rc.bottom);
|
||||
pPath.AddArc(rc.left, rc.bottom - roundSize.cy, roundSize.cx, roundSize.cy, 90, 90);
|
||||
pPath.AddLine(rc.left, rc.bottom - roundSize.cy, rc.left, rc.top + roundSize.cy);
|
||||
pPath.CloseFigure();
|
||||
graphics.FillPath(&brShadow, &pPath);
|
||||
|
||||
graphics.DrawPath(&pen, &pPath);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
virtual void DrawLine(const IPen* pen, int x1, int y1, int x2, int y2) override;
|
||||
virtual void DrawBezier(const IPen* pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) override;
|
||||
virtual void DrawRect(const UiRect& rc, int nSize, DWORD dwPenColor) override;
|
||||
virtual void DrawRoundRect(const UiRect& rc, const SIZE& round, int nSize, DWORD dwPenColor) override;
|
||||
virtual void DrawRoundRect(const UiRect& rc, const CSize& roundSize, int nSize, DWORD dwPenColor) override;
|
||||
virtual void DrawText(const UiRect& rc, const std::wstring& strText, DWORD dwTextColor, const std::wstring& strFontId, UINT uStyle, BYTE uFade = 255, bool bLineLimit = false) override;
|
||||
|
||||
virtual void DrawEllipse(const UiRect& rc, int nSize, DWORD dwColor) override;
|
||||
|
Loading…
Reference in New Issue
Block a user