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

LibGUI+LibGfx+WindowServer: Auto-generate disabled action icons :^)

This patch adds a simple filter that makes button and menu item icons
have that "'90s disabled" look when disabled. It's pretty awesome.
This commit is contained in:
Andreas Kling 2020-10-27 21:17:50 +01:00
parent ea14c67e29
commit 3ec19ae4b6
5 changed files with 23 additions and 3 deletions

View file

@ -37,6 +37,7 @@
#include <AK/Utf32View.h>
#include <AK/Utf8View.h>
#include <LibGfx/CharacterBitmap.h>
#include <LibGfx/Palette.h>
#include <LibGfx/Path.h>
#include <math.h>
#include <stdio.h>
@ -1612,4 +1613,19 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule)
#endif
}
void Painter::blit_disabled(const IntPoint& location, const Gfx::Bitmap& bitmap, const IntRect& rect, const Palette& palette)
{
auto bright_color = palette.threed_highlight();
auto dark_color = palette.threed_shadow1();
blit_filtered(location.translated(1, 1), bitmap, rect, [&](auto) {
return bright_color;
});
blit_filtered(location, bitmap, rect, [&](Color src) {
int gray = src.to_grayscale().red();
if (gray > 160)
return bright_color;
return dark_color;
});
}
}