43 lines
885 B
C++
43 lines
885 B
C++
|
#include "IntervalWidget.hpp"
|
||
|
|
||
|
namespace Hardware
|
||
|
{
|
||
|
IntervalWidget::IntervalWidget(base_widget* parent,
|
||
|
Scenario::IntervalModel& interval)
|
||
|
: bugui::base_widget{parent}
|
||
|
, model{interval}
|
||
|
, skin{Process::Style::instance()}
|
||
|
{
|
||
|
}
|
||
|
|
||
|
int IntervalWidget::x() const
|
||
|
{
|
||
|
return model.date().sec();
|
||
|
}
|
||
|
|
||
|
int IntervalWidget::y() const
|
||
|
{
|
||
|
return model.heightPercentage() * parent->height();
|
||
|
}
|
||
|
|
||
|
int IntervalWidget::width() const
|
||
|
{
|
||
|
return model.duration.defaultDuration().sec();
|
||
|
}
|
||
|
|
||
|
void IntervalWidget::paint(bugui::painter& painter)
|
||
|
{
|
||
|
// Copied from MiniscenarioView
|
||
|
const auto col = skin.IntervalBase().color();
|
||
|
painter.set_color(col.red(), col.green(), col.blue(), col.alpha());
|
||
|
|
||
|
painter.draw_line({x(), y()}, {x() + width(), y()});
|
||
|
}
|
||
|
|
||
|
const Scenario::IntervalModel &IntervalWidget::get_model() const
|
||
|
{
|
||
|
return model;
|
||
|
}
|
||
|
|
||
|
} // namespace hardware
|