more minor polish there and here

This commit is contained in:
2025-11-11 16:07:02 -05:00
parent 2a671e2623
commit d9a05947c0
20 changed files with 221 additions and 81 deletions
+5 -2
View File
@@ -48,7 +48,8 @@ namespace anm2ed::imgui
{
if (auto trigger = animation->triggers.frame_generate(playback.time, anm2::TRIGGER);
trigger.is_visible(anm2::TRIGGER))
if (anm2.content.sounds.contains(trigger.soundID)) anm2.content.sounds[trigger.soundID].audio.play(mixer);
if (anm2.content.sounds.contains(trigger.soundID))
anm2.content.sounds[trigger.soundID].audio.play(false, mixer);
}
}
@@ -132,7 +133,7 @@ namespace anm2ed::imgui
{
if (auto rect = animation->rect(isRootTransform); rect != vec4(-1.0f))
{
size_set(vec2(rect.w, rect.z) * scale);
size_set(vec2(rect.z, rect.w) * scale);
set_to_rect(zoom, pan, rect);
}
}
@@ -583,6 +584,8 @@ namespace anm2ed::imgui
ImGui::ProgressBar(progress);
ImGui::Text("Once recording is complete, rendering may take some time.\nPlease be patient...");
if (ImGui::Button("Cancel", ImVec2(ImGui::GetContentRegionAvail().x, 0)))
{
playback.isPlaying = false;
-1
View File
@@ -5,7 +5,6 @@
#include "audio_stream.h"
#include "canvas.h"
#include "manager.h"
#include "render.h"
#include "resources.h"
#include "settings.h"
+18 -14
View File
@@ -106,22 +106,26 @@ namespace anm2ed::imgui
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.WindowPadding);
auto viewport = ImGui::GetMainViewport();
auto textureSize = texture.size.x * texture.size.y > (viewport->Size.x * viewport->Size.y) * 0.5f
? to_vec2(viewport->Size) * 0.5f
: vec2(texture.size);
auto aspectRatio = (float)texture.size.x / texture.size.y;
if (textureSize.x / textureSize.y > aspectRatio)
textureSize.x = textureSize.y * aspectRatio;
else
textureSize.y = textureSize.x / aspectRatio;
auto textWidth = ImGui::CalcTextSize(path).x;
auto tooltipPadding = style.WindowPadding.x * 4.0f;
auto minWidth = textureSize.x + style.ItemSpacing.x + textWidth + tooltipPadding;
ImGui::SetNextWindowSize(ImVec2(minWidth, 0), ImGuiCond_Appearing);
if (ImGui::BeginItemTooltip())
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
auto viewport = ImGui::GetMainViewport();
auto textureSize = texture.size.x * texture.size.y > (viewport->Size.x * viewport->Size.y) * 0.5f
? to_vec2(viewport->Size) * 0.5f
: vec2(texture.size);
auto aspectRatio = (float)texture.size.x / texture.size.y;
if (textureSize.x / textureSize.y > aspectRatio)
textureSize.x = textureSize.y * aspectRatio;
else
textureSize.y = textureSize.x / aspectRatio;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
if (ImGui::BeginChild("##Spritesheet Tooltip Image Child", to_imvec2(textureSize),
ImGuiChildFlags_Borders))
@@ -148,7 +152,7 @@ namespace anm2ed::imgui
ImGui::PopStyleVar(2);
auto imageSize = to_imvec2(vec2(spritesheetChildSize.y));
auto aspectRatio = (float)texture.size.x / texture.size.y;
aspectRatio = (float)texture.size.x / texture.size.y;
if (imageSize.x / imageSize.y > aspectRatio)
imageSize.x = imageSize.y * aspectRatio;
@@ -284,4 +288,4 @@ namespace anm2ed::imgui
}
ImGui::End();
}
}
}
+18 -6
View File
@@ -176,7 +176,17 @@ namespace anm2ed::imgui
ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4());
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4());
if (ImGui::Selectable("##Item Button", false, ImGuiSelectableFlags_None, itemSize))
{
if (type == anm2::LAYER)
{
document.spritesheet.reference = anm2.content.layers[id].spritesheetID;
document.layer.selection = {id};
}
else if (type == anm2::NULL_)
document.null.selection = {id};
reference = {reference.animationIndex, type, id};
}
ImGui::PopStyleColor(3);
if (ImGui::IsItemHovered())
{
@@ -993,10 +1003,11 @@ namespace anm2ed::imgui
ImGui::SameLine();
ImGui::BeginDisabled(!animation || animation->frameNum == animation->length());
if (ImGui::Button("Fit Animation Length", widgetSize))
DOCUMENT_EDIT(document, "Fit Animation Length", Document::ANIMATIONS,
animation->frameNum = animation->length());
DOCUMENT_EDIT(document, "Fit Animation Length", Document::ANIMATIONS, animation->fit_length());
ImGui::SetItemTooltip("The animation length will be set to the effective length of the animation.");
ImGui::EndDisabled();
ImGui::SameLine();
@@ -1030,7 +1041,7 @@ namespace anm2ed::imgui
auto createdBy = anm2.info.createdBy;
ImGui::SetNextItemWidth(widgetSize.x);
if (input_text_string("Author", &createdBy))
DOCUMENT_EDIT(document, "FPS", Document::ANIMATIONS, anm2.info.createdBy = createdBy);
DOCUMENT_EDIT(document, "Author", Document::ANIMATIONS, anm2.info.createdBy = createdBy);
ImGui::SetItemTooltip("Set the author of the document.");
ImGui::SameLine();
@@ -1239,9 +1250,10 @@ namespace anm2ed::imgui
if (ImGui::Button("Bake", widgetSize))
{
if (auto itemPtr = document.item_get())
DOCUMENT_EDIT(document, "Bake Frames", Document::FRAMES,
itemPtr->frames_bake(reference.frameIndex, interval, isRoundScale, isRoundRotation));
if (auto item = document.item_get())
for (auto i : frames.selection | std::views::reverse)
DOCUMENT_EDIT(document, "Bake Frames", Document::FRAMES,
item->frames_bake(i, interval, isRoundScale, isRoundRotation));
bakePopup.close();
}
ImGui::SetItemTooltip("Bake the selected frame(s) with the options selected.");