diff --git a/3rd-party/arbor b/3rd-party/arbor index bf234aa..0ca5b20 160000 --- a/3rd-party/arbor +++ b/3rd-party/arbor @@ -1 +1 @@ -Subproject commit bf234aa82f497258d1f330ff9311d92463f1929a +Subproject commit 0ca5b20b7a525ea9cb902bdf1af9d85fdd578e33 diff --git a/CMakeLists.txt b/CMakeLists.txt index adcd2e3..dfe8396 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.27) find_package(Git) project(the-arbor-gui - VERSION 0.11.1 + VERSION 0.11.2 LANGUAGES C CXX) set(EXPORT_COMPILE_COMMANDS ON) @@ -186,22 +186,53 @@ if(ARBORGUI_BUILD_BUNDLE) set(ARBORGUI_ICON arbor.icns) set(ARBORGUI_ICON_PATH ${CMAKE_SOURCE_DIR}/images/${ARBORGUI_ICON}) - set_source_files_properties(${ARBORGUI_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) - add_executable(arbor-gui MACOSX_BUNDLE ${ARBORGUI_ICON_PATH} ${gui_srcs} $) - set_target_properties(arbor-gui PROPERTIES MACOSX_BUNDLE_ICONFILE ${ARBORGUI_ICON}) + set(arbgui_resources) + set_source_files_properties(${CMAKE_SOURCE_DIR}/imgui.ini + PROPERTIES + MACOSX_PACKAGE_LOCATION Resources) + list(APPEND arbgui_resources ${CMAKE_SOURCE_DIR}/imgui.ini) + + file(GLOB_RECURSE shaders ${CMAKE_SOURCE_DIR}/glsl/*/*.glsl) + foreach(SHADER_FILE ${shaders}) + list(APPEND arbgui_resources ${SHADER_FILE}) + file(RELATIVE_PATH SHADER_REL ${CMAKE_SOURCE_DIR}/glsl ${SHADER_FILE}) + get_filename_component(SHADER_DIR ${SHADER_REL} DIRECTORY) + set_source_files_properties(${SHADER_FILE} + PROPERTIES + MACOSX_PACKAGE_LOCATION Resources/glsl/${SHADER_DIR}) + endforeach() + + file(GLOB_RECURSE fonts ${CMAKE_SOURCE_DIR}/fonts/*/*.ttf) + foreach(FONT_FILE ${fonts}) + list(APPEND arbgui_resources ${FONT_FILE}) + file(RELATIVE_PATH FONT_REL ${CMAKE_SOURCE_DIR}/fonts ${FONT_FILE}) + get_filename_component(FONT_DIR ${FONT_REL} DIRECTORY) + set_source_files_properties(${FONT_FILE} + PROPERTIES + MACOSX_PACKAGE_LOCATION Resources/fonts/${FONT_DIR}) + endforeach() + + set_source_files_properties(${CMAKE_SOURCE_DIR}/images/arbor.icns + PROPERTIES + MACOSX_PACKAGE_LOCATION Resources) + + add_executable(arbor-gui MACOSX_BUNDLE ${gui_srcs} $ ${arbgui_resources} ${CMAKE_SOURCE_DIR}/images/arbor.icns) + set_target_properties(arbor-gui + PROPERTIES + BUNDLE True + MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME} + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_ICONFILE ${ARBORGUI_ICON} + MACOSX_BUNDLE_INFO_STRING "A GUI for Arbor" + RESOURCE ${arbgui_resources}) target_compile_definitions(arbor-gui PUBLIC FMT_HEADER_ONLY) target_include_directories(arbor-gui PRIVATE src ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(arbor-gui PRIVATE ${ARBORGUI_LIBS} arbor arborio glbinding glfw arbor-gui-deps) install(TARGETS arbor-gui - BUNDLE DESTINATION . COMPONENT Runtime - RUNTIME DESTINATION bin COMPONENT Runtime) - - install(FILES ${ARBORGUI_ICON_PATH} DESTINATION ${resource_path}) - install(FILES default.ini DESTINATION ${resource_path} RENAME imgui.ini) - install(DIRECTORY glsl DESTINATION ${resource_path}) - install(DIRECTORY fonts DESTINATION ${resource_path}) + BUNDLE DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION bin COMPONENT Runtime) set(CPACK_BINARY_DRAGNDROP ON) set(CPACK_GENERATOR "DragNDrop") @@ -237,7 +268,7 @@ else() endif() # install resources - install(DIRECTORY glsl DESTINATION ${resource_path}) - install(DIRECTORY fonts DESTINATION ${resource_path}) - install(FILES default.ini DESTINATION ${resource_path} RENAME imgui.ini) + install(DIRECTORY glsl DESTINATION ${resource_path}) + install(DIRECTORY fonts DESTINATION ${resource_path}) + install(FILES imgui.ini DESTINATION ${resource_path}) endif() diff --git a/README.md b/README.md index 33c23aa..857b42e 100644 --- a/README.md +++ b/README.md @@ -120,31 +120,16 @@ Next, follow the platform specific instructions. ``` bash sudo apt update sudo apt install build-essential libssl-dev \ - libxml2-dev libxrandr-dev libxinerama-dev \ + libxrandr-dev libxinerama-dev \ libxcursor-dev libxi-dev libglu1-mesa-dev \ - freeglut3-dev mesa-common-dev gcc-10 g++-10 + freeglut3-dev mesa-common-dev gcc g++ \ + libglfw3 cmake pkg-config xorg-dev libwayland-dev ``` - If your cmake version is less than 3.18, you will need to update it - as well - ``` bash - cmake --version - 3.16 # default on Ubunte 20.04 LTS - # if pip is present - pip install --update cmake - ``` -2. Add GCC10 as alternative to GCC and select it: - ``` bash - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 - ``` - Use `gcc --version` to confirm it is now version 10. If not you will - need to run `sudo update-alternatives --config gcc` (and its analog for - `g++`) and manually select the right number. - 3. Install Arbor GUI ```bash cmake .. - sudo make install -j 4 + make + sudo make install ``` ## Windows (WSL2) diff --git a/default.ini b/imgui.ini similarity index 100% rename from default.ini rename to imgui.ini diff --git a/src/gui_state.cpp b/src/gui_state.cpp index ac92881..9d85096 100644 --- a/src/gui_state.cpp +++ b/src/gui_state.cpp @@ -380,7 +380,7 @@ namespace { } inline void gui_cell_context_menu(gui_state& state) { - if (ImGui::BeginPopupContextWindow()) { + if (ImGui::BeginPopupContextWindow("cell-ctx-window", ImGuiPopupFlags_MouseButtonRight)) { ImGui::Text("%s Camera", icon_camera); { with_indent indent{}; @@ -469,7 +469,7 @@ namespace { vs.zoom = std::clamp(vs.zoom + delta_zoom, 1.0f, 45.0f); } } - + gui_cell_context_menu(state); // static float t_last = 0.0; float t_now = glfwGetTime(); diff --git a/src/main.cpp b/src/main.cpp index 78ff162..ba99540 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,11 @@ int main(int, char**) { Window window{}; gui_state state{}; + // show at least once. + window.begin_frame(); + state.gui(); + window.end_frame(); + for (;window.running() && !state.shutdown_requested;) { if (!window.visible()) { log_debug("Pausing for events."); diff --git a/src/utils.cpp b/src/utils.cpp index 8b6f3fc..1baeda3 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -21,7 +21,7 @@ std::filesystem::path get_resource_path(const std::filesystem::path& fn) { CFURLRef appUrlRef = CFBundleCopyBundleURL( CFBundleGetMainBundle() ); CFStringRef macPath = CFURLCopyFileSystemPath( appUrlRef, kCFURLPOSIXPathStyle ); CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); - const char* path = CFStringGetCStringPtr(macPath, encodingMethod); + auto path = std::string(CFStringGetCStringPtr(macPath, encodingMethod)); CFRelease(appUrlRef); CFRelease(macPath); return std::filesystem::path{path} / "Contents/Resources" / fn; @@ -29,7 +29,7 @@ std::filesystem::path get_resource_path(const std::filesystem::path& fn) { } void log_init() { - spdlog::set_level(spdlog::level::info); + spdlog::set_level(spdlog::level::debug); } diff --git a/src/window.cpp b/src/window.cpp index 0bc73a2..5b18258 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -41,6 +41,8 @@ Window::Window() { glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, 1); + glfwWindowHint(GLFW_FOCUSED, 1); + glfwWindowHint(GLFW_VISIBLE, 1); glsl_version = "#version 410"; handle = glfwCreateWindow(1280, 720, "arbor-gui", NULL, NULL); if (handle == nullptr) log_fatal("Failed to obtain window");