mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:57:44 +00:00
HexEditor: Render selection background without gaps between rows
The selected region in HexEditor is indicated by rendering a different background color for the selected bytes. Previously this background was rendered so that the background rectangles were not contigous between different rows. This caused a high contrast pattern that interfered with the readability of the hexadecimal digits. Now the background is rendered as a single contiguous block.
This commit is contained in:
parent
e6ea49d10b
commit
7394316818
1 changed files with 20 additions and 8 deletions
|
@ -586,11 +586,17 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
bool const highlight_flag = selection_inbetween_start_end || selection_inbetween_end_start;
|
||||
|
||||
Gfx::IntRect hex_display_rect {
|
||||
frame_thickness() + offset_margin_width() + static_cast<int>(j) * cell_width() + 2 * m_padding,
|
||||
frame_thickness() + m_padding + static_cast<int>(i) * line_height(),
|
||||
frame_thickness() + offset_margin_width() + j * cell_width() + 2 * m_padding,
|
||||
frame_thickness() + m_padding + i * line_height(),
|
||||
cell_width(),
|
||||
line_height() - m_line_spacing
|
||||
};
|
||||
Gfx::IntRect background_rect {
|
||||
frame_thickness() + offset_margin_width() + j * cell_width() + 1 * m_padding,
|
||||
frame_thickness() + m_line_spacing / 2 + i * line_height(),
|
||||
cell_width(),
|
||||
line_height()
|
||||
};
|
||||
|
||||
const u8 cell_value = m_document->get(byte_position).value;
|
||||
auto line = String::formatted("{:02X}", cell_value);
|
||||
|
@ -611,7 +617,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
background_color = palette().inactive_selection();
|
||||
text_color = palette().inactive_selection_text();
|
||||
}
|
||||
painter.fill_rect(hex_display_rect, background_color);
|
||||
painter.fill_rect(background_rect, background_color);
|
||||
|
||||
painter.draw_text(hex_display_rect, line, Gfx::TextAlignment::TopLeft, text_color);
|
||||
|
||||
|
@ -628,10 +634,16 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
}
|
||||
|
||||
Gfx::IntRect text_display_rect {
|
||||
static_cast<int>(frame_thickness() + offset_margin_width() + bytes_per_row() * cell_width() + j * character_width() + 4 * m_padding),
|
||||
static_cast<int>(frame_thickness() + m_padding + i * line_height()),
|
||||
static_cast<int>(character_width()),
|
||||
static_cast<int>(line_height() - m_line_spacing)
|
||||
frame_thickness() + offset_margin_width() + bytes_per_row() * cell_width() + j * character_width() + 4 * m_padding,
|
||||
frame_thickness() + m_padding + i * line_height(),
|
||||
character_width(),
|
||||
line_height() - m_line_spacing
|
||||
};
|
||||
Gfx::IntRect text_background_rect {
|
||||
frame_thickness() + offset_margin_width() + bytes_per_row() * cell_width() + j * character_width() + 4 * m_padding,
|
||||
frame_thickness() + m_line_spacing / 2 + i * line_height(),
|
||||
character_width(),
|
||||
line_height()
|
||||
};
|
||||
|
||||
background_color = palette().color(background_role());
|
||||
|
@ -651,7 +663,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
text_color = palette().inactive_selection_text();
|
||||
}
|
||||
|
||||
painter.fill_rect(text_display_rect, background_color);
|
||||
painter.fill_rect(text_background_rect, background_color);
|
||||
painter.draw_text(text_display_rect, String::formatted("{:c}", isprint(cell_value) ? cell_value : '.'), Gfx::TextAlignment::TopLeft, text_color);
|
||||
|
||||
if (m_edit_mode == EditMode::Text) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue