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

Support rendering of underline style and color #16097

Merged
merged 24 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d2bea4c
initial commit for underline style and color
tusharsnx Oct 3, 2023
d341402
add new underline styles in UIA
tusharsnx Oct 9, 2023
a042401
draw curly line from the shader
tusharsnx Oct 12, 2023
e16055c
revert D2D antialias mode
tusharsnx Oct 12, 2023
1df5894
fix gridlines being drawn with underline color
tusharsnx Oct 14, 2023
0bdeb1a
add dotted underline to BackendD2D and Dx renderers
tusharsnx Oct 14, 2023
c179041
fix ScrollTest's MockScrollRenderEngine wasn't updated to receive und…
tusharsnx Oct 14, 2023
8684de8
make sine wave start with a crest
tusharsnx Oct 16, 2023
dc986c1
fix strikethrough being drawn with underline color
tusharsnx Oct 16, 2023
bea07a5
add support for underline styles in gdi renderer
tusharsnx Oct 24, 2023
4f13a3c
add spellings
tusharsnx Oct 24, 2023
1f3e535
fix signed/unsigned mismatch
tusharsnx Oct 25, 2023
2babe7b
make small improvements to Atlas curlyline rendering
tusharsnx Oct 25, 2023
e31d0fb
AtlasEngine: use cellBottomGap as the peak height for curly line
tusharsnx Oct 27, 2023
63ae6ce
GDIRenderer: use cellBottomGap as the peak height for curly line
tusharsnx Oct 27, 2023
b5574d0
initialize _curlyLineDrawPeakHeight
tusharsnx Oct 27, 2023
b8d3caa
send line rendition scale using texcoord
tusharsnx Oct 28, 2023
a2c4a36
underlines are mutually exclusive
tusharsnx Oct 28, 2023
6e4c65a
revert underline thickness scaling
tusharsnx Oct 28, 2023
b0be8b6
move curlyline peak height constants into the function
tusharsnx Nov 2, 2023
1ba1782
fix curlyline equation that was making a negative peak at the start
tusharsnx Nov 2, 2023
4f7ba10
BackendD2D: use `else if`
tusharsnx Nov 2, 2023
c7a8a55
shrink QuadInstance::ShadingType and add renditionScale member
tusharsnx Nov 3, 2023
3923fde
replace SelectObject with wil::SelectObject
tusharsnx Nov 4, 2023
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
4 changes: 4 additions & 0 deletions .github/actions/spelling/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ CTRLVOLUME
Ctxt
CUF
cupxy
curlyline
CURRENTFONT
currentmode
CURRENTPAGE
Expand Down Expand Up @@ -578,6 +579,7 @@ elems
emacs
EMPTYBOX
enabledelayedexpansion
ENDCAP
endptr
endregion
ENTIREBUFFER
Expand Down Expand Up @@ -826,6 +828,7 @@ hostlib
HPA
hpcon
HPCON
hpen
hpj
HPR
HProvider
Expand Down Expand Up @@ -1010,6 +1013,7 @@ LOBYTE
localappdata
locsrc
Loewen
LOGBRUSH
LOGFONT
LOGFONTA
LOGFONTW
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/UnitTests_TerminalCore/ScrollTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace
HRESULT InvalidateCircling(_Out_ bool* /*pForcePaint*/) noexcept { return S_OK; }
HRESULT PaintBackground() noexcept { return S_OK; }
HRESULT PaintBufferLine(std::span<const Cluster> /*clusters*/, til::point /*coord*/, bool /*fTrimLeft*/, bool /*lineWrapped*/) noexcept { return S_OK; }
HRESULT PaintBufferGridLines(GridLineSet /*lines*/, COLORREF /*color*/, size_t /*cchLine*/, til::point /*coordTarget*/) noexcept { return S_OK; }
HRESULT PaintBufferGridLines(GridLineSet /*lines*/, COLORREF /*gridlineColor*/, COLORREF /*underlineColor*/, size_t /*cchLine*/, til::point /*coordTarget*/) noexcept { return S_OK; }
HRESULT PaintSelection(const til::rect& /*rect*/) noexcept { return S_OK; }
HRESULT PaintCursor(const CursorOptions& /*options*/) noexcept { return S_OK; }
HRESULT UpdateDrawingBrushes(const TextAttribute& /*textAttributes*/, const RenderSettings& /*renderSettings*/, gsl::not_null<IRenderData*> /*pData*/, bool /*usingSoftFont*/, bool /*isSettingDefaultBrushes*/) noexcept { return S_OK; }
Expand Down
7 changes: 4 additions & 3 deletions src/interactivity/onecore/BgfxEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ CATCH_RETURN()
CATCH_RETURN()
}

