diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dbf406e..1276ccd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Notable changes per release. Releases are tagged `vX.Y.Z`; the version lives in - CMake package: `find_package(TachyonUI)` with `TachyonUI::gui_core` and `TachyonUI::gui_controls`; Windows x64 with MSVC. - The backends are libraries of their own: `gui_backend_vulkan`, `gui_backend_d3d12`, `gui_backend_metal`, `gui_backend_sdlgpu` and `gui_backend_sdl` (windows and clipboard). `gui_core` and `gui_controls` hold none of them, so an app that sets its own backends links no SDL, Vulkan, VMA or D3D12MA. Apps link `TachyonUI::gui_backend_default` as well as `gui_controls` to get the built-in backends; without it and without a window backend set, `Initialize` fails and says which library to link. `RegisterGraphicsBackend`, `RegisterDefaultWindowBackend` and `RegisterDefaultClipboard` set the defaults; the `TACHYON_VULKAN`-style definitions come from `gui_backend_default` and the backend libraries. - The package installs third-party headers only for the libraries its public headers include (SDL3, VMA, D3D12 Memory Allocator). The privately linked ones (HarfBuzz, skribidi, SheenBidi, libunibreak, budoux, nanosvg, vk-bootstrap) are there as library files alone, without headers or package configs. +- The file system, file icons and file thumbnails (`IFileSystem`, `MemoryFileSystem`, `FileIcons`, `FileThumbnails`) moved out of `gui_controls` into the examples (`examples/app_controls`, as ``): they serve one kind of app. The showcase's Files panel uses them from there. - No files or DLLs to ship: the shaders, the default themes and the fonts are built into the library (`TACHYON_EMBED_RESOURCES`), and the bundled SDL3 is linked statically. `SetResourceRoot` is only needed for an app's own themes and fonts; a file there replaces the built-in one of the same name. - Resource files must be named in their exact case on every platform. The built-in themes and fonts are no longer found by a name in another case on Windows. `SetPathCaseCheck` compares the paths of the theme, font, icon and shader files the library opens with their names on disk: debug builds log a wrong case, `PathCaseCheck::Fail` refuses the file as Linux would, and the test programs run with it. `FindPathCaseMismatch` and `CheckPathCase` do the same for an app's own files. A test checks every resource path in the source and docs against the files on disk, and that no two files differ only in case. See [Resource paths](docs/contributing/resource-paths.md). - `GraphicsContext::SetShaderDirectory` is gone; `VulkanGraphicsContext::SetShaderDirectory` loads shaders from disk instead of the built-in ones. The package no longer installs `shaders_compiled/`. diff --git a/docs/controls/trees-and-grids.md b/docs/controls/trees-and-grids.md index 0a9b02c9..c4ac0df1 100644 --- a/docs/controls/trees-and-grids.md +++ b/docs/controls/trees-and-grids.md @@ -197,8 +197,14 @@ gridState.onOpen = [this](ID itemID) { ## File views -The file views show a tree and a grid of files. They read the files through an -`IFileSystem` (`gui_controls/gui_file_system.h`), so the files don't have to be on disk: +A tree list and a grid view can browse files, as the showcase's Files panel does. + +- The file code is part of the examples, not the library: it belongs to one kind of app. + - It's in `examples/app_controls/`, a small library the showcase links + (`tachyon_app_controls`). + - Copy it into your app, or use it as a model for your own. +- The panel reads the files through an `IFileSystem` (`app_controls/gui_file_system.h`), so + the files don't have to be on disk: | Method | Effect | | --- | --- | @@ -228,7 +234,7 @@ if (!files.Move("TachyonUI/notes.txt", "Archive", error)) ShowToast(ToastDesc{ .severity = Severity::Error, .title = "Can't move it", .body = error }); ``` -`FileIcons` (`gui_controls/gui_file_icons.h`) gets the OS icon for a file or folder. +`FileIcons` (`app_controls/gui_file_icons.h`) gets the OS icon for a file or folder. - On Windows it uses the shell's icons: - one per extension @@ -256,7 +262,7 @@ const IconID square = textSystem->RegisterIconFromPixels("white-square", uint2{ Button(square, [this] { Fill(); }); ``` -`FileThumbnails` (`gui_controls/gui_file_thumbnails.h`) gets a file's thumbnail: a small +`FileThumbnails` (`app_controls/gui_file_thumbnails.h`) gets a file's thumbnail: a small picture of a photo's contents or of a video frame, as Explorer shows it. - On Windows it reads them from the shell on a background thread. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 499b2862..2c411f9c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,5 +28,6 @@ if(TACHYON_BUILD_EXAMPLES) endif() if(TACHYON_BUILD_SHOWCASE) + add_subdirectory(app_controls) add_subdirectory(showcase) endif() diff --git a/examples/app_controls/CMakeLists.txt b/examples/app_controls/CMakeLists.txt new file mode 100644 index 00000000..18f8a4f8 --- /dev/null +++ b/examples/app_controls/CMakeLists.txt @@ -0,0 +1,14 @@ +# App-level parts the examples build on, which belong to one kind of app rather than the +# library: the file system, file icons and thumbnails of the showcase's Files panel. +add_library(tachyon_app_controls STATIC + gui_file_system.h + gui_file_system.cpp + gui_file_icons.h + gui_file_icons.cpp + gui_file_thumbnails.h + gui_file_thumbnails.cpp) +# Included as . +target_include_directories(tachyon_app_controls PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") +target_link_libraries(tachyon_app_controls PUBLIC gui_core) +tachyon_apply_compile_options(tachyon_app_controls) +set_target_properties(tachyon_app_controls PROPERTIES FOLDER "Examples") diff --git a/src/gui_controls/gui_file_icons.cpp b/examples/app_controls/gui_file_icons.cpp similarity index 99% rename from src/gui_controls/gui_file_icons.cpp rename to examples/app_controls/gui_file_icons.cpp index 553f7fd4..4777403d 100644 --- a/src/gui_controls/gui_file_icons.cpp +++ b/examples/app_controls/gui_file_icons.cpp @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/src/gui_controls/gui_file_icons.h b/examples/app_controls/gui_file_icons.h similarity index 100% rename from src/gui_controls/gui_file_icons.h rename to examples/app_controls/gui_file_icons.h diff --git a/src/gui_controls/gui_file_system.cpp b/examples/app_controls/gui_file_system.cpp similarity index 99% rename from src/gui_controls/gui_file_system.cpp rename to examples/app_controls/gui_file_system.cpp index a013ae9b..993c2a05 100644 --- a/src/gui_controls/gui_file_system.cpp +++ b/examples/app_controls/gui_file_system.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/gui_controls/gui_file_system.h b/examples/app_controls/gui_file_system.h similarity index 100% rename from src/gui_controls/gui_file_system.h rename to examples/app_controls/gui_file_system.h diff --git a/src/gui_controls/gui_file_thumbnails.cpp b/examples/app_controls/gui_file_thumbnails.cpp similarity index 99% rename from src/gui_controls/gui_file_thumbnails.cpp rename to examples/app_controls/gui_file_thumbnails.cpp index 621249e5..12194906 100644 --- a/src/gui_controls/gui_file_thumbnails.cpp +++ b/examples/app_controls/gui_file_thumbnails.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/gui_controls/gui_file_thumbnails.h b/examples/app_controls/gui_file_thumbnails.h similarity index 100% rename from src/gui_controls/gui_file_thumbnails.h rename to examples/app_controls/gui_file_thumbnails.h diff --git a/tests/file_system_test.cpp b/examples/app_controls/tests/file_system_test.cpp similarity index 99% rename from tests/file_system_test.cpp rename to examples/app_controls/tests/file_system_test.cpp index c133b4ae..0a3971f3 100644 --- a/tests/file_system_test.cpp +++ b/examples/app_controls/tests/file_system_test.cpp @@ -3,8 +3,8 @@ #include -#include -#include +#include +#include #include "gui_text_system_stub.h" diff --git a/tests/file_thumbnails_test.cpp b/examples/app_controls/tests/file_thumbnails_test.cpp similarity index 99% rename from tests/file_thumbnails_test.cpp rename to examples/app_controls/tests/file_thumbnails_test.cpp index 19bda8fa..e97003ad 100644 --- a/tests/file_thumbnails_test.cpp +++ b/examples/app_controls/tests/file_thumbnails_test.cpp @@ -3,7 +3,7 @@ #include -#include +#include #include "fake_clock.h" #include "gui_text_system_stub.h" diff --git a/examples/showcase/CMakeLists.txt b/examples/showcase/CMakeLists.txt index eea945d6..c8f40cfa 100644 --- a/examples/showcase/CMakeLists.txt +++ b/examples/showcase/CMakeLists.txt @@ -81,7 +81,9 @@ tachyon_add_example(showcase "${PROJECT_SOURCE_DIR}/workdirectory/themes/dark.css" "${PROJECT_SOURCE_DIR}/workdirectory/themes/light.css" "${PROJECT_SOURCE_DIR}/workdirectory/themes/styles.css" - "${PROJECT_SOURCE_DIR}/workdirectory/themes/showcase.css") + "${PROJECT_SOURCE_DIR}/workdirectory/themes/showcase.css" + + LIBS tachyon_app_controls) tachyon_precompile_headers(showcase ) if(TACHYON_METAL) diff --git a/examples/showcase/panel_files.cpp b/examples/showcase/panel_files.cpp index 8c27b246..0261dfc0 100644 --- a/examples/showcase/panel_files.cpp +++ b/examples/showcase/panel_files.cpp @@ -1,7 +1,7 @@ #include "application.h" -#include -#include -#include +#include +#include +#include #include #include diff --git a/examples/showcase/panel_misc.cpp b/examples/showcase/panel_misc.cpp index a4aa1eb5..794ed6d3 100644 --- a/examples/showcase/panel_misc.cpp +++ b/examples/showcase/panel_misc.cpp @@ -1,5 +1,5 @@ #include "application.h" -#include +#include #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 860aae83..97c1e5ed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -532,13 +532,6 @@ list(APPEND GUI_CONTROLS_FILES gui_controls/gui_tree_utils.h - gui_controls/gui_file_system.h - gui_controls/gui_file_system.cpp - gui_controls/gui_file_icons.h - gui_controls/gui_file_icons.cpp - gui_controls/gui_file_thumbnails.h - gui_controls/gui_file_thumbnails.cpp - gui_controls/controls.cpp gui_controls/controls_box_fields.cpp gui_controls/controls_curve.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fd390cea..b339573f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,8 +5,6 @@ list(APPEND GUI_CORE_TEST_FILES skribidi_text_measurement_test.cpp skribidi_glyph_quad_test.cpp controls_grid_view_test.cpp - file_system_test.cpp - file_thumbnails_test.cpp controls_menu_test.cpp controls_settings_test.cpp transition_manager_test.cpp @@ -243,6 +241,26 @@ set_target_properties(gui_ui_only_tests PROPERTIES ) +# The examples' app-level parts (examples/app_controls), tested with the examples' code. +if(TARGET tachyon_app_controls) + set(_app_controls_test_dir "${PROJECT_SOURCE_DIR}/examples/app_controls/tests") + add_executable(app_controls_tests + "${_app_controls_test_dir}/file_system_test.cpp" + "${_app_controls_test_dir}/file_thumbnails_test.cpp" + main.cpp) + # The tests share this folder's helpers (gui_text_system_stub.h, fake_clock.h). + target_include_directories(app_controls_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + target_link_libraries(app_controls_tests PRIVATE tachyon_app_controls GTest::gtest GTest::gmock) + tachyon_apply_compile_options(app_controls_tests) + tachyon_copy_runtime_dlls(app_controls_tests) + gtest_discover_tests(app_controls_tests DISCOVERY_MODE PRE_TEST DISCOVERY_TIMEOUT 60) + set_target_properties(app_controls_tests PROPERTIES + FOLDER "Tests" + VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/workdirectory" + ) +endif() + + # Tests on a real GPU, in two programs. They drive real windows through SDL, and SKIP # themselves when no suitable device or display is present, so they're safe to build # everywhere.