Imgui Lite-c Development

Posted By: Evo

Imgui Lite-c Development - 09/26/19 19:43

New IMGUI Template Version 2

The original imgui/lite-c contribution can be found at https://github.com/pjen/imgui-Lite-C-integration
Txesmi's File Browser Plugin : https://github.com/txesmi/imgui-Lite-C-integration

Custom v2 Template Includes :
* Template source code
* 4 Plug and Play Icon Kits for images and buttons. (Includes Font Awesome PNG Image Collection and 3 Magicon PNG Icon Kits)
* Custom Imgui Window "Style Script" to customize and create your own theme. (style.h)
* All examples are now divided within their on script file for easier management and editing.
* Integrated Txesmi's File Browser Plugin.
* Also now includes a few new examples for Menubars, Tabs, Histogram, imgui built-in style editor, Grid Examples, tree nodes, progress bar, and a few other new features.

I hope the template can help others that may be wanting to use imgui in their projects.

Template v2 : New
Imgui Template v2
[Linked Image]

Original Template v1
Imgui Template v1
[Linked Image]

Posted By: Emre

Re: Imgui Lite-c Development - 09/26/19 21:44

Good work! Your style script is wonderful!

i'm also add some features to dll; like fonts, tabs, digits, built in stylecolor. i'll send it to JenGs, when all functions are ready. So you guys update it from github.
[Linked Image]

btw: i discovered that we can use "imgui_slider_var" for engine variables directly. e.g:

Code
imgui_slider_var("##Rotation", &mdl_example->pan, set_ent_pan_min, set_ent_pan_max);
Posted By: txesmi

Re: Imgui Lite-c Development - 09/26/19 22:09

Thank you very much to all!
Posted By: Evo

Re: Imgui Lite-c Development - 09/26/19 22:22

Thanks Emre. Once I know the dll has been updated with some new features, I'll update the template.
Posted By: jenGs

Re: Imgui Lite-c Development - 09/27/19 07:27

I went through most of the demo (official imgui demo) and converted a lot of the code to lite_c. I made a lot of improvements to my DLL (structure) and added a lot of features. If you wait until this weekend, I will update the DLL.
Posted By: jenGs

Re: Imgui Lite-c Development - 09/27/19 07:29

@Emre I welcome the tabs and font addition, because they are indeed still missing
Posted By: Emre

Re: Imgui Lite-c Development - 09/27/19 08:24

Originally Posted by jenGs
I went through most of the demo (official imgui demo) and converted a lot of the code to lite_c. I made a lot of improvements to my DLL (structure) and added a lot of features. If you wait until this weekend, I will update the DLL.

Great news!

Originally Posted by jenGs
@Emre I welcome the tabs and font addition, because they are indeed still missing


Tabs are here:

SDK
Code
DLLFUNC var  imgui_begintabbar(char* str_id, long flags)
{
	bool res = ImGui::BeginTabBar(str_id, flags);
	return res ? _VAR(1) : _VAR(0);

}

DLLFUNC void imgui_endtabbar()
{
	ImGui::EndTabBar();
}
DLLFUNC var imgui_begintabitem(char* label,void* state,long flags)
{
	bool* dirty = (bool*)state;
	bool res = ImGui::BeginTabItem(label, dirty,flags);
	return res ? _VAR(1) : _VAR(0);
	
}

DLLFUNC void imgui_endtabitem()
{
	
	ImGui::EndTabItem(); 
}

Lite-c

Code
var  imgui_begintabbar(char* str_id, long flags);
void imgui_endtabbar();
var imgui_begintabitem(char* label,void* state,long flags);
void imgui_endtabitem();


Example:

