mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-10-26 14:57:54 +03:00
Improve CheckBox style a bit.
This commit is contained in:
parent
6f9e0e3876
commit
20a1795218
Notes:
sideshowbarker
2024-07-19 18:49:53 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/20a17952185
@ -30,39 +30,54 @@ void CheckBox::setIsChecked(bool b)
|
||||
}
|
||||
|
||||
static const char* uncheckedBitmap = {
|
||||
"############"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"############"
|
||||
"###########"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"# #"
|
||||
"###########"
|
||||
};
|
||||
|
||||
#if 0
|
||||
static const char* checkedBitmap = {
|
||||
"############"
|
||||
"# #"
|
||||
"# # # #"
|
||||
"# # # #"
|
||||
"# # # #"
|
||||
"# ## #"
|
||||
"# ## #"
|
||||
"# # # #"
|
||||
"# # # #"
|
||||
"# # # #"
|
||||
"# ## #"
|
||||
"# ## #"
|
||||
"# ## #"
|
||||
"# ## #"
|
||||
"# ## #"
|
||||
"# ## ## #"
|
||||
"# ## ## #"
|
||||
"# ### #"
|
||||
"# #"
|
||||
"############"
|
||||
};
|
||||
#endif
|
||||
|
||||
static const char* checkedBitmap = {
|
||||
"###########"
|
||||
"## ##"
|
||||
"# # # #"
|
||||
"# # # #"
|
||||
"# # # #"
|
||||
"# # #"
|
||||
"# # # #"
|
||||
"# # # #"
|
||||
"# # # #"
|
||||
"## ##"
|
||||
"###########"
|
||||
};
|
||||
|
||||
void CheckBox::onPaint(PaintEvent&)
|
||||
{
|
||||
Painter painter(*this);
|
||||
auto bitmap = CBitmap::createFromASCII(isChecked() ? checkedBitmap : uncheckedBitmap, 12, 12);
|
||||
auto bitmap = CBitmap::createFromASCII(isChecked() ? checkedBitmap : uncheckedBitmap, 11, 11);
|
||||
|
||||
auto textRect = rect();
|
||||
textRect.setLeft(bitmap->width() + 4);
|
||||
@ -70,7 +85,7 @@ void CheckBox::onPaint(PaintEvent&)
|
||||
|
||||
Point bitmapPosition;
|
||||
bitmapPosition.setX(2);
|
||||
bitmapPosition.setY(height() / 2 - bitmap->height() / 2);
|
||||
bitmapPosition.setY(height() / 2 - bitmap->height() / 2 - 1);
|
||||
|
||||
painter.fillRect(rect(), backgroundColor());
|
||||
painter.drawBitmap(bitmapPosition, *bitmap, Color(0, 0, 0));
|
||||
|
Loading…
Reference in New Issue
Block a user