From 2a6741975c04e2d5fcf31c16f6cd1ffb31473eea Mon Sep 17 00:00:00 2001 From: Ernesto Rodriguez Date: Thu, 19 Dec 2024 21:08:58 +0000 Subject: [PATCH] replace deprecated imgui functions and add DESKTOP_INSTALL_DIR cache variable for apps (#6854) * Allow compiling open3d-cpu python package on NixOs 24.05 * Remove the use of deprecated functions in ImGui * CMake option to exclude uvatlas as dependency as a single function leads to the inclusion of many libraries. * CMake option to override the desktop install path * Set the frame size as initial item heights in the ListView. * Allow compiling open3d-cpu python package on NixOs 24.05 * Remove the use of deprecated functions in ImGui * CMake option to exclude uvatlas as dependency as a single function leads to the inclusion of many libraries. * CMake option to override the desktop install path * Set the frame size as initial item heights in the ListView. * Fix style errors and disable the 'uvatlas' tests when the feature is not enabled. * make DESKTOP_INSTALL_DIR a CACHE variable to allow setting it on the cmdline * keep compute_uvatlas in the core feature set * add missing docstring --------- Co-authored-by: Ernesto Rodriguez Co-authored-by: Sameer Sheorey Co-authored-by: Benjamin Ummenhofer --- cpp/apps/CMakeLists.txt | 4 ++-- cpp/open3d/visualization/gui/ListView.cpp | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cpp/apps/CMakeLists.txt b/cpp/apps/CMakeLists.txt index 9a3cdea35bb..1d12f58cc24 100644 --- a/cpp/apps/CMakeLists.txt +++ b/cpp/apps/CMakeLists.txt @@ -55,9 +55,9 @@ macro(open3d_add_app_gui SRC_DIR APP_NAME TARGET_NAME) DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" USE_SOURCE_PERMISSIONS) if (CMAKE_INSTALL_PREFIX MATCHES "^(/usr/local|/opt)") - set(DESKTOP_INSTALL_DIR "/usr/share") + set(DESKTOP_INSTALL_DIR "/usr/share" CACHE PATH "The install directory for the desktop apps") else() - set(DESKTOP_INSTALL_DIR "$ENV{HOME}/.local/share") + set(DESKTOP_INSTALL_DIR "$ENV{HOME}/.local/share" CACHE PATH "The install directory for the desktop apps") endif() configure_file("${SOURCE_DIR}/${TARGET_NAME}.desktop.in" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${APP_NAME}.desktop") diff --git a/cpp/open3d/visualization/gui/ListView.cpp b/cpp/open3d/visualization/gui/ListView.cpp index 184234dd974..3234f5187f6 100644 --- a/cpp/open3d/visualization/gui/ListView.cpp +++ b/cpp/open3d/visualization/gui/ListView.cpp @@ -116,15 +116,12 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { ImGui::PushStyleColor(ImGuiCol_HeaderActive, // click-hold color colorToImgui(context.theme.list_selected_color)); - int height_in_items = - int(std::floor(frame.height / ImGui::GetFrameHeight())); - auto result = Widget::DrawResult::NONE; auto new_selected_idx = impl_->selected_index_; bool is_double_click = false; DrawImGuiPushEnabledState(); - if (ImGui::ListBoxHeader(impl_->imgui_id_.c_str(), - int(impl_->items_.size()), height_in_items)) { + ImVec2 initial_size(0, frame.height); + if (ImGui::BeginListBox(impl_->imgui_id_.c_str(), initial_size)) { for (size_t i = 0; i < impl_->items_.size(); ++i) { bool is_selected = (int(i) == impl_->selected_index_); // ImGUI's list wants to hover over items, which is not done by @@ -155,7 +152,7 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { } ImGui::PopStyleColor(); } - ImGui::ListBoxFooter(); + ImGui::EndListBox(); if (new_selected_idx != impl_->selected_index_ || is_double_click) { impl_->selected_index_ = new_selected_idx;