1339{
1340 static ImVec2 size(0.0f, 0.0f);
1341
1342 auto validate_position = [](
const Vec2d& position,
const GLCanvas3D& canvas,
const ImVec2& wnd_size) {
1343 const Size cnv_size = canvas.get_canvas_size();
1344 const float x = std::clamp((float)position.x(), 0.0f, (float)cnv_size.get_width() - wnd_size.x);
1345 const float y = std::clamp((float)position.y() + 16.0f, 0.0f, (float)cnv_size.get_height() - wnd_size.y);
1347 };
1348
1351 return;
1352 }
1353
1354
1355
1356 const float alpha = (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() -
m_start_time).count() < 500) ? 0.01f : 1.0f;
1357
1358 const Vec2f position = validate_position(mouse_position, canvas, size);
1359
1360 ImGuiWrapper& imgui = *wxGetApp().imgui();
1361 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
1362 ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
1363 imgui.set_next_window_pos(position.x(), position.y(), ImGuiCond_Always, 0.0f, 0.0f);
1364
1365 imgui.begin(wxString("canvas_tooltip"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoFocusOnAppearing);
1366 ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow());
1367 ImGui::TextUnformatted(
m_text.c_str());
1368
1369
1370#if ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
1371 if (alpha < 1.0f || ImGui::GetWindowContentRegionWidth() + 2.0f * ImGui::GetStyle().WindowPadding.x != ImGui::CalcWindowNextAutoFitSize(ImGui::GetCurrentWindow()).x)
1372 imgui.set_requires_extra_frame();
1373#else
1374 if (alpha < 1.0f || ImGui::GetWindowContentRegionWidth() + 2.0f * ImGui::GetStyle().WindowPadding.x != ImGui::CalcWindowNextAutoFitSize(ImGui::GetCurrentWindow()).x)
1375 canvas.request_extra_frame();
1376#endif
1377
1378 size = ImGui::GetWindowSize();
1379
1380 imgui.end();
1381 ImGui::PopStyleVar(2);
1382}
GLCanvas3D(wxGLCanvas *canvas, Bed3D &bed)
Definition GLCanvas3D.cpp:1594
Eigen::Matrix< float, 2, 1, Eigen::DontAlign > Vec2f
Definition Point.hpp:64
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67