mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
This commit is contained in:
parent
a92c587c75
commit
897badec7a
@ -88,6 +88,7 @@ Other Changes:
|
|||||||
- ImFont: Added GetGlyphRangesVietnamese() helper. (#2403)
|
- ImFont: Added GetGlyphRangesVietnamese() helper. (#2403)
|
||||||
- Misc: Asserting in NewFrame() if style.WindowMinSize is zero or smaller than (1.0f,1.0f).
|
- Misc: Asserting in NewFrame() if style.WindowMinSize is zero or smaller than (1.0f,1.0f).
|
||||||
- Demo: Using GetBackgroundDrawList() and GetForegroundDrawList() in "Custom Rendering" demo.
|
- Demo: Using GetBackgroundDrawList() and GetForegroundDrawList() in "Custom Rendering" demo.
|
||||||
|
- Demo: InputText: Demonstrating use of ImGuiInputTextFlags_CallbackResize. (#2006, #1443, #1008).
|
||||||
- Examples: OpenGL: Fix to be able to run on ES 2.0 / WebGL 1.0. [@rmitton, @gabrielcuvillier]
|
- Examples: OpenGL: Fix to be able to run on ES 2.0 / WebGL 1.0. [@rmitton, @gabrielcuvillier]
|
||||||
- Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN
|
- Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN
|
||||||
even if the OpenGL headers/loader happens to define the value. (#2366, #2186)
|
even if the OpenGL headers/loader happens to define the value. (#2366, #2186)
|
||||||
|
115
imgui_demo.cpp
115
imgui_demo.cpp
@ -921,48 +921,89 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Filtered Text Input"))
|
if (ImGui::TreeNode("Text Input"))
|
||||||
{
|
{
|
||||||
static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
|
if (ImGui::TreeNode("Multi-line Text Input"))
|
||||||
static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
|
{
|
||||||
static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
|
// Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize
|
||||||
static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
|
// and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings.
|
||||||
static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
|
static char text[1024 * 16] =
|
||||||
struct TextFilters { static int FilterImGuiLetters(ImGuiInputTextCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } };
|
"/*\n"
|
||||||
static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
" The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
|
||||||
|
" the hexadecimal encoding of one offending instruction,\n"
|
||||||
|
" more formally, the invalid operand with locked CMPXCHG8B\n"
|
||||||
|
" instruction bug, is a design flaw in the majority of\n"
|
||||||
|
" Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
|
||||||
|
" processors (all in the P5 microarchitecture).\n"
|
||||||
|
"*/\n\n"
|
||||||
|
"label:\n"
|
||||||
|
"\tlock cmpxchg8b eax\n";
|
||||||
|
|
||||||
ImGui::Text("Password input");
|
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput;
|
||||||
static char bufpass[64] = "password123";
|
HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp)");
|
||||||
ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", (unsigned int*)&flags, ImGuiInputTextFlags_ReadOnly);
|
||||||
ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", (unsigned int*)&flags, ImGuiInputTextFlags_AllowTabInput);
|
||||||
ImGui::InputTextWithHint("password (w/ hint)", "<password>", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", (unsigned int*)&flags, ImGuiInputTextFlags_CtrlEnterForNewLine);
|
||||||
ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
|
ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), flags);
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TreePop();
|
if (ImGui::TreeNode("Filtered Text Input"))
|
||||||
}
|
{
|
||||||
|
static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
|
||||||
|
static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
|
||||||
|
static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
|
||||||
|
static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
|
||||||
|
static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
|
||||||
|
struct TextFilters { static int FilterImGuiLetters(ImGuiInputTextCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } };
|
||||||
|
static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
||||||
|
|
||||||
if (ImGui::TreeNode("Multi-line Text Input"))
|
ImGui::Text("Password input");
|
||||||
{
|
static char bufpass[64] = "password123";
|
||||||
// Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize
|
ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
||||||
// and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings.
|
ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
|
||||||
static char text[1024*16] =
|
ImGui::InputTextWithHint("password (w/ hint)", "<password>", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
||||||
"/*\n"
|
ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
|
||||||
" The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
|
ImGui::TreePop();
|
||||||
" the hexadecimal encoding of one offending instruction,\n"
|
}
|
||||||
" more formally, the invalid operand with locked CMPXCHG8B\n"
|
|
||||||
" instruction bug, is a design flaw in the majority of\n"
|
if (ImGui::TreeNode("Resize Callback"))
|
||||||
" Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
|
{
|
||||||
" processors (all in the P5 microarchitecture).\n"
|
// If you have a custom string type you would typically create a ImGui::InputText() wrapper than takes your type as input.
|
||||||
"*/\n\n"
|
// See misc/cpp/imgui_stdlib.h and .cpp for an implementation of this using std::string.
|
||||||
"label:\n"
|
HelpMarker("Demonstrate using ImGuiInputTextFlags_CallbackResize to wire your resizable string type to InputText().\n\nSee misc/cpp/imgui_stdlib.h for an implementation of this for std::string.");
|
||||||
"\tlock cmpxchg8b eax\n";
|
struct Funcs
|
||||||
|
{
|
||||||
|
static int MyResizeCallback(ImGuiInputTextCallbackData* data)
|
||||||
|
{
|
||||||
|
if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
|
||||||
|
{
|
||||||
|
ImVector<char>* my_str = (ImVector<char>*)data->UserData;
|
||||||
|
IM_ASSERT(my_str->begin() == data->Buf);
|
||||||
|
my_str->resize(data->BufSize); // NB: On resizing calls, generally data->BufSize == data->BufTextLen + 1
|
||||||
|
data->Buf = my_str->begin();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tip: Because ImGui:: is a namespace you can add your own function into the namespace from your own source files.
|
||||||
|
static bool MyInputTextMultiline(const char* label, ImVector<char>* my_str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0)
|
||||||
|
{
|
||||||
|
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
|
||||||
|
return ImGui::InputTextMultiline(label, my_str->begin(), my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, Funcs::MyResizeCallback, (void*)my_str);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// For this demo we are using ImVector as a string container.
|
||||||
|
// Note that because we need to store a terminating zero character, our size/capacity are 1 more than usually reported by a typical string class.
|
||||||
|
static ImVector<char> my_str;
|
||||||
|
if (my_str.empty())
|
||||||
|
my_str.push_back(0);
|
||||||
|
Funcs::MyInputTextMultiline("##MyStr", &my_str, ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16));
|
||||||
|
ImGui::Text("Data: %p\nSize: %d\nCapacity: %d", my_str.begin(), my_str.size(), my_str.capacity());
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput;
|
|
||||||
HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp)");
|
|
||||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", (unsigned int*)&flags, ImGuiInputTextFlags_ReadOnly);
|
|
||||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", (unsigned int*)&flags, ImGuiInputTextFlags_AllowTabInput);
|
|
||||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", (unsigned int*)&flags, ImGuiInputTextFlags_CtrlEnterForNewLine);
|
|
||||||
ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), flags);
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,6 +294,9 @@ MONOSPACE FONTS
|
|||||||
https://github.com/kmar/Sweet16Font
|
https://github.com/kmar/Sweet16Font
|
||||||
Also include .inl file to use directly in dear imgui.
|
Also include .inl file to use directly in dear imgui.
|
||||||
|
|
||||||
|
Google Noto Mono Fonts
|
||||||
|
https://www.google.com/get/noto/
|
||||||
|
|
||||||
Typefaces for source code beautification
|
Typefaces for source code beautification
|
||||||
https://github.com/chrissimpkins/codeface
|
https://github.com/chrissimpkins/codeface
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user