mirror-chatterino2/src/widgets/helper/Line.hpp

49 lines
962 B
C++
Raw Normal View History

2018-06-06 13:35:06 +02:00
#pragma once
2018-06-26 14:09:39 +02:00
#include "widgets/BaseWidget.hpp"
2018-06-06 13:35:06 +02:00
#include <QPainter>
namespace chatterino {
class Line : public BaseWidget
{
public:
Line(bool vertical)
: BaseWidget(nullptr)
, vertical_(vertical)
{
2018-10-21 13:43:02 +02:00
if (this->vertical_)
{
2018-06-06 13:35:06 +02:00
this->setScaleIndependantWidth(8);
2018-10-21 13:43:02 +02:00
}
else
{
2018-06-06 13:35:06 +02:00
this->setScaleIndependantHeight(8);
}
}
virtual void paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(QColor("#999"));
2018-10-21 13:43:02 +02:00
if (this->vertical_)
{
2018-08-06 21:17:03 +02:00
painter.drawLine(this->width() / 2, 0, this->width() / 2,
this->height());
2018-10-21 13:43:02 +02:00
}
else
{
2018-08-06 21:17:03 +02:00
painter.drawLine(0, this->height() / 2, this->width(),
this->height() / 2);
2018-06-06 13:35:06 +02:00
}
}
private:
bool vertical_;
};
} // namespace chatterino