update windows project to add poly2tri

This commit is contained in:
2017-10-09 09:40:40 +01:00
parent 78ec5a079e
commit 163937b4a6
8 changed files with 88 additions and 36 deletions

View File

@@ -140,7 +140,7 @@ bool App::key_down(kKey key)
e.m_type = kEventType::KeyDown;
e.m_key = key;
auto ret = layout[main_id]->on_event(&e);
layout[main_id]->update();
//layout[main_id]->update();
return ret == kEventResult::Consumed;
}
bool App::key_up(kKey key)

View File

@@ -248,7 +248,7 @@ void App::init_toolbar_draw()
layout[main_id]->find<NodeButton>("btn-line")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-cam")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-grid")->set_color(color_button_normal);
//layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
Canvas::set_mode(Canvas::kCanvasMode::Draw);
};
layout[main_id]->find<NodeButton>("btn-pen")->set_color(color_button_hlight);
@@ -278,7 +278,7 @@ void App::init_toolbar_draw()
layout[main_id]->find<NodeButton>("btn-line")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-cam")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-grid")->set_color(color_button_normal);
//layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
Canvas::set_mode(Canvas::kCanvasMode::Erase);
};
}
@@ -290,7 +290,7 @@ void App::init_toolbar_draw()
layout[main_id]->find<NodeButton>("btn-line")->set_color(color_button_hlight);
layout[main_id]->find<NodeButton>("btn-cam")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-grid")->set_color(color_button_normal);
//layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
Canvas::set_mode(Canvas::kCanvasMode::Line);
};
}
@@ -302,7 +302,7 @@ void App::init_toolbar_draw()
layout[main_id]->find<NodeButton>("btn-line")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-cam")->set_color(color_button_hlight);
layout[main_id]->find<NodeButton>("btn-grid")->set_color(color_button_normal);
//layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
Canvas::set_mode(Canvas::kCanvasMode::Camera);
};
}
@@ -314,7 +314,7 @@ void App::init_toolbar_draw()
layout[main_id]->find<NodeButton>("btn-line")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-cam")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-grid")->set_color(color_button_hlight);
//layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_normal);
Canvas::set_mode(Canvas::kCanvasMode::Grid);
};
}
@@ -326,7 +326,7 @@ void App::init_toolbar_draw()
layout[main_id]->find<NodeButton>("btn-line")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-cam")->set_color(color_button_normal);
layout[main_id]->find<NodeButton>("btn-grid")->set_color(color_button_normal);
//layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_hlight);
layout[main_id]->find<NodeButton>("btn-fill")->set_color(color_button_hlight);
Canvas::set_mode(Canvas::kCanvasMode::Fill);
};
}

View File

@@ -572,7 +572,7 @@ void CanvasModeFill::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, cons
{
ui::ShaderManager::use(ui::kShader::Color);
ui::ShaderManager::u_mat4(ui::kShaderUniform::MVP, glm::scale(glm::vec3(1,-1,1)) * ortho);
ui::ShaderManager::u_vec4(ui::kShaderUniform::Col, { node->m_brush.m_tip_color.rgb(), node->m_brush.m_tip_opacity });
ui::ShaderManager::u_vec4(ui::kShaderUniform::Col, { 0, 0, 0, 1 });
m_dragging ? m_shape.draw_stroke() : m_shape.draw_fill();
}
}

View File

@@ -288,7 +288,7 @@ int main(int argc, char** argv)
while (running)
{
// If there any message in the queue process it
if (!App::I.redraw && PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
running = !(msg.message == WM_QUIT/* || gl.keys[VK_ESCAPE]*/);
DispatchMessage(&msg);
@@ -308,10 +308,10 @@ int main(int argc, char** argv)
SwapBuffers(hDC);
}
}
else
{
Sleep((DWORD)(1.0f / 60.0f * 1000.f));
}
// else
// {
// Sleep((DWORD)(1.0f / 60.0f * 1000.f));
// }
}
}
@@ -368,11 +368,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
App::I.key_up(convert_key((int)wp));
break;
case WM_CHAR:
App::I.key_char((int)wp);
//App::I.key_char((int)wp);
break;
case WM_MOUSEMOVE:
//TODO: find a way to check if event is mouse/stylus. For now use Mouse for all
if (leftDown)
if (0 && leftDown)
{
POINT pt = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) };
// See discussion for why this code is wrong
@@ -382,6 +382,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
int cmmpt = GetMouseMovePointsEx(sizeof(mmpt), &mmpt,
rgmmpt, 64, GMMP_USE_DISPLAY_POINTS);
if (cmmpt == -1 || cmmpt == 64)
{
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), WacomTablet::I.get_pressure(), kEventSource::Mouse);
lastPoint = pt;
lastTime = GetMessageTime();
break;
}
POINT ptLastScreen = lastPoint;
ClientToScreen(hWnd, &ptLastScreen);
int i;
@@ -389,6 +397,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
if (rgmmpt[i].x > 32767) rgmmpt[i].x -= 65536;
if (rgmmpt[i].y > 32767) rgmmpt[i].y -= 65536;
LOG("x %4d y %4d", rgmmpt[i].x, rgmmpt[i].y);
if (rgmmpt[i].time < lastTime) break;
if (rgmmpt[i].time == lastTime &&

View File

@@ -50,31 +50,36 @@ kEventResult Node::on_event(Event* e)
{
kEventResult ret = kEventResult::Available;
if (current_mouse_capture)
return current_mouse_capture->on_event(e);
bool skip_children = false;
skip_children |= (e->m_cat == kEventCategory::MouseEvent || e->m_cat == kEventCategory::GestureEvent) &&
(m_mouse_captured) && (root()->current_mouse_capture == this) && m_capture_children;
if (!skip_children)
if (e->m_cat == kEventCategory::MouseEvent)
{
for (auto it = m_children.rbegin(); it != m_children.rend(); ++it)
{
if ((*it)->on_event(e) == kEventResult::Consumed)
if (current_mouse_capture)
return current_mouse_capture->on_event(e);
bool skip_children = false;
skip_children |= (e->m_cat == kEventCategory::MouseEvent || e->m_cat == kEventCategory::GestureEvent) &&
(m_mouse_captured) && (root()->current_mouse_capture == this) && m_capture_children;
if (!skip_children)
{
if (m_flood_events)
for (auto it = m_children.rbegin(); it != m_children.rend(); ++it)
{
ret = kEventResult::Consumed;
}
else
{
return kEventResult::Consumed;
if ((*it)->on_event(e) == kEventResult::Consumed)
{
if (m_flood_events)
{
ret = kEventResult::Consumed;
}
else
{
return kEventResult::Consumed;
}
}
}
if (ret == kEventResult::Consumed)
return ret;
}
}
if (ret == kEventResult::Consumed)
return ret;
}
switch (e->m_cat)