add ComboBox node, add blend modes button in stroke panel, move brush shader code to ShaderManager and avoid the same shader being recompiled many times
This commit is contained in:
56
engine/node_combobox.cpp
Normal file
56
engine/node_combobox.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_combobox.h"
|
||||
#include "node_popup_menu.h"
|
||||
|
||||
Node* NodeComboBox::clone_instantiate() const
|
||||
{
|
||||
return new NodeComboBox;
|
||||
}
|
||||
|
||||
void NodeComboBox::loaded()
|
||||
{
|
||||
NodeButton::loaded();
|
||||
on_click = [this](Node* target) {
|
||||
LOG("ComboBox");
|
||||
NodePopupMenu* popup = new NodePopupMenu;
|
||||
popup->init();
|
||||
popup->create();
|
||||
popup->loaded();
|
||||
root()->add_child(popup);
|
||||
for (int i = 0; i < labels.size(); i++)
|
||||
{
|
||||
NodeButton* btn = new NodeButton;
|
||||
btn->init();
|
||||
btn->create();
|
||||
btn->loaded();
|
||||
popup->add_child(btn);
|
||||
btn->m_text->set_text(labels[i].c_str());
|
||||
btn->m_border->SetWidthP(100.f);
|
||||
btn->m_border->SetHeight(30.f);
|
||||
btn->on_click = [this,popup](Node* target) {
|
||||
int index = popup->get_child_index(target);
|
||||
m_current_index = index;
|
||||
m_text->set_text(labels[index].c_str());
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
}
|
||||
glm::vec2 pos = m_pos + glm::vec2(0, m_size.y - (m_current_index+1) * 30.f);
|
||||
popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
popup->SetPosition(pos.x, pos.y);
|
||||
popup->SetSize(m_size.x, YGUndefined);
|
||||
popup->SetFlexGrow(1.f);
|
||||
popup->update();
|
||||
root()->update();
|
||||
popup->mouse_capture();
|
||||
popup->m_mouse_ignore = false;
|
||||
popup->m_flood_events = true;
|
||||
popup->m_capture_children = false;
|
||||
};
|
||||
}
|
||||
void NodeComboBox::clone_copy(Node* dest) const
|
||||
{
|
||||
NodeButton::clone_copy(dest);
|
||||
NodeComboBox* n = static_cast<NodeComboBox*>(dest);
|
||||
}
|
||||
Reference in New Issue
Block a user