Code
void window_func()
{
	
	imgui_set_next_window_pos(1, 50, ImGuiCond_Once);
	imgui_set_next_window_size(400, 400, ImGuiCond_Once);


	if(imgui_begin("Window1", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove ))
	{
		if(imgui_begintabbar("Tabs",ImGuiTabBarFlags_None))
		{
			if(imgui_begintabitem("Tab 1",0,0))
			{
				imgui_text("Tab 1 Text");
				imgui_endtabitem();
			}
				
			if(imgui_begintabitem("TAB 2",0,0))
			{
				
				imgui_text("Tab 2 Text");
				imgui_endtabitem();
			}
			
			imgui_endtabbar();
			
		}
		
		imgui_end();
	}
	
}



There is an issue about my font method. I'm storing the imgui fonts(ImFont*) in the acknex font(FONT*). i don't know if it may be cause a problem. (Right now it works without problem.) I sent a message to Superku for help/guide. I'm waiting for response. After that, i'll sharet it too.
Posted By: 20BN

Re: Imgui Lite-c Development - 09/27/19 10:40

@jenGs @Emre @EVO

THANKS ALL!

Can't support Asian languages at present, can you update dll?
Posted By: jenGs

Re: Imgui Lite-c Development - 09/27/19 11:13

@20BN Imgui can display unicode, but the problem is Lite-C. I don't know what _chr(STRING) gives back with an unicode STRING. Can't promise anything, but I will look into it. I think I have to decode the characters, because ImGui uses normal char* not wchars to display unicode (If i am not mistaken)
Posted By: Evo

Re: Imgui Lite-c Development - 09/27/19 14:55

@jenGs : Thank you for taking the time to update your dll. I look forward to adding some new features and custom ideas to the imgui template.

@Emre : Thanks for helping get some of these features integrated.

* I was curious about custom window background styling. Windows are separate from lite-c layers and panels can't be layered between windows. The old lbgui had structs set up and BMAP images were used for window BG creation/styling.

Q. Is there a draw_list method for images? (imgui_drawlist_add_image(x,y,size,bmap,etc)). Drawlist commands can render into windows and that would allow me to create a custom feature for adding image backgrounds that are layered behind elements within a transparent window BG (Using the get methods to obtain window xy,size, custom bgs can be drawn for any window). This would let developers match the style of their in-game gui and to use imgui for actual in-game menus. Seamlessly integrating its visual with gui thats already been created for their projects. A drawlist method for images should be all that's needed for me to create the feature.
Posted By: jenGs

Re: Imgui Lite-c Development - 09/27/19 15:32

Yes that is possible. I will add this before I release the new version tomorrow
Posted By: txesmi

Re: Imgui Lite-c Development - 09/28/19 16:17

Hi, I miss to link to the engines SDK for the project in VS2017. I copied the engines SDK plugin folder (adll.h, adll.lib, etc) to my VS projects folder and set the path in the aditional includes of code and in the aditional libraries of the linker, but it is not able to find "adll.h". I believe it was enough. What I am missing? Thank you in advance and excuse the noob question laugh
Posted By: Emre

Re: Imgui Lite-c Development - 09/28/19 16:58

i'm not sure what you are missed. I change the imgui project settings as follows: (maybe it helps)

[Linked Image]
[Linked Image]

That's all. You don't have to copy engine plugin folder to vs project folder. btw; there is two important thing too:

[Linked Image]
[Linked Image]

i hope that helps.
Posted By: txesmi

Re: Imgui Lite-c Development - 09/28/19 17:25

Thank you. That it is. Same as I did. I did not change events because there were not any. Also, no changes on Linker/additional dependencies because is correctly set to "adll.lib". I checked everything again but I don't get what happens.

I decided to copy it because it did not find the file at its original path at first instance and, at the same time, I like to mantain every VS dependency holding from the same folder, but yes, I know it is not necessary, thank you anyway.

EDITED___________________

Ok, I found the problem. I mixed up things with the VS tools version. It compiles now. Thank you for your time!
Posted By: jenGs

Re: Imgui Lite-c Development - 09/28/19 18:03

Hello evryone,
I have updated my project and the dll.

* Reordered methods, deleted unneeded header
* Added a lot of features
* put a part of the Demo in example.c
* Tabs are now available
* drawlist_image is now available
* and a lot more, some of it crap, because I needed it for the demo

