Skip to content

Commit

Permalink
Merge pull request #338 from reupen/fix-item-details-font-then-colour
Browse files Browse the repository at this point in the history
Fix Item details incorrect handling of some font changes
  • Loading branch information
reupen authored Sep 3, 2020
2 parents b2d006f + e98aad8 commit af86385
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

### Bug fixes

* The positioning of lines in Item details when a font change was immediately followed by a colour change was corrected. [[#338](https://github.com/reupen/columns_ui/pull/338)]

Additionally, font changes that don’t affect any text (e.g. due to being immediately followed by another font change) now correctly affect the height of the line.

* A bug was fixed where it sometimes wasn't possible to scroll to the very bottom of Items details when both horizontal and vertical scroll bars were visible. [[#335](https://github.com/reupen/columns_ui/pull/335)]

* Miscalculated bottom padding in the background of some dialogues at high DPIs was fixed. [[#334](https://github.com/reupen/columns_ui/pull/334)]
Expand Down
13 changes: 7 additions & 6 deletions foo_ui_columns/item_details_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,22 @@ DisplayInfo g_get_multiline_text_dimensions(HDC dc, std::wstring_view text, cons

for (auto&& [line, fragments] : fragments_by_line) {
int line_height{gsl::narrow<int>(uGetTextHeight(dc))};
bool is_line_height_explicitly_set{};
int line_width{};

for (auto&& [fragment_index, fragment] : ranges::views::enumerate(fragments)) {
const size_t character_pos = fragment.data() - text.data();
size_t fragment_character_pos{};

while (font_iter != font_changes.end() && font_iter->m_text_index < character_pos)
++font_iter;

while (font_iter != font_changes.end() && font_iter->m_text_index == character_pos) {
while (font_iter != font_changes.end() && font_iter->m_text_index <= character_pos) {
selected_font.reset();
selected_font = wil::SelectObject(dc, font_iter->m_font->m_font.get());
if (fragment_index == 0) {
if (fragment_index == 0 && !is_line_height_explicitly_set) {
line_height = font_iter->m_font->m_height;
is_line_height_explicitly_set = true;
} else {
line_height = (std::max)(line_height, font_iter->m_font->m_height);
is_line_height_explicitly_set = true;
}
++font_iter;
}
Expand Down Expand Up @@ -333,7 +333,8 @@ DisplayInfo g_get_multiline_text_dimensions(HDC dc, std::wstring_view text, cons

fragment_character_pos += max_chars;
last_append_pos = wrapped_line_end - text.data();
line_height = uGetTextHeight(dc);
line_height = gsl::narrow<int>(uGetTextHeight(dc));
is_line_height_explicitly_set = false;
line_width = 0;
} else {
fragment_character_pos += fragment.size();
Expand Down

0 comments on commit af86385

Please sign in to comment.