mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 10:36:24 +00:00
Fix CheckBox caption position.
This commit is contained in:
parent
ff0ce2b921
commit
74aa4d5345
|
@ -1,6 +1,7 @@
|
||||||
#include "CheckBox.h"
|
#include "CheckBox.h"
|
||||||
#include "Painter.h"
|
#include "Painter.h"
|
||||||
#include "CBitmap.h"
|
#include "CBitmap.h"
|
||||||
|
#include "Font.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
CheckBox::CheckBox(Widget* parent)
|
CheckBox::CheckBox(Widget* parent)
|
||||||
|
@ -65,10 +66,14 @@ void CheckBox::onPaint(PaintEvent&)
|
||||||
|
|
||||||
auto textRect = rect();
|
auto textRect = rect();
|
||||||
textRect.setLeft(bitmap->width() + 4);
|
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.fillRect(rect(), backgroundColor());
|
||||||
painter.drawBitmap({ 2, textRect.y() }, *bitmap, Color(0, 0, 0));
|
painter.drawBitmap(bitmapPosition, *bitmap, Color(0, 0, 0));
|
||||||
|
|
||||||
if (!caption().isEmpty()) {
|
if (!caption().isEmpty()) {
|
||||||
painter.drawText(textRect, caption(), Painter::TextAlignment::TopLeft, Color(0, 0, 0));
|
painter.drawText(textRect, caption(), Painter::TextAlignment::TopLeft, Color(0, 0, 0));
|
||||||
|
|
Loading…
Reference in a new issue