Format like smack-a-brother, and write comments as sentences

Four-space indents, braces on their own lines, and one-statement bodies without braces.
Semicolons in comments became full stops.
Designated initializers may leave fields out without a warning.
This commit is contained in:
shweet committed 2026-11-22 17:30:03 -05:00
1 parent 40f6b554b5
commit 7afdf709c3
176 files changed
+20500 -19048

No files matched your search

+53 -47
View File
@@ -4,68 +4,72 @@
#include <glad/glad.h>
constexpr ImU32 DROP_LINE_COLOR = IM_COL32(255, 255, 0, 255);
constexpr float DROP_LINE_THICKNESS = 2.0f;
constexpr ImU32 DROP_LINE_COLOR = IM_COL32(255, 255, 0, 255);
constexpr float DROP_LINE_THICKNESS = 2.0f;
struct CheckerStart
{
struct CheckerStart
{
float position = 0;
long long index = {};
};
};
static CheckerStart checker_start(float minCoord, float offset, float step)
{
static CheckerStart checker_start(float minCoord, float offset, float step)
{
float world = minCoord + offset;
long long index = static_cast<long long>(std::floor(world / step));
float first = minCoord - (world - static_cast<float>(index) * step);
return {first, index};
}
}
bool is_drop_after(ImVec2 min, ImVec2 max)
{
bool is_drop_after(ImVec2 min, ImVec2 max)
{
return ImGui::GetIO().MousePos.y >= (min.y + max.y) * 0.5f;
}
}
void drop_box_draw(ImDrawList* drawList, ImVec2 min, ImVec2 max)
{
if (!drawList) return;
void drop_box_draw(ImDrawList* drawList, ImVec2 min, ImVec2 max)
{
if (!drawList)
return;
auto offset = DROP_LINE_THICKNESS * 0.5f;
drawList->AddRect(ImVec2(min.x + offset, min.y + offset), ImVec2(max.x - offset, max.y - offset),
DROP_LINE_COLOR, 0.0f, 0, DROP_LINE_THICKNESS);
}
drawList->AddRect(ImVec2(min.x + offset, min.y + offset), ImVec2(max.x - offset, max.y - offset), DROP_LINE_COLOR,
0.0f, 0, DROP_LINE_THICKNESS);
}
void drop_line_draw(ImDrawList* drawList, ImVec2 min, ImVec2 max, bool isAfter)
{
if (!drawList) return;
void drop_line_draw(ImDrawList* drawList, ImVec2 min, ImVec2 max, bool isAfter)
{
if (!drawList)
return;
auto offset = DROP_LINE_THICKNESS * 0.5f;
auto y = std::floor(isAfter ? max.y - offset : min.y + offset) + 0.5f;
drawList->AddLine(ImVec2(min.x, y), ImVec2(max.x, y), DROP_LINE_COLOR, DROP_LINE_THICKNESS);
}
}
static void image_premultiplied_blend_set(const ImDrawList*, const ImDrawCmd*)
{
static void image_premultiplied_blend_set(const ImDrawList*, const ImDrawCmd*)
{
glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
}
void image_premultiplied_draw(ImTextureID texture, ImVec2 size)
{
void image_premultiplied_draw(ImTextureID texture, ImVec2 size)
{
auto drawList = ImGui::GetWindowDrawList();
drawList->AddCallback(image_premultiplied_blend_set, nullptr);
ImGui::Image(texture, size);
drawList->AddCallback(ImDrawCallback_ResetRenderState, nullptr);
}
}
void image_premultiplied_draw(ImDrawList* drawList, ImTextureID texture, ImVec2 min, ImVec2 max)
{
if (!drawList) return;
void image_premultiplied_draw(ImDrawList* drawList, ImTextureID texture, ImVec2 min, ImVec2 max)
{
if (!drawList)
return;
drawList->AddCallback(image_premultiplied_blend_set, nullptr);
drawList->AddImage(texture, min, max);
drawList->AddCallback(ImDrawCallback_ResetRenderState, nullptr);
}
}
void render_checker_background(ImDrawList* drawList, ImVec2 min, ImVec2 max, glm::vec2 offset, float step)
{
if (!drawList || step <= 0.0f) return;
void render_checker_background(ImDrawList* drawList, ImVec2 min, ImVec2 max, glm::vec2 offset, float step)
{
if (!drawList || step <= 0.0f)
return;
const ImU32 colorLight = IM_COL32(204, 204, 204, 255);
const ImU32 colorDark = IM_COL32(128, 128, 128, 255);
@@ -73,19 +77,21 @@
auto [startY, rowIndex] = checker_start(min.y, offset.y, step);
for (float y = startY; y < max.y; y += step, ++rowIndex)
{
float y1 = glm::max(y, min.y);
float y2 = glm::min(y + step, max.y);
if (y2 <= y1) continue;
float y1 = glm::max(y, min.y);
float y2 = glm::min(y + step, max.y);
if (y2 <= y1)
continue;
auto [startX, columnIndex] = checker_start(min.x, offset.x, step);
for (float x = startX; x < max.x; x += step, ++columnIndex)
{
float x1 = glm::max(x, min.x);
float x2 = glm::min(x + step, max.x);
if (x2 <= x1) continue;
auto [startX, columnIndex] = checker_start(min.x, offset.x, step);
for (float x = startX; x < max.x; x += step, ++columnIndex)
{
float x1 = glm::max(x, min.x);
float x2 = glm::min(x + step, max.x);
if (x2 <= x1)
continue;
bool isDark = ((rowIndex + columnIndex) & 1LL) != 0;
drawList->AddRectFilled(ImVec2(x1, y1), ImVec2(x2, y2), isDark ? colorDark : colorLight);
}
bool isDark = ((rowIndex + columnIndex) & 1LL) != 0;
drawList->AddRectFilled(ImVec2(x1, y1), ImVec2(x2, y2), isDark ? colorDark : colorLight);
}
}
}
}