Sadly the official Imgui Demo is massive and does a lot of things that are not possible in Lite-C syntax, so it takes a lot of time to find workaround especially with char on the fly declarations.

In my header you will find an "typedef interface". I only did that, so I hadn't to replace every method in the demo. Don't use this at home laugh You may have struct member functions, but it makes the code more ugly.
I have automated my workflow a bit. A crappy Java Programm prases with regex and generates now my headers and "interface" struct.

imgui has hundreds of features, I will try to put more of them in.
Posted By: Emre

Re: Imgui Lite-c Development - 09/28/19 18:21

Originally Posted by txesmi
Ok, I found the problem. I mixed up things with the VS tools version. It compiles now.


Glad to hear that! laugh

Edit: @Jengs: I checked it and got syntax error: "imgui_drawlist_add_polygon" line 41. (imgui_methods.h)
Posted By: Evo

Re: Imgui Lite-c Development - 09/28/19 19:26

@jenGs : I wasn't able to go through the new example.c due to an error, but I updated to the new files for my template and everything works just fine. I see a lot of new features that you included. Thanks for the new update. Once I have time, I'll go through each new feature and add it to the template.
Posted By: jenGs

Re: Imgui Lite-c Development - 09/28/19 19:46

Quote
Edit: @Jengs: I checked it and got syntax error: "imgui_drawlist_add_polygon" line 41. (imgui_methods.h)

That's strange, that's an rather old error, that I fixed last week.
Posted By: jenGs

Re: Imgui Lite-c Development - 09/28/19 19:50

ah you need <windows.h> for the POINT struct. I think I will change that und use an own point struct
Posted By: jenGs

Re: Imgui Lite-c Development - 09/28/19 19:55

One moment, I make the demo runnable. I tested with the wrong script
Posted By: jenGs

Re: Imgui Lite-c Development - 09/28/19 19:58

Originally Posted by jenGs
One moment, I make the demo runnable. I tested with the wrong script


Now it should work
Posted By: txesmi

Re: Imgui Lite-c Development - 10/06/19 07:07

Hi, I will be eternally grateful of sharing your work, to both of you. I would never be able to introduce myself into such a great tool. It has openend many doors for my personal evolution. Thank you very much!

Originally Posted by jenGs
@20BN Imgui can display unicode, but the problem is Lite-C. I don't know what _chr(STRING) gives back with an unicode STRING. Can't promise anything, but I will look into it. I think I have to decode the characters, because ImGui uses normal char* not wchars to display unicode (If i am not mistaken)


One of the things I feel like a must is the mutilanguaje support. I have been investigating and it seems that ImGui uses ANSI or UTF8 encoded and NULL ended char strings. The problem here is that acknex does not correctly interpret UTF8 so there must be some sort of recoding work in order to show unicode characters. As a newby in C++, I found windows 'WideCharToMultiByte' function and its inverse been the key for character arrays transformations.

Code
namespace imgui_helpers {
	typedef char utf8;
	typedef wchar_t unicode;

	#define UTF8_MAX 1024
}

using namespace imgui_helpers;

DLLFUNC utf8 *imgui_h_UnicodeToUtf8(unicode *_text) {
	static utf8 _utf8Text[UTF8_MAX];
	WideCharToMultiByte(CP_UTF8, NULL, _text, -1, _utf8Text, UTF8_MAX, NULL, NULL);
	return _utf8Text;
}


In tandem, I wrote a little helper function in LiteC in order to transform ANSI texts to unicode.

Code
typedef char utf8;
typedef short unicode;

#define UNICODE_MAX 1024

unicode *ansi_to_unicode(char *_chrT) {
	static unicode _unicode[UNICODE_MAX];
	unicode *_sT = _unicode;
	int _count = 0;
	for(; *_chrT!=NULL && _count<UNICODE_MAX-2; _chrT+=1, _sT+=1, _count+=1)
		*_sT = *_chrT;
	*_sT = NULL;
	return _unicode;
}


