added color picking with ALT key, added crash report library for windows

This commit is contained in:
2017-05-29 08:47:04 +01:00
parent 6d14ccd426
commit 0f721393bb
19 changed files with 170 additions and 26 deletions

View File

@@ -5,6 +5,7 @@
#include "canvas.h"
#include "shader.h"
#include "node_canvas.h"
#include "app.h"
NodeCanvas* CanvasMode::node;
ui::Canvas* CanvasMode::canvas;
@@ -71,23 +72,65 @@ void CanvasModePen::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
switch (me->m_type)
{
case kEventType::MouseDownL:
canvas->stroke_start(loc, me->m_pressure, node->m_brush);
m_dragging = true;
if (App::I.keys[(int)kKey::KeyAlt])
{
m_picking = true;
}
else
{
canvas->stroke_start(loc, me->m_pressure, node->m_brush);
m_dragging = true;
}
node->mouse_capture();
break;
case kEventType::MouseUpL:
canvas->stroke_end();
m_dragging = false;
node->mouse_release();
if (m_dragging)
{
canvas->stroke_end();
m_dragging = false;
node->mouse_release();
}
if (m_picking)
{
m_picking = false;
node->mouse_release();
int x = me->m_pos.x;
int y = App::I.height - me->m_pos.y - 1;
float pix[3];
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glReadPixels(x, y, 1, 1, GL_RGB, GL_FLOAT, pix);
auto hsv = convert_rgb2hsv(glm::vec3(pix[0], pix[1], pix[2]));
App::I.color->m_hue->set_value(hsv.x);
App::I.color->m_quad->set_value(1.f - hsv.y, 1.f - hsv.z);
}
break;
case kEventType::MouseMove:
if (m_dragging)
canvas->stroke_update(loc, me->m_pressure);
if (m_picking)
{
int x = me->m_pos.x;
int y = App::I.height - me->m_pos.y - 1;
float pix[3];
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glReadPixels(x, y, 1, 1, GL_RGB, GL_FLOAT, pix);
auto hsv = convert_rgb2hsv(glm::vec3(pix[0], pix[1], pix[2]));
App::I.color->m_hue->set_value(hsv.x);
App::I.color->m_quad->set_value(1.f - hsv.y, 1.f - hsv.z);
}
break;
case kEventType::MouseCancel:
canvas->stroke_cancel();
m_dragging = false;
node->mouse_release();
if (m_dragging)
{
canvas->stroke_cancel();
m_dragging = false;
node->mouse_release();
}
if (m_picking)
{
m_picking = false;
node->mouse_release();
}
break;
default:
break;