fix color picker panel, introduce an added() method when a node is added to che scene

This commit is contained in:
2017-12-23 10:56:38 +00:00
parent b389d895ab
commit 0a3363fb13
6 changed files with 30 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
#include "pch.h"
#include "log.h"
#include "node_panel_color.h"
#include "canvas.h"
Node* NodePanelColor::clone_instantiate() const
{
@@ -27,6 +28,7 @@ void NodePanelColor::init_controls()
m_base_color = m_quad->m_color = hue_color;
float hue = convert_rgb2hsv(m_base_color).x;
m_color = glm::vec4(convert_hsv2rgb(glm::vec3(hue, m_cursor.x, 1.f-m_cursor.y)), 1.f);
m_quad->m_color = hue_color;
if (on_color_changed)
on_color_changed(this, m_color);
};
@@ -40,3 +42,17 @@ void NodePanelColor::init_controls()
};
m_hue->set_value(0);
}
void NodePanelColor::set_color(glm::vec3 rgb)
{
auto hsv = convert_rgb2hsv(rgb);
m_hue->m_value.y = hsv.x;
m_quad->m_value = glm::vec2(hsv.y, 1.f - hsv.z);
m_quad->m_color = glm::vec4(rgb, 1);
m_cursor = m_quad->m_value;
}
void NodePanelColor::added(Node* parent)
{
set_color(ui::Canvas::I->m_current_brush.m_tip_color);
}