Another needed thing is imgui font installation and usage functions. Their are pretty straight so there is nothing to worry about.

Code
namespace imgui_fonts {
	enum GLYPH_RANGE {
		GLYPH_RANGE_Default,
		GLYPH_RANGE_ChineseFull,
		GLYPH_RANGE_ChineseSimplified,
		GLYPH_RANGE_Cyrillic,
		GLYPH_RANGE_Japanese,
		GLYPH_RANGE_Korean,
		GLYPH_RANGE_Thai,
		GLYPH_RANGE_COUNT
	};
};

using namespace imgui_fonts;

DLLFUNC ImFont *imgui_add_ttf_from_file(char *_chrFont, float _size, var _glyph_range) {
	const ImWchar *_glyphRange = NULL;

	ImGuiIO& io = ImGui::GetIO();

	switch (_INT(_glyph_range)) {
		case GLYPH_RANGE_ChineseFull:       _glyphRange = io.Fonts->GetGlyphRangesChineseFull(); break;
		case GLYPH_RANGE_ChineseSimplified: _glyphRange = io.Fonts->GetGlyphRangesChineseSimplifiedCommon(); break;
		case GLYPH_RANGE_Cyrillic:          _glyphRange = io.Fonts->GetGlyphRangesCyrillic(); break;
		case GLYPH_RANGE_Japanese:          _glyphRange = io.Fonts->GetGlyphRangesJapanese(); break;
		case GLYPH_RANGE_Korean:            _glyphRange = io.Fonts->GetGlyphRangesKorean(); break;
		case GLYPH_RANGE_Thai:              _glyphRange = io.Fonts->GetGlyphRangesThai(); break;
		default:                            _glyphRange = io.Fonts->GetGlyphRangesDefault();
	}
	
	return io.Fonts->AddFontFromFileTTF(_chrFont, _size, NULL, _glyphRange);
}

DLLFUNC void imgui_push_font(ImFont* _font) {
	ImGui::PushFont(_font);
}

DLLFUNC void imgui_pop_font() {
	ImGui::PopFont();
}


So in combination, they can be used to show unicode strings with imgui and liteC.

Code
typedef ImFont void;

#define GLYPH_RANGE_Default               0
#define GLYPH_RANGE_ChineseFull           1
#define GLYPH_RANGE_ChineseSimplified     2
#define GLYPH_RANGE_Cyrillic              3
#define GLYPH_RANGE_Japanese              4
#define GLYPH_RANGE_Korean                5
#define GLYPH_RANGE_Thai                  6
#define GLYPH_RANGE_COUNT                 7

...

STRING *strUnicode = str_createw(ansi_to_unicode("My ansi text"));
STRING *strUTF8 = str_create(imgui_h_UnicodeToUtf8(strUnicode->chars));

ImFont *ImFont01 = imgui_add_ttf_from_file("c:\\Windows\\Fonts\\Arial-unicode-ms.ttf", 18, GLYPH_RANGE_Default);
ImFont *ImFont02 = imgui_add_ttf_from_file("c:\\Windows\\Fonts\\Arial-unicode-ms.ttf", 24, GLYPH_RANGE_Default);

...

