diff --git a/.github/workflows/build_android.yml b/.github/workflows/build_android.yml index 2b5b351ac..ca95f690a 100644 --- a/.github/workflows/build_android.yml +++ b/.github/workflows/build_android.yml @@ -119,33 +119,3 @@ jobs: run: ./gradlew assembleDebug - working-directory: ${{ runner.workspace }}/build/examples/graphics run: ./gradlew assemble - - build_render: - runs-on: ubuntu-latest - needs: [configure] - steps: - - uses: actions/checkout@v4 - - uses: seanmiddleditch/gha-setup-ninja@master - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - - name: Setup Android SDK - uses: android-actions/setup-android@v2.0.10 - - name: Setup Android NDK - uses: nttld/setup-ndk@v1 - with: - ndk-version: r26d - - uses: actions/cache/restore@v4 - id: cache-restore - with: - path: ${{ runner.workspace }}/build - key: android-build-${{ github.sha }} - - name: Configure If Cache Missed - if: steps.cache-restore.outputs.cache-hit != 'true' - run: cmake ${{ github.workspace }} -G "Ninja Multi-Config" -B ${{ runner.workspace }}/build -DYUP_TARGET_ANDROID=ON -DYUP_ENABLE_EXAMPLES=ON - - working-directory: ${{ runner.workspace }}/build/examples/render - run: ./gradlew assembleDebug - - working-directory: ${{ runner.workspace }}/build/examples/render - run: ./gradlew assemble diff --git a/.github/workflows/build_ios.yml b/.github/workflows/build_ios.yml index fffc744a9..2c9e38c88 100644 --- a/.github/workflows/build_ios.yml +++ b/.github/workflows/build_ios.yml @@ -107,22 +107,3 @@ jobs: -DPLATFORM=${{ env.IOS_PLATFORM }} -B ${{ runner.workspace }}/build -DYUP_ENABLE_EXAMPLES=ON - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_graphics - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_graphics - - build_render: - runs-on: macos-latest - needs: [configure] - steps: - - uses: actions/checkout@v4 - - uses: seanmiddleditch/gha-setup-ninja@master - - uses: actions/cache/restore@v4 - id: cache-restore - with: - path: ${{ runner.workspace }}/build - key: ios-build-${{ github.sha }} - - name: Configure If Cache Missed - if: steps.cache-restore.outputs.cache-hit != 'true' - run: | - cmake ${{ github.workspace }} -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/ios.cmake \ - -DPLATFORM=${{ env.IOS_PLATFORM }} -B ${{ runner.workspace }}/build -DYUP_ENABLE_EXAMPLES=ON - - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_render - - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_render diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index f8d87f429..69a5c7422 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -131,24 +131,6 @@ jobs: - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_graphics - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_graphics - build_render: - runs-on: ubuntu-latest - needs: [configure] - steps: - - uses: actions/checkout@v4 - - uses: seanmiddleditch/gha-setup-ninja@master - - run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS} - - uses: actions/cache/restore@v4 - id: cache-restore - with: - path: ${{ runner.workspace }}/build - key: linux-build-${{ github.sha }} - - name: Configure If Cache Missed - if: steps.cache-restore.outputs.cache-hit != 'true' - run: cmake ${{ github.workspace }} -G "Ninja Multi-Config" -B ${{ runner.workspace }}/build -DYUP_ENABLE_EXAMPLES=ON - - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_render - - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_render - build_plugin: runs-on: ubuntu-latest needs: [configure] diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index dcb453ace..e323c4a39 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -65,10 +65,10 @@ jobs: run: cmake ${{ github.workspace }} -G "Ninja Multi-Config" -B ${{ runner.workspace }}/build -DYUP_ENABLE_TESTS=ON - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target yup_tests - working-directory: ${{ runner.workspace }}/build/tests/Debug - run: ./yup_tests + run: ./yup_tests.app/Contents/MacOS/yup_tests - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target yup_tests - working-directory: ${{ runner.workspace }}/build/tests/Release - run: ./yup_tests + run: ./yup_tests.app/Contents/MacOS/yup_tests build_console: runs-on: macos-latest @@ -121,23 +121,6 @@ jobs: - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_graphics - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_graphics - build_render: - runs-on: macos-latest - needs: [configure] - steps: - - uses: actions/checkout@v4 - - uses: seanmiddleditch/gha-setup-ninja@master - - uses: actions/cache/restore@v4 - id: cache-restore - with: - path: ${{ runner.workspace }}/build - key: macos-build-${{ github.sha }} - - name: Configure If Cache Missed - if: steps.cache-restore.outputs.cache-hit != 'true' - run: cmake ${{ github.workspace }} -G "Ninja Multi-Config" -B ${{ runner.workspace }}/build -DYUP_ENABLE_EXAMPLES=ON - - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_render - - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_render - build_plugins: runs-on: macos-latest needs: [configure] diff --git a/.github/workflows/build_wasm.yml b/.github/workflows/build_wasm.yml index b5f3f5e6d..1804d0fdb 100644 --- a/.github/workflows/build_wasm.yml +++ b/.github/workflows/build_wasm.yml @@ -99,19 +99,3 @@ jobs: run: emcmake cmake ${{ github.workspace }} -G "Ninja Multi-Config" -B ${{ runner.workspace }}/build -DYUP_ENABLE_TESTS=ON -DYUP_ENABLE_EXAMPLES=ON - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_graphics - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_graphics - - build_render: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: seanmiddleditch/gha-setup-ninja@master - - run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS} - - name: Setup emsdk - uses: mymindstorm/setup-emsdk@v14 - with: - version: ${{ env.EM_VERSION }} - actions-cache-folder: ${{ env.EM_CACHE_FOLDER }} - - name: Configure - run: emcmake cmake ${{ github.workspace }} -G "Ninja Multi-Config" -B ${{ runner.workspace }}/build -DYUP_ENABLE_TESTS=ON -DYUP_ENABLE_EXAMPLES=ON - - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_render - - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_render diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 3925e075a..35e257003 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -62,14 +62,6 @@ jobs: - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_graphics - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_graphics - build_render: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - run: cmake ${{ github.workspace }} -B ${{ runner.workspace }}/build -DYUP_ENABLE_EXAMPLES=ON - - run: cmake --build ${{ runner.workspace }}/build --config Debug --parallel 4 --target example_render - - run: cmake --build ${{ runner.workspace }}/build --config Release --parallel 4 --target example_render - build_plugin: runs-on: windows-latest steps: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4a339e4d6..36d6bd10f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -46,6 +46,7 @@ env: libasound2-dev libjack-jackd2-dev ladspa-sdk libcurl4-openssl-dev libfreetype6-dev libx11-dev libxcomposite-dev libxcursor-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxrender-dev libglu1-mesa-dev libegl1-mesa-dev mesa-common-dev lcov + IGNORE_ERRORS: "mismatch,gcov,source,negative,unused,empty" jobs: coverage: diff --git a/CMakeLists.txt b/CMakeLists.txt index 103d13348..9d2ba6003 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,6 @@ if (YUP_BUILD_EXAMPLES) add_subdirectory (examples/console) add_subdirectory (examples/app) add_subdirectory (examples/graphics) - add_subdirectory (examples/render) if (YUP_PLATFORM_DESKTOP) add_subdirectory (examples/plugin) endif() diff --git a/codecov.yml b/codecov.yml index 36fe860c6..0d47b4d57 100644 --- a/codecov.yml +++ b/codecov.yml @@ -9,6 +9,7 @@ coverage: status: project: default: + informational: true target: 70% threshold: 5% base: auto @@ -22,6 +23,7 @@ coverage: - yup_gui patch: default: + informational: true target: 70% threshold: 5% @@ -114,7 +116,7 @@ ignore: - "cmake/**/*" - "docs/**/*" - "standalone/**/*" - - "**/modules/*/native/*" + - "modules/*/native/**/*" comment: layout: "header, reach, components, diff, flags, files, footer" diff --git a/examples/app/source/main.cpp b/examples/app/source/main.cpp index 2549e56cf..7b6d52ed2 100644 --- a/examples/app/source/main.cpp +++ b/examples/app/source/main.cpp @@ -27,12 +27,12 @@ class Application : public yup::YUPApplication public: Application() = default; - const yup::String getApplicationName() override + yup::String getApplicationName() override { return "yup app!"; } - const yup::String getApplicationVersion() override + yup::String getApplicationVersion() override { return "1.0"; } diff --git a/examples/graphics/CMakeLists.txt b/examples/graphics/CMakeLists.txt index d2abf8a77..02c32094a 100644 --- a/examples/graphics/CMakeLists.txt +++ b/examples/graphics/CMakeLists.txt @@ -25,6 +25,8 @@ set (target_version "1.0.0") project (${target_name} VERSION ${target_version}) +set (rive_file "data/alien.riv") + # ==== Prepare Android build set (link_libraries "") if (ANDROID) @@ -32,16 +34,17 @@ if (ANDROID) _yup_setup_platform() _yup_add_default_modules ("${CMAKE_CURRENT_LIST_DIR}/../..") - #yup_add_embedded_binary_resources ( - # "${target_name}_binary_data" - # OUT_DIR BinaryData - # HEADER BinaryData.h - # NAMESPACE yup - # RESOURCE_NAMES - # RobotoFont - # RESOURCES - # "${CMAKE_CURRENT_LIST_DIR}/data/RobotoFlex-VariableFont.ttf") - #set (link_libraries "${target_name}_binary_data") + yup_add_embedded_binary_resources ( + "${target_name}_binary_data" + OUT_DIR BinaryData + HEADER BinaryData.h + NAMESPACE yup + RESOURCE_NAMES + RiveFile + RESOURCES + "${CMAKE_CURRENT_LIST_DIR}/${rive_file}") + + set (link_libraries "${target_name}_binary_data") endif() # ==== Prepare target @@ -51,13 +54,20 @@ yup_standalone_app ( TARGET_IDE_GROUP "Examples" TARGET_APP_ID "org.yup.${target_name}" TARGET_APP_NAMESPACE "org.yup" + DEFINITIONS + YUP_EXAMPLE_GRAPHICS_RIVE_FILE="${rive_file}" PRELOAD_FILES - "${CMAKE_CURRENT_LIST_DIR}/data/RobotoFlex-VariableFont.ttf@data/RobotoFlex-VariableFont.ttf" + "${CMAKE_CURRENT_LIST_DIR}/${rive_file}@${rive_file}" MODULES + yup::yup_core + yup::yup_audio_basics yup::yup_audio_devices + yup::yup_events + yup::yup_graphics yup::yup_gui yup::yup_audio_processors libpng + libwebp ${link_libraries}) # ==== Prepare sources diff --git a/examples/render/data/alien.rev b/examples/graphics/data/alien.rev similarity index 100% rename from examples/render/data/alien.rev rename to examples/graphics/data/alien.rev diff --git a/examples/render/data/alien.riv b/examples/graphics/data/alien.riv similarity index 100% rename from examples/render/data/alien.riv rename to examples/graphics/data/alien.riv diff --git a/examples/render/data/arcade_controls.rev b/examples/graphics/data/arcade_controls.rev similarity index 100% rename from examples/render/data/arcade_controls.rev rename to examples/graphics/data/arcade_controls.rev diff --git a/examples/render/data/arcade_controls.riv b/examples/graphics/data/arcade_controls.riv similarity index 100% rename from examples/render/data/arcade_controls.riv rename to examples/graphics/data/arcade_controls.riv diff --git a/examples/render/data/audio_sampler.rev b/examples/graphics/data/audio_sampler.rev similarity index 100% rename from examples/render/data/audio_sampler.rev rename to examples/graphics/data/audio_sampler.rev diff --git a/examples/render/data/audio_sampler.riv b/examples/graphics/data/audio_sampler.riv similarity index 100% rename from examples/render/data/audio_sampler.riv rename to examples/graphics/data/audio_sampler.riv diff --git a/examples/render/data/car_interface.rev b/examples/graphics/data/car_interface.rev similarity index 100% rename from examples/render/data/car_interface.rev rename to examples/graphics/data/car_interface.rev diff --git a/examples/render/data/car_interface.riv b/examples/graphics/data/car_interface.riv similarity index 100% rename from examples/render/data/car_interface.riv rename to examples/graphics/data/car_interface.riv diff --git a/examples/render/data/charge.riv b/examples/graphics/data/charge.riv similarity index 100% rename from examples/render/data/charge.riv rename to examples/graphics/data/charge.riv diff --git a/examples/render/data/seasynth.rev b/examples/graphics/data/seasynth.rev similarity index 100% rename from examples/render/data/seasynth.rev rename to examples/graphics/data/seasynth.rev diff --git a/examples/render/data/seasynth.riv b/examples/graphics/data/seasynth.riv similarity index 100% rename from examples/render/data/seasynth.riv rename to examples/graphics/data/seasynth.riv diff --git a/examples/render/data/toymachine_3.rev b/examples/graphics/data/toymachine_3.rev similarity index 100% rename from examples/render/data/toymachine_3.rev rename to examples/graphics/data/toymachine_3.rev diff --git a/examples/render/data/toymachine_3.riv b/examples/graphics/data/toymachine_3.riv similarity index 100% rename from examples/render/data/toymachine_3.riv rename to examples/graphics/data/toymachine_3.riv diff --git a/examples/render/data/ui_elements.rev b/examples/graphics/data/ui_elements.rev similarity index 100% rename from examples/render/data/ui_elements.rev rename to examples/graphics/data/ui_elements.rev diff --git a/examples/render/data/ui_elements.riv b/examples/graphics/data/ui_elements.riv similarity index 100% rename from examples/render/data/ui_elements.riv rename to examples/graphics/data/ui_elements.riv diff --git a/examples/graphics/source/examples/Artboard.h b/examples/graphics/source/examples/Artboard.h new file mode 100644 index 000000000..f59761c7d --- /dev/null +++ b/examples/graphics/source/examples/Artboard.h @@ -0,0 +1,115 @@ +/* + ============================================================================== + + This file is part of the YUP library. + Copyright (c) 2025 - kunitoki@gmail.com + + YUP is an open source library subject to open-source licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + to use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +#pragma once + +namespace yup +{ + +class ArtboardDemo : public yup::Component +{ +public: + ArtboardDemo() + { + setWantsKeyboardFocus (true); + } + + bool loadArtboard() + { + auto factory = getNativeComponent()->getFactory(); + if (factory == nullptr) + return false; + +#if JUCE_ANDROID + yup::MemoryInputStream is (yup::RiveFile_data, yup::RiveFile_size, false); + auto artboardFile = yup::ArtboardFile::load (is, *factory); + +#else + yup::File riveBasePath; +#if YUP_WASM + riveBasePath = yup::File ("/"); +#else + riveBasePath = yup::File (__FILE__) + .getParentDirectory() + .getParentDirectory() + .getParentDirectory(); +#endif + + auto artboardFile = yup::ArtboardFile::load (riveBasePath.getChildFile (YUP_EXAMPLE_GRAPHICS_RIVE_FILE), *factory); +#endif + if (! artboardFile) + return false; + + // Setup artboards + for (int i = 0; i < totalRows * totalColumns; ++i) + { + auto art = artboards.add (std::make_unique (yup::String ("art") + yup::String (i))); + addAndMakeVisible (art); + + art->setFile (artboardFile.getValue()); + + art->advanceAndApply (i * art->durationSeconds()); + } + + return true; + } + + void refreshDisplay (double lastFrameTimeSeconds) override + { + repaint(); + } + + void resized() override + { + //for (int i = 0; i < totalRows * totalColumns; ++i) + // artboards.getUnchecked (i)->setBounds (getLocalBounds().reduced (100.0f)); + + if (artboards.size() != totalRows * totalColumns) + return; + + auto bounds = getLocalBounds().reduced (10, 20); + auto width = bounds.getWidth() / totalColumns; + auto height = bounds.getHeight() / totalRows; + + for (int i = 0; i < totalRows; ++i) + { + auto row = bounds.removeFromTop (height); + for (int j = 0; j < totalColumns; ++j) + { + auto col = row.removeFromLeft (width); + artboards.getUnchecked (j * totalRows + i)->setBounds (col.largestFittingSquare()); + } + } + } + + void paint (Graphics& g) override + { + g.setFillColor (findColor (yup::DocumentWindow::Style::backgroundColorId).value_or (yup::Colors::dimgray)); + g.fillAll(); + } + +private: + yup::OwnedArray artboards; + int totalRows = 1; + int totalColumns = 1; +}; + +} // namespace yup diff --git a/examples/graphics/source/examples/Audio.h b/examples/graphics/source/examples/Audio.h index 4fd18726e..2e036afc2 100644 --- a/examples/graphics/source/examples/Audio.h +++ b/examples/graphics/source/examples/Audio.h @@ -237,6 +237,12 @@ class AudioExample oscilloscope.setBounds (bottomBounds); } + void paint (yup::Graphics& g) override + { + g.setFillColor (findColor (yup::DocumentWindow::Style::backgroundColorId).value_or (yup::Colors::dimgray)); + g.fillAll(); + } + void mouseDown (const yup::MouseEvent& event) override { takeKeyboardFocus(); diff --git a/examples/graphics/source/examples/FileChooser.h b/examples/graphics/source/examples/FileChooser.h index b3764163f..e2e457a2b 100644 --- a/examples/graphics/source/examples/FileChooser.h +++ b/examples/graphics/source/examples/FileChooser.h @@ -29,6 +29,8 @@ class FileChooserDemo : public yup::Component , openFile ("Open File") , openMultipleFiles ("Multiple Files") { + setOpaque (false); + addAndMakeVisible (openFile); openFile.onClick = [this] { @@ -80,6 +82,12 @@ class FileChooserDemo : public yup::Component openMultipleFiles.setBounds (buttons1.removeFromLeft (buttonWidth)); } + void paint (yup::Graphics& g) override + { + g.setFillColor (findColor (yup::DocumentWindow::Style::backgroundColorId).value_or (yup::Colors::dimgray)); + g.fillAll(); + } + private: yup::TextButton openFile; yup::TextButton openMultipleFiles; diff --git a/examples/graphics/source/examples/LayoutFonts.h b/examples/graphics/source/examples/LayoutFonts.h index dde8c2a81..4cd9b8554 100644 --- a/examples/graphics/source/examples/LayoutFonts.h +++ b/examples/graphics/source/examples/LayoutFonts.h @@ -50,6 +50,9 @@ class LayoutFontsExample : public yup::Component void paint (yup::Graphics& g) override { + g.setFillColor (findColor (yup::DocumentWindow::Style::backgroundColorId).value_or (yup::Colors::dimgray)); + g.fillAll(); + const int numTexts = yup::numElementsInArray (text); for (int i = 0; i < numTexts; ++i) { diff --git a/examples/graphics/source/examples/OpaqueDemo.h b/examples/graphics/source/examples/OpaqueDemo.h new file mode 100644 index 000000000..f568c6ae5 --- /dev/null +++ b/examples/graphics/source/examples/OpaqueDemo.h @@ -0,0 +1,224 @@ +/* + ============================================================================== + + This file is part of the YUP library. + Copyright (c) 2025 - kunitoki@gmail.com + + YUP is an open source library subject to open-source licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + to use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace yup +{ + +//============================================================================== +class OpaqueDemo : public Component +{ +public: + OpaqueDemo() + { + auto theme = ApplicationTheme::getGlobalTheme(); + exampleFont = theme->getDefaultFont(); + + // Title label + titleLabel = std::make_unique