Merge branch 'staging'
# Conflicts: # .vscode/launch.json # .vscode/tasks.json # src/imgui/window/animation_preview.cpp # src/imgui/window/regions.cpp
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "dockspace.h"
|
||||
#include "dockspace.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "documents.h"
|
||||
#include "taskbar.h"
|
||||
#include "window/animation_preview.h"
|
||||
#include "window/animations.h"
|
||||
#include "window/regions.h"
|
||||
#include "window/events.h"
|
||||
#include "window/frame_properties.h"
|
||||
#include "window/layers.h"
|
||||
#include "window/nulls.h"
|
||||
#include "window/onionskin.h"
|
||||
#include "window/sounds.h"
|
||||
#include "window/spritesheet_editor.h"
|
||||
#include "window/spritesheets.h"
|
||||
#include "window/timeline.h"
|
||||
#include "window/tools.h"
|
||||
#include "window/welcome.h"
|
||||
#include "documents.hpp"
|
||||
#include "taskbar.hpp"
|
||||
#include "window/animation_preview.hpp"
|
||||
#include "window/animations.hpp"
|
||||
#include "window/regions.hpp"
|
||||
#include "window/events.hpp"
|
||||
#include "window/frame_properties.hpp"
|
||||
#include "window/layers.hpp"
|
||||
#include "window/nulls.hpp"
|
||||
#include "window/onionskin.hpp"
|
||||
#include "window/sounds.hpp"
|
||||
#include "window/spritesheet_editor.hpp"
|
||||
#include "window/spritesheets.hpp"
|
||||
#include "window/timeline.hpp"
|
||||
#include "window/tools.hpp"
|
||||
#include "window/welcome.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "documents.h"
|
||||
#include "documents.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <vector>
|
||||
|
||||
#include "path_.h"
|
||||
#include "strings.h"
|
||||
#include "time_.h"
|
||||
#include "toast.h"
|
||||
#include "log.h"
|
||||
#include "path_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "time_.hpp"
|
||||
#include "toast.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::types;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "strings.h"
|
||||
#include "taskbar.h"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "taskbar.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -6,9 +6,9 @@
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "imgui_.h"
|
||||
#include "path_.h"
|
||||
#include "strings.h"
|
||||
#include "imgui_.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::util;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "strings.h"
|
||||
#include "types.h"
|
||||
#include "strings.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "taskbar.h"
|
||||
#include "taskbar.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include "document.h"
|
||||
#include "log.h"
|
||||
#include "path_.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "types.h"
|
||||
#include "document.hpp"
|
||||
#include "log.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::types;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "canvas.h"
|
||||
#include "dialog.h"
|
||||
#include "imgui_.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "strings.h"
|
||||
#include "canvas.hpp"
|
||||
#include "dialog.hpp"
|
||||
#include "imgui_.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
#include "wizard/about.h"
|
||||
#include "wizard/change_all_frame_properties.h"
|
||||
#include "wizard/configure.h"
|
||||
#include "wizard/generate_animation_from_grid.h"
|
||||
#include "wizard/render_animation.h"
|
||||
#include "wizard/about.hpp"
|
||||
#include "wizard/change_all_frame_properties.hpp"
|
||||
#include "wizard/configure.hpp"
|
||||
#include "wizard/generate_animation_from_grid.hpp"
|
||||
#include "wizard/render_animation.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
#include "toast.h"
|
||||
#include "toast.hpp"
|
||||
|
||||
#include "log.h"
|
||||
#include "log.hpp"
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "types.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
#include "animation_preview.h"
|
||||
#include "animation_preview.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
#include <system_error>
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "imgui_.h"
|
||||
#include "log.h"
|
||||
#include "math_.h"
|
||||
#include "path_.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "tool.h"
|
||||
#include "types.h"
|
||||
#include "imgui_.hpp"
|
||||
#include "log.hpp"
|
||||
#include "math_.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
#include "tool.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::util;
|
||||
@@ -103,6 +105,50 @@ namespace anm2ed::imgui
|
||||
pixels[index + 2] = (uint8_t)glm::clamp((float)std::round((float)pixels[index + 2] / alphaUnit), 0.0f, 255.0f);
|
||||
}
|
||||
}
|
||||
bool render_audio_stream_generate(AudioStream& audioStream, std::map<int, anm2::Sound>& sounds,
|
||||
const std::vector<int>& frameSoundIDs, int fps)
|
||||
{
|
||||
audioStream.stream.clear();
|
||||
if (frameSoundIDs.empty() || fps <= 0) return true;
|
||||
|
||||
SDL_AudioSpec mixSpec = audioStream.spec;
|
||||
mixSpec.format = SDL_AUDIO_F32;
|
||||
auto* mixer = MIX_CreateMixer(&mixSpec);
|
||||
if (!mixer) return false;
|
||||
|
||||
auto channels = std::max(mixSpec.channels, 1);
|
||||
auto sampleRate = std::max(mixSpec.freq, 1);
|
||||
auto framesPerStep = (double)sampleRate / (double)fps;
|
||||
auto sampleFrameAccumulator = 0.0;
|
||||
auto frameBuffer = std::vector<float>{};
|
||||
|
||||
for (auto soundID : frameSoundIDs)
|
||||
{
|
||||
if (soundID != -1 && sounds.contains(soundID)) sounds.at(soundID).audio.play(false, mixer);
|
||||
|
||||
sampleFrameAccumulator += framesPerStep;
|
||||
auto sampleFramesToGenerate = (int)std::floor(sampleFrameAccumulator);
|
||||
sampleFramesToGenerate = std::max(sampleFramesToGenerate, 1);
|
||||
sampleFrameAccumulator -= (double)sampleFramesToGenerate;
|
||||
|
||||
frameBuffer.resize((std::size_t)sampleFramesToGenerate * (std::size_t)channels);
|
||||
if (!MIX_Generate(mixer, frameBuffer.data(), (int)(frameBuffer.size() * sizeof(float))))
|
||||
{
|
||||
for (auto& [_, sound] : sounds)
|
||||
sound.audio.track_detach(mixer);
|
||||
MIX_DestroyMixer(mixer);
|
||||
audioStream.stream.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
audioStream.stream.insert(audioStream.stream.end(), frameBuffer.begin(), frameBuffer.end());
|
||||
}
|
||||
|
||||
for (auto& [_, sound] : sounds)
|
||||
sound.audio.track_detach(mixer);
|
||||
MIX_DestroyMixer(mixer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
AnimationPreview::AnimationPreview() : Canvas(vec2()) {}
|
||||
@@ -118,6 +164,12 @@ namespace anm2ed::imgui
|
||||
auto& overlayIndex = document.overlayIndex;
|
||||
auto& pan = document.previewPan;
|
||||
|
||||
auto stop_all_sounds = [&]()
|
||||
{
|
||||
for (auto& sound : anm2.content.sounds | std::views::values)
|
||||
sound.audio.stop(mixer);
|
||||
};
|
||||
|
||||
if (manager.isRecording)
|
||||
{
|
||||
auto& ffmpegPath = settings.renderFFmpegPath;
|
||||
@@ -127,6 +179,8 @@ namespace anm2ed::imgui
|
||||
|
||||
if (playback.time > end || playback.isFinished)
|
||||
{
|
||||
if (settings.timelineIsSound) audioStream.capture_end(mixer);
|
||||
|
||||
if (type == render::PNGS)
|
||||
{
|
||||
if (!renderTempFrames.empty())
|
||||
@@ -206,7 +260,20 @@ namespace anm2ed::imgui
|
||||
}
|
||||
else
|
||||
{
|
||||
if (animation_render(ffmpegPath, path, renderTempFrames, audioStream, (render::Type)type, anm2.info.fps))
|
||||
if (settings.timelineIsSound && type != render::GIF)
|
||||
{
|
||||
if (!render_audio_stream_generate(audioStream, anm2.content.sounds, renderFrameSoundIDs, anm2.info.fps))
|
||||
{
|
||||
toasts.push(localize.get(TOAST_EXPORT_RENDERED_ANIMATION_FAILED));
|
||||
logger.error("Failed to generate deterministic render audio stream; exporting without audio.");
|
||||
audioStream.stream.clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
audioStream.stream.clear();
|
||||
|
||||
if (animation_render(ffmpegPath, path, renderTempFrames, renderTempFrameDurations, audioStream,
|
||||
(render::Type)type, anm2.info.fps))
|
||||
{
|
||||
toasts.push(std::vformat(localize.get(TOAST_EXPORT_RENDERED_ANIMATION), std::make_format_args(pathString)));
|
||||
logger.info(std::vformat(localize.get(TOAST_EXPORT_RENDERED_ANIMATION, anm2ed::ENGLISH),
|
||||
@@ -225,9 +292,15 @@ namespace anm2ed::imgui
|
||||
{
|
||||
renderTempDirectory.clear();
|
||||
renderTempFrames.clear();
|
||||
renderTempFrameDurations.clear();
|
||||
renderFrameSoundIDs.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
render_temp_cleanup(renderTempDirectory, renderTempFrames);
|
||||
renderTempFrameDurations.clear();
|
||||
renderFrameSoundIDs.clear();
|
||||
}
|
||||
|
||||
if (settings.renderIsRawAnimation)
|
||||
{
|
||||
@@ -241,8 +314,6 @@ namespace anm2ed::imgui
|
||||
isCheckerPanInitialized = false;
|
||||
}
|
||||
|
||||
if (settings.timelineIsSound) audioStream.capture_end(mixer);
|
||||
|
||||
playback.isPlaying = false;
|
||||
playback.isFinished = false;
|
||||
manager.isRecording = false;
|
||||
@@ -250,6 +321,28 @@ namespace anm2ed::imgui
|
||||
}
|
||||
else
|
||||
{
|
||||
if (settings.timelineIsSound && renderTempFrames.empty()) audioStream.capture_begin(mixer);
|
||||
auto frameSoundID = -1;
|
||||
if (settings.timelineIsSound && !anm2.content.sounds.empty())
|
||||
{
|
||||
if (auto animation = document.animation_get();
|
||||
animation && animation->triggers.isVisible && (!settings.timelineIsOnlyShowLayers || manager.isRecording))
|
||||
{
|
||||
if (auto trigger = animation->triggers.frame_generate(playback.time, anm2::TRIGGER); trigger.isVisible)
|
||||
{
|
||||
if (!trigger.soundIDs.empty())
|
||||
{
|
||||
auto soundIndex = trigger.soundIDs.size() > 1
|
||||
? (size_t)math::random_in_range(0.0f, (float)trigger.soundIDs.size())
|
||||
: (size_t)0;
|
||||
soundIndex = std::min(soundIndex, trigger.soundIDs.size() - 1);
|
||||
auto soundID = trigger.soundIDs[soundIndex];
|
||||
if (anm2.content.sounds.contains(soundID)) frameSoundID = soundID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
renderFrameSoundIDs.push_back(frameSoundID);
|
||||
|
||||
bind();
|
||||
auto pixels = pixels_get();
|
||||
@@ -259,6 +352,24 @@ namespace anm2ed::imgui
|
||||
if (Texture::write_pixels_png(framePath, size, pixels.data()))
|
||||
{
|
||||
renderTempFrames.push_back(framePath);
|
||||
auto nowCounter = SDL_GetPerformanceCounter();
|
||||
auto counterFrequency = SDL_GetPerformanceFrequency();
|
||||
auto fallbackDuration = 1.0 / (double)std::max(anm2.info.fps, 1);
|
||||
|
||||
if (renderTempFrames.size() == 1)
|
||||
{
|
||||
renderCaptureCounterPrev = nowCounter;
|
||||
renderTempFrameDurations.push_back(fallbackDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto elapsedCounter = nowCounter - renderCaptureCounterPrev;
|
||||
auto frameDuration = counterFrequency > 0 ? (double)elapsedCounter / (double)counterFrequency : 0.0;
|
||||
frameDuration = std::max(frameDuration, 1.0 / 1000.0);
|
||||
renderTempFrameDurations.back() = frameDuration;
|
||||
renderTempFrameDurations.push_back(frameDuration);
|
||||
renderCaptureCounterPrev = nowCounter;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -267,6 +378,8 @@ namespace anm2ed::imgui
|
||||
logger.error(std::vformat(localize.get(TOAST_EXPORT_RENDERED_ANIMATION_FAILED, anm2ed::ENGLISH),
|
||||
std::make_format_args(pathString)));
|
||||
if (type != render::PNGS) render_temp_cleanup(renderTempDirectory, renderTempFrames);
|
||||
renderTempFrameDurations.clear();
|
||||
renderFrameSoundIDs.clear();
|
||||
playback.isPlaying = false;
|
||||
playback.isFinished = false;
|
||||
manager.isRecording = false;
|
||||
@@ -281,18 +394,23 @@ namespace anm2ed::imgui
|
||||
auto& isSound = settings.timelineIsSound;
|
||||
auto& isOnlyShowLayers = settings.timelineIsOnlyShowLayers;
|
||||
|
||||
if (!anm2.content.sounds.empty() && isSound)
|
||||
if (!manager.isRecording && !anm2.content.sounds.empty() && isSound)
|
||||
{
|
||||
if (auto animation = document.animation_get();
|
||||
animation && animation->triggers.isVisible && (!isOnlyShowLayers || manager.isRecording))
|
||||
{
|
||||
if (auto trigger = animation->triggers.frame_generate(playback.time, anm2::TRIGGER); trigger.isVisible)
|
||||
{
|
||||
auto soundID = trigger.soundIDs.size() > 1
|
||||
? (int)trigger.soundIDs[math::random_in_range(0, trigger.soundIDs.size())]
|
||||
: (int)trigger.soundIDs.front();
|
||||
if (!trigger.soundIDs.empty())
|
||||
{
|
||||
auto soundIndex = trigger.soundIDs.size() > 1
|
||||
? (size_t)math::random_in_range(0.0f, (float)trigger.soundIDs.size())
|
||||
: (size_t)0;
|
||||
soundIndex = std::min(soundIndex, trigger.soundIDs.size() - 1);
|
||||
auto soundID = trigger.soundIDs[soundIndex];
|
||||
|
||||
if (anm2.content.sounds.contains(soundID)) anm2.content.sounds[soundID].audio.play(false, mixer);
|
||||
if (anm2.content.sounds.contains(soundID)) anm2.content.sounds[soundID].audio.play(false, mixer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,6 +422,9 @@ namespace anm2ed::imgui
|
||||
|
||||
frameTime = playback.time;
|
||||
}
|
||||
|
||||
if (wasPlaybackPlaying && !playback.isPlaying) stop_all_sounds();
|
||||
wasPlaybackPlaying = playback.isPlaying;
|
||||
}
|
||||
|
||||
void AnimationPreview::update(Manager& manager, Settings& settings, Resources& resources)
|
||||
@@ -492,8 +613,6 @@ namespace anm2ed::imgui
|
||||
{
|
||||
savedSettings = settings;
|
||||
|
||||
if (settings.timelineIsSound) audioStream.capture_begin(mixer);
|
||||
|
||||
if (settings.renderIsRawAnimation)
|
||||
{
|
||||
settings.previewBackgroundColor = vec4();
|
||||
@@ -520,6 +639,9 @@ namespace anm2ed::imgui
|
||||
manager.isRecordingStart = false;
|
||||
manager.isRecording = true;
|
||||
renderTempFrames.clear();
|
||||
renderTempFrameDurations.clear();
|
||||
renderFrameSoundIDs.clear();
|
||||
renderCaptureCounterPrev = 0;
|
||||
if (settings.renderType == render::PNGS)
|
||||
{
|
||||
renderTempDirectory = settings.renderPath;
|
||||
@@ -1052,9 +1174,13 @@ namespace anm2ed::imgui
|
||||
{
|
||||
renderTempDirectory.clear();
|
||||
renderTempFrames.clear();
|
||||
renderTempFrameDurations.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
render_temp_cleanup(renderTempDirectory, renderTempFrames);
|
||||
renderTempFrameDurations.clear();
|
||||
}
|
||||
|
||||
pan = savedPan;
|
||||
zoom = savedZoom;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "audio_stream.h"
|
||||
#include "canvas.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "audio_stream.hpp"
|
||||
#include "canvas.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -14,6 +14,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
MIX_Mixer* mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, nullptr);
|
||||
AudioStream audioStream = AudioStream(mixer);
|
||||
bool wasPlaybackPlaying{};
|
||||
bool isPreviewHovered{};
|
||||
bool isSizeTrySet{true};
|
||||
Settings savedSettings{};
|
||||
@@ -30,6 +31,9 @@ namespace anm2ed::imgui
|
||||
glm::vec2 moveOffset{};
|
||||
std::filesystem::path renderTempDirectory{};
|
||||
std::vector<std::filesystem::path> renderTempFrames{};
|
||||
std::vector<double> renderTempFrameDurations{};
|
||||
std::vector<int> renderFrameSoundIDs{};
|
||||
Uint64 renderCaptureCounterPrev{};
|
||||
|
||||
public:
|
||||
AnimationPreview();
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "animations.h"
|
||||
#include "animations.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
|
||||
#include "log.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "vector_.h"
|
||||
#include "log.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
#include "vector_.hpp"
|
||||
|
||||
using namespace anm2ed::util;
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "strings.h"
|
||||
#include "clipboard.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "events.h"
|
||||
#include "events.hpp"
|
||||
|
||||
#include <ranges>
|
||||
|
||||
#include "log.h"
|
||||
#include "map_.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "log.hpp"
|
||||
#include "map_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
|
||||
using namespace anm2ed::util;
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "clipboard.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "frame_properties.h"
|
||||
#include "frame_properties.hpp"
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <limits>
|
||||
#include <ranges>
|
||||
#include <vector>
|
||||
|
||||
#include "math_.h"
|
||||
#include "strings.h"
|
||||
#include "types.h"
|
||||
#include "math_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
using namespace anm2ed::util::math;
|
||||
using namespace anm2ed::types;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
#include "manager.h"
|
||||
#include "wizard/change_all_frame_properties.h"
|
||||
#include "manager.hpp"
|
||||
#include "wizard/change_all_frame_properties.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "layers.h"
|
||||
#include "layers.hpp"
|
||||
|
||||
#include <ranges>
|
||||
|
||||
#include "log.h"
|
||||
#include "map_.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "log.hpp"
|
||||
#include "map_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
|
||||
using namespace anm2ed::util;
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "clipboard.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "nulls.h"
|
||||
#include "nulls.hpp"
|
||||
|
||||
#include <ranges>
|
||||
|
||||
#include "log.h"
|
||||
#include "map_.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "log.hpp"
|
||||
#include "map_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::util;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "clipboard.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "onionskin.h"
|
||||
#include "onionskin.hpp"
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "imgui_.h"
|
||||
#include "strings.h"
|
||||
#include "imgui_.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace glm;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "manager.h"
|
||||
#include "manager.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,19 +1,19 @@
|
||||
#include "regions.h"
|
||||
#include "regions.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ranges>
|
||||
|
||||
#include <format>
|
||||
|
||||
#include "document.h"
|
||||
#include "log.h"
|
||||
#include "map_.h"
|
||||
#include "math_.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "vector_.h"
|
||||
#include "document.hpp"
|
||||
#include "log.hpp"
|
||||
#include "map_.hpp"
|
||||
#include "math_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
#include "vector_.hpp"
|
||||
|
||||
#include "../../util/map_.h"
|
||||
#include "../../util/map_.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "clipboard.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "sounds.h"
|
||||
#include "sounds.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ranges>
|
||||
#include <vector>
|
||||
|
||||
#include "log.h"
|
||||
#include "path_.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "log.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
|
||||
using namespace anm2ed::util;
|
||||
using namespace anm2ed::types;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "dialog.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "clipboard.hpp"
|
||||
#include "dialog.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,15 +1,15 @@
|
||||
#include "spritesheet_editor.h"
|
||||
#include "spritesheet_editor.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <format>
|
||||
#include <utility>
|
||||
|
||||
#include "imgui_.h"
|
||||
#include "imgui_.hpp"
|
||||
#include "imgui_internal.h"
|
||||
#include "math_.h"
|
||||
#include "strings.h"
|
||||
#include "tool.h"
|
||||
#include "types.h"
|
||||
#include "math_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "tool.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "canvas.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "canvas.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "spritesheets.h"
|
||||
#include "spritesheets.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ranges>
|
||||
@@ -8,12 +8,12 @@
|
||||
#include <format>
|
||||
#include <functional>
|
||||
|
||||
#include "document.h"
|
||||
#include "log.h"
|
||||
#include "path_.h"
|
||||
#include "strings.h"
|
||||
#include "toast.h"
|
||||
#include "working_directory.h"
|
||||
#include "document.hpp"
|
||||
#include "log.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
#include "working_directory.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "dialog.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "clipboard.hpp"
|
||||
#include "dialog.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "timeline.h"
|
||||
#include "timeline.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
#include <imgui_internal.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "toast.h"
|
||||
#include "log.hpp"
|
||||
#include "toast.hpp"
|
||||
|
||||
#include "vector_.h"
|
||||
#include "vector_.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::types;
|
||||
@@ -83,7 +83,6 @@ namespace anm2ed::imgui
|
||||
constexpr auto FRAME_DRAG_PAYLOAD_ID = "Frame Drag Drop";
|
||||
constexpr auto FRAME_TOOLTIP_HOVER_DELAY = 0.75f; // Extra delay for frame info tooltip.
|
||||
|
||||
#define ITEM_FRAME_CHILD_HEIGHT ImGui::GetTextLineHeightWithSpacing() + (ImGui::GetStyle().WindowPadding.y * 1.5)
|
||||
#define ITEM_CHILD_WIDTH ImGui::GetTextLineHeightWithSpacing() * 12.5
|
||||
|
||||
void Timeline::update(Manager& manager, Settings& settings, Resources& resources, Clipboard& clipboard)
|
||||
@@ -95,6 +94,8 @@ namespace anm2ed::imgui
|
||||
auto& frames = document.frames;
|
||||
auto& region = document.region;
|
||||
auto animation = document.animation_get();
|
||||
auto itemFrameChildHeight = (ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().WindowPadding.y * 1.5f) *
|
||||
settings.timelineItemHeight;
|
||||
|
||||
style = ImGui::GetStyle();
|
||||
auto isLightTheme = settings.theme == theme::LIGHT;
|
||||
@@ -172,6 +173,13 @@ namespace anm2ed::imgui
|
||||
frameFocusRequested = reference.frameIndex >= 0;
|
||||
};
|
||||
|
||||
auto playback_stop = [&]()
|
||||
{
|
||||
playback.isPlaying = false;
|
||||
playback.isFinished = false;
|
||||
playback.timing_reset();
|
||||
};
|
||||
|
||||
auto frame_insert = [&](anm2::Item* item)
|
||||
{
|
||||
if (!item) return;
|
||||
@@ -597,7 +605,7 @@ namespace anm2ed::imgui
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.WindowPadding);
|
||||
|
||||
auto itemSize = ImVec2(ImGui::GetContentRegionAvail().x, ITEM_FRAME_CHILD_HEIGHT);
|
||||
auto itemSize = ImVec2(ImGui::GetContentRegionAvail().x, itemFrameChildHeight);
|
||||
|
||||
if (ImGui::BeginChild(label.c_str(), itemSize, ImGuiChildFlags_Borders, ImGuiWindowFlags_NoScrollWithMouse))
|
||||
{
|
||||
@@ -961,7 +969,7 @@ namespace anm2ed::imgui
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.WindowPadding);
|
||||
|
||||
auto childSize = ImVec2(width, ITEM_FRAME_CHILD_HEIGHT);
|
||||
auto childSize = ImVec2(width, itemFrameChildHeight);
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
@@ -1046,7 +1054,10 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
if (ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) && ImGui::IsMouseDown(0))
|
||||
{
|
||||
if (!isDragging) playback_stop();
|
||||
isDragging = true;
|
||||
}
|
||||
|
||||
auto childPos = ImGui::GetWindowPos();
|
||||
auto mousePos = ImGui::GetIO().MousePos;
|
||||
@@ -1497,12 +1508,11 @@ namespace anm2ed::imgui
|
||||
ImGui::GetTextLineHeightWithSpacing() + (ImGui::GetStyle().WindowPadding.y * 2));
|
||||
auto playheadIndex = std::floor(playback.time);
|
||||
auto lineCenterX = cursorScreenPos.x + frameSize.x * (playheadIndex + 0.6f) - scroll.x;
|
||||
float lineOffsetY = frameSize.y;
|
||||
auto linePos =
|
||||
ImVec2(lineCenterX - (PLAYHEAD_LINE_THICKNESS * 0.5f), cursorScreenPos.y + frameSize.y + lineOffsetY);
|
||||
ImVec2(lineCenterX - (PLAYHEAD_LINE_THICKNESS * 0.5f), cursorScreenPos.y + (frameSize.y * 2.0f));
|
||||
auto lineSize = ImVec2((PLAYHEAD_LINE_THICKNESS / 2.0f),
|
||||
viewListChildSize.y - frameSize.y - lineOffsetY -
|
||||
(isHorizontalScroll ? ImGui::GetStyle().ScrollbarSize : 0.0f));
|
||||
viewListChildSize.y - frameSize.y -
|
||||
(isHorizontalScroll ? ImGui::GetStyle().ScrollbarSize * 2.0f : 0.0f));
|
||||
|
||||
auto rectMin = windowDrawList->GetClipRectMin();
|
||||
auto rectMax = windowDrawList->GetClipRectMax();
|
||||
@@ -1623,7 +1633,8 @@ namespace anm2ed::imgui
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
|
||||
if (ImGui::Begin(localize.get(LABEL_TIMELINE_WINDOW), &settings.windowIsTimeline))
|
||||
{
|
||||
isWindowHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows);
|
||||
isWindowHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows |
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem);
|
||||
frames_child();
|
||||
items_child();
|
||||
}
|
||||
@@ -1853,12 +1864,14 @@ namespace anm2ed::imgui
|
||||
|
||||
if (shortcut(manager.chords[SHORTCUT_MOVE_PLAYHEAD_BACK], shortcut::GLOBAL))
|
||||
{
|
||||
playback_stop();
|
||||
playback.decrement(settings.playbackIsClamp ? animation->frameNum : anm2::FRAME_NUM_MAX);
|
||||
document.frameTime = playback.time;
|
||||
}
|
||||
|
||||
if (shortcut(manager.chords[SHORTCUT_MOVE_PLAYHEAD_FORWARD], shortcut::GLOBAL))
|
||||
{
|
||||
playback_stop();
|
||||
playback.increment(settings.playbackIsClamp ? animation->frameNum : anm2::FRAME_NUM_MAX);
|
||||
document.frameTime = playback.time;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "strings.h"
|
||||
#include "clipboard.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
#include "tools.h"
|
||||
#include "tools.hpp"
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "strings.h"
|
||||
#include "tool.h"
|
||||
#include "types.h"
|
||||
#include "strings.hpp"
|
||||
#include "tool.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::types;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "strings.h"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "welcome.h"
|
||||
#include "welcome.hpp"
|
||||
|
||||
#include <ranges>
|
||||
|
||||
#include "path_.h"
|
||||
#include "strings.h"
|
||||
#include "path_.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
using namespace anm2ed::util;
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "documents.h"
|
||||
#include "manager.h"
|
||||
#include "strings.h"
|
||||
#include "taskbar.h"
|
||||
#include "documents.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "taskbar.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "about.h"
|
||||
#include "about.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <imgui.h>
|
||||
#include <vector>
|
||||
|
||||
#include "strings.h"
|
||||
#include "strings.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../resources.h"
|
||||
#include "../../resources.hpp"
|
||||
|
||||
namespace anm2ed::imgui::wizard
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "change_all_frame_properties.h"
|
||||
#include "change_all_frame_properties.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "math_.h"
|
||||
#include "math_.hpp"
|
||||
|
||||
using namespace anm2ed::util::math;
|
||||
using namespace glm;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "document.h"
|
||||
#include "settings.h"
|
||||
#include "document.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui::wizard
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "configure.h"
|
||||
#include "configure.hpp"
|
||||
|
||||
#include "imgui_.h"
|
||||
#include "imgui_.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
|
||||
@@ -23,6 +23,9 @@ namespace anm2ed::imgui::wizard
|
||||
ImGui::SeparatorText(localize.get(LABEL_WINDOW_MENU));
|
||||
input_float_range(localize.get(LABEL_UI_SCALE), temporary.uiScale, 0.5f, 2.0f, 0.25f, 0.25f, "%.2f");
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_UI_SCALE));
|
||||
input_float_range(localize.get(LABEL_ITEM_HEIGHT), temporary.timelineItemHeight, 0.75f, 1.25f, 0.05f, 0.05f,
|
||||
"%.2f");
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ITEM_HEIGHT));
|
||||
ImGui::Checkbox(localize.get(LABEL_VSYNC), &temporary.isVsync);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_VSYNC));
|
||||
|
||||
@@ -205,4 +208,4 @@ namespace anm2ed::imgui::wizard
|
||||
if (ImGui::Button(localize.get(LABEL_CLOSE), widgetSize)) isSet = true;
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_CLOSE_SETTINGS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "manager.h"
|
||||
#include "manager.hpp"
|
||||
|
||||
namespace anm2ed::imgui::wizard
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "generate_animation_from_grid.h"
|
||||
#include "generate_animation_from_grid.hpp"
|
||||
|
||||
#include "math_.h"
|
||||
#include "types.h"
|
||||
#include "math_.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::util;
|
||||
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "canvas.h"
|
||||
#include "document.h"
|
||||
#include "resources.h"
|
||||
#include "settings.h"
|
||||
#include "canvas.hpp"
|
||||
#include "document.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
namespace anm2ed::imgui::wizard
|
||||
{
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "render_animation.h"
|
||||
#include "render_animation.hpp"
|
||||
|
||||
#include <ranges>
|
||||
#include <string>
|
||||
|
||||
#include "imgui_.h"
|
||||
#include "log.h"
|
||||
#include "path_.h"
|
||||
#include "process_.h"
|
||||
#include "toast.h"
|
||||
#include "imgui_.hpp"
|
||||
#include "log.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "process_.hpp"
|
||||
#include "toast.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::util;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "dialog.h"
|
||||
#include "manager.h"
|
||||
#include "resources.h"
|
||||
#include "dialog.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
|
||||
namespace anm2ed::imgui::wizard
|
||||
{
|
||||
Reference in New Issue
Block a user