Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into with_imgui_test_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Oct 16, 2023
2 parents ae3ce60 + 0e58a7a commit d4276f9
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 114 deletions.
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ set(CMAKE_CXX_STANDARD 17)


###############################################################################
# hello_imgui_add_app location
# hello_imgui_add_app
###############################################################################
# In order to use `hello_imgui_add_app`, just write
# list(APPEND CMAKE_MODULE_PATH ${HELLOIMGUI_CMAKE_PATH})
# include(hello_imgui_add_app)
# somewhere before calling `hello_imgui_add_app`
# hello_imgui_add_app is a helper function, similar to cmake's "add_executable"
# Usage:
# hello_imgui_add_app(app_name file1.cpp file2.cpp ...)
#
# Features:
# * It will automaticaly link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
# * It will embed the assets (for desktop, mobile, and emscripten apps)
# * It will perform additional customization (app icon and name on mobile platforms, etc)
set(HELLOIMGUI_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/hello_imgui_cmake CACHE STRING "" FORCE)
# Make cmake function `hello_imgui_add_app` available
list(APPEND CMAKE_MODULE_PATH ${HELLOIMGUI_CMAKE_PATH})
Expand Down
51 changes: 19 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,15 @@ cmake_minimum_required(VERSION 3.12)
project(helloworld_with_helloimgui)
set(CMAKE_CXX_STANDARD 17)
##########################################################
# Prepare hello_imgui during configure time
##########################################################
# Build hello_imgui
# 1/ Option 1: simply fetch hello_imgui during the build
include(FetchContent)
FetchContent_Declare(
hello_imgui
GIT_REPOSITORY https://github.com/pthom/hello_imgui.git
# Enter the desired git tag below
# GIT_TAG
)
FetchContent_Declare(hello_imgui GIT_REPOSITORY https://github.com/pthom/hello_imgui.git GIT_TAG master)
FetchContent_MakeAvailable(hello_imgui)
# Make cmake function `hello_imgui_add_app` available
list(APPEND CMAKE_MODULE_PATH ${HELLOIMGUI_CMAKE_PATH})
include(hello_imgui_add_app)
# 2/ Option 2: if hello_imgui is available as a submodule for example
# add_subdirectory(path/to/hello_imgui)
##########################################################
# Build your app
##########################################################
hello_imgui_add_app(hello_world hello_world.main.cpp)
```

Expand All @@ -76,6 +67,18 @@ That's it, you do not need to clone HelloImGui, and you do not need to install a

For more detailed info, go to [_example_integration](_example_integration).

**Note about hello_imgui_add_app**

[hello_imgui_add_app](hello_imgui_cmake/hello_imgui_add_app.cmake) is a helper function, similar to cmake's "add_executable" which will:

* automaticaly link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
* embed the assets
* perform additional customization (app icon and name on mobile platforms, etc)

Usage:
```cmake
hello_imgui_add_app(app_name file1.cpp file2.cpp ...)
```

## Do you need more widgets, or do you want to use ImGui with python?

Expand Down Expand Up @@ -170,13 +173,6 @@ int main(int , char *[])
}
```
The CMakeLists fits in two lines, and will work on Linux, Mac, Windows, iOS and Emscripten_
> CMakeLists.txt:
```cmake
include(hello_imgui_add_app)
hello_imgui_add_app(hello_globe hello_globe.main.cpp)
```

## Complete demo - advanced layout, FPS, theme, etc:
Expand All @@ -201,23 +197,14 @@ __Table of contents__
* [Hello ImGui](#hello-imgui)
* [Features](#features)
* [Get started in 5 minutes](#get-started-in-5-minutes)
* [](#)
* [Prepare hello_imgui during configure time](#prepare-hello_imgui-during-configure-time)
* [](#)
* [Make cmake function `hello_imgui_add_app` available](#make-cmake-function-`hello_imgui_add_app`-available)
* [](#)
* [Build your app](#build-your-app)
* [](#)
* [Build](#build)
* [Run the build hello_world app](#run-the-build-hello_world-app)
* [Do you need more widgets, or do you want to use ImGui with python?](#do-you-need-more-widgets-or-do-you-want-to-use-imgui-with-python?)
* [Do you need more widgets, or do you want to use ImGui with python?](#do-you-need-more-widgets-or-do-you-want-to-use-imgui-with-python)
* [Full usage instructions and API](#full-usage-instructions-and-api)
* [Online interactive example applications](#online-interactive-example-applications)
* [Demo - handle events and include assets:](#demo---handle-events-and-include-assets)
* [include assets](#include-assets)
* [handle events](#handle-events)
* [Complete demo - advanced layout, FPS, theme, etc:](#complete-demo---advanced-layout-fps-theme-etc)
* [Main signature: use `int main(int, char**)`](#main-signature-use-`int-mainint-char**`)
* [Main signature: use `int main(int, char**)`](#main-signature-use-int-mainint-char)
* [Build instructions](#build-instructions)
* [Supported platforms and backends](#supported-platforms-and-backends)
* [Clone the repository](#clone-the-repository)
Expand Down
38 changes: 17 additions & 21 deletions README.src.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,15 @@ cmake_minimum_required(VERSION 3.12)
project(helloworld_with_helloimgui)
set(CMAKE_CXX_STANDARD 17)
##########################################################
# Prepare hello_imgui during configure time
##########################################################
# Build hello_imgui
# 1/ Option 1: simply fetch hello_imgui during the build
include(FetchContent)
FetchContent_Declare(
hello_imgui
GIT_REPOSITORY https://github.com/pthom/hello_imgui.git
# Enter the desired git tag below
# GIT_TAG
)
FetchContent_Declare(hello_imgui GIT_REPOSITORY https://github.com/pthom/hello_imgui.git GIT_TAG master)
FetchContent_MakeAvailable(hello_imgui)
# Make cmake function `hello_imgui_add_app` available
list(APPEND CMAKE_MODULE_PATH ${HELLOIMGUI_CMAKE_PATH})
include(hello_imgui_add_app)
# 2/ Option 2: if hello_imgui is available as a submodule for example
# add_subdirectory(path/to/hello_imgui)
##########################################################
# Build your app
##########################################################
hello_imgui_add_app(hello_world hello_world.main.cpp)
```

Expand All @@ -76,6 +67,18 @@ That's it, you do not need to clone HelloImGui, and you do not need to install a

For more detailed info, go to [_example_integration](_example_integration).

**Note about hello_imgui_add_app**

[hello_imgui_add_app](hello_imgui_cmake/hello_imgui_add_app.cmake) is a helper function, similar to cmake's "add_executable" which will:

* automaticaly link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
* embed the assets
* perform additional customization (app icon and name on mobile platforms, etc)

Usage:
```cmake
hello_imgui_add_app(app_name file1.cpp file2.cpp ...)
```

## Do you need more widgets, or do you want to use ImGui with python?

Expand Down Expand Up @@ -147,13 +150,6 @@ int main(int , char *[])
}
```
The CMakeLists fits in two lines, and will work on Linux, Mac, Windows, iOS and Emscripten_
> CMakeLists.txt:
```cmake
include(hello_imgui_add_app)
hello_imgui_add_app(hello_globe hello_globe.main.cpp)
```

## Complete demo - advanced layout, FPS, theme, etc:
Expand Down
34 changes: 15 additions & 19 deletions _example_integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,26 @@ cmake_minimum_required(VERSION 3.12)
project(helloworld_with_helloimgui)
set(CMAKE_CXX_STANDARD 17)

# Enable imgui_test_engine integration if desired
# set(HELLOIMGUI_WITH_TEST_ENGINE ON CACHE BOOL "" FORCE)

##########################################################
# Prepare hello_imgui during configure time
##########################################################
# Download hello_imgui
# Build hello_imgui
# 1/ Option 1: simply fetch hello_imgui during the build
include(FetchContent)
Set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(
hello_imgui
GIT_REPOSITORY https://github.com/pthom/hello_imgui.git
GIT_PROGRESS TRUE
# Enter the desired git tag or branch below
GIT_TAG with_imgui_test_engine
)
FetchContent_Declare(hello_imgui GIT_REPOSITORY https://github.com/pthom/hello_imgui.git GIT_TAG master)
FetchContent_MakeAvailable(hello_imgui)
# 2/ Option 2: if hello_imgui is available as a submodule for example
# add_subdirectory(path/to/hello_imgui)


##########################################################
# Build your app
##########################################################
# Call hello_imgui_add_app
hello_imgui_add_app(hello_world hello_world.main.cpp)


# hello_imgui_add_app is a helper function, similar to cmake's "add_executable"
# Usage:
# hello_imgui_add_app(app_name file1.cpp file2.cpp ...)
#
# Features:
# * It will automaticaly link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
# * It will embed the assets (for desktop, mobile, and emscripten apps)
# * It will perform additional customization (app icon and name on mobile platforms, etc)

# Now you can build your app with
# mkdir build && cd build && cmake .. && cmake --build .
29 changes: 2 additions & 27 deletions _example_integration/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,9 @@ No manual download or git clone is required.

## Explanations

The [CMakeLists.txt](CMakeLists.txt) file will
* download hello_imgui at configure time
* select the desired backend (edit the first lines if you want to use sdl instead of glfw)
* make the "hello_imgui_add_app" cmake function available
* Build HelloImGui and link it with your app at build time
The [CMakeLists.txt](CMakeLists.txt) file will download and build hello_imgui at configure time, and make the "hello_imgui_add_app" cmake function available.

```cmake
##########################################################
# Prepare hello_imgui during configure time
##########################################################
# Download hello_imgui
include(FetchContent)
FetchContent_Declare(
hello_imgui
GIT_REPOSITORY https://github.com/pthom/hello_imgui.git
# Enter the desired git tag below
# GIT_TAG
)
FetchContent_MakeAvailable(hello_imgui)
# Make cmake function `hello_imgui_add_app` available
list(APPEND CMAKE_MODULE_PATH ${HELLOIMGUI_CMAKE_PATH})
include(hello_imgui_add_app)
```

After this, you only need to create your exe with one line!
```cmake
hello_imgui_add_app(hello_world hello_world.main.cpp)
```
*Note: hello_imgui_add_app will automaticaly link your app to hello_imgui, and will embed the assets folder (for desktop, mobile, and emscripten apps)*

### Standard usage

Expand Down
Binary file added _example_integration/assets/fonts/DroidSans.ttf
Binary file not shown.
Binary file not shown.
Binary file added _example_integration/assets/world.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions _example_integration/hello_world.main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include "hello_imgui/hello_imgui.h"

int main(int , char *[])
{
HelloImGui::Run(
[]{ ImGui::Text("Hello, world!"); }, // Gui code
"Hello!", // Window title
true // Window size auto
);
auto guiFunction = []() {
ImGui::Text("Hello, "); // Display a simple label
HelloImGui::ImageFromAsset("world.jpg"); // Display a static image
if (ImGui::Button("Bye!")) // Display a button
// and immediately handle its action if it is clicked!
HelloImGui::GetRunnerParams()->appShallExit = true;
};
HelloImGui::Run(guiFunction, "Hello, globe", true);
return 0;
}
11 changes: 7 additions & 4 deletions hello_imgui_cmake/hello_imgui_add_app.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ endfunction()
# hello_imgui_prepare_app(target_name)
#
# Features:
# * It will automaticaly link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
# * It will embed the assets
# * It will perform additional customization (app icon and name on mobile platforms, etc)
# * It will automaticaly link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
# * It will embed the assets (for desktop, mobile, and emscripten apps)
# * It will perform additional customization (app icon and name on mobile platforms, etc)
function(hello_imgui_prepare_app app_name)
set_bundle_variables_defaults(${app_name})
hello_imgui_bundle_assets(${app_name})
Expand All @@ -67,7 +67,10 @@ endfunction()
# Usage:
# hello_imgui_add_app(app_name file1.cpp file2.cpp ...)
#
# Features: see the doc for hello_imgui_prepare_app, which is called by this function
# Features:
# * It will automaticaly link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
# * It will embed the assets (for desktop, mobile, and emscripten apps)
# * It will perform additional customization (app icon and name on mobile platforms, etc)
function(hello_imgui_add_app)
set(args ${ARGN})
list(GET args 0 app_name)
Expand Down
15 changes: 14 additions & 1 deletion tools/doc/process_md_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def parse_header_line(header_line):
level = len(header_line.split(" ")[0])
title = header_line[level + 1 :].rstrip()
anchor_title = title.lower().replace(" ", "-")
ignored_chars = [":", "+", ",", "!", '"', "(", ")"]
ignored_chars = [":", "+", ",", "!", '"', "(", ")", "?", "*", "`"]
for ignored_char in ignored_chars:
anchor_title = anchor_title.replace(ignored_char, "")
return level, title, anchor_title
Expand All @@ -33,9 +33,22 @@ def is_header_line(line):
return line.startswith("#") and not (line.startswith("#include"))


def remove_code_blocks(lines):
filtered_lines = []
in_code_block = False
for line in lines:
if line.strip().startswith("```"):
in_code_block = not in_code_block
if not in_code_block:
filtered_lines.append(line)
return filtered_lines


def make_toc(file):
with open(file, "r") as f:
lines = f.readlines()
lines = remove_code_blocks(lines)

header_lines = [line[:-1] for line in lines if is_header_line(line)]
toc = '<span id="TOC"/></span>\n\n'
for header_line in header_lines:
Expand Down

0 comments on commit d4276f9

Please sign in to comment.