GithubHelp home page GithubHelp logo

pthom / hello_imgui Goto Github PK

View Code? Open in Web Editor NEW
561.0 14.0 83.0 41.23 MB

Hello, Dear ImGui: unleash your creativity in app development and prototyping

Home Page: https://pthom.github.io/hello_imgui

License: MIT License

CMake 8.59% C++ 67.47% HTML 0.20% C 8.11% Shell 0.58% Python 0.75% Objective-C++ 1.18% Makefile 0.02% Java 12.63% Dockerfile 0.02% Objective-C 0.11% CSS 0.01% TeX 0.34%
imgui cpp hello-world linux windows osx android immediate-gui ios gui

hello_imgui's Introduction

See the HelloImGui documentation website for API, usage and build instructions.

OpenGL
Win_Mac_Linux MinGW

Mobile and web
iOS Android Emscripten

Alternate rendering backends
Metal Vulkan DirectX

Misc
TestEngine Automate StarterTemplate

Vcpkg
VcpkgDeps VcpkgPackage

Hello ImGui

Hello ImGui is a library designed to make multiplatform app development as simple as writing a "Hello World" program, built on top of Dear ImGui.

Its flexibility makes it suited for complex applications, as well as for simple prototypes; allowing you to focus on the creative aspects of your projects.

Features

Multiplatform utilities

  • Seamlessly multiplatform: supports Linux, Windows, macOS, iOS, Android, and Emscripten with minimal setup (1 line of CMake code)
  • Asset embedding across all platforms (no code required)
  • Effortless app customization, including app icons and names for mobile platforms (no code required)
  • Universal application icon customization, extending to mobile and macOS (no code required)

Dear ImGui Tweaks

  • Power Save mode: optimize performance by reducing FPS when idle
  • High DPI support: automatically scales UI to match screen DPI on any platform.
  • Enhanced layout handling: dockable windows and multiple layouts for complex UIs
  • Window geometry utilities: autosize application window, restore app window position
  • Theme tweaking: extensive list of additional themes
  • Support for movable and resizable borderless windows
  • Advanced font support: icons, emojis and colored fonts
  • Integration with ImGui Test Engine: automate and test your apps
  • Save user settings: window position, layout, opened windows, theme, user defined custom settings
  • Easily add a custom 3D background to your app

Backends

  • Available platform backends: SDL2, Glfw3
  • Available rendering backends: OpenGL3, Metal, Vulkan, DirectX

Demos & real world apps

Motto

The minimum code to start developing a GUI app should be... minimal. Here is a multiplatform Hello World in 7 lines.

6 lines of C++

#include "hello_imgui/hello_imgui.h"
int main(int , char *[]) {
    HelloImGui::Run(
        []{ ImGui::Text("Hello, world!"); }, // Gui code
        "Hello!", true);                     // Window title + Window size auto
}

1 line of CMake

hello_imgui_add_app(hello_world hello_world.cpp)

Advanced layout

The docking demo show how to handle complex layouts, use themes, store user settings, reduce FPS and CPU usage when idling, load fonts and icons, and much more

Online demo - Source - Video tutorial: how to handle multiple complex layouts

Custom 3D background

How to use a custom 3D background in your app

Online demo - Source

ImGui Manual

ImGui Manual is an interactive Manual for Dear ImGui, built with Hello ImGui.

Online manual - Source

RPN Calculator

RPN Calculator is a simple RPN calculator, built, built to demonstrate how easy a multiplatform app can be built with Hello ImGui.

Online demo - Source - Video tutorial

Starter template

The starter template will get you started in 5 minutes, and shows how to embed assets, customize the app icon (etc.), on all platforms.

Dear ImGui Bundle

Dear ImGui Bundle, a full-fledged library, built on top of Hello ImGui, provides lots of additional widgets (imgui, implot, imgui-node-editor, ImFileDialog, ImGuiColorTextEdit, imgui_md), as well as complete python bindings.

online interactive demo - Source for C++ demos - Source for Python demos

Theme tweaking

How to use the theme tweaking utilities provided by Hello ImGui

Online video tutorial


About

Credits

Hello ImGui is based on Dear ImGui (MIT License), by Omar Cornut. Portions use ImGui Test Engine, which is governed by a specific license

Portions of this software use the FreeType Project, lunasvg (MIT License), GLFW (zlib/libpng license), SDL (zlib license).

License

Hello ImGui is licensed under the MIT License, see LICENSE

Contribute

Quality contributions are welcome!

Support the project

Hello ImGui is a free and open source project, and its development and maintenance require considerable efforts.

If you find it valuable for your work – especially in a commercial enterprise or a research setting – please consider supporting its development by making a donation. Thank you!

More info

See the HelloImGui documentation website for API, usage and build instructions.

hello_imgui's People

Contributors

bigbiuewhale avatar codecat avatar guillaume227 avatar iandyhd3 avatar learn-more avatar pthom avatar sakuraofficial avatar wkjarosz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hello_imgui's Issues

Linux build error when using glfw

On Archlinux I am getting the following error when compiling with HELLOIMGUI_USE_GLFW_OPENGL3.

