Skip to content

ProtectedVariable/DearImXML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

Dear ImXML

A lightweight XML to ImGui library

About The Project

Dear ImXML allows you to writer ImGui interfaces in an XML format and render / interact with them at runtime.

For example this XML file

<?xml version="1.0" encoding="UTF-8"?>

<begin name="Title window" flags="ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoCollapse">
	<menubar>
		<menu label="File">
			<menuitem label="New..."/>
			<menu label="Open...">
				<menuitem label="File1.txt" />
			</menu>
		</menu>
		<menu label="Edit">
			<menuitem label="Foo"/>
			<menuitem label="Bar"/>
		</menu>
	</menubar>
	<table name="table0" columns="3">
		<setupcolumn label="Column 0" width="0.33" flags="ImGuiTableColumnFlags_WidthStretch"/>
		<setupcolumn label="Column 1" width="0.33" flags="ImGuiTableColumnFlags_WidthStretch"/>
		<setupcolumn label="Column 2" width="0.33" flags="ImGuiTableColumnFlags_WidthStretch"/>
		<header/>
		<row>
			<column>
				<text label="Text"/>
				<button id="btn0" label="Hello!"/>
				<separatortext label="SeparatorText"/>
				<sliderfloat label="float" dynamic="float0" min="0" max="1" />
				<inputtext label="string" dynamic="str0"/>
			</column>
			<column>
				<treenode label="treeroot">
					<treenode label="tree0" />
					<treenode label="tree1">
						<treenode label="tree2" />
					</treenode>
				</treenode>
				<separator/>
				<group>
					<colorpicker3 dynamic="color0" />
				</group>
				<separator/>
				<group>
					<PopupContextWindow>
						<text label="context popup"/>
					</PopupContextWindow>
					<text label="right click to open popup"/>
				</group>
			</column>
			<column>
				<combo label="Combo" preview_value="Preview" >
					<selectable label="Option 1" selected="true" />
					<selectable label="Option 2" selected="false" />
					<selectable label="Option 3" selected="false" />
					<selectable label="Option 4" selected="false" />
				</combo>
				<inputfloat label="Input float" dynamic="float1" step="0.1" step_fast="0.25" format="%.4f"/>
				<checkbox label="Checkbox" dynamic="bool0"/>
			</column>
		</row>
	</table>
	<child label="Child window">
		<tabbar id="tabbar0">
			<tabitem label="Tab 1">
				<InputTextMultiline label="Sample text" dynamic="str1" />
			</tabitem>
			<tabitem label="Tab 2">
				<InputTextMultiline label="Another Sample text" dynamic="str2" />
			</tabitem>
			<tabitem label="Tab 3">
				<InputTextMultiline label="Yet Another Sample text" dynamic="str3" />
			</tabitem>
		</tabbar>
	</child>
</begin>

Turns into this window (without the gif compression artifacts) Demo gif

Note that the project is at an early phase, not all ImGui elements are supported but it's rapidly being expanded.

(back to top)

Built With

CMake C++

(back to top)

Getting Started

Prerequisites

You will probably need CMake

Installation

If you use CMake you can simply do

message(STATUS "Fetching DearImXML")
include(FetchContent)
FetchContent_Declare(
  DearImXML
  GIT_REPOSITORY https://github.com/ProtectedVariable/DearImXML.git
  GIT_TAG master
)
FetchContent_MakeAvailable(DearImXML)

And then target_link_libraries(${PROJECT_NAME} PUBLIC DearImXML)

This library comes with DearImGui v1.95.2-docking included for convenience, but you still need to add your implementation files e.g:

add_executable(DearImXMLExample
	main.cpp
    includes/GL/gl3w.c
    Backend/ImGUI/imgui_impl_opengl3.cpp
	Backend/ImGUI/imgui_impl_glfw.cpp)

If you wish to use a different version of ImGui, you can set the option IMXML_INTERNAL_IMGUI to OFF and link your own ImGui library.

(back to top)

Usage

The documentation is available in the doc folder of the repo.

Check out the example folder of the repo for a quick example.

You can also check out https://github.com/ProtectedVariable/ICE for a complete application using this library.

(back to top)

Contributing

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the LGPLv2.1 License. See LICENSE for more information.

(back to top)

Contact

Feel free to tag me in an issue :).

(back to top)

Acknowledgments

(back to top)

About

Create ImGui interfaces from a XML file

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages