diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0d5bf1..3c838c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,13 +15,13 @@ jobs: strategy: matrix: config: - - { + - { name: "Ubuntu GCC", os: "ubuntu-24.04", cc: "gcc-14", cxx: "g++-14" } - - { + - { name: "Ubuntu Clang", os: "ubuntu-24.04", cc: "clang-18", @@ -35,10 +35,14 @@ jobs: bld_dir: build_dir steps: - name: "Clone w/ submodules" - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 submodules: "recursive" + - name: Set up cmake + uses: jwlawson/actions-setup-cmake@v2.2 + with: + cmake-version: 4.0.x - name: Update apt run: sudo apt update - name: Install missing packages @@ -66,7 +70,7 @@ jobs: - name: Delete Linuxdeploy if: ${{ startsWith(matrix.config.cc, 'gcc') }} run: rm -f ./linuxdeploy-x86_64.AppImage - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 if: ${{ startsWith(matrix.config.cc, 'gcc') }} with: name: linux appimage @@ -94,10 +98,14 @@ jobs: CXX: ${{ matrix.config.cxx }} steps: - name: "Clone w/ submodules" - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 submodules: "recursive" + - name: Set up cmake + uses: jwlawson/actions-setup-cmake@v2.2 + with: + cmake-version: 4.0.x - name: Check config run: | $CC --version @@ -106,7 +114,7 @@ jobs: run: cmake -S . -B build -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_COMPILER=$CC -DARBORGUI_BUILD_BUNDLE=ON - name: Build run: cmake --build build -j 2 --target package - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 with: name: arbor-gui-${{ matrix.config.os }} path: build/*.dmg diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d925a32..a504581 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,9 +14,9 @@ jobs: config: - { name: "Ubuntu", - os: "ubuntu-22.04", - cc: "gcc-12", - cxx: "g++-12" + os: "ubuntu-24.04", + cc: "gcc-14", + cxx: "g++-14" } fail-fast: false env: @@ -26,7 +26,7 @@ jobs: bld_dir: build_dir steps: - name: "Clone w/ submodules" - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 submodules: "recursive" @@ -64,7 +64,7 @@ jobs: config: - { name: "MacOS", - os: "macos-12", + os: "macos-4", cc: "clang", cxx: "clang++" } @@ -73,7 +73,7 @@ jobs: CXX: ${{ matrix.config.cxx }} steps: - name: "Clone w/ submodules" - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 submodules: "recursive" @@ -103,7 +103,7 @@ jobs: - name: Move and rename dmg run: mv */*.dmg arbor-gui.dmg - name: "Clone w/ submodules" - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 submodules: "recursive" diff --git a/3rd-party/arbor b/3rd-party/arbor index bf234aa..16fd7dc 160000 --- a/3rd-party/arbor +++ b/3rd-party/arbor @@ -1 +1 @@ -Subproject commit bf234aa82f497258d1f330ff9311d92463f1929a +Subproject commit 16fd7dc024ee378ad8691492c2a84dbaa9cb2883 diff --git a/CMakeLists.txt b/CMakeLists.txt index adcd2e3..bed073f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 3.27) +cmake_minimum_required(VERSION 4.0.0) 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") @@ -221,8 +252,7 @@ else() # Set icon on output if (APPLE) add_custom_command(TARGET arbor-gui POST_BUILD - COMMAND sh ${CMAKE_SOURCE_DIR}/scripts/set-osx-icon.sh ${CMAKE_SOURCE_DIR}/images/arbor.png ${CMAKE_CURRENT_BINARY_DIR}/arbor-gui - DEPENDS ${CMAKE_SOURCE_DIR}/scripts/set-osx-icon.sh ${CMAKE_SOURCE_DIR}/images/arbor.png) + COMMAND sh ${CMAKE_SOURCE_DIR}/scripts/set-osx-icon.sh ${CMAKE_SOURCE_DIR}/images/arbor.png ${CMAKE_CURRENT_BINARY_DIR}/arbor-gui) endif() if (CMAKE_SYSTEM MATCHES "Linux") install(FILES ${CMAKE_SOURCE_DIR}/images/arbor.png DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/icons/hicolor/256x256/apps/) @@ -237,7 +267,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..dae74ce 100644 --- a/src/gui_state.cpp +++ b/src/gui_state.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -380,7 +381,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 +470,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(); @@ -1078,7 +1079,8 @@ void gui_state::deserialize(const std::filesystem::path& fn) { auto cat = split_off(raw, "::"); if (raw.empty()) log_error("Need 'catalogue::name', got 'name'."); auto name = split_off(raw, "/"); - auto values = t.values(); + auto values = std::unordered_map{}; + for (const auto& [k, v]: t.values()) values[k] = v; for (;raw.size();) { auto val = split_off(raw, ","); auto key = split_off(val, "="); 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");