Skip to content

Commit

Permalink
Add doc / app settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 5, 2023
1 parent ac4f0bf commit 04bd70d
Show file tree
Hide file tree
Showing 19 changed files with 541 additions and 129 deletions.
41 changes: 23 additions & 18 deletions bindings/imgui_bundle/demos_cpp/demos_immapp/demo_docking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,20 +480,17 @@ int main(int, char**)
{
ChdirBesideAssetsFolder();

//###############################################################################################
// Part 1: Define the application state, fill the status and menu bars, and load additional font
//###############################################################################################
//#############################################################################################
// Part 1: Define the application state, fill the status and menu bars, load additional font
//#############################################################################################

// Our application state
AppState appState;

// Hello ImGui params (they hold the settings as well as the Gui callbacks)
HelloImGui::RunnerParams runnerParams;

// Note: by setting the window title, we also set the name of the ini files in which the settings for the user
// layout will be stored: Docking_demo.ini
runnerParams.appWindowParams.windowTitle = "Docking demo";

runnerParams.imGuiWindowParams.menuAppTitle = "Docking App";
runnerParams.appWindowParams.windowGeometry.size = {1000, 900};
runnerParams.appWindowParams.restorePreviousGeometry = true;
Expand Down Expand Up @@ -525,9 +522,9 @@ int main(int, char**)
runnerParams.callbacks.PostInit = [&appState] { LoadMyAppSettings(appState);};
runnerParams.callbacks.BeforeExit = [&appState] { SaveMyAppSettings(appState);};

//###############################################################################################
//#############################################################################################
// Part 2: Define the application layout and windows
//###############################################################################################
//#############################################################################################

// First, tell HelloImGui that we want full screen dock space (this will create "MainDockSpace")
runnerParams.imGuiWindowParams.defaultImGuiWindowType = HelloImGui::DefaultImGuiWindowType::ProvideFullScreenDockSpace;
Expand All @@ -542,32 +539,40 @@ int main(int, char**)
// (otherwise, modifications to the layout applied by the user layout will be remembered)
// runnerParams.dockingParams.layoutCondition = HelloImGui::DockingLayoutCondition::ApplicationStart;

//###############################################################################################
//#############################################################################################
// Part 3: Where to save the app settings
//###############################################################################################
// By default, HelloImGui will save the settings in the current folder. This is convenient when developing,
// but not so much when deploying the app.
// You can tell HelloImGui to save the settings in a specific folder: choose between
//#############################################################################################
// tag::app_settings[]
// By default, HelloImGui will save the settings in the current folder.
// This is convenient when developing, but not so much when deploying the app.
// You can tell HelloImGui to save the settings in a specific folder: choose between
// CurrentFolder
// AppUserConfigFolder
// AppExecutableFolder
// HomeFolder
// TempFolder
// DocumentsFolder
//
// Note: AppUserConfigFolder is:
// Note: AppUserConfigFolder is:
// AppData under Windows (Example: C:\Users\[Username]\AppData\Roaming)
// ~/.config under Linux
// "~/Library/Application Support" under macOS or iOS
runnerParams.iniFolderType = HelloImGui::IniFolderType::AppUserConfigFolder;
// This will be the name of the ini file in which the settings will be stored
// The subdirectory Docking_Demo will be created under the folder defined by runnerParams.iniFolderType

// runnerParams.iniFilename: this will be the name of the ini file in which the settings
// will be stored.
// In this example, the subdirectory Docking_Demo will be created under the folder defined
// by runnerParams.iniFolderType.
//
// Note: if iniFilename is left empty, the name of the ini file will be derived
// from appWindowParams.windowTitle
runnerParams.iniFilename = "Docking_Demo/Docking_demo.ini";
// end::app_settings[]


//###############################################################################################
//#############################################################################################
// Part 4: Run the app
//###############################################################################################
//#############################################################################################
HelloImGui::Run(runnerParams); // Note: with ImGuiBundle, it is also possible to use ImmApp::Run(...)


Expand Down
27 changes: 17 additions & 10 deletions bindings/imgui_bundle/demos_python/demos_immapp/demo_docking.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,6 @@ def main():

# Hello ImGui params (they hold the settings as well as the Gui callbacks)
runner_params = hello_imgui.RunnerParams()

# Note: by setting the window title, we also set the name of the ini files in which the settings for the user
# layout will be stored: Docking_demo.ini
runner_params.app_window_params.window_title = "Docking demo"

runner_params.imgui_window_params.menu_app_title = "Docking App"
Expand All @@ -547,7 +544,7 @@ def main():
runner_params.imgui_window_params.show_menu_bar = (
True # We use the default menu of Hello ImGui
)
# fill callbacks ShowMenuGui and ShowAppMenuItems, to add items to the default menu and to the App menu
# fill callbacks ShowMenuGui and ShowAppMenuItems, to add items to the default menu & App menu
runner_params.callbacks.show_menus = show_menu_gui
runner_params.callbacks.show_app_menu_items = show_app_menu_items

Expand All @@ -565,8 +562,8 @@ def main():
runner_params.imgui_window_params.default_imgui_window_type = (
hello_imgui.DefaultImGuiWindowType.provide_full_screen_dock_space
)
# In this demo, we also demonstrate multiple viewports: you can drag windows outside out the main window
# in order to put their content into new native windows
# In this demo, we also demonstrate multiple viewports: you can drag windows outside
# out the main window in order to put their content into new native windows
runner_params.imgui_window_params.enable_viewports = True
# Set the default layout (this contains the default DockingSplits and DockableWindows)
runner_params.docking_params = create_default_layout(app_state)
Expand All @@ -576,22 +573,32 @@ def main():
#
# Part 3: Where to save the app settings
#
# By default, HelloImGui will save the settings in the current folder. This is convenient when developing,
# but not so much when deploying the app.
# You can tell HelloImGui to save the settings in a specific folder: choose between
# tag::app_settings[]
# By default, HelloImGui will save the settings in the current folder.
# This is convenient when developing, but not so much when deploying the app.
# You can tell HelloImGui to save the settings in a specific folder: choose between
# current_folder
# app_user_config_folder
# app_executable_folder
# home_folder
# temp_folder
# documents_folder
#
# Note: app_user_config_folder is:
# Note: app_user_config_folder is:
# AppData under Windows (Example: C:\Users\[Username]\AppData\Roaming)
# ~/.config under Linux
# "~/Library/Application Support" under macOS or iOS
runner_params.ini_folder_type = hello_imgui.IniFolderType.app_user_config_folder

# runnerParams.ini_filename: this will be the name of the ini file in which the settings
# will be stored.
# In this example, the subdirectory Docking_Demo will be created under the folder defined
# by runnerParams.ini_folder_type.
#
# Note: if ini_filename is left empty, the name of the ini file will be derived
# from app_window_params.window_title
runner_params.ini_filename = "Docking_Demo/Docking_demo.ini"
# end::app_settings[]

#
# Part 4: Run the app
Expand Down
Loading

0 comments on commit 04bd70d

Please sign in to comment.