create NodeDialogOpen and bind it to the layout template
This commit is contained in:
@@ -1898,6 +1898,42 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class NodeDialogOpen : public NodeBorder
|
||||
{
|
||||
public:
|
||||
NodeButton* btn_cancel;
|
||||
NodeButton* btn_ok;
|
||||
std::string data_path;
|
||||
virtual Node* clone_instantiate() const override { return new NodeDialogOpen(); }
|
||||
virtual void clone_finalize(Node* dest) const override
|
||||
{
|
||||
NodeDialogOpen* n = static_cast<NodeDialogOpen*>(dest);
|
||||
n->init_controls();
|
||||
}
|
||||
virtual void init() override
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(init_template("dialog-open"));
|
||||
m_color = tpl->m_color;
|
||||
m_border_color = tpl->m_border_color;;
|
||||
m_thinkness = tpl->m_thinkness;;
|
||||
init_controls();
|
||||
}
|
||||
void init_controls()
|
||||
{
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_cancel = find<NodeButton>("btn-cancel");
|
||||
btn_cancel->on_click = [this](Node*) {
|
||||
destroy();
|
||||
};
|
||||
}
|
||||
virtual void loaded() override
|
||||
{
|
||||
ui::Image thumb = ui::Canvas::I->thumbnail_read(data_path);
|
||||
auto image_tex = find<NodeImageTexture>("thumb-tex");
|
||||
image_tex->tex.create(thumb);
|
||||
}
|
||||
};
|
||||
|
||||
class NodeCanvas : public Node
|
||||
{
|
||||
bool m_dragging = false;
|
||||
|
||||
Reference in New Issue
Block a user