feat(tab menu): read opDefTable, fix focus bug

This commit is contained in:
parker
2025-07-16 18:59:40 +01:00
parent a56d379442
commit 6c67d5cb36
5 changed files with 16 additions and 3 deletions

View File

@@ -21,4 +21,10 @@ enzo::nt::opConstructor enzo::op::OperatorTable::getOpConstructor(std::string na
return nullptr; return nullptr;
} }
std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::getData()
{
return opInfoStore_;
}
std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::opInfoStore_; std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::opInfoStore_;

View File

@@ -19,6 +19,7 @@ class BOOST_SYMBOL_EXPORT OperatorTable
public: public:
static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc); static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc);
static nt::opConstructor getOpConstructor(std::string name); static nt::opConstructor getOpConstructor(std::string name);
static std::vector<OpInfo> getData();
private: private:
static std::vector<OpInfo> opInfoStore_; static std::vector<OpInfo> opInfoStore_;
}; };

View File

@@ -410,3 +410,4 @@ void Network::mouseReleaseEvent(QMouseEvent *event)
} }
} }
} }

View File

@@ -151,6 +151,7 @@ private:
return closestItem; return closestItem;
} }
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override;

View File

@@ -1,4 +1,5 @@
#include "Gui/Network/TabMenu.h" #include "Gui/Network/TabMenu.h"
#include "Engine/Operator/OperatorTable.h"
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <iostream> #include <iostream>
@@ -24,6 +25,7 @@ enzo::ui::TabMenu::TabMenu(QWidget *parent, Qt::WindowFlags f)
setLayout(mainLayout_); setLayout(mainLayout_);
searchBar_ = new QLineEdit(); searchBar_ = new QLineEdit();
searchBar_->setFocusPolicy(Qt::NoFocus);
nodeHolder_ = new QWidget(); nodeHolder_ = new QWidget();
nodeScrollArea_ = new QScrollArea(); nodeScrollArea_ = new QScrollArea();
@@ -35,9 +37,12 @@ enzo::ui::TabMenu::TabMenu(QWidget *parent, Qt::WindowFlags f)
nodeHolderLayout_ = new QVBoxLayout(); nodeHolderLayout_ = new QVBoxLayout();
nodeHolder_->setLayout(nodeHolderLayout_); nodeHolder_->setLayout(nodeHolderLayout_);
for(int i=0; i<10; ++i) auto tableItems = enzo::op::OperatorTable::getData();
nodeScrollArea_->setFocusPolicy(Qt::NoFocus);
for(auto tableItem : tableItems)
{ {
auto button = new QPushButton(std::string("Node " + std::to_string(i)).c_str()); auto button = new QPushButton(tableItem.displayName.c_str());
button->setFocusPolicy(Qt::NoFocus);
button->setStyleSheet(R"( button->setStyleSheet(R"(
QPushButton { QPushButton {
background-color: #181c1d; background-color: #181c1d;
@@ -85,7 +90,6 @@ void enzo::ui::TabMenu::focusOutEvent(QFocusEvent *event)
bool enzo::ui::TabMenu::event(QEvent *event) bool enzo::ui::TabMenu::event(QEvent *event)
{ {
std::cout << "event\n";
if( if(
(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
&& event->spontaneous() && event->spontaneous()