Build cleanly under clang, and name the remaining booleans with is

Exported XML templates lose the static clang rejects. Unused this captures,
a dead null check, an undefined declaration, an unused constant and stray
semicolons go, and single statements lose their braces.
This commit is contained in:
shweet committed 2026-11-22 19:35:33 -05:00
1 parent c5a2bddfa1
commit f35f9cb4b8
21 files changed
+59 -72

No files matched your search

+1 -1
View File
@@ -84,7 +84,7 @@ Mat4 quad_model_parent_get(Vec2 position, Vec2 pivot, Vec2 scale, float rotation
float random_unit_get()
{
return (float)rand() / RAND_MAX;
return (float)rand() / (float)RAND_MAX;
}
float random_in_range(float min, float max)
+3 -3
View File
@@ -308,10 +308,10 @@ struct JsonWriter
// Each returns what it expected when the value is the wrong kind (and leaves the value as it was).
static std::string_view value_read(dom::element element, bool& value)
{
bool read = false;
if (element.get(read))
bool isTrue = false;
if (element.get(isTrue))
return "true or false";
value = read;
value = isTrue;
return {};
}
+2 -3
View File
@@ -56,7 +56,6 @@ constexpr std::size_t VALUE_BUFFER_SIZE = 64;
constexpr int FLOAT_DIGITS = 8;
constexpr int DOUBLE_DIGITS = 17;
constexpr double FLOAT_WHOLE_MAX = 1e8;
constexpr std::size_t FRAME_ATTRIBUTES_MAX = 27;
constexpr std::string_view INDENT = " ";
constexpr int TEXT_ENTITY_COUNT = 3;
constexpr std::pair<char, std::string_view> ENTITIES[] = {
@@ -1914,12 +1913,12 @@ std::vector<AnimationEntry> animations_from_string(const std::string& text, std:
return entries;
}
template <class Item> static std::string item_to_string(const Item& item)
template <class Item> std::string item_to_string(const Item& item)
{
return text_get([&](Sink& sink) { element_write(sink, Writer(SAVE_CLIPBOARD), item, item.id); });
}
template <class Item> static std::vector<Item> items_from_string(const std::string& text, std::string* errorString)
template <class Item> std::vector<Item> items_from_string(const std::string& text, std::string* errorString)
{
pugi::xml_document document;
if (!document_parse(document, text, errorString))
-1
View File
@@ -185,6 +185,5 @@ private:
bool animation_record(const RecorderOptions&, Canvas&, ShaderProgram&, Document&, const Animation&, Vec4, float, Vec4,
bool);
std::filesystem::path ffmpeg_log_path();
bool animation_render(const std::filesystem::path&, const std::filesystem::path&,
const std::vector<std::filesystem::path>&, const std::vector<float>&, RenderType, int);
+1 -1
View File
@@ -67,7 +67,7 @@ Resources::Resources()
for (auto [i, shaderInfo] : std::views::enumerate(SHADERS))
shaders[i] = ShaderProgram(shaderInfo.vertex, shaderInfo.fragment);
};
}
GLuint Resources::icon_id_get(int icon)
{
-4
View File
@@ -211,9 +211,7 @@ Settings::Settings(const std::filesystem::path& path)
dest = (val == "true" || val == "1");
}
else if constexpr (std::is_same_v<T, std::string>)
{
std::getline(ss, dest);
}
else if constexpr (std::is_same_v<T, std::filesystem::path>)
{
std::string value;
@@ -221,9 +219,7 @@ Settings::Settings(const std::filesystem::path& path)
dest = path_from_utf8(value);
}
else
{
stream_assign(dest, ss);
}
};
auto entry_load = [&](const std::string& key, std::istringstream& ss, const std::string& name, auto& value,
+4 -4
View File
@@ -143,7 +143,7 @@ void AnimationPreview::tick(Manager& manager, Settings& settings, float deltaSec
recording_stop(manager, document);
}
stop_all_sounds();
wasPlaybackPlaying = false;
isPlaybackPlayingBefore = false;
return;
}
@@ -161,7 +161,7 @@ void AnimationPreview::tick(Manager& manager, Settings& settings, float deltaSec
{
auto fps = std::max(model.info.fps, 1);
auto range = animation_play_range_get(*animation);
if (!wasPlaybackPlaying)
if (!isPlaybackPlayingBefore)
soundFrame = (int)std::floor(playback.time) - 1;
auto isLoop = (animation->isLoop || settings.playbackIsLoop) && !manager.isRecording;
playback.tick(fps, range.x, range.y, isLoop ? PLAYBACK_LOOP : PLAYBACK_ONCE, deltaSeconds);
@@ -181,9 +181,9 @@ void AnimationPreview::tick(Manager& manager, Settings& settings, float deltaSec
}
}
if (wasPlaybackPlaying && !playback.isPlaying)
if (isPlaybackPlayingBefore && !playback.isPlaying)
stop_all_sounds();
wasPlaybackPlaying = playback.isPlaying;
isPlaybackPlayingBefore = playback.isPlaying;
}
void AnimationPreview::recording_stop(Manager& manager, Document& document)
+1 -1
View File
@@ -12,7 +12,7 @@
class AnimationPreview : public CanvasView
{
bool wasPlaybackPlaying = false;
bool isPlaybackPlayingBefore = false;
int soundFrame = -1;
bool isMoveDragging = false;
Vec2 moveOffset{};
+4 -4
View File
@@ -123,7 +123,7 @@ void CanvasView::checker_pan_reset(float zoom, Vec2 pan)
checkerSyncPan = pan;
checkerSyncZoom = zoom;
isCheckerPanInitialized = true;
hasPendingZoomPanAdjust = false;
isZoomPanAdjustPending = false;
}
void CanvasView::checker_pan_sync(float zoom, Vec2 pan)
@@ -133,13 +133,13 @@ void CanvasView::checker_pan_sync(float zoom, Vec2 pan)
if (pan == checkerSyncPan && zoom == checkerSyncZoom)
return;
auto isPanDeltaIgnored = hasPendingZoomPanAdjust && zoom != checkerSyncZoom;
auto isPanDeltaIgnored = isZoomPanAdjustPending && zoom != checkerSyncZoom;
if (!isPanDeltaIgnored)
checkerPan += pan - checkerSyncPan;
checkerSyncPan = pan;
checkerSyncZoom = zoom;
if (isPanDeltaIgnored)
hasPendingZoomPanAdjust = false;
isZoomPanAdjustPending = false;
}
void CanvasView::zoom_step(float& zoom, Vec2& pan, Vec2 focus, int levelDelta)
@@ -147,7 +147,7 @@ void CanvasView::zoom_step(float& zoom, Vec2& pan, Vec2 focus, int levelDelta)
auto previousZoom = zoom;
zoom_level_adjust(zoom, pan, focus, levelDelta);
if (zoom != previousZoom)
hasPendingZoomPanAdjust = true;
isZoomPanAdjustPending = true;
}
void CanvasView::grid_child_draw(ImVec2 childSize, bool& isGrid, Vec4& gridColor, IVec2& gridSize, IVec2& gridOffset,
+1 -1
View File
@@ -52,7 +52,7 @@ protected:
Vec2 checkerSyncPan{};
float checkerSyncZoom = 0;
bool isCheckerPanInitialized = false;
bool hasPendingZoomPanAdjust = false;
bool isZoomPanAdjustPending = false;
bool isFocused = false;
void checker_pan_reset(float, Vec2);
+3 -3
View File
@@ -124,7 +124,7 @@ void Documents::update(Taskbar& taskbar, Manager& manager, Settings& settings, R
auto viewport = ImGui::GetMainViewport();
auto windowHeight = ImGui::GetFrameHeightWithSpacing();
bool isLightTheme = settings.theme == THEME_LIGHT;
bool pushedStyle = false;
bool isStylePushed = false;
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + taskbar.height));
@@ -132,7 +132,7 @@ void Documents::update(Taskbar& taskbar, Manager& manager, Settings& settings, R
if (isLightTheme)
{
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImGui::GetStyleColorVec4(ImGuiCol_TitleBgActive));
pushedStyle = true;
isStylePushed = true;
}
for (auto i = 0; i < (int)manager.documents.size(); ++i)
@@ -336,7 +336,7 @@ void Documents::update(Taskbar& taskbar, Manager& manager, Settings& settings, R
}
ImGui::End();
if (pushedStyle)
if (isStylePushed)
ImGui::PopStyleColor();
if (manager.isAnm2DragDrop)
+6 -6
View File
@@ -1,14 +1,14 @@
#include "ui/multiselect.h"
void external_storage_set(ImGuiSelectionExternalStorage* self, int id, bool isSelected)
static void external_storage_set(ImGuiSelectionExternalStorage* self, int id, bool isSelected)
{
auto* storage = static_cast<MultiSelectStorage*>(self->UserData);
auto value = storage ? storage->resolve_index(id) : id;
auto& storage = *(MultiSelectStorage*)self->UserData;
auto value = storage.resolve_index(id);
if (isSelected)
storage->insert(value);
storage.insert(value);
else
storage->erase(value);
};
storage.erase(value);
}
MultiSelectStorage::MultiSelectStorage()
{
-1
View File
@@ -24,4 +24,3 @@ public:
int resolve_index(int) const;
};
void external_storage_set(ImGuiSelectionExternalStorage*, int, bool);
+6 -12
View File
@@ -250,7 +250,7 @@ void SpritesheetEditor::update(Manager& manager, Settings& settings, Resources&
[pivot = pivot_snap(mousePos - region->crop, region->pivot)](Vec2) { return pivot; });
if (isArrow)
region_pivot_update(
[=, this](Vec2 pivot) { return isGridSnap ? Vec2(IVec2(pivot + arrow)) : pivot + arrow; });
[=](Vec2 pivot) { return isGridSnap ? Vec2(IVec2(pivot + arrow)) : pivot + arrow; });
if (isDuring)
tooltip_lines_draw({localize_format(FORMAT_PIVOT, region->pivot.x, region->pivot.y)});
if (isEnd)
@@ -315,14 +315,14 @@ void SpritesheetEditor::update(Manager& manager, Settings& settings, Resources&
// Arrow nudges are snapped (and the rectangle normalized) when the command runs, after the nudge.
if (isDuring && !isMouseDown && isRegionCrop)
regions_update(regionSelection, [=, this](Region& region) {
regions_update(regionSelection, [=](Region& region) {
auto [minPoint, maxPoint] =
rect_snap(region.crop, region.crop + region.size, isGridSnap, gridSize, gridOffset);
region.crop = minPoint;
region.size = maxPoint - minPoint;
});
else if (isDuring && !isMouseDown)
manager.command_push({manager.selected, [=, this](Manager&, Document& document) {
manager.command_push({manager.selected, [=](Manager&, Document& document) {
auto source = document.model.frame_get(editReference);
if (!source)
return;
@@ -455,19 +455,13 @@ void SpritesheetEditor::update(Manager& manager, Settings& settings, Resources&
frame && reference.itemID > -1 && layer && layer->spritesheetId == referenceSpritesheet;
int highlightedRegionId = -1;
if (document.editTarget == Document::EditTarget::REGION && regionReference != -1 &&
region_get(regionReference))
{
auto isRegionReferenced = regionReference != -1 && region_get(regionReference);
if (document.editTarget == Document::EditTarget::REGION && isRegionReferenced)
highlightedRegionId = regionReference;
}
else if (isReferenceLayerOnSpritesheet && frame->regionId != -1 && region_get(frame->regionId))
{
highlightedRegionId = frame->regionId;
}
else if (regionReference != -1 && region_get(regionReference))
{
else if (isRegionReferenced)
highlightedRegionId = regionReference;
}
auto draw_region_rect = [&](const Region& region, Vec4 regionColor) {
auto cropModel = quad_model_get(region.size, region.crop);
+2 -2
View File
@@ -77,7 +77,7 @@ void Taskbar::update(Manager& manager, Settings& settings, Resources& resources,
auto animation = document ? document->model.animation_get(document->reference_get().animationIndex) : nullptr;
auto layerReferences = document ? document->layer_references_get() : std::vector<Reference>{};
bool isGenerateAnimationFromGridAvailable = !layerReferences.empty();
bool hasRegions =
bool isRegions =
document && std::ranges::any_of(document->model.content.spritesheets,
[](const auto& spritesheet) { return !spritesheet.regions.empty(); });
@@ -165,7 +165,7 @@ void Taskbar::update(Manager& manager, Settings& settings, Resources& resources,
generateRegionsPopup.open();
tooltip_set(TOOLTIP_WIZARD_GENERATE_REGIONS_FROM_ANIMATIONS);
if (ImGui::MenuItem(localize.get(LABEL_SCAN_AND_SET_REGIONS), nullptr, false, document && hasRegions))
if (ImGui::MenuItem(localize.get(LABEL_SCAN_AND_SET_REGIONS), nullptr, false, document && isRegions))
{
manager.command_push({manager.selected, [](Manager&, Document& document) {
document.edit_apply(EDIT_SCAN_AND_SET_REGIONS,
+1 -1
View File
@@ -199,7 +199,7 @@ void TimelineContext::shortcuts_update()
{
if (resizeChordTabIds[i] != document.tabId)
edit_begin_push(resize.edit);
command_push([=, this](Manager&, Document& document) {
command_push([=](Manager&, Document& document) {
for (auto frameReference : selectedFrames)
if (auto frame = document.model.frame_edit(frameReference))
frame->duration =
+1 -1
View File
@@ -208,7 +208,7 @@ struct TimelineContext : TimelineState
template <class Operation>
void edit_push(StringType label, Operation operation, std::function<void(Document&, const Uids&)> select = {})
{
command_push([=, this](Manager&, Document& document) mutable {
command_push([=](Manager&, Document& document) mutable {
auto uids = document.edit_apply(label, operation);
select ? select(document, uids) : document.frames_select(uids);
});
+5 -5
View File
@@ -16,7 +16,7 @@ void TimelineContext::frames_delete_action()
return;
edit_push(
EDIT_DELETE_FRAMES, [=](Model& model) { return frames_delete(model, selectedFrames); },
[this](Document& document, const Uids&) { document.frame_focus_select(); });
[](Document& document, const Uids&) { document.frame_focus_select(); });
}
void TimelineContext::frames_duplicate()
@@ -190,7 +190,7 @@ void TimelineContext::item_group()
name = std::string(localize.get(TEXT_NEW_GROUP))](Model& model) {
return items_group(model, animationIndex, type, ids, name);
},
[=, this](Document& document, const Uids& uids) {
[=](Document& document, const Uids& uids) {
if (uids.empty())
return;
document.selected_set(SelectionKind::TRACKS, {targetReferences.begin(), targetReferences.end()});
@@ -233,7 +233,7 @@ void TimelineContext::rows_move_to_row(std::vector<TimelineRow> draggedRows, Tim
edit_push(
EDIT_MOVE_ITEMS,
[=](Model& model) { return items_move(model, animationIndex, targetType, ids, groupIds, target, zone); },
[=, this](Document& document, const Uids&) {
[=](Document& document, const Uids&) {
document.selection.uids[SelectionKind::TRACKS] = moved.uids.at(SelectionKind::TRACKS);
document.selection.uids[SelectionKind::GROUPS] = moved.uids.at(SelectionKind::GROUPS);
if (tracks.empty())
@@ -289,7 +289,7 @@ void TimelineContext::cut()
frame_references_copy(selectedFrames);
edit_push(
EDIT_CUT_FRAMES, [=](Model& model) { return frames_delete(model, selectedFrames); },
[this](Document& document, const Uids&) { document.frame_focus_select(); });
[](Document& document, const Uids&) { document.frame_focus_select(); });
}
void TimelineContext::paste()
@@ -311,7 +311,7 @@ void TimelineContext::paste()
time = hoveredTime](Model& model) {
return frames_paste(model, targetReference, selectedFrames, text, time, errorString.get());
},
[=, this](Document& document, const Uids& uids) {
[=](Document& document, const Uids& uids) {
if (errorString->empty())
return document.frames_select(uids);
toasts.push(std::format("{} {}", localize.get(TOAST_DESERIALIZE_FRAMES_FAILED), *errorString));
+2 -2
View File
@@ -19,7 +19,7 @@ void TimelineContext::frames_move_to(Reference target)
edit_push(
EDIT_MOVE_FRAMES,
[frames, target, insertIndex](Model& model) { return frames_move(model, frames, target, insertIndex); },
[=, this](Document& document, const Uids& uids) {
[=](Document& document, const Uids& uids) {
document.frames_select(uids);
if (target.itemType == LAYER)
if (auto layer = ::item_get(document.model.content.layers, target.itemID))
@@ -607,7 +607,7 @@ void TimelineContext::frame_drag_update()
{
auto targetReference = draggedFrameReference;
auto targetType = draggedFrameType;
command_push([=, this](Manager&, Document& document) {
command_push([=](Manager&, Document& document) {
auto item = document.model.track_edit(targetReference);
if (targetType == TRIGGER && item)
frames_sort_by_at_frame(*item);
+14 -14
View File
@@ -75,7 +75,7 @@ void TimelineContext::context_menu()
return;
auto settingsPtr = &settings;
command_push([=, this](Manager& manager, Document& document) {
command_push([=](Manager& manager, Document& document) {
auto frame = document.model.frame_get(targetReference);
if (!frame || frame->regionId != -1)
return;
@@ -127,20 +127,20 @@ void TimelineContext::context_menu()
.shortcut = SHORTCUT_INSERT_FRAME,
.isEnabled = [&]() { return item; },
.run = [&]() { frame_insert(); }});
actions.add(ACTION_DUPLICATE, [=, this]() { return !selectedBakeFrames.empty(); }, [&]() { frames_duplicate(); });
actions.add(ACTION_DUPLICATE, [=]() { return !selectedBakeFrames.empty(); }, [&]() { frames_duplicate(); });
actions.add({.label = LABEL_SPLIT,
.shortcut = SHORTCUT_SPLIT,
.isEnabled = [=, this]() { return !selectedBakeFrames.empty(); },
.isEnabled = [=]() { return !selectedBakeFrames.empty(); },
.run = [&]() { frame_split(); }});
actions.add(ACTION_REVERSE, [=, this]() { return isReverseFrames; }, [&]() { frames_reverse(); });
actions.add(ACTION_REVERSE, [=]() { return isReverseFrames; }, [&]() { frames_reverse(); });
actions.separator();
actions.add({.label = LABEL_BAKE,
.shortcut = SHORTCUT_BAKE,
.isEnabled = [=, this]() { return !selectedBakeFrames.empty(); },
.isEnabled = [=]() { return !selectedBakeFrames.empty(); },
.run = [&]() { frames_bake(); }});
actions.add({.label = LABEL_BAKE_INTO_OTHER_FRAMES,
.shortcut = -1,
.isEnabled = [=, this]() { return !selectedRootFrames.empty(); },
.isEnabled = [=]() { return !selectedRootFrames.empty(); },
.run = [&]() { bakeIntoOtherFramesPopup.open(); }});
actions.add({.label = LABEL_FIT_ANIMATION_LENGTH,
.shortcut = SHORTCUT_FIT,
@@ -149,7 +149,7 @@ void TimelineContext::context_menu()
actions.separator();
actions.add({.label = isMakeManyRegions ? LABEL_MAKE_MANY_REGIONS : LABEL_MAKE_REGION,
.shortcut = -1,
.isEnabled = [=, this]() { return isMakeManyRegions || isMakeRegion; },
.isEnabled = [=]() { return isMakeManyRegions || isMakeRegion; },
.run =
[&]() {
if (!isMakeManyRegions)
@@ -160,7 +160,7 @@ void TimelineContext::context_menu()
actions.separator();
actions.add({.label = LABEL_DELETE,
.shortcut = SHORTCUT_REMOVE,
.isEnabled = [=, this]() { return !selectedFrames.empty(); },
.isEnabled = [=]() { return !selectedFrames.empty(); },
.run = [&]() { frames_delete_action(); }});
actions.separator();
// Cut, copy and paste each open onto the whole frame, or one property of it.
@@ -199,10 +199,10 @@ void TimelineContext::context_menu()
return sourceFrame != nullptr;
};
clipboard_menu_add(
ACTION_CUT, [=, this]() { return !selectedFrames.empty(); }, [this]() { cut(); },
ACTION_CUT, [=]() { return !selectedFrames.empty(); }, [this]() { cut(); },
properties_get(sourceType, is_source, [this](FrameProperty property) { property_cut(property); }));
clipboard_menu_add(
ACTION_COPY, [=, this]() { return !copyFrames.empty(); }, [this]() { copy(); },
ACTION_COPY, [=]() { return !copyFrames.empty(); }, [this]() { copy(); },
properties_get(sourceType, is_source, [this](FrameProperty property) { property_copy(property); }));
// Only one property is ever on the clipboard, so pasting one is a single item.
auto clipboardProperty = (FrameProperty)frameClipboard.property;
@@ -317,11 +317,11 @@ void TimelineContext::item_context_menu()
item_base_properties_open(type, id);
});
actions.add(ACTION_ADD, [&]() { return animation; }, [&]() { itemProperties.open(); });
actions.add(ACTION_REMOVE, [=, this]() { return isRemoveAvailable; }, [&]() { item_remove(); });
actions.add(ACTION_GROUP, [=, this]() { return !selectedGroupableItems.empty(); }, [&]() { item_group(); });
actions.add(ACTION_REMOVE, [=]() { return isRemoveAvailable; }, [&]() { item_remove(); });
actions.add(ACTION_GROUP, [=]() { return !selectedGroupableItems.empty(); }, [&]() { item_group(); });
actions.separator();
actions.add(ACTION_CUT, [=, this]() { return !copyFrames.empty() && isRemoveAvailable; }, item_cut);
actions.add(ACTION_COPY, [=, this]() { return !copyFrames.empty(); }, [this]() { copy(); });
actions.add(ACTION_CUT, [=]() { return !copyFrames.empty() && isRemoveAvailable; }, item_cut);
actions.add(ACTION_COPY, [=]() { return !copyFrames.empty(); }, [this]() { copy(); });
actions.add(ACTION_PASTE, [&]() { return item && !clipboard.is_empty(); }, [this]() { paste(); });
if (shortcut(manager.chords[SHORTCUT_CUT], SCOPE_FOCUSED) && !copyFrames.empty() && isRemoveAvailable)
item_cut();
+2 -2
View File
@@ -203,11 +203,11 @@ void TimelineContext::item_child(const TimelineRow& row, int index)
ImGuiHoveredFlags_AllowWhenDisabled |
ImGuiHoveredFlags_NoSharedDelay;
imguiStyle.HoverDelayNormal = FRAME_TOOLTIP_HOVER_DELAY;
bool showItemTooltip = ImGui::BeginItemTooltip();
bool isItemTooltipShown = ImGui::BeginItemTooltip();
imguiStyle.HoverFlagsForTooltipMouse = previousTooltipFlags;
imguiStyle.HoverDelayNormal = previousTooltipDelay;
if (showItemTooltip)
if (isItemTooltipShown)
{
auto yesNoLabel = [&](bool value) {
return value ? localize.get(BASIC_YES) : localize.get(BASIC_NO);