[[nodiscard]] HRESULT BgfxEngine::PaintBufferGridLines(GridLineSet const /*lines*/,
COLORREF const /*color*/,
size_t const /*cchLine*/,
[[nodiscard]] HRESULT BgfxEngine::PaintBufferGridLines(const GridLineSet /*lines*/,
const COLORREF /*gridlineColor*/,
const COLORREF /*underlineColor*/,
const size_t /*cchLine*/,
const til::point /*coordTarget*/) noexcept
{
return S_OK;
Expand Down
2 changes: 1 addition & 1 deletion src/interactivity/onecore/BgfxEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Microsoft::Console::Render
const til::point coord,
const bool trimLeft,
const bool lineWrapped) noexcept override;
[[nodiscard]] HRESULT PaintBufferGridLines(GridLineSet const lines, COLORREF const color, size_t const cchLine, til::point const coordTarget) noexcept override;
[[nodiscard]] HRESULT PaintBufferGridLines(const GridLineSet lines, const COLORREF gridlineColor, const COLORREF underlineColor, const size_t cchLine, const til::point coordTarget) noexcept override;
[[nodiscard]] HRESULT PaintSelection(const til::rect& rect) noexcept override;

[[nodiscard]] HRESULT PaintCursor(const CursorOptions& options) noexcept override;
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/atlas/AtlasEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,17 @@ try
}
CATCH_RETURN()