imgui_begin(....
   imgui_push_font(ImFont01);
   imgui_text(strUTF8->chars);
   imgui_pop_font();

   imgui_push_font(ImFont02);
   imgui_text(strUTF8->chars);
   imgui_pop_font();
...


Here is the result of buiilding a single string with cyrillic and japanese character codes, converted to UTF8 and shown with two different fonts created with their corresponding glyph ranges.
[Linked Image]

I wrote all this stuff in order to create some helper fuctions so I can build an in-game file explorer with unicode, so it will come in a near future, I hope laugh

Salud!


Posted By: txesmi

Re: Imgui Lite-c Development - 10/11/19 16:42

I have got working a basic file explorer in UTF8. It is not ready to use but maybe someone wants to keep an eye on it.

[Linked Image]

You can find the source code at GitHub, forked from jenGs's repository, all my functions are included in two new files: imgui_dll_fonts.cpp and imgui_dll_helpers.cpp.

The main work has been around a function that prepares the folder data to be shown in an imgui list box: an array of char*. I tried different methods and finally ended up with a function that fills a buffer owned by the caller instead of the dynamic allocation I tried first, so at the end it can happen that the folder content names are longer that the space available and will result in a clipped content list. I do all the stuff with experimental::filesystem. The function can inject a prefix to folders. In the example I used one of the private ucodes (E800-E8FF) to show that folder icon I inserted into the ttf file (with Type Light).

The file explorer behaviour is in liteC with the help of some helper functions included in the dll. It desplegates a combo in root drives and a button per folder in the path. It rebuilds the data when clicking over a subfolder and activates the selection button when clicking over a file.

The fonts implementation is pretty choppy. I have no idea how to easily implement the custom glyph ranges.
Posted By: Evo

Re: Imgui Lite-c Development - 10/11/19 23:53

@Txesmi : Thanks for getting involved and creating some new features.

Sadly I haven't had much time to work on my projects, but once I can, I'll have a new source code template update with some new ideas and new custom plug-n-play examples.
Thanks to everyone for helping out.
Posted By: jenGs

Re: Imgui Lite-c Development - 10/12/19 01:11

thank you txesmi. Due to work obligations I have not much time at the moment to work on more features. And I always hated unicode and ackenx in combination laugh
Posted By: txesmi

Re: Imgui Lite-c Development - 10/12/19 19:06

you are welcome laugh

little by little, step by step
Posted By: txesmi

Re: Imgui Lite-c Development - 10/13/19 09:40

Hi,
I have just seen the other ImGui::ListBox implementation that uses a label getter function for each list item. I think it is the key to not get lost on char* arrays allocations by using engines native methods. It allows to a 3dgs user the use of TEXT structs to hold arrays of char arrays. It can use any custom data struct at the end.

Code
// C++
DLLFUNC var imgui_h_list_box (const char* label, int* current_item, bool(*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items) {
	bool res = ImGui::ListBox(label, current_item, items_getter, data, items_count, height_in_items);
	return res ? _VAR(1) : _VAR(0);
}

// liteC
var imgui_h_list_box (char* label, int* current_item, void *items_getter, void* data, int items_count, int height_in_items);
...
TEXT *txtList = {
	string = (
		"eoeoeo 1"
		"eoeoeo 2"
		"eoeoeo 3"
		"eoeoeo 4"
		"eoeoeo 5"
		"eoeoeo 6"
	);
}

BOOL _label_for_text(TEXT *_txt, int _index, char **_label) {
	*_label = (_txt->pstring)[_index]->chars;
	return TRUE;
}

...
static int _currentItem = -1;
imgui_h_list_box ("##TEXT list box", &_currentItem, _label_for_text, txtList, (int)txtList->strings, 10);


-------------

I have got another newby question related to the memory and dynamic libraries. As far as I read last days the executable binary and the dinamic library use two different memory areas. I read that the main law is that the allocator have to be the releaser. In the case of using the engine functions into a dll, the allocated memory shall be into the memory asigned to the engines dll, so it is managed same as it would be allocated in liteC, isn't it?

I did some test and I do not receive any errors, so, my question is: Is it safe to add newly created STRINGs into a dll to a TEXT struct passed from liteC and realease them all in liteC?
Posted By: Emre

Re: Imgui Lite-c Development - 10/24/19 07:53

Thank you txesmi!

And one for frome me. There is a member of ImGuiIO, named "FontGlobalScale". I use it for scaling everything. You guys can use it too if you need it.

[Linked Image]

//DLL (i'm still using first version of dll.)
Code
DLLFUNC void imgui_set_global_fontscale(float scalefactor)
{
    ImGuiIO& io = ImGui::GetIO();
    io.FontGlobalScale = scalefactor;
	
}

//Lite-c
Code
void imgui_set_global_fontscale(float scalefactor);

float global_font_scale=1.0;
void window_func() //loop
{
	...
        imgui_set_global_fontscale(global_font_scale);
    	...
}


You can use "global_font_scale", wherever you wish. This way, you can scale everything.


Code
void window_func() //loop
{
	...
	imgui_begin_child("ChildVideo", vector(272*global_font_scale,272*global_font_scale,0), 4,ImGuiWindowFlags_NoScrollWithMouse);
	imgui_push_item_width(200*global_font_scale); 
	imgui_input_text("", _chr(klasor_name), MAX_PATH, ImGuiInputTextFlags_ReadOnly);
	...
}


and result is here: https://www.youtube.com/watch?v=AISuErDfPOU&feature=youtu.be
Posted By: 3run

Re: Imgui Lite-c Development - 01/23/20 15:03

@txesmi hey! just looked into your git example, can you tell me how and were you created that 'Debug' window, I can't find it myself... It has to be somewhere before
Code
void ShowDemoWindowWidgets()
{
	if (!ImGui->CollapsingHeader("Widgets", NULL, 0))
	return;
But where? grin I'm a bit lost... Want to create same, resizeable window but without close button at the upper right corner.

Plus, can you guys tell me how to make button resize itself with it's parent (f.e. I have collapsing_header and inside of a button, how to make it fill the width of the collapsing_header)?
Thank you all for this awesome contribution and examples, this really makes life easier!

Edit: ok, I found out that debug window will appear automatically, when you create any item without a window for it.. as for the buttons, it seems that it has something to do with imgui_push_item_width(xq), but I didn't figure out yet how.

Edit2: also, would be great to know, how to align text to center (f.e. of a button, or other elements as well), it has to do something with styles I guess..
Posted By: txesmi

Re: Imgui Lite-c Development - 01/23/20 17:15

Hi @3Run
That is the original example of the ImGui module. I did not write it myself.

You can find all the window flags into 'imgui_enums.h' file. Not sure what are you trying to thought.

About the button width, you need to get the available width so you can create the button with it.
Code
var _width = imgui_get_content_region_avail_width();
if(imgui_h_button("Button text", _width, 0)) {
   ...
}


I am not at home and I can't try it but I think it should work as spected.

Salud!
Posted By: 3run

Re: Imgui Lite-c Development - 01/23/20 21:18

Thank you for quick reply! I just saw that you were using that 'imgui_h_button' in your example, my bad. I need to be more attentive. I was previously using imgui_button(text), which doesn't allow to set the size, but only created a button, which will change it's size automatically depending on the text length.

Small tip: just found out how to remove close button from the window, without using NoTitleBar flag seton. In 'imgui_begin(char *name, void *p_close, long flags);' simply pass NULL for p_close.
Posted By: txesmi

Re: Imgui Lite-c Development - 01/23/20 23:26

You are welcome
Originally Posted by 3run
pass NULL for p_close

nice to know wink

edited__________
Just updated the file browser: A new way based on TEXT structs.
Posted By: 3run

Re: Imgui Lite-c Development - 01/29/20 13:28

There was a memory leak:
Code
Unfreed: 1082,    , 8 bytes
Unfreed: 1083,    , 876 bytes

In original and txesmi's examples, so I had to add this:
Code
void on_exit_event()
{
	sys_free(ImGui->lpVtbl);
	sys_free(ImGui);
}

void main()
{
	on_exit = on_exit_event;
        ....
}

Also, there is a typo (no space between ImGuiWindowFlags_AlwaysUseWindowPadding and 1) in imgui_enums.h, in line 35.
Code
#define ImGuiWindowFlags_AlwaysUseWindowPadding1 << 16 // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windowsbecause more convenient)
Posted By: txesmi

Re: Imgui Lite-c Development - 01/30/20 10:26

@3run
I will try to fix that inside the module...
Posted By: Evo

Re: Imgui Lite-c Development - 04/02/20 17:33

Created a new v2 of the Imgui Template. The main post has been updated with the new info and links.
Posted By: alibaba

Re: Imgui Lite-c Development - 04/02/20 21:17

Holy moly, this comes just right!! Thanks a bunch!
Posted By: Evo

Re: Imgui Lite-c Development - 04/03/20 14:50

Thanks. Once more development and plugins are created, I'll update it again in the future.
Posted By: Emre

Re: Imgui Lite-c Development - 04/05/20 04:47

Hi everybody. i made a simple theme editor. You can easily create your theme and export it. It's not that great, but still it's useful i guess. You can download from here.

[Linked Image]

Posted By: alibaba

Re: Imgui Lite-c Development - 04/05/20 11:47

I love you guys! Only recently I've started with 3dgs again and at the right time you come around the corner with such useful contributions! Cheers!
Posted By: Emre

Re: Imgui Lite-c Development - 04/06/20 05:12

Originally Posted by alibaba
I love you guys! Only recently I've started with 3dgs again and at the right time you come around the corner with such useful contributions! Cheers!

Well i can't beleive we are still here. You, me, 3run, txesmi, jenGs, Evo, Quad and some others. (:
i think imgui is the biggest factor lately. Thanks to jenGs!

it is indeed good that we are still here for whatever reason.
Posted By: 20BN

Re: Imgui Lite-c Development - 04/10/20 03:39

@Emre

Thank you!
And how to display CHS / CHT text and change any font in this imgui demo?
Posted By: Emre

Re: Imgui Lite-c Development - 04/10/20 05:18

Originally Posted by 20BN
@Emre

Thank you!
And how to display CHS / CHT text and change any font in this imgui demo?

You are welcome. i've changed/updated the link yesterday. Now the rar file contain source code. You can change anything you want. wink
Posted By: 20BN

Re: Imgui Lite-c Development - 04/10/20 11:34

Originally Posted by Emre
Originally Posted by 20BN
@Emre

Thank you!
And how to display CHS / CHT text and change any font in this imgui demo?

You are welcome. i've changed/updated the link yesterday. Now the rar file contain source code. You can change anything you want. wink


OK! I'm use imgui_add_ttf_from_file("zz.ttf", 16, 0); change any font.
But, not support display Simplified Chinese or Japanese text.(error show: ?????? )
What should I script?
Posted By: txesmi

Re: Imgui Lite-c Development - 04/10/20 12:50

Hi,
The last parameter of 'imgui_add_ttf_from_file' is a ImGui preset of ranges of glyphs. For full chinesse should be 1, and for simplified 2. You can find the defines at 'imgui_helpers.h'.

You can build yor own glyph ranges with 'imgui_add_ttf_from_file_ranged' where the last parameter is an array of shorts with all the ranges from unicode table ended with a null entry.

The array should look something like this:
Code
short  myGlyphRanges[7] = {
   30, 127,            // Latin1 basic
   2087, 3048,      // Imaginary range as example
   16524, 16524,  // A single character range
   0                       // array ended with a null entry
}
...
imgui_add_ttf_from_file_ranged("myFont.ttf", 16, myGlyphRanges);


I did not try with chinesse, but cyrillic was working perfectly.

The glyph range of my main project looks like the following. I included all the latin characters, some of the symbols and a piece of the private area:
Code
short glyphRanges[23] = {
//	0x0000, 0x001F, // Control characters
	0x0020, 0x007F, // Basic Latin
//	0x0080, 0x00FF, // Latin supplement
		0x00A0, 0x00FF,
	0x0100, 0x017F, // Latin extended-A
	0x0180, 0x024F, // Latin extended-B
//	0x02B0, 0x02FF, // Spacing modifier letters
		0x02C0, 0x02DF,
//	0x2000, 0x206F, // General punctuation
		0x2010, 0x2027,
		0x2030, 0x205E,
//	0x20A0, 0x20CF, // Currency symbols
		0x20AC, 0x20AC,
//	0x2100, 0x214F, // Letterlike symbols
		0x2122, 0x2122,
//	0x2600, 0x26FF, // Miscellaneous symbols
		0x2600, 0x2647,
//	0xE800, 0xE8FF, // Private use area
		0xE800, 0xE808,
	0
};


I used hexadecimal notation because it is the common way to refer to unicode characters

I hope it helps,
Salud!
Posted By: 3run

Re: Imgui Lite-c Development - 04/28/20 16:20

Hey guys!

Do any of you know, how to disable filtering for images?
Also, is there any way to set custom 'flag' (check?) image for checkboxes:
[Linked Image]
I couldn't really find anything about this over the web...

Greets
Posted By: Emre

Re: Imgui Lite-c Development - 04/28/20 23:20

Originally Posted by 3run
Also, is there any way to set custom 'flag' (check?) image for checkboxes:

You mean custom checkmark? Afaik imgui has no such an option. This is the function which draw checkmarks;

Code
void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col, float sz)
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;

    float thickness = ImMax(sz / 5.0f, 1.0f);
    sz -= thickness*0.5f;
    pos += ImVec2(thickness*0.25f, thickness*0.25f);

    float third = sz / 3.0f;
    float bx = pos.x + third;
    float by = pos.y + sz -third * 0.5f;
    window->DrawList->PathLineTo(ImVec2(bx - third, by - third));
    window->DrawList->PathLineTo(ImVec2(bx, by));
    window->DrawList->PathLineTo(ImVec2(bx + third*2, by - third*2));
    window->DrawList->PathStroke(col, false, thickness);
}


You can change the shape for sure. I don't know if there is a way to load a custom image. Maybe you can try to use "window->DrawList->AddImage" instead of "window->DrawList->PathLineTo" but i'm not sure if this is safe and will work.

in any case, you'll have to create your own dll to do something like this.
Posted By: 3run

Re: Imgui Lite-c Development - 04/29/20 09:30

Thank you! laugh

I also read that in previous versions imgui used square instead of a checkmark, maybe I could try to find older version.
What about image filtering, what do you think? Will that also require building own dll?

Edit: I think I found old version of RenderCheckMark function (if someone interested)
Nope, it doesn't work... So I left the checkmark as it is, tried to draw X but failed grin

And for disabling linear filtering, indeed, changing D3DTEXF_LINEAR to D3DTEXF_NONE in imgui_impl_dx9.cpp works.
Code
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_NONE);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_NONE);
Posted By: exile

