[widgets] rebase on container_widget
This commit is contained in:
parent
2108bda343
commit
d52e74eb27
7 changed files with 18 additions and 88 deletions
2
Hardware/3rdparty/bugui
vendored
2
Hardware/3rdparty/bugui
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 0f5aabb4a70a5e0e82a758a17d27f700a21830e8
|
Subproject commit dfa356a6fe5d8fd215fae4e59d0b662938b17d7b
|
|
@ -17,38 +17,13 @@ Controller::Controller(const score::DocumentContext& document,
|
||||||
{
|
{
|
||||||
auto scnr = qobject_cast<Scenario::ProcessModel*>(&*interval.processes.begin());
|
auto scnr = qobject_cast<Scenario::ProcessModel*>(&*interval.processes.begin());
|
||||||
|
|
||||||
if (scnr) widgets.emplace_back(std::make_unique<ScenarioWidget>(this, scnr));
|
if (scnr)
|
||||||
|
bugui::container_widget::children.emplace_back(
|
||||||
|
std::make_unique<ScenarioWidget>(this, scnr));
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Controller::on_press(int x, int y, bool pressed)
|
|
||||||
{
|
|
||||||
for (auto& w : widgets)
|
|
||||||
if (w->on_press(x, y, pressed))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Controller::on_double_press(int x, int y)
|
|
||||||
{
|
|
||||||
for (auto& w : widgets)
|
|
||||||
if (w->on_double_press(x, y))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Controller::on_drag(int from_x, int from_y, int to_x, int to_y)
|
|
||||||
{
|
|
||||||
for (auto& w : widgets)
|
|
||||||
if (w->on_drag(from_x, from_y, to_x, to_y))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Controller::on_play(bool pressed)
|
void Controller::on_play(bool pressed)
|
||||||
{
|
{
|
||||||
if (m_shift)
|
if (m_shift)
|
||||||
|
|
|
@ -28,10 +28,6 @@ public:
|
||||||
void on_down(bool pressed);
|
void on_down(bool pressed);
|
||||||
void on_left(bool pressed);
|
void on_left(bool pressed);
|
||||||
void on_right(bool pressed);
|
void on_right(bool pressed);
|
||||||
|
|
||||||
bool on_press(int x, int y, bool pressed) override;
|
|
||||||
bool on_double_press(int x, int y) override;
|
|
||||||
bool on_drag(int from_x, int from_y, int to_x, int to_y) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Scenario::IntervalModel* interval;
|
Scenario::IntervalModel* interval;
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
IntervalWidget::IntervalWidget(base_widget* parent,
|
IntervalWidget::IntervalWidget(container_widget *parent,
|
||||||
Scenario::IntervalModel& interval)
|
Scenario::IntervalModel& interval)
|
||||||
: bugui::base_widget{parent}
|
: bugui::container_widget{parent}
|
||||||
, model{interval}
|
, model{interval}
|
||||||
, skin{Process::Style::instance()}
|
, skin{Process::Style::instance()}
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
#include <Scenario/Document/Interval/IntervalModel.hpp>
|
#include <Scenario/Document/Interval/IntervalModel.hpp>
|
||||||
#include <Process/Style/ScenarioStyle.hpp>
|
#include <Process/Style/ScenarioStyle.hpp>
|
||||||
#include <base_widget.hpp>
|
#include <widgets/container_widget.hpp>
|
||||||
|
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
struct IntervalWidget final : bugui::base_widget
|
struct IntervalWidget final : bugui::container_widget
|
||||||
{
|
{
|
||||||
explicit IntervalWidget(base_widget* parent,
|
explicit IntervalWidget(container_widget* parent,
|
||||||
Scenario::IntervalModel& interval);
|
Scenario::IntervalModel& interval);
|
||||||
|
|
||||||
void paint(bugui::painter& painter) const override;
|
void paint(bugui::painter& painter) const override;
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
ScenarioWidget::ScenarioWidget(base_widget* parent,
|
ScenarioWidget::ScenarioWidget(bugui::container_widget* parent,
|
||||||
Scenario::ProcessModel* scenario)
|
Scenario::ProcessModel* scenario)
|
||||||
: bugui::base_widget{parent}
|
: bugui::container_widget{parent}
|
||||||
, model{scenario}
|
, model{scenario}
|
||||||
{
|
{
|
||||||
model->intervals.mutable_added.connect<&ScenarioWidget::on_interval_added>(this);
|
model->intervals.mutable_added.connect<&ScenarioWidget::on_interval_added>(this);
|
||||||
|
@ -16,42 +16,7 @@ ScenarioWidget::ScenarioWidget(base_widget* parent,
|
||||||
[this] { update(); });
|
[this] { update(); });
|
||||||
|
|
||||||
for(Scenario::IntervalModel& s : model->intervals)
|
for(Scenario::IntervalModel& s : model->intervals)
|
||||||
widgets.emplace_back(std::make_unique<IntervalWidget>(this, s));
|
bugui::container_widget::children.emplace_back(std::make_unique<IntervalWidget>(this, s));
|
||||||
}
|
|
||||||
|
|
||||||
void ScenarioWidget::paint(bugui::painter& painter) const
|
|
||||||
{
|
|
||||||
for (const auto& w : widgets) w->paint(painter);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScenarioWidget::on_press(int x, int y, bool pressed)
|
|
||||||
{
|
|
||||||
if (!is_inside(x, y)) return false;
|
|
||||||
|
|
||||||
for (auto& w : widgets)
|
|
||||||
if (w->on_press(x, y, pressed)) return true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScenarioWidget::on_double_press(int x, int y)
|
|
||||||
{
|
|
||||||
if (!is_inside(x, y)) return false;
|
|
||||||
|
|
||||||
for (auto& w : widgets)
|
|
||||||
if (w->on_double_press(x, y)) return true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScenarioWidget::on_drag(int from_x, int from_y, int to_x, int to_y)
|
|
||||||
{
|
|
||||||
if (!is_inside(from_x, from_y)) return false;
|
|
||||||
|
|
||||||
for (auto& w : widgets)
|
|
||||||
if (w->on_drag(from_x, from_y, to_x, to_y)) return true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScenarioWidget::x() const
|
int ScenarioWidget::x() const
|
||||||
|
@ -76,15 +41,15 @@ int ScenarioWidget::height() const
|
||||||
|
|
||||||
void ScenarioWidget::on_interval_added(Scenario::IntervalModel& interval)
|
void ScenarioWidget::on_interval_added(Scenario::IntervalModel& interval)
|
||||||
{
|
{
|
||||||
widgets.emplace_back(std::make_unique<IntervalWidget>(this, interval));
|
bugui::container_widget::children.emplace_back(std::make_unique<IntervalWidget>(this, interval));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScenarioWidget::on_interval_removed(const Scenario::IntervalModel& interval)
|
void ScenarioWidget::on_interval_removed(const Scenario::IntervalModel& interval)
|
||||||
{
|
{
|
||||||
std::erase_if(widgets,
|
std::erase_if(bugui::container_widget::children,
|
||||||
[&interval]
|
[&interval]
|
||||||
(auto& w)
|
(const auto& w)
|
||||||
{
|
{
|
||||||
auto ntrvl = static_cast<IntervalWidget*>(w.get());
|
auto ntrvl = static_cast<IntervalWidget*>(w.get());
|
||||||
return ntrvl->get_model().id() == interval.id();
|
return ntrvl->get_model().id() == interval.id();
|
||||||
|
|
|
@ -3,25 +3,20 @@
|
||||||
#include <wobjectdefs.h>
|
#include <wobjectdefs.h>
|
||||||
|
|
||||||
#include <Scenario/Process/ScenarioModel.hpp>
|
#include <Scenario/Process/ScenarioModel.hpp>
|
||||||
#include <base_widget.hpp>
|
#include <widgets/container_widget.hpp>
|
||||||
|
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
class ScenarioWidget final
|
class ScenarioWidget final
|
||||||
: public bugui::base_widget
|
: public bugui::container_widget
|
||||||
, public QObject
|
, public QObject
|
||||||
{
|
{
|
||||||
W_OBJECT(ScenarioWidget)
|
W_OBJECT(ScenarioWidget)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScenarioWidget(bugui::base_widget* parent,
|
explicit ScenarioWidget(bugui::container_widget* parent,
|
||||||
Scenario::ProcessModel* scenario);
|
Scenario::ProcessModel* scenario);
|
||||||
|
|
||||||
void paint(bugui::painter& painter) const override;
|
|
||||||
bool on_press(int x, int y, bool pressed) override;
|
|
||||||
bool on_double_press(int x, int y) override;
|
|
||||||
bool on_drag(int from_x, int from_y, int to_x, int to_y) override;
|
|
||||||
|
|
||||||
int x() const override;
|
int x() const override;
|
||||||
int y() const override;
|
int y() const override;
|
||||||
int width() const override;
|
int width() const override;
|
||||||
|
@ -32,7 +27,6 @@ private:
|
||||||
void on_interval_removed(const Scenario::IntervalModel& interval);
|
void on_interval_removed(const Scenario::IntervalModel& interval);
|
||||||
void on_interval_changed(const Scenario::IntervalModel&);
|
void on_interval_changed(const Scenario::IntervalModel&);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<base_widget>> widgets;
|
|
||||||
Scenario::ProcessModel* model;
|
Scenario::ProcessModel* model;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue