implementing color wheel and new color picker

This commit is contained in:
2017-11-23 20:26:57 +00:00
parent d44434a458
commit a90aa4a60e
23 changed files with 371 additions and 26 deletions

View File

@@ -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