mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Fix CheckBox caption position.
This commit is contained in:
parent
ff0ce2b921
commit
74aa4d5345
Notes:
sideshowbarker
2024-07-19 18:49:58 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/74aa4d53453
@ -1,6 +1,7 @@
|
||||
#include "CheckBox.h"
|
||||
#include "Painter.h"
|
||||
#include "CBitmap.h"
|
||||
#include "Font.h"
|
||||
#include <cstdio>
|
||||
|
||||
CheckBox::CheckBox(Widget* parent)
|
||||
@ -65,10 +66,14 @@ void CheckBox::onPaint(PaintEvent&)
|
||||
|
||||
auto textRect = rect();
|
||||
textRect.setLeft(bitmap->width() + 4);
|
||||
textRect.setTop(height() / 2 - bitmap->height() / 2);
|
||||
textRect.setTop(height() / 2 - Font::defaultFont().glyphHeight() / 2);
|
||||
|
||||
Point bitmapPosition;
|
||||
bitmapPosition.setX(2);
|
||||
bitmapPosition.setY(height() / 2 - bitmap->height() / 2);
|
||||
|
||||
painter.fillRect(rect(), backgroundColor());
|
||||
painter.drawBitmap({ 2, textRect.y() }, *bitmap, Color(0, 0, 0));
|
||||
painter.drawBitmap(bitmapPosition, *bitmap, Color(0, 0, 0));
|
||||
|
||||
if (!caption().isEmpty()) {
|
||||
painter.drawText(textRect, caption(), Painter::TextAlignment::TopLeft, Color(0, 0, 0));
|
||||
|
Loading…
Reference in New Issue
Block a user