refactor layout.h into single file per Node* classes
This commit is contained in:
42
engine/node_panel_color.cpp
Normal file
42
engine/node_panel_color.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_panel_color.h"
|
||||
|
||||
Node* NodePanelColor::clone_instantiate() const
|
||||
{
|
||||
return new NodePanelColor();
|
||||
}
|
||||
|
||||
void NodePanelColor::clone_finalize(Node* dest) const
|
||||
{
|
||||
NodePanelColor* n = static_cast<NodePanelColor*>(dest);
|
||||
n->init_controls();
|
||||
}
|
||||
|
||||
void NodePanelColor::init()
|
||||
{
|
||||
init_template("tpl-panel-color");
|
||||
init_controls();
|
||||
}
|
||||
|
||||
void NodePanelColor::init_controls()
|
||||
{
|
||||
m_quad = find<NodeColorQuad>("quad");
|
||||
m_hue = find<NodeSliderHue>("hue");
|
||||
m_hue->on_hue_changed = [this](Node*, glm::vec4 hue_color) {
|
||||
m_base_color = m_quad->m_color = hue_color;
|
||||
auto x = glm::mix(m_base_color, glm::vec4(1, 1, 1, 1), m_cursor.x);
|
||||
m_color = glm::mix(x, glm::vec4(0, 0, 0, 1), m_cursor.y);
|
||||
if (on_color_changed)
|
||||
on_color_changed(this, m_color);
|
||||
};
|
||||
m_quad->on_value_changed = [this](Node*, glm::vec2 pos)
|
||||
{
|
||||
auto x = glm::mix(m_base_color, glm::vec4(1, 1, 1, 1), pos.x);
|
||||
m_color = glm::mix(x, glm::vec4(0, 0, 0, 1), pos.y);
|
||||
m_cursor = pos;
|
||||
if (on_color_changed)
|
||||
on_color_changed(this, m_color);
|
||||
};
|
||||
m_hue->set_value(0);
|
||||
}
|
||||
Reference in New Issue
Block a user