From 549c205dd3ca98f18fcf541a2ebbfc5abdd10410 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Mon, 8 Jan 2024 20:19:44 +0100 Subject: [PATCH] doc / AssetsData --- src/hello_imgui/doc_api.md | 91 +++++++++++++++------------- src/hello_imgui/doc_api.src.md | 24 ++++---- src/hello_imgui/hello_imgui_assets.h | 3 + 3 files changed, 64 insertions(+), 54 deletions(-) diff --git a/src/hello_imgui/doc_api.md b/src/hello_imgui/doc_api.md index c06a616d..7903d2a9 100644 --- a/src/hello_imgui/doc_api.md +++ b/src/hello_imgui/doc_api.md @@ -130,6 +130,9 @@ struct AssetFileData // LoadAssetFileData(const char *assetPath)` // Will load an entire asset file into memory. This works on all platforms, // including android. +// You *have* to call FreeAssetFileData to free the memory, except if you use +// ImGui::GetIO().Fonts->AddFontFromMemoryTTF, which will take ownership of the +// data and free it for you. AssetFileData LoadAssetFileData(const char *assetPath); // FreeAssetFileData(AssetFileData *) @@ -227,7 +230,50 @@ ImVec2 ImageProportionalSize(const ImVec2& askedSize, const ImVec2& imageSize); ---- -# Ini settings location +# Utility functions + +```cpp + + +// `FrameRate(durationForMean = 0.5)`: Returns the current FrameRate. +// May differ from ImGui::GetIO().FrameRate, since one can choose the duration +// for the calculation of the mean value of the fps +// Returns the current FrameRate. May differ from ImGui::GetIO().FrameRate, +// since one can choose the duration for the calculation of the mean value of the fps +// (Will only lead to accurate values if you call it at each frame) +float FrameRate(float durationForMean = 0.5f); + +// `ImGuiTestEngine* GetImGuiTestEngine()`: returns a pointer to the global instance +// of ImGuiTestEngine that was initialized by HelloImGui +// (iif ImGui Test Engine is active). +ImGuiTestEngine* GetImGuiTestEngine(); +``` + +---- +# Switch between several layouts +See [hello_imgui.h](https://github.com/pthom/hello_imgui/blob/master/src/hello_imgui/hello_imgui.h). + +```cpp + +// In advanced cases when several layouts are available, you can switch between layouts. +// See demo inside +// https://github.com/pthom/hello_imgui/tree/master/src/hello_imgui_demos/hello_imgui_demodocking/hello_imgui_demodocking.main.cpp + +// `SwitchLayout(layoutName)` +// Changes the application current layout. Only used in advanced cases +// when several layouts are available, i.e. if you filled +// runnerParams.alternativeDockingLayouts. +void SwitchLayout(const std::string& layoutName); + +// `CurrentLayoutName()`: returns the name of the current layout +std::string CurrentLayoutName(); +``` + +---- + +# Ini settings + +## Ini settings location ```cpp @@ -296,48 +342,7 @@ void DeleteIniSettings(const RunnerParams& runnerParams); ---- -# Utility functions - -```cpp - - -// `FrameRate(durationForMean = 0.5)`: Returns the current FrameRate. -// May differ from ImGui::GetIO().FrameRate, since one can choose the duration -// for the calculation of the mean value of the fps -// Returns the current FrameRate. May differ from ImGui::GetIO().FrameRate, -// since one can choose the duration for the calculation of the mean value of the fps -// (Will only lead to accurate values if you call it at each frame) -float FrameRate(float durationForMean = 0.5f); - -// `ImGuiTestEngine* GetImGuiTestEngine()`: returns a pointer to the global instance -// of ImGuiTestEngine that was initialized by HelloImGui -// (iif ImGui Test Engine is active). -ImGuiTestEngine* GetImGuiTestEngine(); -``` - ----- -# Switch between several layouts -See [hello_imgui.h](https://github.com/pthom/hello_imgui/blob/master/src/hello_imgui/hello_imgui.h). - -```cpp - -// In advanced cases when several layouts are available, you can switch between layouts. -// See demo inside -// https://github.com/pthom/hello_imgui/tree/master/src/hello_imgui_demos/hello_imgui_demodocking/hello_imgui_demodocking.main.cpp - -// `SwitchLayout(layoutName)` -// Changes the application current layout. Only used in advanced cases -// when several layouts are available, i.e. if you filled -// runnerParams.alternativeDockingLayouts. -void SwitchLayout(const std::string& layoutName); - -// `CurrentLayoutName()`: returns the name of the current layout -std::string CurrentLayoutName(); -``` - ----- - -# Store user settings in the ini file +## Store user settings in the ini file See [hello_imgui.h](https://github.com/pthom/hello_imgui/blob/master/src/hello_imgui/hello_imgui.h). ```cpp diff --git a/src/hello_imgui/doc_api.src.md b/src/hello_imgui/doc_api.src.md index 3e64db3e..15db606d 100644 --- a/src/hello_imgui/doc_api.src.md +++ b/src/hello_imgui/doc_api.src.md @@ -49,35 +49,37 @@ See [image_from_asset.h](https://github.com/pthom/hello_imgui/blob/master/src/he ---- -# Ini settings location +# Utility functions ```cpp -@import "runner_params.h" {md_id=IniFolderType} +@import "hello_imgui.h" {md_id=UtilityFunctions} ``` +---- +# Switch between several layouts +See [hello_imgui.h](https://github.com/pthom/hello_imgui/blob/master/src/hello_imgui/hello_imgui.h). + ```cpp -@import "runner_params.h" {md_id=IniIniSettingsLocation} +@import "hello_imgui.h" {md_id=HelloImGui::Layouts} ``` ---- -# Utility functions +# Ini settings + +## Ini settings location ```cpp -@import "hello_imgui.h" {md_id=UtilityFunctions} +@import "runner_params.h" {md_id=IniFolderType} ``` ----- -# Switch between several layouts -See [hello_imgui.h](https://github.com/pthom/hello_imgui/blob/master/src/hello_imgui/hello_imgui.h). - ```cpp -@import "hello_imgui.h" {md_id=HelloImGui::Layouts} +@import "runner_params.h" {md_id=IniIniSettingsLocation} ``` ---- -# Store user settings in the ini file +## Store user settings in the ini file See [hello_imgui.h](https://github.com/pthom/hello_imgui/blob/master/src/hello_imgui/hello_imgui.h). ```cpp diff --git a/src/hello_imgui/hello_imgui_assets.h b/src/hello_imgui/hello_imgui_assets.h index 91f1f6df..37930116 100644 --- a/src/hello_imgui/hello_imgui_assets.h +++ b/src/hello_imgui/hello_imgui_assets.h @@ -35,6 +35,9 @@ struct AssetFileData // LoadAssetFileData(const char *assetPath)` // Will load an entire asset file into memory. This works on all platforms, // including android. +// You *have* to call FreeAssetFileData to free the memory, except if you use +// ImGui::GetIO().Fonts->AddFontFromMemoryTTF, which will take ownership of the +// data and free it for you. AssetFileData LoadAssetFileData(const char *assetPath); // FreeAssetFileData(AssetFileData *)