implementing color wheel and new color picker
This commit is contained in:
@@ -27,7 +27,7 @@ void NodeColorQuad::init()
|
||||
|
||||
void NodeColorQuad::set_value(float x, float y)
|
||||
{
|
||||
auto sz = GetSize();
|
||||
auto sz = m_size;
|
||||
auto pos = glm::clamp(glm::vec2(x, y) * sz, { 0, 0 }, sz);
|
||||
m_picker->SetPosition(pos - m_picker->GetSize() * .5f);
|
||||
m_value = pos / glm::max({ 1,1 }, sz); // avoid div0
|
||||
@@ -45,7 +45,7 @@ kEventResult NodeColorQuad::handle_event(Event* e)
|
||||
m_old_value = m_value;
|
||||
dragging = true;
|
||||
mouse_capture();
|
||||
auto sz = GetSize();
|
||||
auto sz = m_size;
|
||||
auto pos = glm::clamp(((MouseEvent*)e)->m_pos - m_pos, { 0, 0 }, sz);
|
||||
m_picker->SetPosition(pos - m_picker->GetSize() * .5f);
|
||||
m_value = pos / glm::max({ 1,1 }, sz); // avoid div0
|
||||
@@ -60,7 +60,7 @@ kEventResult NodeColorQuad::handle_event(Event* e)
|
||||
case kEventType::MouseMove:
|
||||
if (dragging)
|
||||
{
|
||||
auto sz = GetSize();
|
||||
auto sz = m_size;
|
||||
auto pos = glm::clamp(((MouseEvent*)e)->m_pos - m_pos, { 0, 0 }, sz);
|
||||
m_picker->SetPosition(pos - m_picker->GetSize() * .5f);
|
||||
m_value = pos / glm::max({ 1,1 }, sz); // avoid div0
|
||||
|
||||
Reference in New Issue
Block a user