Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more IMGUI widgets for GGUI #3013

Open
AmesingFlank opened this issue Sep 26, 2021 · 8 comments
Open

Add more IMGUI widgets for GGUI #3013

AmesingFlank opened this issue Sep 26, 2021 · 8 comments
Labels
feature request Suggest an idea on this project gui GUI & GGUI medium Medium level difficulty, give it a shot :-) welcome contribution

Comments

@AmesingFlank
Copy link
Collaborator

Concisely describe the proposed feature
Currently, GGUI only supports 5 basic widgets (text,button,check_box,slider_float,color_edit_3). It would be nice to have support for more complicated widgets such as drop-down menus, menu bars, etc.

Describe the solution you'd like (if any)
GGUI uses dear imgui internally. It's quite simple to write a wrapper for a widget. Take button for example, here are all the relevant code:

virtual bool button(std::string text) = 0;

virtual bool button(std::string text) override;

bool Gui::button(std::string text) {
if (!initialized()) {
return false;
}
return ImGui::Button(text.c_str());
}

bool button(std::string name) {
return gui->button(name);
}

def button(self, text):
"""Declares a button, and returns whether or not it had just been clicked.
Args:
text (str): a line of text to be shown next to the button
"""
return self.gui.button(text)

@AmesingFlank AmesingFlank added feature request Suggest an idea on this project good first issue A great chance for starters gui GUI & GGUI labels Sep 26, 2021
@gaocegege
Copy link
Collaborator

Hi, I am new to Taichi and glad to help improve it.

I will start from an easy widget, maybe colored text. But I do not want to dibs the whole issue. Other people can also work on it since there are so many widgets in dear imgui, if I have understood well.

@gaocegege
Copy link
Collaborator

Additional info for the issue:

python ./examples/ggui_examples/fem128_ggui.py
[Taichi] version 0.8.1, llvm 10.0.0, commit cc2dd342, osx, python 3.7.9
[Taichi] Starting on arch=metal
Traceback (most recent call last):
  File "./examples/ggui_examples/fem128_ggui.py", line 95, in <module>
    window = ti.ui.Window('FEM128', (512, 512))
  File "/Users/gaocedidi/code/taichi/python/taichi/ui/ui.py", line 30, in __init__
    err_no_ggui()
  File "/Users/gaocedidi/code/taichi/python/taichi/ui/ui.py", line 26, in err_no_ggui
    raise Exception("GGUI Not Available")
Exception: GGUI Not Availabl

@gaocegege
Copy link
Collaborator

@AmesingFlank Hi, it seems that there is only the Vulkan backend for GGUI, then why do we need to enable CUDA to compile GGUI here? https://github.com/taichi-dev/taichi/blob/master/cmake/TaichiCore.cmake#L36

set(TI_WITH_GGUI OFF)
if(TI_WITH_CUDA AND TI_WITH_VULKAN)
    set(TI_WITH_GGUI ON)
endif()

@AmesingFlank
Copy link
Collaborator Author

@AmesingFlank Hi, it seems that there is only the Vulkan backend for GGUI, then why do we need to enable CUDA to compile GGUI here? https://github.com/taichi-dev/taichi/blob/master/cmake/TaichiCore.cmake#L36

set(TI_WITH_GGUI OFF)
if(TI_WITH_CUDA AND TI_WITH_VULKAN)
    set(TI_WITH_GGUI ON)
endif()

Currently, the Vulkan backend for GGUI is only works with the CUDA/x64 compute backend of taichi. That is, you need ti.init(arch=ti.cuda) or ti.init(arch=ti.x64) for GGUI to work. This will be changed in the near future, as we are planning support for GGUI to work with other compute backends such as Vulkan itself and OpenGL.

@gaocegege
Copy link
Collaborator

OK, get it.

Thanks for your reply.

@k-ye k-ye added welcome contribution medium Medium level difficulty, give it a shot :-) and removed good first issue A great chance for starters labels Oct 19, 2021
@gaocegege
Copy link
Collaborator

Hi @AmesingFlank

Do we have tests for GGUI? I am trying to add some new test cases for the widget, but I did not find any.

@AmesingFlank
Copy link
Collaborator Author

Hi @AmesingFlank

Do we have tests for GGUI? I am trying to add some new test cases for the widget, but I did not find any.

We don't, adding tests for GGUI is on the top of my to-do list right now, but I just haven't found the time to do it :((

@gaocegege
Copy link
Collaborator

gaocegege commented Nov 3, 2021

I am trying to add a colored text widget. You can take it as an example https://github.com/taichi-dev/taichi/pull/3078/files about how to add a new GGUI widget in Taichi. There are so many widgets not supported now. Welcome contributions!

I am unassigning myself since it is an umbrella issue.

@gaocegege gaocegege removed their assignment Nov 3, 2021
bobcao3 pushed a commit that referenced this issue Jan 4, 2023
Issue: #3013

### Brief Summary

Implementing colored texts:
```py
window = ti.ui.Window('Window', (768, 768),
                        vsync=True)
canvas = window.get_canvas()
gui = window.get_gui()
while window.running:
    with gui.sub_window("Yo", 0.05, 0.05, 0.9, 0.2) as w:
        w.text("haha", (1.0,0.2,0.3))
    window.show()
```
<img width="767" alt="Screenshot 2023-01-03 at 20 07 11"
src="https://user-images.githubusercontent.com/16066115/210433302-e58fbc41-5331-4904-ae10-65f60e0b3446.png">

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
feisuzhu pushed a commit to feisuzhu/taichi that referenced this issue Jan 5, 2023
Issue: taichi-dev#3013

### Brief Summary

Implementing colored texts:
```py
window = ti.ui.Window('Window', (768, 768),
                        vsync=True)
canvas = window.get_canvas()
gui = window.get_gui()
while window.running:
    with gui.sub_window("Yo", 0.05, 0.05, 0.9, 0.2) as w:
        w.text("haha", (1.0,0.2,0.3))
    window.show()
```
<img width="767" alt="Screenshot 2023-01-03 at 20 07 11"
src="https://user-images.githubusercontent.com/16066115/210433302-e58fbc41-5331-4904-ae10-65f60e0b3446.png">

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
Issue: taichi-dev#3013

### Brief Summary

Implementing colored texts:
```py
window = ti.ui.Window('Window', (768, 768),
                        vsync=True)
canvas = window.get_canvas()
gui = window.get_gui()
while window.running:
    with gui.sub_window("Yo", 0.05, 0.05, 0.9, 0.2) as w:
        w.text("haha", (1.0,0.2,0.3))
    window.show()
```
<img width="767" alt="Screenshot 2023-01-03 at 20 07 11"
src="https://user-images.githubusercontent.com/16066115/210433302-e58fbc41-5331-4904-ae10-65f60e0b3446.png">

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Suggest an idea on this project gui GUI & GGUI medium Medium level difficulty, give it a shot :-) welcome contribution
Projects
None yet
Development

No branches or pull requests

3 participants