mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-20 05:39:18 +02:00
reformat: use auto on certain types
This commit is contained in:
@@ -169,7 +169,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
|
||||
int lines_skipped = 0;
|
||||
while (line < text_end && lines_skipped < lines_skippable)
|
||||
{
|
||||
const char* line_end = (const char*)memchr(line, '\n', text_end - line);
|
||||
auto line_end = (const char*)memchr(line, '\n', text_end - line);
|
||||
if (!line_end)
|
||||
line_end = text_end;
|
||||
if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0)
|
||||
@@ -190,7 +190,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
|
||||
if (IsClippedEx(line_rect, 0, false))
|
||||
break;
|
||||
|
||||
const char* line_end = (const char*)memchr(line, '\n', text_end - line);
|
||||
auto line_end = (const char*)memchr(line, '\n', text_end - line);
|
||||
if (!line_end)
|
||||
line_end = text_end;
|
||||
text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x);
|
||||
@@ -205,7 +205,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
|
||||
int lines_skipped = 0;
|
||||
while (line < text_end)
|
||||
{
|
||||
const char* line_end = (const char*)memchr(line, '\n', text_end - line);
|
||||
auto line_end = (const char*)memchr(line, '\n', text_end - line);
|
||||
if (!line_end)
|
||||
line_end = text_end;
|
||||
if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0)
|
||||
@@ -1124,7 +1124,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
||||
fraction = ImSaturate(fraction);
|
||||
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
|
||||
const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y);
|
||||
const auto fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y);
|
||||
RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding);
|
||||
|
||||
// Default displaying the fraction as percentage string, but user can override it
|
||||
@@ -1360,8 +1360,8 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float
|
||||
|
||||
static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs)
|
||||
{
|
||||
const ImGuiShrinkWidthItem* a = (const ImGuiShrinkWidthItem*)lhs;
|
||||
const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs;
|
||||
auto a = (const ImGuiShrinkWidthItem*)lhs;
|
||||
auto b = (const ImGuiShrinkWidthItem*)rhs;
|
||||
if (int d = (int)(b->Width - a->Width))
|
||||
return d;
|
||||
return (b->Index - a->Index);
|
||||
@@ -1533,7 +1533,7 @@ void ImGui::EndCombo()
|
||||
// Getter for the old Combo() API: const char*[]
|
||||
static bool Items_ArrayGetter(void* data, int idx, const char** out_text)
|
||||
{
|
||||
const char* const* items = (const char* const*)data;
|
||||
auto items = (const char* const*)data;
|
||||
if (out_text)
|
||||
*out_text = items[idx];
|
||||
return true;
|
||||
@@ -1543,7 +1543,7 @@ static bool Items_ArrayGetter(void* data, int idx, const char** out_text)
|
||||
static bool Items_SingleStringGetter(void* data, int idx, const char** out_text)
|
||||
{
|
||||
// FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited.
|
||||
const char* items_separated_by_zeros = (const char*)data;
|
||||
auto items_separated_by_zeros = (const char*)data;
|
||||
int items_count = 0;
|
||||
const char* p = items_separated_by_zeros;
|
||||
while (*p)
|
||||
@@ -1794,7 +1794,7 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
int arg1i = 0;
|
||||
if (data_type == ImGuiDataType_S32)
|
||||
{
|
||||
int* v = (int*)data_ptr;
|
||||
auto v = (int*)data_ptr;
|
||||
int arg0i = *v;
|
||||
float arg1f = 0.0f;
|
||||
if (op && sscanf(initial_value_buf, format, &arg0i) < 1)
|
||||
@@ -1809,7 +1809,7 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
{
|
||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
||||
format = "%f";
|
||||
float* v = (float*)data_ptr;
|
||||
auto v = (float*)data_ptr;
|
||||
float arg0f = *v, arg1f = 0.0f;
|
||||
if (op && sscanf(initial_value_buf, format, &arg0f) < 1)
|
||||
return false;
|
||||
@@ -1823,7 +1823,7 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
else if (data_type == ImGuiDataType_Double)
|
||||
{
|
||||
format = "%lf"; // scanf differentiate float/double unlike printf which forces everything to double because of ellipsis
|
||||
double* v = (double*)data_ptr;
|
||||
auto v = (double*)data_ptr;
|
||||
double arg0f = *v, arg1f = 0.0;
|
||||
if (op && sscanf(initial_value_buf, format, &arg0f) < 1)
|
||||
return false;
|
||||
@@ -3109,7 +3109,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* t
|
||||
const float line_height = g.FontSize;
|
||||
const float scale = line_height / font->FontSize;
|
||||
|
||||
ImVec2 text_size = ImVec2(0,0);
|
||||
auto text_size = ImVec2(0,0);
|
||||
float line_width = 0.0f;
|
||||
|
||||
const ImWchar* s = text_begin;
|
||||
@@ -3720,7 +3720,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
const int ib = state->HasSelection() ? ImMin(state->Stb.select_start, state->Stb.select_end) : 0;
|
||||
const int ie = state->HasSelection() ? ImMax(state->Stb.select_start, state->Stb.select_end) : state->CurLenW;
|
||||
const int clipboard_data_len = ImTextCountUtf8BytesFromStr(state->TextW.Data + ib, state->TextW.Data + ie) + 1;
|
||||
char* clipboard_data = (char*)IM_ALLOC(clipboard_data_len * sizeof(char));
|
||||
auto clipboard_data = (char*)IM_ALLOC(clipboard_data_len * sizeof(char));
|
||||
ImTextStrToUtf8(clipboard_data, clipboard_data_len, state->TextW.Data + ib, state->TextW.Data + ie);
|
||||
SetClipboardText(clipboard_data);
|
||||
MemFree(clipboard_data);
|
||||
@@ -3739,7 +3739,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
{
|
||||
// Filter pasted buffer
|
||||
const int clipboard_len = (int)strlen(clipboard);
|
||||
ImWchar* clipboard_filtered = (ImWchar*)IM_ALLOC((clipboard_len+1) * sizeof(ImWchar));
|
||||
auto clipboard_filtered = (ImWchar*)IM_ALLOC((clipboard_len+1) * sizeof(ImWchar));
|
||||
int clipboard_filtered_len = 0;
|
||||
for (const char* s = clipboard; *s; )
|
||||
{
|
||||
@@ -4032,7 +4032,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
}
|
||||
|
||||
// Draw selection
|
||||
const ImVec2 draw_scroll = ImVec2(state->ScrollX, 0.0f);
|
||||
const auto draw_scroll = ImVec2(state->ScrollX, 0.0f);
|
||||
if (render_selection)
|
||||
{
|
||||
const ImWchar* text_selected_begin = text_begin + ImMin(state->Stb.select_start, state->Stb.select_end);
|
||||
@@ -4512,9 +4512,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
|
||||
// Note: the triangle is displayed rotated with triangle_pa pointing to Hue, but most coordinates stays unrotated for logic.
|
||||
float triangle_r = wheel_r_inner - (int)(sv_picker_size * 0.027f);
|
||||
ImVec2 triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point.
|
||||
ImVec2 triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point.
|
||||
ImVec2 triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point.
|
||||
auto triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point.
|
||||
auto triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point.
|
||||
auto triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point.
|
||||
|
||||
float H = col[0], S = col[1], V = col[2];
|
||||
float R = col[0], G = col[1], B = col[2];
|
||||
@@ -5630,7 +5630,7 @@ bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg)
|
||||
|
||||
// Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar.
|
||||
ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y);
|
||||
ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y));
|
||||
auto frame_size = ImVec2(size.x, ImMax(size.y, label_size.y));
|
||||
ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size);
|
||||
ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
|
||||
window->DC.LastItemRect = bb; // Forward storage for ListBoxFooter.. dodgy.
|
||||
@@ -5808,7 +5808,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
||||
|
||||
float v0 = values_getter(data, (0 + values_offset) % values_count);
|
||||
float t0 = 0.0f;
|
||||
ImVec2 tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) * inv_scale) ); // Point in the normalized space of our target rectangle
|
||||
auto tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) * inv_scale) ); // Point in the normalized space of our target rectangle
|
||||
float histogram_zero_line_t = (scale_min * scale_max < 0.0f) ? (-scale_min * inv_scale) : (scale_min < 0.0f ? 0.0f : 1.0f); // Where does the zero line stands
|
||||
|
||||
const ImU32 col_base = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLines : ImGuiCol_PlotHistogram);
|
||||
@@ -5820,7 +5820,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
||||
const int v1_idx = (int)(t0 * item_count + 0.5f);
|
||||
IM_ASSERT(v1_idx >= 0 && v1_idx < values_count);
|
||||
const float v1 = values_getter(data, (v1_idx + values_offset + 1) % values_count);
|
||||
const ImVec2 tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) * inv_scale) );
|
||||
const auto tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) * inv_scale) );
|
||||
|
||||
// NB: Draw calls are merged together by the DrawList system. Still, we should render our batch are lower level to save a bit of CPU.
|
||||
ImVec2 pos0 = ImLerp(inner_bb.Min, inner_bb.Max, tp0);
|
||||
@@ -5859,7 +5859,7 @@ struct ImGuiPlotArrayGetterData
|
||||
|
||||
static float Plot_ArrayGetter(void* data, int idx)
|
||||
{
|
||||
ImGuiPlotArrayGetterData* plot_data = (ImGuiPlotArrayGetterData*)data;
|
||||
auto plot_data = (ImGuiPlotArrayGetterData*)data;
|
||||
const float v = *(const float*)(const void*)((const unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride);
|
||||
return v;
|
||||
}
|
||||
@@ -6350,8 +6350,8 @@ ImGuiTabBar::ImGuiTabBar()
|
||||
|
||||
static int IMGUI_CDECL TabItemComparerByVisibleOffset(const void* lhs, const void* rhs)
|
||||
{
|
||||
const ImGuiTabItem* a = (const ImGuiTabItem*)lhs;
|
||||
const ImGuiTabItem* b = (const ImGuiTabItem*)rhs;
|
||||
auto a = (const ImGuiTabItem*)lhs;
|
||||
auto b = (const ImGuiTabItem*)rhs;
|
||||
return (int)(a->Offset - b->Offset);
|
||||
}
|
||||
|
||||
@@ -6378,7 +6378,7 @@ bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
|
||||
|
||||
ImGuiID id = window->GetID(str_id);
|
||||
ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id);
|
||||
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
|
||||
auto tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
|
||||
tab_bar->ID = id;
|
||||
return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused);
|
||||
}
|
||||
@@ -7087,7 +7087,7 @@ ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
ImVec2 size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0f);
|
||||
auto size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0f);
|
||||
if (has_close_button)
|
||||
size.x += g.Style.FramePadding.x + (g.Style.ItemInnerSpacing.x + g.FontSize); // We use Y intentionally to fit the close button circle.
|
||||
else
|
||||
@@ -7130,7 +7130,7 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
||||
return false;
|
||||
|
||||
// Render text label (with clipping + alpha gradient) + unsaved marker
|
||||
const char* TAB_UNSAVED_MARKER = "*";
|
||||
auto TAB_UNSAVED_MARKER = "*";
|
||||
ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y);
|
||||
if (flags & ImGuiTabItemFlags_UnsavedDocument)
|
||||
{
|
||||
@@ -7670,7 +7670,7 @@ bool ImGui::Spinner( const char* label, float radius, int thickness, const ImU32
|
||||
const float a_min = IM_PI * 2.0f * ( (float)start ) / (float)num_segments;
|
||||
const float a_max = IM_PI * 2.0f * ( (float)num_segments - 3 ) / (float)num_segments;
|
||||
|
||||
const ImVec2 centre = ImVec2( pos.x + radius, pos.y + radius + style.FramePadding.y );
|
||||
const auto centre = ImVec2( pos.x + radius, pos.y + radius + style.FramePadding.y );
|
||||
|
||||
for( int i = 0; i < num_segments; i++ ) {
|
||||
const float a = a_min + ( (float)i / (float)num_segments ) * ( a_max - a_min );
|
||||
|
||||
Reference in New Issue
Block a user