Skip to content

Commit 115370a

Browse files
committed
Draw a border around the selection again
Commit 09800bd dropped the black outline from PaintTransparentRectangles for a Chrome-style borderless look. Restore the border, but only for the user's selection: add a drawBorder param (default false, so find-match and read-aloud highlights stay borderless) and pass true from PaintSelection. prompt: when painting selection and find matches we used to draw a border around it; restore it only for selection, leave find match painting unchanged
1 parent ffdd153 commit 115370a

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎src/Selection.cpp‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ void DeleteOldSelectionInfo(MainWindow* win, bool alsoTextSel) {
105105
}
106106
}
107107

108-
void PaintTransparentRectangles(HDC hdc, Rect screenRc, Vec<Rect>& rects, COLORREF selectionColor, u8 alpha, int pad) {
108+
void PaintTransparentRectangles(HDC hdc, Rect screenRc, Vec<Rect>& rects, COLORREF selectionColor, u8 alpha, int pad,
109+
bool drawBorder) {
109110
// create path from rectangles
110111
Gdiplus::GraphicsPath path(Gdiplus::FillModeWinding);
111112
screenRc.Inflate(pad, pad);
@@ -126,6 +127,13 @@ void PaintTransparentRectangles(HDC hdc, Rect screenRc, Vec<Rect>& rects, COLORR
126127
Gdiplus::Color c(alpha, r, g, b);
127128
Gdiplus::SolidBrush tmpBrush(c);
128129
gs.FillPath(&tmpBrush, &path);
130+
if (drawBorder && pad > 0) {
131+
// black outline around the filled region (only the selection asks for this;
132+
// find-match and read-aloud highlights stay borderless)
133+
path.Outline(nullptr, 0.2f);
134+
Gdiplus::Pen tmpPen(Gdiplus::Color(alpha, 0, 0, 0), (float)pad);
135+
gs.DrawPath(&tmpPen, &path);
136+
}
129137
}
130138

131139
void PaintSelection(MainWindow* win, HDC hdc) {
@@ -182,7 +190,7 @@ void PaintSelection(MainWindow* win, HDC hdc) {
182190
if (alpha == 0) {
183191
alpha = kSelectionDefaultAlpha;
184192
}
185-
PaintTransparentRectangles(hdc, win->canvasRc, rects, parsedCol->col, alpha);
193+
PaintTransparentRectangles(hdc, win->canvasRc, rects, parsedCol->col, alpha, 2, /*drawBorder*/ true);
186194
}
187195

188196
void UpdateTextSelection(MainWindow* win, bool select) {

‎src/Selection.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ constexpr u8 kSelectionDefaultAlpha = 0x5f;
2727

2828
void DeleteOldSelectionInfo(MainWindow* win, bool alsoTextSel = false);
2929
void PaintTransparentRectangles(HDC hdc, Rect screenRc, Vec<Rect>& rects, COLORREF selectionColor,
30-
u8 alpha = kSelectionDefaultAlpha, int pad = 2);
30+
u8 alpha = kSelectionDefaultAlpha, int pad = 2, bool drawBorder = false);
3131
void PaintSelection(MainWindow* win, HDC hdc);
3232
void UpdateTextSelection(MainWindow* win, bool select = true);
3333
void CopySelectionToClipboard(MainWindow* win);

0 commit comments

Comments
 (0)