Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
haddock7 committed Aug 5, 2020
1 parent 451c549 commit 6600ed0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Heaps/HashLink native binding for [Dear ImGui](https://github.com/ocornut/imgui)

## Build & Install
The native extension needs first to be built.
First, the native extension needs to be built.

```
cd extension
Expand All @@ -16,23 +16,23 @@ This commands build a the target `hdll` file, and copy it to the root of the pro
To add this library to your project, you need to include these files:

- The previously compiled `hlimgui.hdll` file.
- `imgui/ImGuiDrawable.hx`: this class derives from the standard Heaps `Drawable` class and contains and displays all ImGui widgets.
- `imgui/ImGuiDrawable.hx`: this class derives from the standard Heaps `Drawable` class and contains/displays all ImGui widgets.
- `imgui/ImGui.hx`: interface to the native extension.

See `Main.hx` to see how to implement this library.

## Supported ImGui features
Most of the ImGui functionalities are supported and binded. Look at [https://github.com/ocornut/imgui](https://github.com/ocornut/imgui) to get documentation on how ImGui works and exposed functions.
Most of the ImGui functionalities are supported and binded. Look at [https://github.com/ocornut/imgui](https://github.com/ocornut/imgui) to get documentation on exposed functions AND how ImGui works.

Here is a list of unsupported features and changes:

- Custom fonts aren't implemented.
- As Haxe doesn't function overloading, so if two original functions have the same name, the second one in Haxe has a suffix `2` to disguish it. For example:
- As Haxe doesn't support function overloading, so if two original functions have the same name, the second one in Haxe has a suffix `2` to disguish it. For example:
```haxe
public static function treeNode(label : String) : Bool {return false;}
public static function treeNode2(str_id : String, label : String) : Bool {return false;}
```
- ImGui has several functions which takes a variable number of parameters in order to format strings. This feature isn't supported in Haxe, so all string formatting must be done in Haxe before passing it to ImGui.
- ImGui has several functions which take a variable number of parameters in order to format strings. This feature isn't supported in Haxe, so all string formatting must be done in Haxe before passing it to ImGui.

- `InputText` function takes a byte buffer as parameter. This needs to be converted to a string like this example:
```haxe
Expand All @@ -45,7 +45,7 @@ if (ImGui.inputText('Text', input_text_buffer, 128)) {
- The function `setIniFilename` doesn't exist in ImGui, it has been added to modify the filename of the default ini file saved by ImGui (pass null to turn off this feature).

## Bugs
I you find bugs, please report them on the GitHub project page. Most of the binded functions have been tested, but as it's a new library some bugs might remain.
If you find bugs, please report them on the GitHub project page. Most of the binded functions have been tested, but as it's a new library some bugs might remain.

## Thanks
I would like to thanks [Aidan63](https://github.com/Aidan63/linc_imgui) for their Haxe/cpp binding. I have borrowed all the structure declaration code which remains the same between the two bindings.
2 changes: 1 addition & 1 deletion extension/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ HL_PRIM void HL_NAME(log_buttons)()

HL_PRIM void HL_NAME(log_text)(vstring* text)
{
ImGui::LogText("%s", convertString(text));
ImGui::LogText("%s", convertStringNullAsEmpty(text));
}

DEFINE_PRIM(_VOID, log_to_tty, _REF(_I32));
Expand Down
2 changes: 1 addition & 1 deletion extension/tooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ HL_PRIM void HL_NAME(end_tooltip)()

HL_PRIM void HL_NAME(set_tooltip)(vstring* fmt)
{
ImGui::SetTooltip("%s", convertString(fmt));
ImGui::SetTooltip("%s", convertStringNullAsEmpty(fmt));
}

DEFINE_PRIM(_VOID, begin_tooltip, _NO_ARG);
Expand Down
1 change: 1 addition & 0 deletions extension/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "imgui/imgui.h"

#define convertString(st) st != nullptr ? unicodeToUTF8(st).c_str() : NULL
#define convertStringNullAsEmpty(st) st != nullptr ? unicodeToUTF8(st).c_str() : ""
#define convertPtr(ptr,default_value) ptr != nullptr ? *ptr : default_value

void convertColor(ImU32 color, float& r, float& g, float& b, float& a);
Expand Down
6 changes: 3 additions & 3 deletions extension/widgets_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ HL_PRIM void HL_NAME(text_colored)(vdynamic* col, vstring* text)

HL_PRIM void HL_NAME(text_disabled)(vstring* text)
{
ImGui::TextDisabled("%s", convertString(text));
ImGui::TextDisabled("%s", convertStringNullAsEmpty(text));
}

HL_PRIM void HL_NAME(text_wrapped)(vstring* text)
{
ImGui::TextWrapped("%s", convertString(text));
ImGui::TextWrapped("%s", convertStringNullAsEmpty(text));
}

HL_PRIM void HL_NAME(label_text)(vstring* label, vstring* text)
Expand All @@ -31,7 +31,7 @@ HL_PRIM void HL_NAME(label_text)(vstring* label, vstring* text)

HL_PRIM void HL_NAME(bullet_text)(vstring* text)
{
ImGui::BulletText("%s", convertString(text));
ImGui::BulletText("%s", convertStringNullAsEmpty(text));
}

DEFINE_PRIM(_VOID, text, _STRING);
Expand Down

0 comments on commit 6600ed0

Please sign in to comment.