fix color picker panel, introduce an added() method when a node is added to che scene
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user