mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Misc: Asserting in NewFrame() if style.WindowMinSize is zero or smaller than (1.0f,1.0f). Internal: ImHash functions tweaks. Added InputText() to query status section.
This commit is contained in:
parent
f02705fbaa
commit
1d0b4df3d9
@ -41,7 +41,7 @@ Breaking Changes:
|
|||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigation to the menu layer.
|
- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigating to the menu layer.
|
||||||
- DragScalar, InputScalar, SliderScalar: Added support for u8/s8/u16/s16 data types.
|
- DragScalar, InputScalar, SliderScalar: Added support for u8/s8/u16/s16 data types.
|
||||||
We are reusing function instances for larger types to reduce code size. (#643, #320, #708, #1011)
|
We are reusing function instances for larger types to reduce code size. (#643, #320, #708, #1011)
|
||||||
- InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when
|
- InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when
|
||||||
@ -63,6 +63,7 @@ Other Changes:
|
|||||||
- Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute
|
- Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute
|
||||||
tree depth instead of a relative one.
|
tree depth instead of a relative one.
|
||||||
- Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##".
|
- Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##".
|
||||||
|
- Misc: Asserting in NewFrame() if style.WindowMinSize is zero or smaller than (1.0f,1.0f).
|
||||||
- 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)
|
||||||
- Examples: Allegro: Added support for touch events (emulating mouse). (#2219) [@dos1]
|
- Examples: Allegro: Added support for touch events (emulating mouse). (#2219) [@dos1]
|
||||||
|
15
imgui.cpp
15
imgui.cpp
@ -1480,27 +1480,27 @@ ImU32 ImHashData(const void* data_p, size_t data_size, ImU32 seed)
|
|||||||
// - If we reach ### in the string we discard the hash so far and reset to the seed.
|
// - If we reach ### in the string we discard the hash so far and reset to the seed.
|
||||||
// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build)
|
// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build)
|
||||||
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
||||||
ImU32 ImHashStr(const char* data, size_t data_size, ImU32 seed)
|
ImU32 ImHashStr(const char* data_p, size_t data_size, ImU32 seed)
|
||||||
{
|
{
|
||||||
seed = ~seed;
|
seed = ~seed;
|
||||||
ImU32 crc = seed;
|
ImU32 crc = seed;
|
||||||
const unsigned char* src = (const unsigned char*)data;
|
const unsigned char* data = (const unsigned char*)data_p;
|
||||||
const ImU32* crc32_lut = GCrc32LookupTable;
|
const ImU32* crc32_lut = GCrc32LookupTable;
|
||||||
if (data_size != 0)
|
if (data_size != 0)
|
||||||
{
|
{
|
||||||
while (data_size-- != 0)
|
while (data_size-- != 0)
|
||||||
{
|
{
|
||||||
unsigned char c = *src++;
|
unsigned char c = *data++;
|
||||||
if (c == '#' && src[0] == '#' && src[1] == '#')
|
if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#')
|
||||||
crc = seed;
|
crc = seed;
|
||||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (unsigned char c = *src++)
|
while (unsigned char c = *data++)
|
||||||
{
|
{
|
||||||
if (c == '#' && src[0] == '#' && src[1] == '#')
|
if (c == '#' && data[0] == '#' && data[1] == '#')
|
||||||
crc = seed;
|
crc = seed;
|
||||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
||||||
}
|
}
|
||||||
@ -3368,12 +3368,13 @@ void ImGui::NewFrame()
|
|||||||
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
||||||
IM_ASSERT(g.Initialized);
|
IM_ASSERT(g.Initialized);
|
||||||
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
|
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
|
||||||
|
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
|
||||||
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
|
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
|
||||||
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||||
IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||||
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
|
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
|
||||||
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
|
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
|
||||||
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
|
IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
|
||||||
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
||||||
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
||||||
|
|
||||||
|
@ -1460,20 +1460,23 @@ static void ShowDemoWindowWidgets()
|
|||||||
static int item_type = 1;
|
static int item_type = 1;
|
||||||
static bool b = false;
|
static bool b = false;
|
||||||
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
|
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
|
||||||
|
static char str[16] = {};
|
||||||
ImGui::RadioButton("Text", &item_type, 0);
|
ImGui::RadioButton("Text", &item_type, 0);
|
||||||
ImGui::RadioButton("Button", &item_type, 1);
|
ImGui::RadioButton("Button", &item_type, 1);
|
||||||
ImGui::RadioButton("Checkbox", &item_type, 2);
|
ImGui::RadioButton("Checkbox", &item_type, 2);
|
||||||
ImGui::RadioButton("SliderFloat", &item_type, 3);
|
ImGui::RadioButton("SliderFloat", &item_type, 3);
|
||||||
ImGui::RadioButton("ColorEdit4", &item_type, 4);
|
ImGui::RadioButton("InputText", &item_type, 4);
|
||||||
ImGui::RadioButton("ListBox", &item_type, 5);
|
ImGui::RadioButton("ColorEdit4", &item_type, 5);
|
||||||
|
ImGui::RadioButton("ListBox", &item_type, 6);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
||||||
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
||||||
if (item_type == 2) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
|
if (item_type == 2) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
|
||||||
if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
||||||
if (item_type == 4) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
if (item_type == 4) { ret = ImGui::InputText("ITEM: InputText", &str[0], IM_ARRAYSIZE(str)); } // Testing input text (which handles tabbing)
|
||||||
if (item_type == 5) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
if (item_type == 5) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
||||||
|
if (item_type == 6) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
||||||
ImGui::BulletText(
|
ImGui::BulletText(
|
||||||
"Return value = %d\n"
|
"Return value = %d\n"
|
||||||
"IsItemFocused() = %d\n"
|
"IsItemFocused() = %d\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user