[bug] fix bugui/issues/8
This commit is contained in:
parent
294e23cc9b
commit
a6c770c4f8
5 changed files with 23 additions and 8 deletions
|
@ -28,6 +28,11 @@ EventWidget::EventWidget(Scenario::EventModel& event,
|
|||
static_cast<StateWidget*>(s.get())->set_y();
|
||||
}
|
||||
|
||||
void EventWidget::set_y()
|
||||
{
|
||||
m_y = m_absolute_y - parent->y();
|
||||
}
|
||||
|
||||
void EventWidget::set_span_recursive()
|
||||
{
|
||||
int lowest{std::numeric_limits<int>::max()};
|
||||
|
@ -45,8 +50,6 @@ void EventWidget::set_span_recursive()
|
|||
|
||||
static_cast<TimeSyncWidget*>(bugui::base_widget::parent)->set_span();
|
||||
|
||||
m_y = m_absolute_y - parent->y();
|
||||
|
||||
for(const auto& s : bugui::container_widget::children)
|
||||
static_cast<StateWidget*>(s.get())->set_y();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ struct EventWidget final : Nano::Observer
|
|||
int get_absolute_y() { return m_absolute_y; };
|
||||
int height() const override { return m_height; }
|
||||
|
||||
void set_y();
|
||||
void set_span_recursive();
|
||||
|
||||
private:
|
||||
|
|
|
@ -31,8 +31,7 @@ bool IntervalWidget::contains(int px, int py) const
|
|||
// ignore first and last cell
|
||||
// so that timesyncs are pressed
|
||||
// at the extremeties
|
||||
if (px > 0 && px < width() &&
|
||||
py == 0)
|
||||
if (px > 0 && px < width() && py == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -60,8 +59,12 @@ void IntervalWidget::on_double_press(int x, int y)
|
|||
|
||||
void IntervalWidget::on_drag(int from_x, int from_y, int to_x, int to_y)
|
||||
{
|
||||
double increment{to_y / static_cast<double>(scenario->height())};
|
||||
model.requestHeightChange(model.heightPercentage() + increment);
|
||||
double new_height{model.heightPercentage() +
|
||||
to_y / static_cast<double>(scenario->height())};
|
||||
|
||||
// prevent dragging out of scenario
|
||||
if (new_height >= 0 && new_height <= 1)
|
||||
model.setHeightPercentage(new_height);
|
||||
}
|
||||
|
||||
} // namespace hardware
|
||||
|
|
|
@ -53,8 +53,13 @@ void StateWidget::on_double_press(int x, int y)
|
|||
|
||||
void StateWidget::on_drag(int from_x, int from_y, int to_x, int to_y)
|
||||
{
|
||||
double increment{to_y / static_cast<double>(scenario->height())};
|
||||
model.setHeightPercentage(model.heightPercentage() + increment);
|
||||
double new_height{model.heightPercentage() +
|
||||
to_y / static_cast<double>(scenario->height())};
|
||||
|
||||
// prevent dragging out of scenario
|
||||
if (new_height >= 0 && new_height <= 1)
|
||||
model.setHeightPercentage(new_height);
|
||||
|
||||
}
|
||||
|
||||
void StateWidget::set_absolute_y()
|
||||
|
|
|
@ -79,6 +79,9 @@ void TimeSyncWidget::set_span()
|
|||
|
||||
m_y = lowest;
|
||||
m_height = heighest - lowest;
|
||||
|
||||
for(const auto& e : bugui::container_widget::children)
|
||||
static_cast<EventWidget*>(e.get())->set_y();
|
||||
}
|
||||
|
||||
void TimeSyncWidget::paint(bugui::painter& painter) const
|
||||
|
|
Loading…
Add table
Reference in a new issue