/usr/bin/ld: external/hello_imgui/external/libglad.a(glad.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'

I can fix this by linking with dl, but perhaps this should be fixed in the library directly:

target_link_libraries(${target_name} PUBLIC glfw)

Should add `encoding='utf8'` to open

Given OS=Windows, imgui-bundle=0.8.5

Click and crash here:

image

Log:

Traceback (most recent call last):
  File "C:\Users\tangz\test.py", line 183, in <module>
    immapp.run(demo_gui, with_markdown=True, window_size=(1000, 800))  # type: ignore
  File "C:\Users\tangz\test.py", line 172, in demo_gui
    show_markdown_file("ibd_faq")
  File "C:\Users\tangz\miniconda3\lib\site-packages\imgui_bundle\demos_python\demo_utils\api_demos.py", line 79, in show_markdown_file
    code = read_markdown_code(doc_filename)
  File "C:\Users\tangz\miniconda3\lib\site-packages\imgui_bundle\demos_python\demo_utils\api_demos.py", line 106, in read_markdown_code
    r = read_code(doc_file)
  File "C:\Users\tangz\miniconda3\lib\site-packages\imgui_bundle\demos_python\demo_utils\functional_utils.py", line 11, in wrapper
    cache[key] = func(*args, **kwargs)
  File "C:\Users\tangz\miniconda3\lib\site-packages\imgui_bundle\demos_python\demo_utils\api_demos.py", line 88, in read_code
    r = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x8b in position 7774: illegal multibyte sequence

Need to add encoding='utf8' to open here:

@memoize
def read_code(filename: str) -> str:
    if not os.path.isfile(filename):
        return ""
    with open(filename, encoding='utf8') as f: # a small fix
        r = f.read()
        return r

App Menu vs Main Window Title

Hello again !

I initially populate my RunnerParams with:

  runnerParams.appWindowParams.windowTitle = "MyApp"
  runnerParams.imGuiWindowParams.showMenuBar = true;
  runnerParams.imGuiWindowParams.showMenu_App = true;
  runnerParams.imGuiWindowParams.showMenu_View = true;

When I update the window title once the application is up and running with the following statement:

HelloImGui::GetRunnerParams()->appWindowParams.windowTitle = "MyApp 2023.1.1";

I noticed that the App menu name gets updated to my title variable while the main window title remains the same as the value that was in the RunnerParams I originally passed to HelloImGui::Run().
In the following example the initial value of appWindowParams.windowTitle was just "MyApp", then updated to "MyApp 2023.1.1" :
image

Note: the Settings menu you can see in the image is my own custom menu on top of the App and View built-ins.

This behavior is a bit surprising to me and I want to clarify what is a feature and what might be a bug.
It also makes me wonder if there is a way to control separately the name of the App menu from the main window title ?
My expectation was that appWindowParams.windowTitle would only affect the main window title bar and not the App menu entry name.

Could NOT find X11 ( missing: X11_X11_LIB) when building web app(emscripten)

Updated

I'm now able to build emscripten on this project imgui_manual and it works on browser. Although below errors haven't solved but I should be able to figure it out what went wrong below by looking into imgui_manual.

Original

Thanks for the awesome project !

I was able to build linux desktop app in _example_integration but failed to build the web app(emscripten).
If someone can guide me through this would be really appreciative!
I use docker for quickly get the development environment and it works for linux desktop app well.

The failed part is in the Build web app(emscripten) below.

Build pthom/hello_imgui.git

requirements

Docker version 20.10.7, build f0df350

Steps

$ docker run --rm -it --user 0 -p 5901:5901 -p 6901:6901 consol/debian-xfce-vnc

open browser and navigate to http://localhost:6901/?password=vncpassword

open Terminal app and install tools

apt update && apt install -y git build-essential cmake`
apt install libglfw3-dev libxinerama-dev libxcursor-dev libxi-dev libx11-dev

Download pthom/hello_imgui.git

cd ~
git clone https://github.com/pthom/hello_imgui.git

Build linux desktop app and run

cd ~/hello_imgui/
cd _example_integration
mkdir build && cd build
cmake .. && make hello_world .. && ./hello_world

Yayyy~~ I can see hello world application running in the linux now

Install emscripten

~/hello_imgui/tools/emscripten/install_emscripten.sh
source ~/emsdk/emsdk_env.sh

Build web app(emscripten)

cd ~/hello_imgui/src/hello_imgui_demos/_example_integration

mkdir build_emscripten && cd build_emscripten

emcmake cmake .. -DHELLOIMGUI_USE_SDL_OPENGL3=ON ..

./_deps/hello_imgui-src/tools/sdl_download.sh

emcmake cmake .. -DHELLOIMGUI_USE_SDL_OPENGL3=ON .. #again

After emcmake cmake .. -DHELLOIMGUI_USE_SDL_OPENGL3=ON ...

the Error shows Could NOT find X11 as below

Screenshot 2022-12-08 at 5 08 03 pm

Dynamic FPS

Hello phtom,

thanks for hello imgui.

My project could benefit from having a parameter for FPS.
I do not need full FPS all the time.
Would be good on accu powered devices or when having other resource hungry apps running, to lower the FPS when not needed.
Since imgui has the trickling input queue, this could be possible, I think.
What do you think about a parameter for FPS, which the app can set dynamically at runtime?

Best regards

Imgui Ini Settings Parts

It appears that author forgot to either ignore or correctly format the line to not cause a crash:

hello_imgui_ini_settings.cpp: line 116
std::string r = ";;; !!! This configuration is handled by HelloImGui and stores several Ini Files, separated by markers like this:\n ;;;<<<INI_NAME>>>;;;\n\n";

This line is causing the application to abort whenever it attempts to read/save.

I had to readjust the string so that each line opened/closed with ;;;<<< >>>;;; in order for the app to correctly read/save file.

Update imgui

Hey there, was hoping to get an imgui update in hello_imgui to fix an issue I was having: ocornut/imgui#3982

I'm not sure how often imgui generally gets updated for hello_imgui, so figured I'd just ask. Thanks! 🥰

Access to imgui/misc/cpp/ extension

I am getting unresolved external errors for calls to ImGui methods placed in imgui/misc/cpp/imgui_stdlib.h.
Are these sources not compiled by default alongside other imgui code?
Are there some specific steps to take in the CMakeLists.txt to pull them in?

Drag/move window without decorations?

Hello, is it possible to make "backend window" of GLFW draggable for example by grabbing the top "menu bar"?
I'd like to replace OS window decorations with my own, but then I think there's no way to drag the window around.
I don't use fullscreen or docking, I'd just like to render one small window with it.

Ctrl+Tab in Web

Just perusing the Imgui Manual this morning and came across the part where it says Ctrl+Tab selects window. This won't work on emscripten because that is already bound to change tabs.Not sure what to do about this. Could use vim bindings (Ctrl+w, Ctrl+Shift+w) but those are not as well known to the world. Alt+Tab is in uded in most OSes. Could use Ctrl+Alt+tab but it's cumbersome...

Anyhow, my point was just to catalog the issue for others. - This may be something to bring up to the main Imgui repo. dunno...

Thoughts?

Errors when build for Emscripten with-DHELLOIMGUI_USE_SDL_OPENGL3=ON

The signature of Demo main() function is exactly int main(int argc, char **argv) and returns an int.
//-----------------------------
37>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@yahxz)
37>C:\GUI\Imgui\hello_imgui-master\build_emscripten\src\hello_imgui_demos\hello_imgui_demo_minimal\Debug\hello_imgui_demo_minimal.exe : fatal error LNK1120: 1 unresolved externals
39>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@yahxz)
39>C:\GUI\Imgui\hello_imgui-master\build_emscripten\src\hello_imgui_demos\hello_world\Debug\hello_world.exe : fatal error LNK1120: 1 unresolved externals
40>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@yahxz)
40>C:\GUI\Imgui\hello_imgui-master\build_emscripten\src\hello_imgui_demos\hello_imgui_demo_classic\Debug\hello_imgui_demo_classic.exe : fatal error LNK1120: 1 unresolved externals

creating hidden window

I'd like to create a window that is initially hidden, i will only show it later. right now it flashes up before i get a chance to call glfw.hide_window(self._glfw_window) in the post_init callback.
I tried:

glfw.window_hint(glfw.VISIBLE, False)
immapp.run(params)

but it makes sense that wouldn't work since glfw isn't even initialized at this point, correct?

Is it possible to make a window that is initially hidden?

Programmatically opening more windows in dock space

I would like to add a window to a dockspace programmatically. However, trying to do so crashes.
I take the source of demo_docking.py and add the following to the bottom of command_gui():

    if imgui.button("Add window"):
        temp = hello_imgui.DockableWindow()
        temp.label = "Test"
        temp.dock_space_name = "MainDockSpace"
        temp.gui_function = lambda: imgui.text('yo')
        wins = hello_imgui.get_runner_params().docking_params.dockable_windows
        wins.append(temp)
        hello_imgui.get_runner_params().docking_params.dockable_windows = wins

The crash i then get is:

Exception has occurred: RuntimeError
IM_ASSERT( name != 0 && name[0] != '\0' )   ---   imgui.cpp:6366
  File "C:\...\demo_docking.py", line 265, in main
    immapp.run(runner_params, addons_params)
  File "C:\...\demo_docking.py", line 269, in <module>
    main()
RuntimeError: IM_ASSERT( name != 0 && name[0] != '\0' )   ---   imgui.cpp:6366

Is this the correct way to add more dockable windows to a program? And will they correctly be docked to the indicated dockspace, not free floating?

Cannot load a font during frame rendering

Hello👋!
I want to load a ttf font into hello_imgui,but it can't work;

void Draw()
{
    ImFont* font1;    ImFont* font1;
    static bool bool1 = true;
    if (bool1)
    {
        font1 = HelloImGui::LoadFontTTF_WithFontAwesomeIcons(
            "/usr/share/fonts/truetype/ms-core-fonts/AndaleMo.TTF", 25.0f);
        bool1 = false;
    }

    ImGui::PushFont(font1);
    ImGui::Text("Hello");
    ImGui::PopFont();

⬇⬇It likely load success,but it show "unknown".
And when i select it,my program will crash ( show: 18762 segmentation fault (core dumped) ./hello_world ).
image

_example_integration.zip

Pre-exit behavior

I am looking a way to have a confirmation dialog appear to ask the user whether they really want to close the app (e.g. because some changes might be lost).
The BeforeExit callback is called at a stage when there is no way back, more like a c++ destructor that you can use to clean-up resources but from which you cannot change your mind about leaving a context.

I would like to achieve that while reusing the default 'Quit' menu entry that ships with the App menu.

Is that a case for introducing a new callback? Or is there another way I have overlooked?

Application Window Icon

Based on that (old-ish) imgui issue: ocornut/imgui#2715
I am wondering whether providing a way to display a main window icon should be part of what the battery-included, cross platform hello_imgui approach should offer.

I have looked at the doc and the hello_imgui_app example but it's not obvious how to achieve that currently.

Compilation warnings clean-up

I have noticed the following warnings when building on windows.
Absolutely not critical but I like to have a clean build, so would be nice to get rid of them.
Let me know if you would like a PR or just handle them on your end when time permits.

Commenting out the parameter name should do for those:

hello_imgui\hello_imgui_cmake\HelloImGui_WinMain.cpp(7): warning C4100: 'nCmdShow': unreferenced formal parameter
hello_imgui\hello_imgui_cmake\HelloImGui_WinMain.cpp(7): warning C4100: 'lpCmdLine': unreferenced formal parameter
hello_imgui\hello_imgui_cmake\HelloImGui_WinMain.cpp(7): warning C4100: 'hPrevInstance': unreferenced formal parameter
hello_imgui\hello_imgui_cmake\HelloImGui_WinMain.cpp(7): warning C4100: 'hInstance': unreferenced formal parameter
hello_imgui\internal\backend_impls\backend_window_helper\glfw_window_helper.cpp(14): warning C4100: 'backendOptions': unreferenced formal parameter

Not sure about that one:

hello_imgui\internal\backend_impls\backend_window_helper\glfw_window_helper.cpp(9): warning C4505: 'HelloImGui::BackendApi::glfw_error_callback': unreferenced function with internal linkage has been removed

That one is probably a release vs debug thing: the value is used by an assert macro that does not do anything in release.

hello_imgui\internal\backend_impls\runner_glfw_opengl3.cpp(42): warning C4189: 'glfwInitSuccess': local variable is initialized but not referenced

A static_cast should be ok for that one (although that's 3rd party code):

hello_imgui\src\hello_imgui\..\hello_imgui/internal/pnm.h(1046): warning C4267: 'argument': conversion from 'size_t' to 'const uint8_t', possible loss of data

Build failure in MinGW 8.1

An issue in the file "hello_imgui/internal/backend_impls/backend_window_helper/window_geometry_helper.cpp"
Unnecessary include:
#include <filesystem>
Causes build failure when compiling with MinGW 8.1
That's because MinGW 8.1 has a known bug where including causes a build failure: https://stackoverflow.com/a/56493176/7753444

Also requires adding this line
set(HELLOIMGUI_WIN32_EXECUTABLE OFF)
and only then
include(hello_imgui_add_app)
because otherwise the build fails with a linker error:

[build] [ 98%] Linking CXX executable hello_world.exe
[build] G__~1.EXE: error: /SUBSYSTEM:WINDOWS: No such file or directory
[build] G__~1.EXE: error: /ENTRY:mainCRTStartup: No such file or directory

That's because the correct compiler flag for MinGW to compile an executable without a console is:
target_link_options(Main PRIVATE -Wl,--subsystem,windows) # The two options are: windows, console

With those two fixes, the build succeeds.
I now created a poll request that fixes the issue
#31 (comment)

Initial Draw Sequence

Upon launching my the hello_imgui powered version of my app I am seeing the main window appear in two steps, which does not look great. I am trying to understand where that's coming from.
I am still on Windows.

For a split second I first see this:
image

That's after the first call to ShowGui() callback.

And then it becomes:
image

Interestingly both the position of the window on the screen and the window size change (and that can't be told from the images above).
It seems that there is a first rendering pass of just the empty main window and then it picks up the dock spaces contents and somehow relocates the window (my code is not attempting any resize/change of position).

When should ImageGl be destructed?

If I use HelloImGui::ImageGl, when am I supposed to destruct the object? It's currently happening when the program exits, but it seems like (on Linux at least) this is too late as glDeleteTextures is pointing to invalid memory.

GL version

Running the imgui_example_glfw_opengl3.py demo, when I print:
print(GL.glGetString(GL.GL_VERSION)) I get 4.6.0 NVIDIA...
But, when I run any immapp or hello_imgui demo, I get:
3.3.0 NVIDIA...

I would like to use immap, but how would I use the latest OpenGL on my machine?

Thanks,
Nick

glfw callback chaincalls

I am trying to add my own callbacks to hello_imgui's glfw window. There is an order issue here however. I've been modifying the heart haiku, this is the state i am in now. With this, any mouse click interaction with the gui is not possible, mouse clicks are not received. This is not strange, since the glfw backend's callback has been replaced by mine.

import time
import numpy as np

from imgui_bundle import implot, imgui_knobs, imgui, immapp, hello_imgui, glfw_window_hello_imgui
import glfw

# Fill x and y whose plot is a heart
vals = np.arange(0, np.pi * 2, 0.01)
x = np.power(np.sin(vals), 3) * 16
y = 13 * np.cos(vals) - 5 * np.cos(2 * vals) - 2 * np.cos(3 * vals) - np.cos(4 * vals)
# Heart pulse rate and time tracking
phase = 0
t0 = time.time() + 0.2
heart_pulse_rate = 80


def gui():
    global heart_pulse_rate, phase, t0, x, y
    # Make sure that the animation is smooth
    #hello_imgui.get_runner_params().fps_idling.enable_idling = False

    t = time.time()
    phase += (t - t0) * heart_pulse_rate / (np.pi * 2)
    k = 0.8 + 0.1 * np.cos(phase)
    t0 = t

    imgui.text("Bloat free code")
    implot.begin_plot("Heart", immapp.em_to_vec2(21, 21))
    implot.plot_line("", x * k, y * k)
    implot.end_plot()

    _, heart_pulse_rate = imgui_knobs.knob("Pulse", heart_pulse_rate, 30, 180)

def post_init():
    print(hello_imgui.get_runner_params().backend_pointers.glfw_window)
    #print(hello_imgui.get_glfw_window())
    print(glfw_window_hello_imgui())

    window = glfw_window_hello_imgui()

    # define a callback
    def my_window_size_callback(window: glfw._GLFWwindow, w: int, h: int):
        print(f"Window size changed to {w}x{h}")
    def my_mouse_button_callback(window: glfw._GLFWwindow, w: int, h: int, c: int):
        print(f"Mouse button")

    glfw.set_window_size_callback(window, my_window_size_callback)
    glfw.set_mouse_button_callback(window, my_mouse_button_callback)

if __name__ == "__main__":

    params = hello_imgui.RunnerParams()
    params.app_window_params.window_geometry.size = (300,450)
    params.app_window_params.window_title = window_title="Hello!"
    params.fps_idling.fps_idle = 0
    params.callbacks.show_gui = gui
    params.callbacks.post_init = post_init

    add_params = immapp.AddOnsParams()
    add_params.with_implot = True

    immapp.run(params, add_params)

The thing is, user callbacks need to be set before the glfw backend is initialized (see ImGui_ImplGlfw_InstallCallbacks). This from code not using hello_imgui works fine:

# set our own callbacks before calling
# imgui.backends.glfw_init_for_open_gl(), then imgui's
# glfw backend will chaincall them
glfw.set_char_callback(self.window, self.char_callback)
glfw.set_window_focus_callback(self.window, self.focus_callback)
glfw.set_window_pos_callback(self.window, self.pos_callback)
glfw.set_drop_callback(self.window, self.drop_callback)

# transfer the window address to imgui.backends.glfw_init_for_open_gl
import ctypes
window_address = ctypes.cast(self.window, ctypes.c_void_p).value
imgui.backends.glfw_init_for_open_gl(window_address, True)
imgui.backends.opengl3_init("#version 150")
glfw.swap_interval(globals.settings.vsync_ratio)

Could hello_imgui support this? Perhaps another callback is needed here, for in between glfw window being created and glfw_init_for_open_gl being called?

And a small question:
Should i still set fps_idling.enable_idling = False when i already set fps_idling.fps_idle = 0, or are they equivalent? Your haiku demo does both.

Copy Paste in emscripten

Tested the webapp on ChromeOS everything worked great. Resize is clean anti-alias is great. However, copy/paste did not seem to work at all. I don't know if this is a feature of your wrapper or something on my side. But Thought it would be good to report.

Docking Demo Keyboard Input Problems

On Chrome it seams that the Classic and Docking Demos differ in their keyboard input...

Things that work in the Classic Demo and Not in Docking Demo:

  • ioConfigFlags: NavEnabledKeyboard
  • Backspace / Back Delete
  • Ctrl+A / Select All
  • Ctrl+X / Cut
  • Ctrl+V / Paste
  • Ctrl-C / Copy

Since both are built from the same docking branch I'm confused as to why one would work and the other not...

Thought it was worth a report.

To duplicate go to the Dear Imgui Demo > Configuration and enable ioConfigFlags: NavEnableKeyboard and press down / up / space. After turning this off you can go to Dear Imgui Demo > Widgets > Basic. Type "asdf, Ctrl+A, Ctrl+X, Ctrl+VV, Backspace, Ctrl+C, Ctrl+VV...

This all works fine on the Classic demo but not on the Docking demo... Weird!

cannot run GUI from separate Python thread

I am trying to run my hello_imgui gui in a separate Python thread, but it seems hello_imgui.run isn't able to do so on Mac OS. This code works fine on Windows and Linux (Ubuntu 22.04). On Mac OS, post_init is never called, the GUI is never shown, and the process spins eating all my CPU.

This is on an M1 mac, imgui_bundle 0.8.2 (compiled as part of the pip install, guess the wheel is only for the intel mac?), Mac OS 13.1, Python 3.10.9. Edit: just tested on an Intel Mac, same thing happens.

import time
import threading

from imgui_bundle import imgui, hello_imgui
import glfw

should_exit = False
def gui():
    if should_exit:
        print('requesting window close')
        hello_imgui.get_runner_params().app_shall_exit = True


    imgui.text("Bloat free code")

def post_init():
    print('post init')

def thread_fun():
    params = hello_imgui.RunnerParams()
    params.app_window_params.window_geometry.size = (100,200)
    params.app_window_params.window_title = "Hello!"
    params.fps_idling.fps_idle = 0
    params.callbacks.show_gui = gui
    params.callbacks.post_init = post_init

    print('lets go')
    hello_imgui.run(params)

if __name__ == "__main__":
    if True:
        thread = threading.Thread(target=thread_fun)
        thread.start()

        time.sleep(6)
        print('window should close')
        should_exit = True

        thread.join()
    else:
        thread_fun()

creating multiple windows without docking

I like the convenience hello_imgui provides as well as its extra features (autosize, etc).

I needed more than one window in my program, so i tried to find out how to do that with hello_imgui. Turns out i can (kinda ab-)use the docking support for that. See lines 140-164 in the diff of _image_gui.py here dcnieho/glassesValidator@6982233. That gives me nice windows with native decorations for additional windows. At least on Windows, didn't test further yet.

I did however lose a lot of the hello_imgui features in the process for the additional windows: e.g. autosizing and such only works for the main window. And the fact that just about all in the docking support can be used without docking, makes it seem like docking is a bit of a misnomer. It suggests a (possibly significant) API change. I haven't fully thought this through:

  • default case as is, use just has a single window and API is as is. This is a light abstraction from the more involved way:
  • user has one or multiple windows. There is a settings struct per window (like you have for docking windows now) as well as runner parameters per window. So i can set e.g. resize_app_window_at_next_frame and all the window geometry stuff on a specific window, the main window is not special. params.docking_params.dockable_windows would become something like just params.windows
  • docking is some additional logic, where windows can be flagged as either host or dockable (if thats how it works, i'm hardly familiar with imgui docking). Thats only a few fields besides the many more per window fields that are for window setup whether docking or not.
  • Ideally it would be possible to create new windows at any time. You can envision users sometimes needed to use a second window for a while, e.g. to preview the effect of some image processing settings they did in some GUI (some random example).
  • There is the problem that it seems to be not possible to set your own user callbacks on newly created platform windows with the glfw backend, but thats an dear imgui problem. Or yeah, it would be possible, but the user would have to do their own chaincalling of imgui callbacks instead of the backend handling that nicely. Just an FYI, not your problem. I didn't end up needing it.

Font memory deallocation problem

The user loaded fonts throw an exception in debug mode on windows 10.

ucrtbased.dll!00007ffc46341bc0() (Unknown Source:0)
ucrtbased.dll!00007ffc463451c5() (Unknown Source:0)
ucrtbased.dll!00007ffc463458c8() (Unknown Source:0)
hello.exe!FreeWrapper(void * ptr, void * user_data) Line 1019 (hello_imgui\external\imgui\imgui.cpp:1019)
:288)
static void    FreeWrapper(void* ptr, void* user_data)        { IM_UNUSED(user_data); free(ptr); }

Building Android

How do you build this? I ran the SDL.sh first, then the cmake_arm7.sh, but I don't get a Android Studio project of IMGUI. It always shows an error that CMakeLists.txt(error7).

More FontAwesome options

The FontAwesome feature could use a couple new features.

A locked glyph size will allow for menu items to align nicely in vertical menus, giving icons all the same width. Here's an example I use in one of my projects:

config.GlyphMinAdvanceX = 18;
config.GlyphMaxAdvanceX = 18;

Also, exposing MergeFontAwesomeToLastFont to the public API will allow using a custom font size, which can in some times be beneficial. For example, in my case, having the icon font be 1 pixel smaller fixes an issue in multi-line text fields where icons will blend into each other if they're right underneath other icons on the next line. (And they kinda align better in menu bars if they're 1 pixel smaller than the main font.)

Docking feature and persisted window layout

One thing with Docking is not super clear yet: what's the 'right' (as in idiomatic) way to load the layout from the *.ini file that persists user modifications to the layout, after closing and reopening the application?

Right now on startup I populate dockingParams.dockableWindows programmatically every time so it gets rid of whatever customization was made the previous time the app was run.

Also, would be nice to have a way to customize the name of the ini file (imgui.ini is not appropriate in the presence of several co-existing imgui-based apps).
I have done it before with:

ImGuiIO& io = ImGui::GetIO();
io.IniFilename = ...;

but maybe you want to expose that in the RunnerParams ?

Two questions about HELLOIMGUI_USE_SDL_DIRECTX11 and ImGuiConfigFlags_ViewportsEnable

Hello. I have two questions.

  1. What is HELLOIMGUI_USE_SDL_DIRECTX11 for? It does build but there is no such a backend so FactorRunner emits an exception.
  2. I have uncommented io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; line in void SetupDefaultImGuiConfig() and the hello_world.exe application window content gets stuck to the upper left corner of the primary monitor (I have two monitors). I can move the application window and resize it. The content resizes but does not move. May it be fixed?
    The hello_imgui_demodocking.exe is kind of works but the behavior of the fps line is strange (it is stuck to a constant position too). hello_imgui_demo_minimal.exe behaves the same way as described in (2). hello_imgui_demo_classic.exe work normally (at least I have not noticed an unusual behavior).

Operator"" _str compilation error

I am trying to compile my app against hello_imgui checked-out as a submodule on Windows.
I am surprised it's complaining out of the box about the following statement in pnm.h :
using detail::literals::operator"" _str;

"C:\PROGRA~1\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx86\x64\cl.exe"  /nologo /TP  -DHELLOIMGUI_HAS_OPENGL -DHELLOIMGUI_USE_GLAD -DHELLOIMGUI_USE_GLFW -DHELLOIMGUI_USE_GLFW_OPENGL3 -DIMGUI_IMPL_OPENGL_LOADER_GLAD -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -IC:\...\extern\imlibs\hello_imgui\src\hello_imgui -IC:\...\extern\imlibs\hello_imgui\src\hello_imgui\.. -IC:\...\extern\imlibs\hello_imgui\external\imgui -IC:\...\cmake-build-debug-visual-studio\_deps\glfw-src\include -IC:\...\extern\imlibs\hello_imgui\external\SYSTEM -IC:\...\extern\imlibs\hello_imgui\external\OpenGL_Loaders\glad\include /DWIN32 /D_WINDOWS  /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /W4 /Zc:preprocessor /permissive- -D_CRT_SECURE_NO_WARNINGS -std:c++17 /showIncludes /Foextern\imlibs\hello_imgui\src\hello_imgui\CMakeFiles\hello_imgui.dir\internal\backend_impls\opengl_setup_helper\opengl_screenshot.cpp.obj /Fdextern\imlibs\hello_imgui\src\hello_imgui\CMakeFiles\hello_imgui.dir\hello_imgui.pdb /FS -c C:\...\extern\imlibs\hello_imgui\src\hello_imgui\internal\backend_impls\opengl_setup_helper\opengl_screenshot.cpp
C:\...\extern\imlibs\hello_imgui\src\hello_imgui/internal/pnm.h(1046): warning C4267: 'argument': conversion from 'size_t' to 'const uint8_t', possible loss of data```
C:\...\extern\imlibs\hello_imgui\src\hello_imgui/internal/pnm.h(1076): error C3688: invalid literal suffix '_str'; literal operator or literal operator template 'operator ""_str' not found

I haven't found authoritative info about the proper way to import literal operators but I tried locally replacing the using statements with:
using namespace details::literals and that makes the error go away.

  1. could I be hitting a cross platform glitch? Am I missing a compiler flag or something?
  2. c++ 14 has std::literals::string_literals::operator""s - why not use that one instead by the way? Is there a commitment to not exceeding c++11 compat ?

'SDL_FLASH_UNTIL_FOCUSED': undeclared identifier

Hi,
Make compile on windos, is get this error can make help?
\hello_imgui\internal\backend_impls\backend_window_helper\sdl_window_helper.cpp(145,36): error C2065: 'SDL_FLASH_UNTIL_FOCUSED': undeclared identifier

Thanks you

IDBFS Support

I am trying to implement support for IDBFS for Emscripten. Emscripten by default does not include IDBFS and we have to include it by -lidbfs.js.

I've been struggling to include it - granted I am not great with CMake yet. If anyone is able to help me resolve this, that would be great!

My CMake is essentially the same as the example integration file with almost zero changes (just listing include dirs and source files).
This is what I tried to do:

if (EMSCRIPTEN)
    add_link_options(-lidbfs.js)
endif()

Exception (and thread) safety/awareness of hello_imgui question

Hello. Imgui itself is not exception safe or exceptions aware but I know how to deal with this mainly C code. What is about hello_imgui? I consider it as a kind of window management system for Imgui that hides some its mechanics so I must be sure I may or may not use exceptions with hello_imgui.
Sorry for the noob question but it is a blocker for me so I want to be sure about the facts, approaches and plans. Thank you.

P.S. It would be worth to mention about thread safety/awareness too.

android: fix build

I assume that line testedPaths.push_back(assetPath); is a residual from tests.
It breaks android build.

 /home/vin/git/hello_imgui/build_android/hello_imgui_demodocking_AndroidStudio/app/jni/hello_imgui_subrepo/src/hello_imgui/internal/hello_imgui_assets.cpp:179:9: error: use of undeclared identifier 'testedPaths'
          testedPaths.push_back(assetPath);
          ^
  1 error generated.
  ninja: build stopped: subcommand failed.

requrest:How to know which dockspace is currently active

I have two pages. click first or second .Display different page layouts
image

leftspack***####firstspace############################
**************#######################################
**************#######################################
**************#######################################
**************#######################################
**************#######################################
**************#######################################
**************#######################################

####secondspace###################################
#################################################
#################################################
#################################################
#################################################
bottomspace***************************************************





hello_imgui iOS and Android canvas rendering

Hi pthom!

I have an issue with rendering using your imgui libray.

The application works great, and I used your imgui_manual project for source code hacking too :P but I have an issue when I am trying to draw in the background GL canvas, behind imGui on mobile phones. This issue is reproducible even on Firefox mobile emulation, like iOS 6, etc. It occurs on all mobile devices as far as I can tell.

Browser:
Chrome/Firefox

Steps to Reproduce:

  1. Open new browser tab or window
  2. open DevTools console (F12 is standard binding)
  3. Open link https://jrpc.pl (You need to open Dev Tools first, as once the app is loaded you can't use the F12 binding anymore - my app catches and overrides that binding - you can still open DevTools normally through browser interface however that's a hassle :P)
  4. Go to mobile emulation in Google Chrome or Firefox (I haven't tested other browsers)
  5. enable mobile emulation and test the different options

Expected Result:
The jrpc.pl website should load the same as on Desktop monitors/computers

Actual Behaviour:
The background canvas behind the imgui interface is scaled down and placed in the bottom left corner. This applies to all browser tests and physical device tests I performed on iOS (iPhone6s) and Android (Blackberry Key2)

👋👋,CMake can't find the source files:

Hello! I want to make the sources in Ubuntu22.10,and i ran into a problem🥵🥵
I'm very sorry I came for your help.

CMake Error at external/CMakeLists.txt:33 (add_library):
  Cannot find source file:

    /home/zhouzihao/MYFILE/imgui_learning1/hello_imgui/external/imgui/misc/cpp/imgui_stdlib.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc


CMake Error at src/hello_imgui/CMakeLists.txt:11 (add_library):
  Cannot find source file:

    /home/zhouzihao/MYFILE/imgui_learning1/hello_imgui/external/imgui/backends/imgui_impl_opengl3.h

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc


CMake Error at external/CMakeLists.txt:33 (add_library):
  No SOURCES given to target: imgui

I cd to this path ,and I can't find these sources.
ps.I use these commands to make CMake file

mkdir build && cd build && cmake .. && cmake --build . -j 4
./hello_world

Emscripten multithread compile options

I would like to start experimenting with an emscripten build of my app (that was part of the original draw to hello_imgui as I was able to bring up the minimal example hello_imgui_app on a localhost server so quickly).
My imgui application uses std::thread and my understanding is I need to turn on a number of additional compilation flags like -pthread and -sASYNCIFY.
I am struggling to find where these should go in the current hello_imgui setup.

I see the following comment in hello_imgui_emscripten.cmake:

# hello_imgui_emscripten_target_compile_options needs fix!
# For the moment, these options are global via hello_imgui_emscripten_global_options.cmake
# function(hello_imgui_emscripten_target_compile_options target_name)
#     target_compile_options(
#         ${target_name} 
#         PUBLIC
#         "SHELL:-s USE_SDL=2"
#         "SHELL:-s USE_WEBGL2=1"
#         "SHELL:-s WASM=1" 
#         "SHELL:-s FULL_ES3=1"
#         "SHELL:-s ALLOW_MEMORY_GROWTH=1"
#     )
# endfunction()

Is the idea to add something like

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -sASYNCIFY")

in hello_imgui_emscripten_global_options.cmake ?

I can't seem to marry the settings working on e.g. this sample emscripten with threads project :
https://github.com/jiulongw/emscripten-mutex-test/blob/main/run
to the hello_imgui cmake framework.

The minimal example I am working with is:

#include "hello_imgui/hello_imgui.h"
#include <thread>

int main(int , char *[]) {

  std::thread thread([]{}); // should run, do nothing and exit.

  HelloImGui::Run(
          [] { ImGui::Text("%s", "Hello World!"); }, // Gui code
          "Hello!",                            // Window title
          true                                 // Window size auto
  );

}

It compiles but doesn't display anything in the browser (if I comment out the thread line, it's basically the hello_imgui_app and it works).

Please set apkCMake_ndkDir

-- Library hello_imgui
VERBOSEhello_imgui_bundle_assets_from_folder hello_imgui_demo_minimal /home/hi/hello_imgui/build_android/src/hello_imgui_demos/hello_imgui_demo_minimal/tmp/common_assets
-- apkCMake_makeAndroidStudioProject hello_imgui_demo_minimal
    > apkCMake_projectTemplateFolder=/home/hi/hello_imgui/hello_imgui_cmake/android/apkCMake/templates/sdl
    > ANDROID_HOME=/home/hi/android-sdk-linux/
    > apkCMake_sdkDir=/home/hi/android-sdk-linux/
CMake Error at hello_imgui_cmake/android/apkCMake/apkCMake.cmake:35 (message):
  Please set apkCMake_ndkDir
Call Stack (most recent call first):
  hello_imgui_cmake/android/apkCMake/apkCMake.cmake:73 (apkCMake_fillAndroidSdkVariables)
  hello_imgui_cmake/android/apkCMake/apkCMake.cmake:215 (apkCMake_fillVariables)
  hello_imgui_cmake/hello_imgui_add_app.cmake:60 (apkCMake_makeAndroidStudioProject)
  hello_imgui_cmake/hello_imgui_add_app.cmake:84 (hello_imgui_prepare_app)
  src/hello_imgui_demos/hello_imgui_demo_minimal/CMakeLists.txt:2 (hello_imgui_add_app)


-- Configuring incomplete, errors occurred!

resizing window

I have a window whose size i only know later, not on the first or the second frame. I need some advice how to deal with this with hello_imgui using Python. My window is real simple, it just has an image (imgui.image()) to show. I have the following questions:

  1. How to size my window such that is has the size of the image, taking into account DPI scaling of the monitor? I think that app_window_params.window_geometry.window_size_measure_mode = hello_imgui.WindowSizeMeasureMode.relative_to96_ppi is key here, right?
  2. How to only size the window once its size is know? The first image to show may arrive seconds after the window has been created. I tried hiding the window (glfw.hide_window) in post_init and only showing it once the image is about to be drawn for the first time. Can i invoke the sizing (and positioning) logic at a later time instead of only at window creation?`
  3. Ideally i'd like the logic to scale the window to 100% image size if that fits on the monitor, else to clamp the window size down to the monitor size while maintaining aspect ratio. Is that possible?

Shortcuts or key events API

There should be a convenient way of handling shortcuts. Right now there is AnyBackendEventCallback which would technically allow me to make shortcuts work, but it's backend-dependent and so any code handled by that would be kind of weird to work with.

Perhaps there could be an event specifically for passing through key down/up events?

Edit: Actually, perhaps ImGui::IsKeyDown and ImGui::IsKeyPressed would work just fine for this, so this might not even be completely necessary! Maybe I jumped the gun a bit too quick with a github issue 😳

An api which can help us get assets folder path

An New API

Source(In hello_imgui_assets.cpp)

    std::string GetAssetFolderPath() {
        std::string a = FileUtils::GetCurrentDirectory();
#if defined(__ANDROID__)
        a+="/";
#else
        a += "\\";
#endif
        a += gAssetsSubfolderFolderName;
        return a;
    }

How to use

    ImGui::Text("%s", HelloImGui::GetAssetFolderPath().c_str());

Photo

Photo

some linux issues

my system: arch linux, dell xps 13

desktop: SDL opengl:
issue: can't build with SDL2::SDL2-static
my workaround: build with SDL2::SDL2

android:
issue: assets are not automatically copied
workaround: manually copy assets to app/src/main

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.