1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 02:38:13 +00:00

HexEditor: Make edited bytes bold

This will help them still stand out once we introduce annotations, which
also modify the colors.
This commit is contained in:
Sam Atkins 2023-12-31 17:04:33 +00:00 committed by Sam Atkins
parent 27adbd1792
commit da52c5e82a

View file

@ -674,6 +674,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
return palette().color(foreground_role());
}();
Gfx::Color text_color_text = text_color_hex;
auto& font = edited_flag ? this->font().bold_variant() : this->font();
if (highlight_flag) {
background_color_hex = background_color_text = edited_flag ? palette().selection().inverted() : palette().selection();
@ -709,11 +710,11 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
draw_cursor_rect();
if (byte_position == m_position && !edited_flag) {
painter.draw_text(hex_display_rect_high_nibble, high_nibble, Gfx::TextAlignment::TopLeft, m_cursor_at_low_nibble ? text_color_hex : palette().selection_text());
painter.draw_text(hex_display_rect_low_nibble, low_nibble, Gfx::TextAlignment::TopLeft, m_cursor_at_low_nibble ? palette().selection_text() : text_color_hex);
painter.draw_text(hex_display_rect_high_nibble, high_nibble, font, Gfx::TextAlignment::TopLeft, m_cursor_at_low_nibble ? text_color_hex : palette().selection_text());
painter.draw_text(hex_display_rect_low_nibble, low_nibble, font, Gfx::TextAlignment::TopLeft, m_cursor_at_low_nibble ? palette().selection_text() : text_color_hex);
} else {
painter.draw_text(hex_display_rect_high_nibble, high_nibble, Gfx::TextAlignment::TopLeft, text_color_hex);
painter.draw_text(hex_display_rect_low_nibble, low_nibble, Gfx::TextAlignment::TopLeft, text_color_hex);
painter.draw_text(hex_display_rect_high_nibble, high_nibble, font, Gfx::TextAlignment::TopLeft, text_color_hex);
painter.draw_text(hex_display_rect_low_nibble, low_nibble, font, Gfx::TextAlignment::TopLeft, text_color_hex);
}
Gfx::IntRect text_background_rect {
@ -731,9 +732,9 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
char const character = is_ascii_printable(cell_value) ? cell_value : '.';
auto character_sv = StringView { &character, 1 };
if (byte_position == m_position)
painter.draw_text(text_display_rect, character_sv, Gfx::TextAlignment::TopLeft, palette().selection_text());
painter.draw_text(text_display_rect, character_sv, font, Gfx::TextAlignment::TopLeft, palette().selection_text());
else
painter.draw_text(text_display_rect, character_sv, Gfx::TextAlignment::TopLeft, text_color_text);
painter.draw_text(text_display_rect, character_sv, font, Gfx::TextAlignment::TopLeft, text_color_text);
}
}
}