mirror-chatterino2/src/widgets/label.hpp

48 lines
1.2 KiB
C++
Raw Normal View History

2018-06-11 15:04:54 +02:00
#pragma once
#include "singletons/fontmanager.hpp"
#include "widgets/basewidget.hpp"
namespace chatterino {
namespace widgets {
class Label : public BaseWidget
{
public:
explicit Label(QString text = QString(), FontStyle style = FontStyle::UiMedium);
explicit Label(BaseWidget *parent, QString text = QString(),
FontStyle style = FontStyle::UiMedium);
const QString &getText() const;
void setText(const QString &text);
FontStyle getFontStyle() const;
void setFontStyle(FontStyle style);
bool getCentered() const;
void setCentered(bool centered);
bool getHasOffset() const;
2018-06-19 18:55:45 +02:00
void setHasOffset(bool hasOffset);
2018-06-11 15:04:54 +02:00
protected:
virtual void scaleChangedEvent(float scale) override;
virtual void paintEvent(QPaintEvent *) override;
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
private:
QString text_;
FontStyle fontStyle_;
QSize preferedSize_;
bool centered_ = false;
bool hasOffset_ = true;
void updateSize();
2018-06-11 21:57:17 +02:00
int getOffset();
2018-06-11 15:04:54 +02:00
};
} // namespace widgets
} // namespace chatterino