[[nodiscard]] HRESULT AtlasEngine::PaintBufferGridLines(const GridLineSet lines, const COLORREF color, const size_t cchLine, const til::point coordTarget) noexcept
[[nodiscard]] HRESULT AtlasEngine::PaintBufferGridLines(const GridLineSet lines, const COLORREF gridlineColor, const COLORREF underlineColor, const size_t cchLine, const til::point coordTarget) noexcept
try
{
const auto shift = gsl::narrow_cast<u8>(_api.lineRendition != LineRendition::SingleWidth);
const auto x = std::max(0, coordTarget.x - (_p.s->viewportOffset.x >> shift));
const auto y = gsl::narrow_cast<u16>(clamp<til::CoordType>(coordTarget.y, 0, _p.s->viewportCellCount.y));
const auto from = gsl::narrow_cast<u16>(clamp<til::CoordType>(x << shift, 0, _p.s->viewportCellCount.x - 1));
const auto to = gsl::narrow_cast<u16>(clamp<size_t>((x + cchLine) << shift, from, _p.s->viewportCellCount.x));
const auto fg = gsl::narrow_cast<u32>(color) | 0xff000000;
_p.rows[y]->gridLineRanges.emplace_back(lines, fg, from, to);
const auto glColor = gsl::narrow_cast<u32>(gridlineColor) | 0xff000000;
const auto ulColor = gsl::narrow_cast<u32>(underlineColor) | 0xff000000;
_p.rows[y]->gridLineRanges.emplace_back(lines, glColor, ulColor, from, to);
return S_OK;
}
CATCH_RETURN()
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/atlas/AtlasEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace Microsoft::Console::Render::Atlas
[[nodiscard]] HRESULT PrepareLineTransform(LineRendition lineRendition, til::CoordType targetRow, til::CoordType viewportLeft) noexcept override;
[[nodiscard]] HRESULT PaintBackground() noexcept override;
[[nodiscard]] HRESULT PaintBufferLine(std::span<const Cluster> clusters, til::point coord, bool fTrimLeft, bool lineWrapped) noexcept override;
[[nodiscard]] HRESULT PaintBufferGridLines(GridLineSet lines, COLORREF color, size_t cchLine, til::point coordTarget) noexcept override;
[[nodiscard]] HRESULT PaintBufferGridLines(const GridLineSet lines, const COLORREF gridlineColor, const COLORREF underlineColor, const size_t cchLine, const til::point coordTarget) noexcept override;
[[nodiscard]] HRESULT PaintSelection(const til::rect& rect) noexcept override;
[[nodiscard]] HRESULT PaintCursor(const CursorOptions& options) noexcept override;
[[nodiscard]] HRESULT UpdateDrawingBrushes(const TextAttribute& textAttributes, const RenderSettings& renderSettings, gsl::not_null<IRenderData*> pData, bool usingSoftFont, bool isSettingDefaultBrushes) noexcept override;
Expand Down
28 changes: 14 additions & 14 deletions src/renderer/atlas/BackendD2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void BackendD2D::_drawGridlineRow(const RenderingPayload& p, const ShapedRow* ro

D2D1_POINT_2F point0{ 0, static_cast<f32>(textCellCenter) };
D2D1_POINT_2F point1{ 0, static_cast<f32>(textCellCenter + cellSize.y) };
const auto brush = _brushWithColor(r.color);
const auto brush = _brushWithColor(r.gridlineColor);
const f32 w = pos.height;
const f32 hw = w * 0.5f;

Expand All @@ -421,11 +421,11 @@ void BackendD2D::_drawGridlineRow(const RenderingPayload& p, const ShapedRow* ro
_renderTarget->DrawLine(point0, point1, brush, w, nullptr);
}
};
const auto appendHorizontalLine = [&](const GridLineRange& r, FontDecorationPosition pos, ID2D1StrokeStyle* strokeStyle) {
const auto appendHorizontalLine = [&](const GridLineRange& r, FontDecorationPosition pos, ID2D1StrokeStyle* strokeStyle, const u32 color) {
const auto from = r.from >> widthShift;
const auto to = r.to >> widthShift;

const auto brush = _brushWithColor(r.color);
const auto brush = _brushWithColor(color);
const f32 w = pos.height;
const f32 centerY = textCellCenter + pos.position + w * 0.5f;
const D2D1_POINT_2F point0{ static_cast<f32>(from * cellSize.x), centerY };
Expand All @@ -448,32 +448,32 @@ void BackendD2D::_drawGridlineRow(const RenderingPayload& p, const ShapedRow* ro
}
if (r.lines.test(GridLines::Top))
{
appendHorizontalLine(r, p.s->font->gridTop, nullptr);
appendHorizontalLine(r, p.s->font->gridTop, nullptr, r.gridlineColor);
}
if (r.lines.test(GridLines::Bottom))
{
appendHorizontalLine(r, p.s->font->gridBottom, nullptr);
appendHorizontalLine(r, p.s->font->gridBottom, nullptr, r.gridlineColor);
}
if (r.lines.test(GridLines::Strikethrough))
{
appendHorizontalLine(r, p.s->font->strikethrough, nullptr, r.gridlineColor);
}

if (r.lines.test(GridLines::Underline))
{
appendHorizontalLine(r, p.s->font->underline, nullptr);
appendHorizontalLine(r, p.s->font->underline, nullptr, r.underlineColor);
}
if (r.lines.test(GridLines::HyperlinkUnderline))
else if (r.lines.any(GridLines::DottedUnderline, GridLines::HyperlinkUnderline))
{
appendHorizontalLine(r, p.s->font->underline, _dottedStrokeStyle.get());
appendHorizontalLine(r, p.s->font->underline, _dottedStrokeStyle.get(), r.underlineColor);
}
if (r.lines.test(GridLines::DoubleUnderline))
else if (r.lines.test(GridLines::DoubleUnderline))
{
for (const auto pos : p.s->font->doubleUnderline)
{
appendHorizontalLine(r, pos, nullptr);
appendHorizontalLine(r, pos, nullptr, r.underlineColor);
}
}
if (r.lines.test(GridLines::Strikethrough))
{
appendHorizontalLine(r, p.s->font->strikethrough, nullptr);
}
}
}

Expand Down
Loading
Loading