构建框架
This commit is contained in:
parent
c18aad62b3
commit
03958c106f
|
@ -23,7 +23,7 @@ QRectF NodePresent::boundingRect() const
|
|||
void NodePresent::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
painter->drawRect(boundingRect());
|
||||
painter->fillRect(option->rect - QMargins(8,8,8,8), Qt::gray);
|
||||
painter->fillRect(option->rect - QMargins(8, 8, 8, 8), Qt::gray);
|
||||
|
||||
painter->translate(QPointF(15, 15));
|
||||
auto rect = contentMeasure();
|
||||
|
@ -66,10 +66,10 @@ void BehaviorsPresent::presentAllocate(std::shared_ptr<LogicalNode> ins)
|
|||
if (_present_peers.contains(ins))
|
||||
return;
|
||||
|
||||
for(auto idx=_column_aligns.size(); idx < ins->depth() + 1; ++idx)
|
||||
for (auto idx = _column_aligns.size(); idx < ins->depth() + 1; ++idx)
|
||||
_column_aligns.append(0);
|
||||
|
||||
auto ¤t_width = _column_aligns[ins->depth()];
|
||||
auto& current_width = _column_aligns[ins->depth()];
|
||||
_present_peers[ins] = new NodePresent(this, current_width, ins);
|
||||
this->_bind_scene.addItem(_present_peers[ins]);
|
||||
break;
|
||||
|
@ -178,3 +178,23 @@ uint qHash(const std::shared_ptr<LogicalNode> data, uint seed) noexcept
|
|||
{
|
||||
return qHash((void*)data.get(), seed);
|
||||
}
|
||||
|
||||
#include <QSplitter>
|
||||
BehaviorEditor::BehaviorEditor(QWidget* parent /*= nullptr*/)
|
||||
: QMainWindow(parent),
|
||||
_type_view(new QListView(this)),
|
||||
_type_model(new QStandardItemModel(this)),
|
||||
_logical_present(new BehaviorsPresent(this)),
|
||||
_logs_present(new QTextBrowser(this))
|
||||
{
|
||||
auto split_h = new QSplitter(Qt::Horizontal, this);
|
||||
this->setCentralWidget(split_h);
|
||||
|
||||
split_h->addWidget(_type_view);
|
||||
_type_view->setModel(_type_model);
|
||||
auto split_v = new QSplitter(Qt::Vertical, this);
|
||||
split_h->addWidget(split_v);
|
||||
|
||||
split_v->addWidget(_logical_present);
|
||||
split_v->addWidget(_logs_present);
|
||||
}
|
||||
|
|
|
@ -86,3 +86,17 @@ public:
|
|||
std::shared_ptr<LogicalNode> ins, const QPointF &origin_offset);
|
||||
};
|
||||
|
||||
|
||||
#include <QListView>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTextBrowser>
|
||||
class BehaviorEditor : public QMainWindow {
|
||||
private:
|
||||
QListView *const _type_view;
|
||||
QStandardItemModel *const _type_model;
|
||||
BehaviorsPresent *const _logical_present;
|
||||
QTextBrowser *const _logs_present;
|
||||
|
||||
public:
|
||||
BehaviorEditor(QWidget *parent = nullptr);
|
||||
};
|
|
@ -7,42 +7,9 @@
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
BehaviorsPresent w;
|
||||
|
||||
BehaviorEditor w;
|
||||
w.show();
|
||||
|
||||
auto loader = std::make_shared<MessageLoader>();
|
||||
auto kernal = std::make_shared<MapKernal>(loader);
|
||||
|
||||
auto root = std::make_shared<BehaviorMapNode>(kernal);
|
||||
root->setID(0);
|
||||
|
||||
auto seqs = std::make_shared<SequenceNode>();
|
||||
seqs->setID(10);
|
||||
root->insert(seqs);
|
||||
|
||||
auto seqsx = std::make_shared<SequenceNode>();
|
||||
seqsx->setID(100);
|
||||
seqs->insert(seqsx);
|
||||
|
||||
auto selex = std::make_shared<SelectorNode>();
|
||||
selex->setID(101);
|
||||
seqs->insert(selex);
|
||||
|
||||
auto parallel = std::make_shared<ParallelNode>();
|
||||
parallel->setID(1000);
|
||||
selex->insert(parallel);
|
||||
parallel = std::make_shared<ParallelNode>();
|
||||
parallel->setID(1001);
|
||||
selex->insert(parallel);
|
||||
|
||||
auto item = std::make_shared<CompareNode>();
|
||||
item->setID(10000);
|
||||
parallel->insert(item);
|
||||
item = std::make_shared<CompareNode>();
|
||||
item->setID(100010000);
|
||||
parallel->insert(item);
|
||||
|
||||
w.setRoot(root);
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue