Skip to content

Commit

Permalink
Merge pull request #622 from reupen/fix-dark-tabs-ampersand
Browse files Browse the repository at this point in the history
Fix rendering of tabs containing ampersands in dark mode
  • Loading branch information
reupen committed Nov 3, 2022
2 parents f73420c + a72014f commit f71b79f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change log

## Development version

### Bug fixes

- A bug where ampersands didn’t render correctly in tab names in the Playlist
tabs and Tab stack panels when dark mode is active was fixed.
[[#622](https://github.com/reupen/columns_ui/pull/622)]

## 2.0.0-alpha.5

### Features
Expand Down
11 changes: 4 additions & 7 deletions foo_ui_columns/dark_mode_tabs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,12 @@ void handle_tab_control_paint(HWND wnd)
LineTo(buffered_dc.get(), item_rect.left, item_rect.bottom);
}

SIZE sz{};
GetTextExtentPoint32(buffered_dc.get(), item.text.data(), gsl::narrow<int>(item.text.length()), &sz);

// Position using original rect, but shift up 1px if it's the active tab
const auto x = item.rc.left + (RECT_CX(item.rc) - sz.cx) / 2;
const auto y = item.rc.top + (RECT_CY(item.rc) - sz.cy) / 2 - (item.is_active ? 1_spx : 0);
RECT text_rect = {item.rc.left, item.rc.top - (item.is_active ? 1_spx : 0), item.rc.right,
item.rc.bottom - (item.is_active ? 1_spx : 0)};

ExtTextOut(buffered_dc.get(), x, y, ETO_CLIPPED, &item_rect, item.text.data(),
gsl::narrow<UINT>(item.text.length()), nullptr);
DrawTextEx(buffered_dc.get(), const_cast<wchar_t*>(item.text.data()), gsl::narrow<int>(item.text.length()),
&text_rect, DT_CENTER | DT_HIDEPREFIX | DT_SINGLELINE | DT_VCENTER, nullptr);
}
}

Expand Down

0 comments on commit f71b79f

Please sign in to comment.