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