Re: Imgui Lite-c Development - 06/12/20 01:23

Hey all. Having some issues with imgui_add_ttf_from_file. Trying to use the previously provided examples in the demo but the font either doesn't change or causes an immediate crash. Before the imgui_begin function I am defining;

ImFont *ImFont01 = imgui_add_ttf_from_file("c:\\Windows\\Fonts\\FuturBlock-Regular.ttf", 18, GLYPH_RANGE_Default);

Then in the function I am calling it as;

imgui_push_font(ImFont01);
imgui_text("Test\r\n");
imgui_pop_font();

Any idea on what I am doing wrong?
Posted By: 20BN

Re: Imgui Lite-c Development - 06/12/20 07:30

[Linked Image]

Hello,
Can DLL currently implement this kind of node UI?
Posted By: txesmi

Re: Imgui Lite-c Development - 06/12/20 20:18

@exile
I experimented some crashes when font do not contain the glyphs stated in the array. Did you try with other fonts?
Posted By: 20BN

Re: Imgui Lite-c Development - 08/02/20 12:59

Hope to update this plugin:
https://github.com/Nelarius/imnodes
Posted By: gamers

Re: Imgui Lite-c Development - 01/13/22 13:33

Hello guys,

Is there a way to type Turkish characters (i.e., i,ç,ğ,ş,ö,ü) in text box in IMGUI's multiline textbox? In addition, how can I change the font in this field?
Posted By: gamers

Re: Imgui Lite-c Development - 01/09/23 13:25

Can anyone help with how to adapt the ImGUI project to the Lite-C? I changed the default font in ImGUI but I can't do it in Lite-C.
© 2024 lite-C Forums