How to design page navigation system using ImGui

182 Views Asked by At

I am trying to build a desktop application using ImGui. How do I design a page navigation system to be able to switch between pages. I have an application class and a page class with specific pages derived from it. The application class has a method which registers all pages class into list of pages container or structure. The application class has a pointer to a current page. I want the page class to inform the application class to switch to another page from the current page when a button is clicked or an event of occurs.

1

There are 1 best solutions below

0
On

I just made such a simple system for in-app help/documentation.

I specify the pages in a very simple format, read from a text file. Each page has an identifier or label, for example "Page0", and some content(title, sections, images, buttons, etc). All these pages are put into a map [label, shared_pointer_to_contents]. Then I have a current_page pointer, initially the first entry, if "MainPage" or similar does not exist. Navigation is done simply by using buttons, so the content for that is in the lines of:

if (ImGui::Button(text))
     currentPage = FindPage(label);

It was pretty easy to get up and running.

enter image description here