mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Demo: Custom Rendering: Tweak so end of line can be dropped outside of canvas, more pleasing.
This commit is contained in:
parent
907dd2ed20
commit
357167f917
@ -2041,21 +2041,21 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
|
|
||||||
bool adding_preview = false;
|
bool adding_preview = false;
|
||||||
ImGui::InvisibleButton("canvas", canvas_size);
|
ImGui::InvisibleButton("canvas", canvas_size);
|
||||||
|
ImVec2 mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y);
|
||||||
|
if (adding_line)
|
||||||
|
{
|
||||||
|
adding_preview = true;
|
||||||
|
points.push_back(mouse_pos_in_canvas);
|
||||||
|
if (!ImGui::GetIO().MouseDown[0])
|
||||||
|
adding_line = adding_preview = false;
|
||||||
|
}
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
{
|
{
|
||||||
ImVec2 mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y);
|
|
||||||
if (!adding_line && ImGui::IsMouseClicked(0))
|
if (!adding_line && ImGui::IsMouseClicked(0))
|
||||||
{
|
{
|
||||||
points.push_back(mouse_pos_in_canvas);
|
points.push_back(mouse_pos_in_canvas);
|
||||||
adding_line = true;
|
adding_line = true;
|
||||||
}
|
}
|
||||||
if (adding_line)
|
|
||||||
{
|
|
||||||
adding_preview = true;
|
|
||||||
points.push_back(mouse_pos_in_canvas);
|
|
||||||
if (!ImGui::GetIO().MouseDown[0])
|
|
||||||
adding_line = adding_preview = false;
|
|
||||||
}
|
|
||||||
if (ImGui::IsMouseClicked(1) && !points.empty())
|
if (ImGui::IsMouseClicked(1) && !points.empty())
|
||||||
{
|
{
|
||||||
adding_line = adding_preview = false;
|
adding_line = adding_preview = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user