mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-19 17:27:51 +03:00
HexEditor: Avoid painting white rectangle on a white background
Most of the time, the background color for the hex and text areas will be the widget's normal background color, so skip painting it in those cases.
This commit is contained in:
parent
d4c051ece2
commit
f00afa4a71
Notes:
sideshowbarker
2024-07-16 23:52:10 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/f00afa4a71 Pull-request: https://github.com/SerenityOS/serenity/pull/23542 Reviewed-by: https://github.com/ADKaster ✅
@ -707,14 +707,14 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
||||
// 4. Annotations
|
||||
// 5. Null bytes
|
||||
// 6. Regular formatting
|
||||
auto determine_background_color = [&](EditMode edit_mode) -> Gfx::Color {
|
||||
auto determine_background_color = [&](EditMode edit_mode) -> Optional<Gfx::Color> {
|
||||
if (selected)
|
||||
return cell.modified ? palette().selection().inverted() : palette().selection();
|
||||
if (byte_position == m_position && m_edit_mode != edit_mode)
|
||||
return palette().inactive_selection();
|
||||
if (annotation.has_value())
|
||||
return annotation->background_color;
|
||||
return palette().color(background_role());
|
||||
return {};
|
||||
};
|
||||
auto determine_text_color = [&](EditMode edit_mode) -> Gfx::Color {
|
||||
if (cell.modified)
|
||||
@ -729,13 +729,14 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
||||
return palette().color(ColorRole::PlaceholderText);
|
||||
return palette().color(foreground_role());
|
||||
};
|
||||
Gfx::Color background_color_hex = determine_background_color(EditMode::Hex);
|
||||
Gfx::Color background_color_text = determine_background_color(EditMode::Text);
|
||||
Gfx::Color text_color_hex = determine_text_color(EditMode::Hex);
|
||||
Gfx::Color text_color_text = determine_text_color(EditMode::Text);
|
||||
auto background_color_hex = determine_background_color(EditMode::Hex);
|
||||
auto background_color_text = determine_background_color(EditMode::Text);
|
||||
auto text_color_hex = determine_text_color(EditMode::Hex);
|
||||
auto text_color_text = determine_text_color(EditMode::Text);
|
||||
auto& font = cell.modified ? this->font().bold_variant() : this->font();
|
||||
|
||||
painter.fill_rect(background_rect, background_color_hex);
|
||||
if (background_color_hex.has_value())
|
||||
painter.fill_rect(background_rect, *background_color_hex);
|
||||
|
||||
Gfx::IntRect text_display_rect {
|
||||
static_cast<int>(text_area_text_start_x + column * character_width()),
|
||||
@ -774,7 +775,8 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
||||
static_cast<int>(line_height()),
|
||||
};
|
||||
|
||||
painter.fill_rect(text_background_rect, background_color_text);
|
||||
if (background_color_text.has_value())
|
||||
painter.fill_rect(text_background_rect, *background_color_text);
|
||||
|
||||
if (m_edit_mode == EditMode::Text)
|
||||
draw_cursor_rect();
|
||||
|
Loading…
Reference in New Issue
Block a user