1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

LibGUI: Add ModelRole::IconOpacity and support it in all views :^)

This role allows you to specify a custom opacity for icon painting.
Note that the opacity is not in effect when the item is either
selected and/or hovered.
This commit is contained in:
Andreas Kling 2021-07-27 17:23:52 +02:00
parent 2d1eff01a2
commit 8ba47facf6
6 changed files with 20 additions and 10 deletions

View file

@ -118,8 +118,10 @@ void ListView::paint_list_item(Painter& painter, int row_index, int painted_item
if (data.is_bitmap()) {
painter.blit(row_rect.location(), data.as_bitmap(), data.as_bitmap().rect());
} else if (data.is_icon()) {
if (auto bitmap = data.as_icon().bitmap_for_size(16))
painter.blit(row_rect.location(), *bitmap, bitmap->rect());
if (auto bitmap = data.as_icon().bitmap_for_size(16)) {
auto opacity = index.data(ModelRole::IconOpacity).as_float_or(1.0f);
painter.blit(row_rect.location(), *bitmap, bitmap->rect(), opacity);
}
} else {
Color text_color;
if (is_selected_row)