Stage 10a: delete dead code, merge tiny files, unify duplicated concepts
- Dead code: util/map, util/unordered_map, unused vector/math/string/input helpers, Document getters, special-interpolation bake leftovers, triggers_sort, SnapshotStack::max_size_get, AudioStream capture API. - Merges: util/xml, util/string, resource/strings.cpp inlined; constants into input.hpp; tooltip into layout; Recorder into render; onionskin, tools, welcome and frame properties are panel functions; timeline popups.cpp folded into timeline.cpp. - util/origin.hpp replaced by model Origin (the merge setting stays a combo index, so saved preferences keep their meaning). - Item type names/icons/colors moved from model/common.hpp to the timeline header; the model no longer includes icon/strings headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d16f21541
commit
4c569cb1e5
60 files changed
+605
-1021
No files matched your search
@@ -28,7 +28,7 @@
|
||||
#include "util/imgui/input.hpp"
|
||||
#include "util/imgui/layout.hpp"
|
||||
#include "util/imgui/shortcut.hpp"
|
||||
#include "util/imgui/tooltip.hpp"
|
||||
#include "window/timeline/timeline.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::util;
|
||||
@@ -38,7 +38,7 @@ using namespace glm;
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
constexpr auto NULL_COLOR = vec4(0.0f, 0.0f, 1.0f, 0.90f);
|
||||
constexpr auto NULL_RECT_COLOR = vec4(0.0f, 0.0f, 1.0f, 0.90f);
|
||||
constexpr auto SELECTED_LAYER_BORDER_COLOR = vec4(1.0f, 0.1059f, 0.5882f, 1.0f);
|
||||
constexpr auto TARGET_SIZE = vec2(32, 32);
|
||||
constexpr auto POINT_SIZE = vec2(4, 4);
|
||||
@@ -209,19 +209,20 @@ namespace anm2ed::imgui
|
||||
const model::Animation* animation)
|
||||
{
|
||||
auto animationFps = std::max(document.model.info.fps, 1);
|
||||
RecorderOptions options{.type = (render::Type)settings.renderType,
|
||||
.path = settings.renderPath,
|
||||
.format = settings.renderFormat,
|
||||
.ffmpegPath = settings.renderFFmpegPath,
|
||||
.start = manager.recordingStart,
|
||||
.end = manager.recordingEnd,
|
||||
.animationFps = animationFps,
|
||||
.fps = render::fps_get(settings.renderFpsMode, animationFps, settings.playbackTickRate),
|
||||
.rows = settings.renderRows,
|
||||
.columns = settings.renderColumns,
|
||||
.isSound = settings.timelineIsSound,
|
||||
.isIsolated = settings.renderIsUseIsolatedAnimation,
|
||||
.isBounded = settings.renderIsUseAnimationBounds};
|
||||
render::RecorderOptions options{
|
||||
.type = (render::Type)settings.renderType,
|
||||
.path = settings.renderPath,
|
||||
.format = settings.renderFormat,
|
||||
.ffmpegPath = settings.renderFFmpegPath,
|
||||
.start = manager.recordingStart,
|
||||
.end = manager.recordingEnd,
|
||||
.animationFps = animationFps,
|
||||
.fps = render::fps_get(settings.renderFpsMode, animationFps, settings.playbackTickRate),
|
||||
.rows = settings.renderRows,
|
||||
.columns = settings.renderColumns,
|
||||
.isSound = settings.timelineIsSound,
|
||||
.isIsolated = settings.renderIsUseIsolatedAnimation,
|
||||
.isBounded = settings.renderIsUseAnimationBounds};
|
||||
if (options.isBounded)
|
||||
{
|
||||
recordSize = size;
|
||||
@@ -573,7 +574,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto isShowRect = model::item_get(sampleModel.content.nulls, draw.id)->isShowRect;
|
||||
auto isSelected = isActiveDocument && draw.id == reference.itemID && referenceItemType == ItemType::NULL_;
|
||||
auto color = isOnion ? onionColor : isSelected ? color::RED : NULL_COLOR;
|
||||
auto color = isOnion ? onionColor : isSelected ? color::RED : NULL_RECT_COLOR;
|
||||
auto markerSize = isShowRect ? POINT_SIZE : TARGET_SIZE;
|
||||
texture_render(shaderTexture, isShowRect ? resources.icon_id_get(icon::POINT) : targetIcon,
|
||||
transform * marker_model_get(markerSize), color);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "audio_stream.hpp"
|
||||
#include "canvas_view.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "recorder.hpp"
|
||||
#include "render.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace anm2ed::imgui
|
||||
bool isMoveDragging{};
|
||||
glm::vec2 moveOffset{};
|
||||
glm::vec2 nullRectScaleAnchor{};
|
||||
Recorder recorder{};
|
||||
render::Recorder recorder{};
|
||||
glm::vec2 recordSize{};
|
||||
glm::vec2 recordPan{};
|
||||
float recordZoom{};
|
||||
|
||||
@@ -4,11 +4,9 @@
|
||||
|
||||
#include "actions.hpp"
|
||||
#include "edit/edit.hpp"
|
||||
#include "util/imgui/constants.hpp"
|
||||
#include "util/imgui/input.hpp"
|
||||
#include "util/imgui/layout.hpp"
|
||||
#include "util/imgui/shortcut.hpp"
|
||||
#include "util/imgui/tooltip.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::util;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "frame_properties.hpp"
|
||||
#include "panel.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <ranges>
|
||||
@@ -45,8 +45,9 @@ namespace anm2ed::imgui
|
||||
constexpr FlipButton FLIP_BUTTONS[] = {{LABEL_FLIP_X, EDIT_FRAME_FLIP_X, TOOLTIP_FLIP_X},
|
||||
{LABEL_FLIP_Y, EDIT_FRAME_FLIP_Y, TOOLTIP_FLIP_Y}};
|
||||
|
||||
void FrameProperties::update(Manager& manager, Settings& settings)
|
||||
void frame_properties_update(Manager& manager, Settings& settings, FramePropertiesPanel& panel)
|
||||
{
|
||||
auto& [changeAllFrameProperties, isBatchMode] = panel;
|
||||
auto& document = *manager.get();
|
||||
auto frameSelectionCount = document.frame_references_get(Document::FrameReferenceFallback::NONE).size();
|
||||
if (frameSelectionCount == 0 && document.reference_get().frameIndex >= 0) frameSelectionCount = 1;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
#include "manager.hpp"
|
||||
#include "wizard/change_all_frame_properties.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
class FrameProperties
|
||||
{
|
||||
wizard::ChangeAllFrameProperties changeAllFrameProperties{};
|
||||
bool isBatchMode{};
|
||||
|
||||
public:
|
||||
void update(Manager&, Settings&);
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "onionskin.hpp"
|
||||
#include "panel.hpp"
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "strings.hpp"
|
||||
#include "util/imgui/input.hpp"
|
||||
#include "util/imgui/layout.hpp"
|
||||
#include "util/imgui/shortcut.hpp"
|
||||
#include "util/imgui/tooltip.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace glm;
|
||||
@@ -14,7 +14,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
constexpr auto FRAMES_MAX = 100;
|
||||
|
||||
void Onionskin::update(Manager& manager, Settings& settings)
|
||||
void onionskin_update(Manager& manager, Settings& settings)
|
||||
{
|
||||
auto& isEnabled = settings.onionskinIsEnabled;
|
||||
auto& beforeCount = settings.onionskinBeforeCount;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "manager.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
class Onionskin
|
||||
{
|
||||
public:
|
||||
void update(Manager&, Settings&);
|
||||
};
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "util/imgui/multiselect.hpp"
|
||||
#include "util/imgui/popup.hpp"
|
||||
#include "util/imgui/selectable.hpp"
|
||||
#include "wizard/change_all_frame_properties.hpp"
|
||||
|
||||
// Panels are plain functions: each draws from the document and its selection, and queues edits as commands.
|
||||
namespace anm2ed::imgui
|
||||
@@ -132,6 +133,15 @@ namespace anm2ed::imgui
|
||||
int mergeReference{-1};
|
||||
};
|
||||
|
||||
struct FramePropertiesPanel
|
||||
{
|
||||
wizard::ChangeAllFrameProperties changeAllFrameProperties{};
|
||||
bool isBatchMode{};
|
||||
};
|
||||
|
||||
class Taskbar;
|
||||
class Documents;
|
||||
|
||||
void animations_update(Panel&, AnimationsPanel&);
|
||||
void layers_update(Panel&);
|
||||
void nulls_update(Panel&);
|
||||
@@ -139,6 +149,10 @@ namespace anm2ed::imgui
|
||||
void sounds_update(Panel&);
|
||||
void spritesheets_update(Panel&, SpritesheetsPanel&);
|
||||
void regions_update(Panel&, RegionsPanel&);
|
||||
void frame_properties_update(Manager&, Settings&, FramePropertiesPanel&);
|
||||
void onionskin_update(Manager&, Settings&);
|
||||
void tools_update(Manager&, Settings&, Resources&, PopupHelper&);
|
||||
void welcome_update(Manager&, Resources&, Dialog&, Taskbar&, Documents&);
|
||||
|
||||
template <class Items> std::vector<int> item_ids_get(const Items& items)
|
||||
{
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
#include "recorder.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <format>
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "log.hpp"
|
||||
#include "path.hpp"
|
||||
#include "toast.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::util;
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
constexpr int TEMP_DIRECTORY_ATTEMPTS = 1000;
|
||||
constexpr int ALPHA_OPAQUE = 255;
|
||||
constexpr float CHANNEL_MAX = 255.0f;
|
||||
|
||||
std::filesystem::path frame_filename_get(const std::filesystem::path& format, int index, render::Type type)
|
||||
{
|
||||
auto fallback = path::from_utf8(std::format("frame_{:06}.png", index));
|
||||
if (type != render::PNGS) return fallback;
|
||||
try
|
||||
{
|
||||
auto filename = path::from_utf8(std::vformat(path::to_utf8(format), std::make_format_args(index))).filename();
|
||||
if (filename.empty()) return fallback;
|
||||
if (filename.extension().empty()) filename.replace_extension(render::EXTENSIONS[render::SPRITESHEET]);
|
||||
return filename;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
// PNG sequences go straight to their folder; other outputs collect frames in a temporary folder beside the output.
|
||||
std::filesystem::path frames_directory_create(const RecorderOptions& options)
|
||||
{
|
||||
std::error_code ec{};
|
||||
if (options.type == render::PNGS)
|
||||
{
|
||||
std::filesystem::create_directories(options.path, ec);
|
||||
return options.path;
|
||||
}
|
||||
auto directory = options.path.parent_path();
|
||||
if (directory.empty()) directory = std::filesystem::current_path();
|
||||
std::filesystem::create_directories(directory, ec);
|
||||
auto timestamp =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
|
||||
.count();
|
||||
for (int suffix = 0; suffix < TEMP_DIRECTORY_ATTEMPTS; ++suffix)
|
||||
{
|
||||
auto temporary = directory / path::from_utf8(std::format(".anm2ed_render_tmp_{}_{}", timestamp, suffix));
|
||||
if (std::filesystem::create_directories(temporary, ec)) return temporary;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// Rendered pixels are premultiplied; outputs on a transparent background want straight alpha.
|
||||
void pixels_unpremultiply(std::vector<uint8_t>& pixels)
|
||||
{
|
||||
for (std::size_t index = 0; index + 3 < pixels.size(); index += image::CHANNELS)
|
||||
{
|
||||
auto alpha = pixels[index + 3];
|
||||
if (alpha == ALPHA_OPAQUE) continue;
|
||||
for (int channel = 0; channel < 3; ++channel)
|
||||
pixels[index + channel] =
|
||||
alpha == 0
|
||||
? 0
|
||||
: (uint8_t)glm::clamp(std::round(pixels[index + channel] * CHANNEL_MAX / alpha), 0.0f, CHANNEL_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
void sounds_detach(const Document& document, MIX_Mixer* mixer)
|
||||
{
|
||||
for (auto& [id, _] : document.sounds)
|
||||
if (auto sound = document.sound_get(id)) audio::track_detach(*sound, mixer);
|
||||
}
|
||||
|
||||
// Mixes each frame's trigger sound into one stream at the render frame rate.
|
||||
bool audio_stream_generate(AudioStream& audioStream, const Document& document, const std::vector<int>& soundIds,
|
||||
int fps)
|
||||
{
|
||||
audioStream.stream.clear();
|
||||
if (soundIds.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 framesPerStep = (double)std::max(mixSpec.freq, 1) / (double)fps;
|
||||
auto accumulator = 0.0;
|
||||
std::vector<float> buffer{};
|
||||
auto isGenerated = true;
|
||||
for (auto soundId : soundIds)
|
||||
{
|
||||
if (auto sound = document.sound_get(soundId)) audio::play(*sound, false, mixer);
|
||||
accumulator += framesPerStep;
|
||||
auto sampleFrames = std::max((int)std::floor(accumulator), 1);
|
||||
accumulator -= (double)sampleFrames;
|
||||
buffer.resize((std::size_t)sampleFrames * (std::size_t)channels);
|
||||
if (!(isGenerated = MIX_Generate(mixer, buffer.data(), (int)(buffer.size() * sizeof(float))))) break;
|
||||
audioStream.stream.insert(audioStream.stream.end(), buffer.begin(), buffer.end());
|
||||
}
|
||||
sounds_detach(document, mixer);
|
||||
MIX_DestroyMixer(mixer);
|
||||
if (!isGenerated) audioStream.stream.clear();
|
||||
return isGenerated;
|
||||
}
|
||||
|
||||
bool Recorder::start(const RecorderOptions& recorderOptions)
|
||||
{
|
||||
options = recorderOptions;
|
||||
index = 0;
|
||||
count = render::frame_count_get(options.start, options.end, options.animationFps, options.fps);
|
||||
frames.clear();
|
||||
soundIds.clear();
|
||||
soundTime = -1;
|
||||
directory = frames_directory_create(options);
|
||||
return !directory.empty();
|
||||
}
|
||||
|
||||
bool Recorder::is_done() const { return index >= count; }
|
||||
|
||||
float Recorder::time_get() const
|
||||
{
|
||||
return render::frame_time_get(options.start, index, options.animationFps, options.fps);
|
||||
}
|
||||
|
||||
// A trigger sound is taken once per animation frame, however many render frames it spans.
|
||||
bool Recorder::is_sound_frame() const { return (int)std::floor(time_get()) != soundTime; }
|
||||
|
||||
bool Recorder::frame_capture(std::vector<uint8_t> pixels, glm::ivec2 size, int soundId)
|
||||
{
|
||||
soundTime = (int)std::floor(time_get());
|
||||
soundIds.push_back(soundId);
|
||||
if (options.isIsolated || options.isBounded) pixels_unpremultiply(pixels);
|
||||
auto framePath = directory / frame_filename_get(options.format, index, options.type);
|
||||
if (!Image::write_pixels_png(framePath, size, pixels.data())) return false;
|
||||
frames.push_back(framePath);
|
||||
++index;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Recorder::finish(const Document& document, AudioStream& audioStream)
|
||||
{
|
||||
auto pathString = path::to_utf8(options.path);
|
||||
if (options.type == render::PNGS)
|
||||
toast_log(frames.empty() ? Level::ERROR : Level::INFO,
|
||||
frames.empty() ? TOAST_EXPORT_RENDERED_FRAMES_FAILED : TOAST_EXPORT_RENDERED_FRAMES, pathString);
|
||||
else if (options.type == render::SPRITESHEET)
|
||||
{
|
||||
auto layout = render::spritesheet_layout_get(options.rows, options.columns, (int)frames.size());
|
||||
auto first = frames.empty() ? Image{} : Image(frames.front());
|
||||
if (frames.empty())
|
||||
toast_log(Level::WARNING, TOAST_SPRITESHEET_NO_FRAMES);
|
||||
else if (!first.is_valid())
|
||||
toast_log(Level::ERROR, TOAST_SPRITESHEET_EMPTY);
|
||||
else
|
||||
{
|
||||
Image sheet{};
|
||||
sheet.size = first.size * glm::ivec2(layout.columns, layout.rows);
|
||||
sheet.pixels.resize((std::size_t)sheet.size.x * sheet.size.y * image::CHANNELS);
|
||||
for (int i = 0; i < (int)frames.size() && i < layout.rows * layout.columns; ++i)
|
||||
if (auto frame = Image(frames[i]); frame.size == first.size)
|
||||
sheet.paste(frame, first.size * glm::ivec2(i % layout.columns, i / layout.columns));
|
||||
auto isSaved = sheet.write_png(options.path);
|
||||
toast_log(isSaved ? Level::INFO : Level::ERROR,
|
||||
isSaved ? TOAST_EXPORT_SPRITESHEET : TOAST_EXPORT_SPRITESHEET_FAILED, pathString);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
audioStream.stream.clear();
|
||||
if (options.isSound && options.type != render::GIF &&
|
||||
!audio_stream_generate(audioStream, document, soundIds, options.fps))
|
||||
{
|
||||
toasts.push(localize.get(TOAST_EXPORT_RENDERED_ANIMATION_FAILED));
|
||||
logger.error("Failed to generate deterministic render audio stream; exporting without audio.");
|
||||
}
|
||||
auto isRendered =
|
||||
animation_render(options.ffmpegPath, options.path, frames, audioStream, options.type, options.fps);
|
||||
toast_log(isRendered ? Level::INFO : Level::ERROR,
|
||||
isRendered ? TOAST_EXPORT_RENDERED_ANIMATION : TOAST_EXPORT_RENDERED_ANIMATION_FAILED, pathString);
|
||||
}
|
||||
cancel();
|
||||
}
|
||||
|
||||
// Stops; the temporary frame folder is removed (a PNG sequence's own folder is kept).
|
||||
void Recorder::cancel()
|
||||
{
|
||||
std::error_code ec{};
|
||||
if (options.type != render::PNGS && !directory.empty()) std::filesystem::remove_all(directory, ec);
|
||||
directory.clear();
|
||||
frames.clear();
|
||||
soundIds.clear();
|
||||
index = count = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
|
||||
#include "audio_stream.hpp"
|
||||
#include "document.hpp"
|
||||
#include "render.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
struct RecorderOptions
|
||||
{
|
||||
render::Type type{};
|
||||
std::filesystem::path path{};
|
||||
std::filesystem::path format{};
|
||||
std::filesystem::path ffmpegPath{};
|
||||
int start{};
|
||||
int end{};
|
||||
int animationFps{1};
|
||||
int fps{1};
|
||||
int rows{};
|
||||
int columns{};
|
||||
bool isSound{};
|
||||
bool isIsolated{};
|
||||
bool isBounded{};
|
||||
};
|
||||
|
||||
// A render in progress: which animation times to capture, the frames captured so far (written to disk) and the
|
||||
// trigger sound of each, and assembling the output when done.
|
||||
class Recorder
|
||||
{
|
||||
public:
|
||||
RecorderOptions options{};
|
||||
int index{};
|
||||
int count{};
|
||||
|
||||
bool start(const RecorderOptions&);
|
||||
bool is_done() const;
|
||||
float time_get() const;
|
||||
bool is_sound_frame() const;
|
||||
bool frame_capture(std::vector<uint8_t>, glm::ivec2, int);
|
||||
void finish(const Document&, AudioStream&);
|
||||
void cancel();
|
||||
|
||||
private:
|
||||
std::filesystem::path directory{};
|
||||
std::vector<std::filesystem::path> frames{};
|
||||
std::vector<int> soundIds{};
|
||||
int soundTime{-1};
|
||||
};
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "util/imgui/input.hpp"
|
||||
#include "util/imgui/layout.hpp"
|
||||
#include "util/imgui/shortcut.hpp"
|
||||
#include "util/imgui/tooltip.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
using namespace anm2ed::resource;
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace anm2ed::imgui
|
||||
constexpr int SPRITESHEET_CARD_LINES = 4;
|
||||
constexpr int MERGE_OPTIONS_ROWS = 6;
|
||||
constexpr int PADDING_MAX = 100;
|
||||
// The merge region origin setting indexes this (top-left or center).
|
||||
constexpr Origin MERGE_REGION_ORIGINS[] = {Origin::TOP_LEFT, Origin::CENTER};
|
||||
|
||||
auto& spritesheets_get(model::Model& model) { return model.content.spritesheets; }
|
||||
|
||||
@@ -122,7 +124,7 @@ namespace anm2ed::imgui
|
||||
if (!ImGui::BeginPopupModal(popup.label(), &popup.isOpen, ImGuiWindowFlags_NoResize)) return popup.end();
|
||||
|
||||
settings.mergeSpritesheetsRegionOrigin =
|
||||
glm::clamp(settings.mergeSpritesheetsRegionOrigin, (int)origin::TOP_LEFT, (int)origin::ORIGIN_CENTER);
|
||||
glm::clamp(settings.mergeSpritesheetsRegionOrigin, 0, (int)std::size(MERGE_REGION_ORIGINS) - 1);
|
||||
if (ImGui::BeginChild("##Merge Spritesheets Options", child_size_get(MERGE_OPTIONS_ROWS), ImGuiChildFlags_Borders))
|
||||
{
|
||||
ImGui::SeparatorText(localize.get(LABEL_REGION_PROPERTIES_ORIGIN));
|
||||
@@ -156,7 +158,7 @@ namespace anm2ed::imgui
|
||||
[ids = spritesheets.mergeIds, isAppendRight = settings.mergeSpritesheetsOrigin == APPEND_RIGHT,
|
||||
isMakeRegions = settings.mergeSpritesheetsIsMakeRegions,
|
||||
isMakePrimaryRegion = settings.mergeSpritesheetsIsMakePrimaryRegion,
|
||||
regionOrigin = (origin::Type)settings.mergeSpritesheetsRegionOrigin](Document& document)
|
||||
regionOrigin = MERGE_REGION_ORIGINS[settings.mergeSpritesheetsRegionOrigin]](Document& document)
|
||||
{
|
||||
spritesheet_textures_edit(
|
||||
document, EDIT_MERGE_SPRITESHEETS,
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "util/imgui/input.hpp"
|
||||
#include "util/imgui/layout.hpp"
|
||||
#include "util/imgui/shortcut.hpp"
|
||||
#include "util/imgui/tooltip.hpp"
|
||||
|
||||
#include "model/frames.hpp"
|
||||
#include "vector.hpp"
|
||||
|
||||
@@ -1,213 +0,0 @@
|
||||
#include "context.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
void TimelineContext::draw()
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
|
||||
if (ImGui::Begin(localize.get(LABEL_TIMELINE_WINDOW), &settings.windowIsTimeline))
|
||||
{
|
||||
isWindowHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows |
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem);
|
||||
frames_child();
|
||||
if (frameMoveDrag.isActive && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
{
|
||||
if (frameMoveDropTarget) frames_move_to(*frameMoveDropTarget);
|
||||
frameMoveDrag = {};
|
||||
}
|
||||
items_child();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
|
||||
if (itemProperties.update(manager, settings, document, reference)) group_selection_reset_for(document);
|
||||
group_properties_update();
|
||||
|
||||
makeManyRegionsPopup.trigger();
|
||||
if (ImGui::BeginPopupModal(makeManyRegionsPopup.label(), &makeManyRegionsPopup.isOpen, ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
input_text_string(localize.get(LABEL_FORMAT), &settings.generateRegionNameFormat);
|
||||
ImGui::Checkbox(localize.get(LABEL_MAP_FRAMES_TO_REGIONS), &isMakeManyRegionsMapFrames);
|
||||
|
||||
auto result = popup_buttons_draw(manager, localize.get(LABEL_MAKE_MANY_REGIONS));
|
||||
if (result == PopupButton::CONFIRM)
|
||||
edit_push(EDIT_GENERATE_REGIONS_FROM_ANIMATIONS,
|
||||
[targetFrames = makeManyRegionReferences, format = settings.generateRegionNameFormat,
|
||||
mapping = isMakeManyRegionsMapFrames ? RegionFrameMapping::SET
|
||||
: RegionFrameMapping::PRESERVE](model::Model& model)
|
||||
{ return edit::regions_generate(model, {}, targetFrames, format, mapping); });
|
||||
if (result != PopupButton::NONE) makeManyRegionsPopup.close();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
makeManyRegionsPopup.end();
|
||||
|
||||
bakePopup.trigger();
|
||||
|
||||
if (ImGui::BeginPopupModal(bakePopup.label(), &bakePopup.isOpen, ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
auto& interval = settings.bakeInterval;
|
||||
auto& isRoundRotation = settings.bakeIsRoundRotation;
|
||||
auto& isRoundScale = settings.bakeIsRoundScale;
|
||||
|
||||
auto frame = frame_get();
|
||||
|
||||
input_int_range(localize.get(LABEL_INTERVAL), interval, FRAME_DURATION_MIN,
|
||||
frame ? frame->duration : FRAME_DURATION_MIN);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_INTERVAL));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_ROUND_ROTATION), &isRoundRotation);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ROUND_ROTATION));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_ROUND_SCALE), &isRoundScale);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ROUND_SCALE));
|
||||
|
||||
auto widgetSize = widget_size_with_row_get(2);
|
||||
|
||||
shortcut(manager.chords[SHORTCUT_CONFIRM]);
|
||||
if (ImGui::Button(localize.get(LABEL_BAKE), widgetSize))
|
||||
{
|
||||
frames_bake();
|
||||
bakePopup.close();
|
||||
}
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_FRAMES_OPTIONS));
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
shortcut(manager.chords[SHORTCUT_CANCEL]);
|
||||
if (ImGui::Button(localize.get(BASIC_CANCEL), widgetSize)) bakePopup.close();
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_CANCEL_BAKE_FRAMES));
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
bakeIntoOtherFramesPopup.trigger();
|
||||
|
||||
if (ImGui::BeginPopupModal(bakeIntoOtherFramesPopup.label(), &bakeIntoOtherFramesPopup.isOpen,
|
||||
ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
auto& isRoundRotation = settings.bakeIsRoundRotation;
|
||||
auto& isRoundScale = settings.bakeIsRoundScale;
|
||||
auto& isMatchRootInterpolation = settings.bakeIsMatchRootInterpolation;
|
||||
auto& isUseRootPivot = settings.bakeIsUseRootPivot;
|
||||
int target = (int)bakeIntoOtherFramesTarget;
|
||||
ImGui::RadioButton(localize.get(LABEL_CURRENT_SELECTION), &target,
|
||||
(int)BakeIntoOtherFramesTarget::CURRENT_SELECTION);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_INTO_OTHER_FRAMES_CURRENT_SELECTION));
|
||||
ImGui::SameLine();
|
||||
ImGui::RadioButton(localize.get(LABEL_ALL), &target, (int)BakeIntoOtherFramesTarget::ALL);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_INTO_OTHER_FRAMES_ALL));
|
||||
bakeIntoOtherFramesTarget = (BakeIntoOtherFramesTarget)target;
|
||||
|
||||
auto isCurrentSelection = bakeIntoOtherFramesTarget == BakeIntoOtherFramesTarget::CURRENT_SELECTION;
|
||||
ImGui::BeginDisabled(isCurrentSelection);
|
||||
ImGui::Checkbox(localize.get(LABEL_LAYERS), &isBakeIntoOtherFramesLayers);
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox(localize.get(LABEL_NULLS), &isBakeIntoOtherFramesNulls);
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_ROUND_ROTATION), &isRoundRotation);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ROUND_ROTATION));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_ROUND_SCALE), &isRoundScale);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ROUND_SCALE));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_BAKE_MATCH_ROOT_INTERPOLATION), &isMatchRootInterpolation);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_MATCH_ROOT_INTERPOLATION));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_BAKE_USE_ROOT_PIVOT), &isUseRootPivot);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_USE_ROOT_PIVOT));
|
||||
|
||||
auto widgetSize = widget_size_with_row_get(2);
|
||||
|
||||
shortcut(manager.chords[SHORTCUT_CONFIRM]);
|
||||
ImGui::BeginDisabled(!is_bake_into_other_frames_ready());
|
||||
if (ImGui::Button(localize.get(LABEL_BAKE), widgetSize))
|
||||
{
|
||||
bake_into_other_frames();
|
||||
bakeIntoOtherFramesPopup.close();
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
shortcut(manager.chords[SHORTCUT_CANCEL]);
|
||||
if (ImGui::Button(localize.get(BASIC_CANCEL), widgetSize)) bakeIntoOtherFramesPopup.close();
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_CANCEL_BAKE_FRAMES));
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
if (animation)
|
||||
{
|
||||
if (shortcut(manager.chords[SHORTCUT_PLAY_PAUSE], shortcut::GLOBAL)) playback.toggle();
|
||||
|
||||
if (shortcut(manager.chords[SHORTCUT_MOVE_PLAYHEAD_BACK], shortcut::GLOBAL))
|
||||
{
|
||||
playback_stop();
|
||||
playback.decrement(settings.playbackIsClamp ? animation->frameNum : 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 : FRAME_NUM_MAX);
|
||||
document.frameTime = playback.time;
|
||||
}
|
||||
|
||||
struct FrameResize
|
||||
{
|
||||
int shortcut;
|
||||
StringType edit;
|
||||
int delta;
|
||||
};
|
||||
constexpr FrameResize FRAME_RESIZES[] = {{SHORTCUT_SHORTEN_FRAME, EDIT_SHORTEN_FRAME, -1},
|
||||
{SHORTCUT_EXTEND_FRAME, EDIT_EXTEND_FRAME, 1}};
|
||||
static bool isResizeChordHeld[std::size(FRAME_RESIZES)]{};
|
||||
for (int i = 0; i < (int)std::size(FRAME_RESIZES); ++i)
|
||||
{
|
||||
auto resize = FRAME_RESIZES[i];
|
||||
auto isPressed = shortcut(manager.chords[resize.shortcut], shortcut::GLOBAL);
|
||||
auto selectedFrames =
|
||||
isPressed ? document.frame_references_get(Document::FrameReferenceFallback::NONE) : std::set<Reference>{};
|
||||
std::erase_if(selectedFrames, is_trigger_reference);
|
||||
if (!selectedFrames.empty())
|
||||
{
|
||||
if (!isResizeChordHeld[i]) edit_begin_push(resize.edit);
|
||||
command_push(
|
||||
[=, this](Manager&, Document& document)
|
||||
{
|
||||
for (auto frameReference : selectedFrames)
|
||||
if (auto frame = document.model.frame_edit(frameReference))
|
||||
frame->duration =
|
||||
std::clamp(frame->duration + resize.delta, FRAME_DURATION_MIN, FRAME_DURATION_MAX);
|
||||
document.change();
|
||||
});
|
||||
}
|
||||
isResizeChordHeld[i] = isPressed;
|
||||
}
|
||||
|
||||
auto isPreviousFrame = shortcut(manager.chords[SHORTCUT_PREVIOUS_FRAME], shortcut::GLOBAL);
|
||||
auto isNextFrame = shortcut(manager.chords[SHORTCUT_NEXT_FRAME], shortcut::GLOBAL);
|
||||
auto isPreviousItem = shortcut(manager.chords[SHORTCUT_PREVIOUS_ITEM], shortcut::GLOBAL);
|
||||
auto isNextItem = shortcut(manager.chords[SHORTCUT_NEXT_ITEM], shortcut::GLOBAL);
|
||||
|
||||
if (isPreviousFrame || isNextFrame)
|
||||
if (auto item = selected_item_get(); item && !item->frames.empty())
|
||||
{
|
||||
auto frameReference = reference;
|
||||
frameReference.frameIndex = glm::clamp(reference.frameIndex + (int)isNextFrame - (int)isPreviousFrame, 0,
|
||||
(int)item->frames.size() - 1);
|
||||
reference_set(frameReference);
|
||||
document.frame_focus_select();
|
||||
document.frameTime = model::frame_time_from_index_get(*item, reference.frameIndex);
|
||||
}
|
||||
|
||||
if (isPreviousItem) reference_set_adjacent_item(-1);
|
||||
if (isNextItem) reference_set_adjacent_item(1);
|
||||
}
|
||||
|
||||
if (isTextPushed) ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,213 @@ namespace anm2ed::imgui
|
||||
context = std::make_unique<TimelineContext>(std::move(state), manager, settings, resources, clipboard);
|
||||
context->update();
|
||||
}
|
||||
|
||||
void TimelineContext::draw()
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
|
||||
if (ImGui::Begin(localize.get(LABEL_TIMELINE_WINDOW), &settings.windowIsTimeline))
|
||||
{
|
||||
isWindowHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows |
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem);
|
||||
frames_child();
|
||||
if (frameMoveDrag.isActive && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
{
|
||||
if (frameMoveDropTarget) frames_move_to(*frameMoveDropTarget);
|
||||
frameMoveDrag = {};
|
||||
}
|
||||
items_child();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
|
||||
if (itemProperties.update(manager, settings, document, reference)) group_selection_reset_for(document);
|
||||
group_properties_update();
|
||||
|
||||
makeManyRegionsPopup.trigger();
|
||||
if (ImGui::BeginPopupModal(makeManyRegionsPopup.label(), &makeManyRegionsPopup.isOpen, ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
input_text_string(localize.get(LABEL_FORMAT), &settings.generateRegionNameFormat);
|
||||
ImGui::Checkbox(localize.get(LABEL_MAP_FRAMES_TO_REGIONS), &isMakeManyRegionsMapFrames);
|
||||
|
||||
auto result = popup_buttons_draw(manager, localize.get(LABEL_MAKE_MANY_REGIONS));
|
||||
if (result == PopupButton::CONFIRM)
|
||||
edit_push(EDIT_GENERATE_REGIONS_FROM_ANIMATIONS,
|
||||
[targetFrames = makeManyRegionReferences, format = settings.generateRegionNameFormat,
|
||||
mapping = isMakeManyRegionsMapFrames ? RegionFrameMapping::SET
|
||||
: RegionFrameMapping::PRESERVE](model::Model& model)
|
||||
{ return edit::regions_generate(model, {}, targetFrames, format, mapping); });
|
||||
if (result != PopupButton::NONE) makeManyRegionsPopup.close();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
makeManyRegionsPopup.end();
|
||||
|
||||
bakePopup.trigger();
|
||||
|
||||
if (ImGui::BeginPopupModal(bakePopup.label(), &bakePopup.isOpen, ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
auto& interval = settings.bakeInterval;
|
||||
auto& isRoundRotation = settings.bakeIsRoundRotation;
|
||||
auto& isRoundScale = settings.bakeIsRoundScale;
|
||||
|
||||
auto frame = frame_get();
|
||||
|
||||
input_int_range(localize.get(LABEL_INTERVAL), interval, FRAME_DURATION_MIN,
|
||||
frame ? frame->duration : FRAME_DURATION_MIN);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_INTERVAL));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_ROUND_ROTATION), &isRoundRotation);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ROUND_ROTATION));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_ROUND_SCALE), &isRoundScale);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ROUND_SCALE));
|
||||
|
||||
auto widgetSize = widget_size_with_row_get(2);
|
||||
|
||||
shortcut(manager.chords[SHORTCUT_CONFIRM]);
|
||||
if (ImGui::Button(localize.get(LABEL_BAKE), widgetSize))
|
||||
{
|
||||
frames_bake();
|
||||
bakePopup.close();
|
||||
}
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_FRAMES_OPTIONS));
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
shortcut(manager.chords[SHORTCUT_CANCEL]);
|
||||
if (ImGui::Button(localize.get(BASIC_CANCEL), widgetSize)) bakePopup.close();
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_CANCEL_BAKE_FRAMES));
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
bakeIntoOtherFramesPopup.trigger();
|
||||
|
||||
if (ImGui::BeginPopupModal(bakeIntoOtherFramesPopup.label(), &bakeIntoOtherFramesPopup.isOpen,
|
||||
ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
auto& isRoundRotation = settings.bakeIsRoundRotation;
|
||||
auto& isRoundScale = settings.bakeIsRoundScale;
|
||||
auto& isMatchRootInterpolation = settings.bakeIsMatchRootInterpolation;
|
||||
auto& isUseRootPivot = settings.bakeIsUseRootPivot;
|
||||
int target = (int)bakeIntoOtherFramesTarget;
|
||||
ImGui::RadioButton(localize.get(LABEL_CURRENT_SELECTION), &target,
|
||||
(int)BakeIntoOtherFramesTarget::CURRENT_SELECTION);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_INTO_OTHER_FRAMES_CURRENT_SELECTION));
|
||||
ImGui::SameLine();
|
||||
ImGui::RadioButton(localize.get(LABEL_ALL), &target, (int)BakeIntoOtherFramesTarget::ALL);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_INTO_OTHER_FRAMES_ALL));
|
||||
bakeIntoOtherFramesTarget = (BakeIntoOtherFramesTarget)target;
|
||||
|
||||
auto isCurrentSelection = bakeIntoOtherFramesTarget == BakeIntoOtherFramesTarget::CURRENT_SELECTION;
|
||||
ImGui::BeginDisabled(isCurrentSelection);
|
||||
ImGui::Checkbox(localize.get(LABEL_LAYERS), &isBakeIntoOtherFramesLayers);
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox(localize.get(LABEL_NULLS), &isBakeIntoOtherFramesNulls);
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_ROUND_ROTATION), &isRoundRotation);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ROUND_ROTATION));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_ROUND_SCALE), &isRoundScale);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ROUND_SCALE));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_BAKE_MATCH_ROOT_INTERPOLATION), &isMatchRootInterpolation);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_MATCH_ROOT_INTERPOLATION));
|
||||
|
||||
ImGui::Checkbox(localize.get(LABEL_BAKE_USE_ROOT_PIVOT), &isUseRootPivot);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_BAKE_USE_ROOT_PIVOT));
|
||||
|
||||
auto widgetSize = widget_size_with_row_get(2);
|
||||
|
||||
shortcut(manager.chords[SHORTCUT_CONFIRM]);
|
||||
ImGui::BeginDisabled(!is_bake_into_other_frames_ready());
|
||||
if (ImGui::Button(localize.get(LABEL_BAKE), widgetSize))
|
||||
{
|
||||
bake_into_other_frames();
|
||||
bakeIntoOtherFramesPopup.close();
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
shortcut(manager.chords[SHORTCUT_CANCEL]);
|
||||
if (ImGui::Button(localize.get(BASIC_CANCEL), widgetSize)) bakeIntoOtherFramesPopup.close();
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_CANCEL_BAKE_FRAMES));
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
if (animation)
|
||||
{
|
||||
if (shortcut(manager.chords[SHORTCUT_PLAY_PAUSE], shortcut::GLOBAL)) playback.toggle();
|
||||
|
||||
if (shortcut(manager.chords[SHORTCUT_MOVE_PLAYHEAD_BACK], shortcut::GLOBAL))
|
||||
{
|
||||
playback_stop();
|
||||
playback.decrement(settings.playbackIsClamp ? animation->frameNum : 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 : FRAME_NUM_MAX);
|
||||
document.frameTime = playback.time;
|
||||
}
|
||||
|
||||
struct FrameResize
|
||||
{
|
||||
int shortcut;
|
||||
StringType edit;
|
||||
int delta;
|
||||
};
|
||||
constexpr FrameResize FRAME_RESIZES[] = {{SHORTCUT_SHORTEN_FRAME, EDIT_SHORTEN_FRAME, -1},
|
||||
{SHORTCUT_EXTEND_FRAME, EDIT_EXTEND_FRAME, 1}};
|
||||
static bool isResizeChordHeld[std::size(FRAME_RESIZES)]{};
|
||||
for (int i = 0; i < (int)std::size(FRAME_RESIZES); ++i)
|
||||
{
|
||||
auto resize = FRAME_RESIZES[i];
|
||||
auto isPressed = shortcut(manager.chords[resize.shortcut], shortcut::GLOBAL);
|
||||
auto selectedFrames =
|
||||
isPressed ? document.frame_references_get(Document::FrameReferenceFallback::NONE) : std::set<Reference>{};
|
||||
std::erase_if(selectedFrames, is_trigger_reference);
|
||||
if (!selectedFrames.empty())
|
||||
{
|
||||
if (!isResizeChordHeld[i]) edit_begin_push(resize.edit);
|
||||
command_push(
|
||||
[=, this](Manager&, Document& document)
|
||||
{
|
||||
for (auto frameReference : selectedFrames)
|
||||
if (auto frame = document.model.frame_edit(frameReference))
|
||||
frame->duration =
|
||||
std::clamp(frame->duration + resize.delta, FRAME_DURATION_MIN, FRAME_DURATION_MAX);
|
||||
document.change();
|
||||
});
|
||||
}
|
||||
isResizeChordHeld[i] = isPressed;
|
||||
}
|
||||
|
||||
auto isPreviousFrame = shortcut(manager.chords[SHORTCUT_PREVIOUS_FRAME], shortcut::GLOBAL);
|
||||
auto isNextFrame = shortcut(manager.chords[SHORTCUT_NEXT_FRAME], shortcut::GLOBAL);
|
||||
auto isPreviousItem = shortcut(manager.chords[SHORTCUT_PREVIOUS_ITEM], shortcut::GLOBAL);
|
||||
auto isNextItem = shortcut(manager.chords[SHORTCUT_NEXT_ITEM], shortcut::GLOBAL);
|
||||
|
||||
if (isPreviousFrame || isNextFrame)
|
||||
if (auto item = selected_item_get(); item && !item->frames.empty())
|
||||
{
|
||||
auto frameReference = reference;
|
||||
frameReference.frameIndex = glm::clamp(reference.frameIndex + (int)isNextFrame - (int)isPreviousFrame, 0,
|
||||
(int)item->frames.size() - 1);
|
||||
reference_set(frameReference);
|
||||
document.frame_focus_select();
|
||||
document.frameTime = model::frame_time_from_index_get(*item, reference.frameIndex);
|
||||
}
|
||||
|
||||
if (isPreviousItem) reference_set_adjacent_item(-1);
|
||||
if (isNextItem) reference_set_adjacent_item(1);
|
||||
}
|
||||
|
||||
if (isTextPushed) ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "clipboard.hpp"
|
||||
#include "icon.hpp"
|
||||
#include "manager.hpp"
|
||||
#include "popup/item_properties.hpp"
|
||||
#include "resources.hpp"
|
||||
@@ -16,6 +17,59 @@
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
inline const glm::vec4 ROOT_COLOR = glm::vec4(0.140f, 0.310f, 0.560f, 1.000f);
|
||||
inline const glm::vec4 ROOT_COLOR_ACTIVE = glm::vec4(0.240f, 0.520f, 0.880f, 1.000f);
|
||||
inline const glm::vec4 ROOT_COLOR_HOVERED = glm::vec4(0.320f, 0.640f, 1.000f, 1.000f);
|
||||
|
||||
inline const glm::vec4 LAYER_COLOR = glm::vec4(0.640f, 0.320f, 0.110f, 1.000f);
|
||||
inline const glm::vec4 LAYER_COLOR_ACTIVE = glm::vec4(0.840f, 0.450f, 0.170f, 1.000f);
|
||||
inline const glm::vec4 LAYER_COLOR_HOVERED = glm::vec4(0.960f, 0.560f, 0.240f, 1.000f);
|
||||
|
||||
inline const glm::vec4 NULL_COLOR = glm::vec4(0.140f, 0.430f, 0.200f, 1.000f);
|
||||
inline const glm::vec4 NULL_COLOR_ACTIVE = glm::vec4(0.250f, 0.650f, 0.350f, 1.000f);
|
||||
inline const glm::vec4 NULL_COLOR_HOVERED = glm::vec4(0.350f, 0.800f, 0.480f, 1.000f);
|
||||
|
||||
inline const glm::vec4 TRIGGER_COLOR = glm::vec4(0.620f, 0.150f, 0.260f, 1.000f);
|
||||
inline const glm::vec4 TRIGGER_COLOR_ACTIVE = glm::vec4(0.820f, 0.250f, 0.380f, 1.000f);
|
||||
inline const glm::vec4 TRIGGER_COLOR_HOVERED = glm::vec4(0.950f, 0.330f, 0.490f, 1.000f);
|
||||
|
||||
#define ANM2_ITEM_TYPES \
|
||||
X(NONE, STRING_UNDEFINED, resource::icon::NONE, glm::vec4(), glm::vec4(), glm::vec4()) \
|
||||
X(ROOT, BASIC_ROOT, resource::icon::ROOT, ROOT_COLOR, ROOT_COLOR_ACTIVE, ROOT_COLOR_HOVERED) \
|
||||
X(LAYER, BASIC_LAYER_ANIMATION, resource::icon::LAYER, LAYER_COLOR, LAYER_COLOR_ACTIVE, LAYER_COLOR_HOVERED) \
|
||||
X(NULL_, BASIC_NULL_ANIMATION, resource::icon::NULL_, NULL_COLOR, NULL_COLOR_ACTIVE, NULL_COLOR_HOVERED) \
|
||||
X(TRIGGER, BASIC_TRIGGERS, resource::icon::TRIGGERS, TRIGGER_COLOR, TRIGGER_COLOR_ACTIVE, TRIGGER_COLOR_HOVERED)
|
||||
|
||||
constexpr StringType TYPE_STRINGS[] = {
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) string,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr resource::icon::Type TYPE_ICONS[] = {
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) icon,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR[] = {
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) color,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR_ACTIVE[] = {
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) colorActive,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR_HOVERED[] = {
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) colorHovered,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
struct TimelineContext;
|
||||
|
||||
// A timeline row: a track (in a group or not), a group, or a group's root. groupType/groupId name the group a
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
#include "tools.hpp"
|
||||
#include "panel.hpp"
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "strings.hpp"
|
||||
#include "tool.hpp"
|
||||
#include "types.hpp"
|
||||
#include "util/imgui/layout.hpp"
|
||||
#include "util/imgui/shortcut.hpp"
|
||||
#include "util/imgui/tooltip.hpp"
|
||||
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::types;
|
||||
@@ -15,7 +15,7 @@ using namespace glm;
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
void Tools::update(Manager& manager, Settings& settings, Resources& resources)
|
||||
void tools_update(Manager& manager, Settings& settings, Resources& resources, PopupHelper& colorEditPopup)
|
||||
{
|
||||
auto& document = *manager.get();
|
||||
|
||||
@@ -66,8 +66,6 @@ namespace anm2ed::imgui
|
||||
if (ImGui::ColorButton(labelText, to_imvec4(settings.toolColor), ImGuiColorEditFlags_NoTooltip,
|
||||
to_imvec2(size)))
|
||||
tool_use((tool::Type)i);
|
||||
|
||||
colorEditPosition = ImGui::GetCursorScreenPos();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "strings.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
class Tools
|
||||
{
|
||||
bool isOpenColorEdit{};
|
||||
ImVec2 colorEditPosition{};
|
||||
|
||||
PopupHelper colorEditPopup{
|
||||
PopupHelper(LABEL_TOOLS_COLOR_EDIT_POPUP, POPUP_TO_CONTENT, POPUP_BY_ITEM)};
|
||||
|
||||
public:
|
||||
void update(Manager&, Settings&, Resources&);
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "welcome.hpp"
|
||||
#include "documents.hpp"
|
||||
#include "panel.hpp"
|
||||
#include "taskbar.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
@@ -13,7 +15,7 @@ using namespace anm2ed::resource;
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
void Welcome::update(Manager& manager, Resources& resources, Dialog& dialog, Taskbar& taskbar, Documents& documents)
|
||||
void welcome_update(Manager& manager, Resources& resources, Dialog& dialog, Taskbar& taskbar, Documents& documents)
|
||||
{
|
||||
auto viewport = ImGui::GetMainViewport();
|
||||
auto windowHeight = viewport->Size.y - taskbar.height - documents.height;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "documents.hpp"
|
||||
#include "taskbar.hpp"
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
class Welcome
|
||||
{
|
||||
public:
|
||||
void update(Manager&, Resources&, Dialog&, Taskbar&, Documents&);
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user