Dear ImGui用のHDRグラデーション編集ウィジェットです。色・アルファ・強度を編集できます。
CMake 3.15以上、C++14コンパイラー、Gitを使用します。 単独ビルドではDear ImGui v1.91.9bとGLFW 3.4を初回構成時に取得します。 サンプルにはOpenGLとウィンドウ環境が必要です。LinuxではGLFW用のX11/Wayland開発パッケージも必要です。
Windows(Visual Studio 2022)の例:
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Debug --parallel
cd build
ctest -C Debug --output-on-failure
.\Debug\ImGradientHDRExample.exeLinux/macOSの単一構成Generatorの例:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel
cd build
ctest --output-on-failure
./ImGradientHDRExampleReleaseを使う場合は上記のDebugをReleaseへ置き換えます。
CTestはウィンドウを開かず、キー挿入・削除、HDR色・アルファの補間、ドラッグ・無効化・選択保持、編集通知、狭い領域、HDR描画色を確認します。
サンプルに--smoke-testを指定すると、非表示ウィンドウで3フレーム描画して終了します。
この確認にも利用可能なOpenGL環境が必要で、マウス操作や見た目の一致までは検証しません。
通常起動では色・アルファのキーを追加・移動し、選択したキーの値や強度、削除を確認できます。
| CMakeオプション | 単独ビルド時の既定値 | 用途 |
|---|---|---|
IMGRADIENTHDR_BUILD_EXAMPLE |
ON | GLFW/OpenGLサンプル |
IMGRADIENTHDR_BUILD_TESTS |
ON | CTest用の状態・ウィジェットテスト |
サンプルをOFFにするとOpenGL・GLFWは不要です。
取得済みソースを使う場合は、FetchContent標準のFETCHCONTENT_SOURCE_DIR_IMGUI・FETCHCONTENT_SOURCE_DIR_GLFWへ絶対パスを指定できます。
add_subdirectoryで追加し、ImGradientHDR::ImGradientHDRへリンクします。
サンプルとテストは組み込み時には既定でOFFです。
既存のimguiターゲットがあれば再利用し、なければ固定版を取得します。
既存ターゲットを使ってサンプルもビルドする場合は、Backendソースの場所をimgui_SOURCE_DIRで指定してください。
ImGradientHDRは値が変わったときにtrueを返します。
呼び出し直後のImGui::IsItemEdited()とImGui::IsItemDeactivatedAfterEdit()で、変更中と編集終了を取得できます。
BeginDisabled()中は操作を停止します。キー追加時は既存の選択を保持します。
HDRのプレビューは1ピクセル間隔で評価し、表示可能な色域へ制限します。HDR値そのものは変更しません。
An HDR gradient editor widget for Dear ImGui, supporting color, alpha, and intensity.
Requires CMake 3.15 or newer, a C++14 compiler, and Git. Standalone configuration fetches Dear ImGui v1.91.9b and GLFW 3.4 on first use. The example requires OpenGL and a window system. Linux also needs GLFW's X11/Wayland development packages.
Windows example (Visual Studio 2022):
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Debug --parallel
cd build
ctest -C Debug --output-on-failure
.\Debug\ImGradientHDRExample.exeLinux/macOS example with a single-configuration generator:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel
cd build
ctest --output-on-failure
./ImGradientHDRExampleReplace Debug with Release for release builds.
CTest runs without a window and checks key insertion/removal, HDR color/alpha interpolation, dragging/disabling/selection preservation, edit notifications, narrow regions, and HDR display colors.
Pass --smoke-test to the example to render three frames in a hidden window and exit.
This still requires a working OpenGL environment and does not verify mouse interactions or visual equivalence.
Run normally to add/move color and alpha keys, edit selected values/intensity, and delete keys.
| CMake option | Standalone default | Purpose |
|---|---|---|
IMGRADIENTHDR_BUILD_EXAMPLE |
ON | GLFW/OpenGL example |
IMGRADIENTHDR_BUILD_TESTS |
ON | State and widget tests through CTest |
Disabling the example removes the OpenGL/GLFW requirement.
To use existing source checkouts, set FetchContent's standard FETCHCONTENT_SOURCE_DIR_IMGUI and FETCHCONTENT_SOURCE_DIR_GLFW to absolute paths.
Use add_subdirectory and link to ImGradientHDR::ImGradientHDR.
Examples and tests default to OFF when embedded.
An existing imgui target is reused; otherwise the pinned version is fetched.
To build the example with an existing target, set imgui_SOURCE_DIR to locate its backend sources.
ImGradientHDR returns true when values change.
Immediately afterward, use ImGui::IsItemEdited() and ImGui::IsItemDeactivatedAfterEdit() to track changes and edit completion.
BeginDisabled() stops interaction. Adding a key preserves the existing selection.
The HDR preview samples at one-pixel intervals and clamps to displayable colors without changing the stored HDR values.
