Trim trailing whitespace (#305)

This commit is contained in:
ocornut
2015-08-24 13:50:18 +02:00
parent 425c6cb3a3
commit b1987d697f
5 changed files with 221 additions and 221 deletions

224
imgui.cpp
View File

@ -18,13 +18,13 @@
- How do I update to a newer version of ImGui?
- Can I have multiple widgets with the same label? Can I have widget without a label? (Yes)
- Why is my text output blurry?
- How can I load a different font than the default?
- How can I load a different font than the default?
- How can I load multiple fonts?
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
- ISSUES & TODO-LIST
- CODE
MISSION STATEMENT
=================
@ -78,11 +78,11 @@
- getting started:
- initialisation: call ImGui::GetIO() to retrieve the ImGuiIO structure and fill the 'Settings' data.
- every frame:
- every frame:
1/ in your mainloop or right after you got your keyboard/mouse info, call ImGui::GetIO() and fill the 'Input' data, then call ImGui::NewFrame().
2/ use any ImGui function you want between NewFrame() and Render()
3/ ImGui::Render() to render all the accumulated command-lists. it will call your RenderDrawListFn handler that you set in the IO structure.
- all rendering information are stored into command-lists until ImGui::Render() is called.
- all rendering information are stored into command-lists until ImGui::Render() is called.
- ImGui never touches or know about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you must provide.
- effectively it means you can create widgets at any time in your code, regardless of "update" vs "render" considerations.
- refer to the examples applications in the examples/ folder for instruction on how to setup your code.
@ -100,7 +100,7 @@
unsigned char* pixels;
int width, height, bytes_per_pixels;
io.Fonts->GetTexDataAsRGBA32(pixels, &width, &height, &bytes_per_pixels);
// TODO: copy texture to graphics memory.
// TODO: copy texture to graphics memory.
// TODO: store your texture pointer/identifier in 'io.Fonts->TexID'
// Application main loop
@ -108,7 +108,7 @@
{
// 1) get low-level input
// e.g. on Win32, GetKeyboardState(), or poll your events, etc.
// 2) TODO: fill all fields of IO structure and call NewFrame
ImGuiIO& io = ImGui::GetIO();
io.MousePos = mouse_pos;
@ -139,7 +139,7 @@
Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix.
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
- 2015/08/05 (1.44) - split imgui.cpp into extra files: imgui_demo.cpp imgui_draw.cpp imgui_internal.h that you need to add to your project.
- 2015/07/18 (1.44) - fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (introduced in 1.43) being off by an extra PI for no justifiable reason
- 2015/07/14 (1.43) - add new ImFontAtlas::AddFont() API. For the old AddFont***, moved the 'font_no' parameter of ImFontAtlas::AddFont** functions to the ImFontConfig structure.
@ -147,10 +147,10 @@
- 2015/07/08 (1.43) - switched rendering data to use indexed rendering. this is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost.
this necessary change will break your rendering function! the fix should be very easy. sorry for that :(
- if you are using a vanilla copy of one of the imgui_impl_XXXX.cpp provided in the example, you just need to update your copy and you can ignore the rest.
- the signature of the io.RenderDrawListsFn handler has changed!
- the signature of the io.RenderDrawListsFn handler has changed!
ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
became:
ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data).
ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data).
argument 'cmd_lists' -> 'draw_data->CmdLists'
argument 'cmd_lists_count' -> 'draw_data->CmdListsCount'
ImDrawList 'commands' -> 'CmdBuffer'
@ -238,12 +238,12 @@
Q: Can I have multiple widgets with the same label? Can I have widget without a label? (Yes)
A: Yes. A primer on the use of labels/IDs in ImGui..
- Elements that are not clickable, such as Text() items don't need an ID.
- Interactive widgets require state to be carried over multiple frames (most typically ImGui often needs to remember what is the "active" widget).
to do so they need an unique ID. unique ID are typically derived from a string label, an integer index or a pointer.
Button("OK"); // Label = "OK", ID = hash of "OK"
Button("Cancel"); // Label = "Cancel", ID = hash of "Cancel"
@ -320,7 +320,7 @@
}
- when working with trees, ID are used to preserve the opened/closed state of each tree node.
depending on your use cases you may want to use strings, indices or pointers as ID.
depending on your use cases you may want to use strings, indices or pointers as ID.
e.g. when displaying a single object that may change over time (1-1 relationship), using a static string as ID will preserve your node open/closed state when the targeted object change.
e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently. experiment and see what makes more sense!
@ -381,7 +381,7 @@
The list below consist mostly of notes of things to do before they are requested/discussed by users (at that point it usually happens on the github)
- window: autofit feedback loop when user relies on any dynamic layout (window width multiplier, column). maybe just clearly drop manual autofit?
- window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list.
- window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list.
- window: allow resizing of child windows (possibly given min/max for each axis?)
- window: background options for child windows, border option (disable rounding)
- window: resizing from any sides? + mouse cursor directives for app.
@ -391,7 +391,7 @@
!- scrolling: allow immediately effective change of scroll if we haven't appended items yet
- widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc.
- widgets: clean up widgets internal toward exposing everything.
- widgets: add a disabled/read-only mode (#211)
- widgets: add a disabled/read-only mode (#211)
- main: considering adding EndFrame()/Init(). some constructs are awkward in the implementation because of the lack of them.
- main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
- main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
@ -439,7 +439,7 @@
- drag float: up/down axis
- text edit: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now.
- text edit: centered text for slider as input text so it matches typical positioning.
- text edit: flag to disable live update of the user buffer.
- text edit: flag to disable live update of the user buffer.
- text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
- tree: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
- textwrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (git issue #249)
@ -502,7 +502,7 @@
#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it.
#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
#pragma clang diagnostic ignored "-Wmissing-noreturn" // warning : function xx could be declared with attribute 'noreturn' warning // GetDefaultFontData() asserts which some implementation makes it never return.
#pragma clang diagnostic ignored "-Wdeprecated-declarations"// warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
@ -820,30 +820,30 @@ int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args)
// Pass data_size==0 for zero-terminated strings
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
ImU32 ImHash(const void* data, int data_size, ImU32 seed)
{
ImU32 ImHash(const void* data, int data_size, ImU32 seed)
{
static ImU32 crc32_lut[256] = { 0 };
if (!crc32_lut[1])
{
const ImU32 polynomial = 0xEDB88320;
for (ImU32 i = 0; i < 256; i++)
{
ImU32 crc = i;
for (ImU32 j = 0; j < 8; j++)
crc = (crc >> 1) ^ (ImU32(-int(crc & 1)) & polynomial);
crc32_lut[i] = crc;
for (ImU32 i = 0; i < 256; i++)
{
ImU32 crc = i;
for (ImU32 j = 0; j < 8; j++)
crc = (crc >> 1) ^ (ImU32(-int(crc & 1)) & polynomial);
crc32_lut[i] = crc;
}
}
seed = ~seed;
ImU32 crc = seed;
ImU32 crc = seed;
const unsigned char* current = (const unsigned char*)data;
if (data_size > 0)
{
// Known size
while (data_size--)
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *current++];
while (data_size--)
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *current++];
}
else
{
@ -852,7 +852,7 @@ ImU32 ImHash(const void* data, int data_size, ImU32 seed)
{
// We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed.
// Because this syntax is rarely used we are optimizing for the common case.
// - 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.
if (c == '#' && current[0] == '#' && current[1] == '#')
crc = seed;
@ -860,8 +860,8 @@ ImU32 ImHash(const void* data, int data_size, ImU32 seed)
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
}
}
return ~crc;
}
return ~crc;
}
//-----------------------------------------------------------------------------
// ImText* helpers
@ -880,10 +880,10 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
*out_char = c;
return 1;
}
if ((*str & 0xe0) == 0xc0)
if ((*str & 0xe0) == 0xc0)
{
*out_char = 0;
if (in_text_end && in_text_end - (const char*)str < 2) return 0;
if (in_text_end && in_text_end - (const char*)str < 2) return 0;
if (*str < 0xc2) return 0;
c = (unsigned int)((*str++ & 0x1f) << 6);
if ((*str & 0xc0) != 0x80) return 0;
@ -891,7 +891,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
*out_char = c;
return 2;
}
if ((*str & 0xf0) == 0xe0)
if ((*str & 0xf0) == 0xe0)
{
*out_char = 0;
if (in_text_end && in_text_end - (const char*)str < 3) return 0;
@ -905,7 +905,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
*out_char = c;
return 3;
}
if ((*str & 0xf8) == 0xf0)
if ((*str & 0xf8) == 0xf0)
{
*out_char = 0;
if (in_text_end && in_text_end - (const char*)str < 4) return 0;
@ -965,12 +965,12 @@ int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end)
// Based on stb_to_utf8() from github.com/nothings/stb/
static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
{
if (c < 0x80)
if (c < 0x80)
{
buf[0] = (char)c;
return 1;
}
if (c < 0x800)
}
if (c < 0x800)
{
if (buf_size < 2) return 0;
buf[0] = (char)(0xc0 + (c >> 6));
@ -980,8 +980,8 @@ static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
if (c >= 0xdc00 && c < 0xe000)
{
return 0;
}
if (c >= 0xd800 && c < 0xdc00)
}
if (c >= 0xd800 && c < 0xdc00)
{
if (buf_size < 4) return 0;
buf[0] = (char)(0xf0 + (c >> 18));
@ -1073,7 +1073,7 @@ void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float&
// Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593
// also http://en.wikipedia.org/wiki/HSL_and_HSV
void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b)
{
{
if (s == 0.0f)
{
// gray
@ -1366,7 +1366,7 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
// ImGuiTextBuffer
//-----------------------------------------------------------------------------
// On some platform vsnprintf() takes va_list by reference and modifies it.
// On some platform vsnprintf() takes va_list by reference and modifies it.
// va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it.
#ifndef va_copy
#define va_copy(dest, src) (dest = src)
@ -1406,12 +1406,12 @@ void ImGuiTextBuffer::append(const char* fmt, ...)
// ImGuiSimpleColumns
//-----------------------------------------------------------------------------
ImGuiSimpleColumns::ImGuiSimpleColumns()
{
Count = 0;
Spacing = Width = NextWidth = 0.0f;
memset(Pos, 0, sizeof(Pos));
memset(NextWidths, 0, sizeof(NextWidths));
ImGuiSimpleColumns::ImGuiSimpleColumns()
{
Count = 0;
Spacing = Width = NextWidth = 0.0f;
memset(Pos, 0, sizeof(Pos));
memset(NextWidths, 0, sizeof(NextWidths));
}
void ImGuiSimpleColumns::Update(int count, float spacing, bool clear)
@ -1454,7 +1454,7 @@ float ImGuiSimpleColumns::CalcExtraSpace(float avail_w)
ImGuiWindow::ImGuiWindow(const char* name)
{
Name = ImStrdup(name);
ID = ImHash(name, 0);
ID = ImHash(name, 0);
IDStack.push_back(ID);
MoveID = GetID("#MOVE");
@ -1547,10 +1547,10 @@ ImGuiWindow* ImGui::GetParentWindow()
return g.CurrentWindowStack[g.CurrentWindowStack.Size - 2];
}
void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL)
void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL)
{
ImGuiState& g = *GImGui;
g.ActiveId = id;
g.ActiveId = id;
g.ActiveIdIsFocusedOnly = false;
g.ActiveIdIsJustActivated = true;
g.ActiveIdWindow = window;
@ -1587,8 +1587,8 @@ void ImGui::ItemSize(const ImVec2& size, float text_offset_y)
}
void ImGui::ItemSize(const ImRect& bb, float text_offset_y)
{
ItemSize(bb.GetSize(), text_offset_y);
{
ItemSize(bb.GetSize(), text_offset_y);
}
// Declare item bounding box for clipping and interaction.
@ -2242,11 +2242,11 @@ void ImGui::Render()
const bool first_render_of_the_frame = (g.FrameCountRendered != g.FrameCount);
g.FrameCountRendered = g.FrameCount;
if (first_render_of_the_frame)
{
// Hide implicit "Debug" window if it hasn't been used
IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin/End
IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin/End
if (g.CurrentWindow && !g.CurrentWindow->Accessed)
g.CurrentWindow->Active = false;
ImGui::End();
@ -2584,7 +2584,7 @@ void ImGui::RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale, bool
b = center + ImVec2(-0.500f,0.866f)*r;
c = center + ImVec2(-0.500f,-0.866f)*r;
}
if (shadow && (window->Flags & ImGuiWindowFlags_ShowBorders) != 0)
window->DrawList->AddTriangleFilled(a+ImVec2(2,2), b+ImVec2(2,2), c+ImVec2(2,2), window->Color(ImGuiCol_BorderShadow));
window->DrawList->AddTriangleFilled(a, b, c, window->Color(ImGuiCol_Text));
@ -2628,7 +2628,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
// Cancel out character spacing for the last character of a line (it is baked into glyph->XAdvance field)
const float font_scale = font_size / font->FontSize;
const float font_scale = font_size / font->FontSize;
const float character_spacing_x = 1.0f * font_scale;
if (text_size.x > 0.0f)
text_size.x -= character_spacing_x;
@ -2636,7 +2636,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
return text_size;
}
// Helper to calculate coarse clipping of large list of evenly sized items.
// Helper to calculate coarse clipping of large list of evenly sized items.
// NB: Prefer using the ImGuiListClipper higher-level helper if you can!
// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX
// If you are displaying thousands of items and you have a random access to the list, you can perform clipping yourself to save on CPU.
@ -3234,7 +3234,7 @@ void ImGui::EndChild()
sz.x = ImMax(4.0f, sz.x - g.Style.WindowPadding.x);
if (window->Flags & ImGuiWindowFlags_ChildWindowAutoFitY)
sz.y = ImMax(4.0f, sz.y - g.Style.WindowPadding.y);
ImGui::End();
window = GetCurrentWindow();
@ -3281,7 +3281,7 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size,
const ImGuiStyle& style = GImGui->Style;
// Clamp into visible area while not overlapping the cursor
ImRect r_outer(GetVisibleRect());
ImRect r_outer(GetVisibleRect());
r_outer.Reduce(style.DisplaySafeAreaPadding);
ImVec2 base_pos_clamped = ImClamp(base_pos, r_outer.Min, r_outer.Max - size);
@ -3381,11 +3381,11 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
return window;
}
// Push a new ImGui window to add widgets to.
// Push a new ImGui window to add widgets to.
// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair.
// - Begin/End can be called multiple times during the frame with the same window name to append content.
// - 'size_on_first_use' for a regular window denote the initial size for first-time creation (no saved data) and isn't that useful. Use SetNextWindowSize() prior to calling Begin() for more flexible window manipulation.
// - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file).
// - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file).
// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file.
// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned.
// - Passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
@ -3414,7 +3414,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
window_is_new = true;
}
window->Flags = (ImGuiWindowFlags)flags;
// Add to stack
ImGuiWindow* parent_window = !g.CurrentWindowStack.empty() ? g.CurrentWindowStack.back() : NULL;
g.CurrentWindowStack.push_back(window);
@ -3839,7 +3839,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
window->DC.ChildWindows.resize(0);
window->DC.LayoutType = ImGuiLayoutType_Vertical;
window->DC.ItemWidth = window->ItemWidthDefault;
window->DC.ItemWidthStack.resize(0);
window->DC.ItemWidthStack.resize(0);
window->DC.ButtonRepeat = false;
window->DC.ButtonRepeatStack.resize(0);
window->DC.AllowKeyboardFocus = true;
@ -3870,7 +3870,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
const ImVec2 text_size = CalcTextSize(name, NULL, true);
if (!(flags & ImGuiWindowFlags_NoCollapse))
RenderCollapseTriangle(window->Pos + style.FramePadding, !window->Collapsed, 1.0f, true);
ImVec2 text_min = window->Pos + style.FramePadding;
ImVec2 text_max = window->Pos + ImVec2(window->Size.x - style.FramePadding.x, style.FramePadding.y*2 + text_size.y);
ImVec2 clip_max = ImVec2(window->Pos.x + window->Size.x - (p_opened ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x), text_max.y); // Match the size of CloseWindowButton()
@ -4035,7 +4035,7 @@ void ImGui::FocusWindow(ImGuiWindow* window)
if (!window)
return;
// And move its root window to the top of the pile
// And move its root window to the top of the pile
if (window->RootWindow)
window = window->RootWindow;
@ -4794,7 +4794,7 @@ void ImGui::TextUnformatted(const char* text, const char* text_end)
{
// Long text!
// Perform manual coarse clipping to optimize for long multi-line text
// From this point we will only compute the width of lines that are visible. Optimization only available when word-wrapping is disabled.
// From this point we will only compute the width of lines that are visible. Optimization only available when word-wrapping is disabled.
// We also don't vertically center the text within the line full height, which is unlikely to matter because we are likely the biggest and only item on the line.
const char* line = text;
const float line_height = ImGui::GetTextLineHeight();
@ -5154,7 +5154,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding;
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding*2);
const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size);
const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size);
ItemSize(bb);
if (!ItemAdd(bb, &id))
return false;
@ -5259,7 +5259,7 @@ void ImGui::LogButtons()
ImGui::PushID("LogButtons");
const bool log_to_tty = ImGui::Button("Log To TTY");
ImGui::SameLine();
ImGui::SameLine();
const bool log_to_file = ImGui::Button("Log To File");
ImGui::SameLine();
const bool log_to_clipboard = ImGui::Button("Log To Clipboard");
@ -5423,7 +5423,7 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
ImGuiState& g = *GImGui;
const ImGuiStyle& style = g.Style;
@ -5602,16 +5602,16 @@ static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const
if (data_type == ImGuiDataType_Int)
{
if (op == '+')
*(int*)value1 = *(int*)value1 + *(const int*)value2;
*(int*)value1 = *(int*)value1 + *(const int*)value2;
else if (op == '-')
*(int*)value1 = *(int*)value1 - *(const int*)value2;
*(int*)value1 = *(int*)value1 - *(const int*)value2;
}
else if (data_type == ImGuiDataType_Float)
{
if (op == '+')
*(float*)value1 = *(float*)value1 + *(const float*)value2;
*(float*)value1 = *(float*)value1 + *(const float*)value2;
else if (op == '-')
*(float*)value1 = *(float*)value1 - *(const float*)value2;
*(float*)value1 = *(float*)value1 - *(const float*)value2;
}
}
@ -5639,7 +5639,7 @@ static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
if (data_type == ImGuiDataType_Int)
{
if (!scalar_format)
if (!scalar_format)
scalar_format = "%d";
int* v = (int*)data_ptr;
int ref_v = *v;
@ -5655,7 +5655,7 @@ static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
}
else if (data_type == ImGuiDataType_Float)
{
if (!scalar_format)
if (!scalar_format)
scalar_format = "%f";
float* v = (float*)data_ptr;
float ref_v = *v;
@ -5729,7 +5729,7 @@ float ImGui::RoundScalar(float value, int decimal_precision)
// Round past decimal precision
// So when our value is 1.99999 with a precision of 0.001 we'll end up rounding to 2.0
// FIXME: Investigate better rounding methods
static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f };
static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f };
float min_step = (decimal_precision >= 0 && decimal_precision < 10) ? min_steps[decimal_precision] : powf(10.0f, (float)-decimal_precision);
bool negative = value < 0.0f;
value = fabsf(value);
@ -6432,7 +6432,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f);
const int v_idx = (int)(t * (values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0)));
IM_ASSERT(v_idx >= 0 && v_idx < values_count);
const float v0 = values_getter(data, (v_idx + values_offset) % values_count);
const float v1 = values_getter(data, (v_idx + 1 + values_offset) % values_count);
if (plot_type == ImGuiPlotType_Lines)
@ -6549,7 +6549,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
if (*v)
{
const float check_sz = ImMin(check_bb.GetWidth(), check_bb.GetHeight());
const float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f));
const float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f));
window->DrawList->AddRectFilled(check_bb.Min+ImVec2(pad,pad), check_bb.Max-ImVec2(pad,pad), window->Color(ImGuiCol_CheckMark), style.FrameRounding);
}
@ -6610,7 +6610,7 @@ bool ImGui::RadioButton(const char* label, bool active)
if (active)
{
const float check_sz = ImMin(check_bb.GetWidth(), check_bb.GetHeight());
const float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f));
const float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f));
window->DrawList->AddCircleFilled(center, radius-pad, window->Color(ImGuiCol_CheckMark), 16);
}
@ -6728,9 +6728,9 @@ static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n)
obj->CurLenW -= n;
// Offset remaining text
const ImWchar* src = obj->Text.Data + pos + n;
const ImWchar* src = obj->Text.Data + pos + n;
while (ImWchar c = *src++)
*dst++ = c;
*dst++ = c;
*dst = '\0';
}
@ -6779,10 +6779,10 @@ static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const Im
}
void ImGuiTextEditState::OnKeyPressed(int key)
{
stb_textedit_key(this, &StbState, key);
{
stb_textedit_key(this, &StbState, key);
CursorFollow = true;
CursorAnimReset();
CursorAnimReset();
}
// Public API to manipulate UTF-8 text
@ -6864,7 +6864,7 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f
{
ImGuiTextEditCallbackData callback_data;
memset(&callback_data, 0, sizeof(ImGuiTextEditCallbackData));
callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter;
callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter;
callback_data.EventChar = (ImWchar)c;
callback_data.Flags = flags;
callback_data.UserData = user_data;
@ -6961,7 +6961,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
{
edit_state.Id = id;
edit_state.ScrollX = 0.f;
stb_textedit_initialize_state(&edit_state.StbState, !is_multiline);
stb_textedit_initialize_state(&edit_state.StbState, !is_multiline);
if (!is_multiline && focus_requested_by_code)
select_all = true;
}
@ -7055,9 +7055,9 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
{
bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0;
if (!is_multiline || (ctrl_enter_for_new_line && !is_ctrl_down) || (!ctrl_enter_for_new_line && is_ctrl_down))
{
SetActiveID(0);
enter_pressed = true;
{
SetActiveID(0);
enter_pressed = true;
}
else // New line
{
@ -7172,7 +7172,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
if (event_key != ImGuiKey_COUNT || (flags & ImGuiInputTextFlags_CallbackAlways) != 0)
{
ImGuiTextEditCallbackData callback_data;
callback_data.EventFlag = event_flag;
callback_data.EventFlag = event_flag;
callback_data.EventKey = event_key;
callback_data.Buf = edit_state.TempTextBuffer.Data;
callback_data.BufSize = edit_state.BufSizeA;
@ -7279,7 +7279,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
{
const float scroll_increment_x = size.x * 0.25f;
if (cursor_offset.x < edit_state.ScrollX)
edit_state.ScrollX = ImMax(0.0f, cursor_offset.x - scroll_increment_x);
edit_state.ScrollX = ImMax(0.0f, cursor_offset.x - scroll_increment_x);
else if (cursor_offset.x - size.x >= edit_state.ScrollX)
edit_state.ScrollX = cursor_offset.x - size.x + scroll_increment_x;
}
@ -7345,7 +7345,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
bool cursor_is_visible = (g.InputTextState.CursorAnim <= 0.0f) || fmodf(g.InputTextState.CursorAnim, 1.20f) <= 0.80f;
if (cursor_is_visible)
draw_window->DrawList->AddLine(cursor_screen_pos + ImVec2(0.0f,-g.FontSize+0.5f), cursor_screen_pos + ImVec2(0.0f,-1.5f), window->Color(ImGuiCol_Text));
// Notify OS of text input position for advanced IME
if (io.ImeSetInputScreenPosFn && ImLengthSqr(edit_state.InputCursorScreenPos - cursor_screen_pos) > 0.0001f)
io.ImeSetInputScreenPosFn((int)cursor_screen_pos.x - 1, (int)(cursor_screen_pos.y - g.FontSize)); // -1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.
@ -7644,7 +7644,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
if (label_size.x > 0)
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
bool menu_toggled = false;
if (hovered)
{
@ -7664,7 +7664,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
}
}
}
bool value_changed = false;
if (IsPopupOpen(id))
{
@ -7845,7 +7845,7 @@ void ImGui::ListBoxFooter()
ImGuiWindow* parent_window = GetParentWindow();
const ImRect bb = parent_window->DC.LastItemRect;
const ImGuiStyle& style = ImGui::GetStyle();
ImGui::EndChildFrame();
// Redeclare item size so that it includes the label (we have stored the full size in LastItemRect)
@ -7995,7 +7995,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return false;
ImGuiState& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
@ -8057,7 +8057,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
//window->DrawList->PushClipRectFullScreen(); window->DrawList->AddTriangleFilled(ta, tb, tc, moving_within_opened_triangle ? 0x80008000 : 0x80000080); window->DrawList->PopClipRect(); // Debug
}
}
want_close = (opened && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_within_opened_triangle);
want_open = (!opened && hovered && !moving_within_opened_triangle) || (!opened && hovered && pressed);
}
@ -8188,13 +8188,13 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
const bool hide_prefix = (w_item_one <= CalcTextSize("M:999").x);
const char* ids[4] = { "##X", "##Y", "##Z", "##W" };
const char* fmt_table[3][4] =
const char* fmt_table[3][4] =
{
{ "%3.0f", "%3.0f", "%3.0f", "%3.0f" },
{ "%3.0f", "%3.0f", "%3.0f", "%3.0f" },
{ "R:%3.0f", "G:%3.0f", "B:%3.0f", "A:%3.0f" },
{ "H:%3.0f", "S:%3.0f", "V:%3.0f", "A:%3.0f" }
{ "H:%3.0f", "S:%3.0f", "V:%3.0f", "A:%3.0f" }
};
const char** fmt = hide_prefix ? fmt_table[0] : hsv ? fmt_table[2] : fmt_table[1];
const char** fmt = hide_prefix ? fmt_table[0] : hsv ? fmt_table[2] : fmt_table[1];
ImGui::PushItemWidth(w_item_one);
for (int n = 0; n < components; n++)
@ -8222,7 +8222,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
value_changed |= ImGui::InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
ImGui::PopItemWidth();
char* p = buf;
while (*p == '#' || ImCharIsSpace(*p))
while (*p == '#' || ImCharIsSpace(*p))
p++;
// Treat at unsigned (%X is unsigned)
@ -8404,7 +8404,7 @@ void ImGui::SameLine(float local_pos_x, float spacing_w)
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
ImGuiState& g = *GImGui;
float x, y;
if (local_pos_x != 0.0f)
@ -8749,9 +8749,9 @@ static const char* GetClipboardTextFn_DefaultImpl()
ImGui::MemFree(buf_local);
buf_local = NULL;
}
if (!OpenClipboard(NULL))
if (!OpenClipboard(NULL))
return NULL;
HANDLE wbuf_handle = GetClipboardData(CF_UNICODETEXT);
HANDLE wbuf_handle = GetClipboardData(CF_UNICODETEXT);
if (wbuf_handle == NULL)
return NULL;
if (ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle))
@ -8760,8 +8760,8 @@ static const char* GetClipboardTextFn_DefaultImpl()
buf_local = (char*)ImGui::MemAlloc(buf_len * sizeof(char));
ImTextStrToUtf8(buf_local, buf_len, wbuf_global, NULL);
}
GlobalUnlock(wbuf_handle);
CloseClipboard();
GlobalUnlock(wbuf_handle);
CloseClipboard();
return buf_local;
}
@ -8771,12 +8771,12 @@ static void SetClipboardTextFn_DefaultImpl(const char* text)
return;
const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1;
HGLOBAL wbuf_handle = GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar));
HGLOBAL wbuf_handle = GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar));
if (wbuf_handle == NULL)
return;
ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle);
ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle);
ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL);
GlobalUnlock(wbuf_handle);
GlobalUnlock(wbuf_handle);
EmptyClipboard();
SetClipboardData(CF_UNICODETEXT, wbuf_handle);
CloseClipboard();
@ -8879,8 +8879,8 @@ void ImGui::ShowMetricsWindow(bool* opened)
for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
vtxs_rect.Add(draw_list->VtxBuffer[draw_list->IdxBuffer[i]].pos);
GImGui->OverlayDrawList.PushClipRectFullScreen();
clip_rect.Round(); GImGui->OverlayDrawList.AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
vtxs_rect.Round(); GImGui->OverlayDrawList.AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
clip_rect.Round(); GImGui->OverlayDrawList.AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
vtxs_rect.Round(); GImGui->OverlayDrawList.AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
GImGui->OverlayDrawList.PopClipRect();
}
}