some nice tooltip stuff
This commit is contained in:
@@ -26,10 +26,10 @@ namespace anm2ed::anm2
|
||||
|
||||
#define TYPE_LIST \
|
||||
X(NONE, "", "", resource::icon::NONE, glm::vec4(), glm::vec4(), glm::vec4()) \
|
||||
X(ROOT, "Root", "RootAnimation", resource::icon::ROOT, ROOT_COLOR, ROOT_COLOR_ACTIVE, ROOT_COLOR_HOVERED) \
|
||||
X(ROOT, "Root", "Root", resource::icon::ROOT, ROOT_COLOR, ROOT_COLOR_ACTIVE, ROOT_COLOR_HOVERED) \
|
||||
X(LAYER, "Layer", "Layer Animation", resource::icon::LAYER, LAYER_COLOR, LAYER_COLOR_ACTIVE, LAYER_COLOR_HOVERED) \
|
||||
X(NULL_, "Null", "Null Animation", resource::icon::NULL_, NULL_COLOR, NULL_COLOR_ACTIVE, NULL_COLOR_HOVERED) \
|
||||
X(TRIGGER, "Triggers", "Triggers", resource::icon::TRIGGERS, TRIGGER_COLOR, TRIGGER_COLOR_ACTIVE, \
|
||||
X(TRIGGER, "Trigger", "Triggers", resource::icon::TRIGGERS, TRIGGER_COLOR, TRIGGER_COLOR_ACTIVE, \
|
||||
TRIGGER_COLOR_HOVERED)
|
||||
|
||||
enum Type
|
||||
|
||||
@@ -100,6 +100,8 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::SetItemTooltip("%s", document.path.c_str());
|
||||
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,13 +94,7 @@ namespace anm2ed::imgui
|
||||
ImGui::TextUnformatted(animation.name.c_str());
|
||||
ImGui::PopFont();
|
||||
|
||||
if (isDefault)
|
||||
{
|
||||
|
||||
ImGui::PushFont(resources.fonts[font::ITALICS].get(), font::SIZE);
|
||||
ImGui::TextUnformatted("(Default Animation)");
|
||||
ImGui::PopFont();
|
||||
}
|
||||
if (isDefault) ImGui::TextUnformatted("(Default Animation)");
|
||||
|
||||
ImGui::Text("Length: %d", animation.frameNum);
|
||||
ImGui::Text("Loop: %s", animation.isLoop ? "true" : "false");
|
||||
|
||||
@@ -111,15 +111,13 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
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 maxPreviewSize = to_vec2(viewport->Size) * 0.5f;
|
||||
vec2 textureSize = vec2(glm::max(texture.size.x, 1), glm::max(texture.size.y, 1));
|
||||
if (textureSize.x > maxPreviewSize.x || textureSize.y > maxPreviewSize.y)
|
||||
{
|
||||
auto scale = glm::min(maxPreviewSize.x / textureSize.x, maxPreviewSize.y / textureSize.y);
|
||||
textureSize *= scale;
|
||||
}
|
||||
|
||||
auto textWidth = ImGui::CalcTextSize(pathCStr).x;
|
||||
auto tooltipPadding = style.WindowPadding.x * 4.0f;
|
||||
@@ -132,20 +130,28 @@ namespace anm2ed::imgui
|
||||
if (ImGui::BeginItemTooltip())
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
|
||||
if (ImGui::BeginChild("##Spritesheet Tooltip Image Child", to_imvec2(textureSize),
|
||||
ImGuiChildFlags_Borders))
|
||||
ImGui::Image(texture.id, ImGui::GetContentRegionAvail());
|
||||
auto childFlags = ImGuiChildFlags_Borders | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY;
|
||||
auto noScrollFlags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
if (ImGui::BeginChild("##Spritesheet Tooltip Image Child", to_imvec2(textureSize), childFlags,
|
||||
noScrollFlags))
|
||||
ImGui::Image(texture.id, to_imvec2(textureSize));
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::BeginChild("##Spritesheet Info Tooltip Child"))
|
||||
auto infoChildFlags = ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY;
|
||||
if (ImGui::BeginChild("##Spritesheet Info Tooltip Child", ImVec2(0, 0), infoChildFlags, noScrollFlags))
|
||||
{
|
||||
ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE);
|
||||
ImGui::TextUnformatted(pathCStr);
|
||||
ImGui::PopFont();
|
||||
|
||||
ImGui::Text("ID: %d", id);
|
||||
|
||||
if (!spritesheet.texture.is_valid())
|
||||
ImGui::Text("This spritesheet isn't valid!\nLoad an existing, valid texture.");
|
||||
else
|
||||
ImGui::Text("Size: %d x %d", texture.size.x, texture.size.y);
|
||||
}
|
||||
ImGui::EndChild();
|
||||
@@ -155,7 +161,7 @@ namespace anm2ed::imgui
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
auto imageSize = to_imvec2(vec2(spritesheetChildSize.y));
|
||||
aspectRatio = (float)texture.size.x / texture.size.y;
|
||||
auto aspectRatio = (float)texture.size.x / texture.size.y;
|
||||
|
||||
if (imageSize.x / imageSize.y > aspectRatio)
|
||||
imageSize.x = imageSize.y * aspectRatio;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <imgui_internal.h>
|
||||
|
||||
#include "math_.h"
|
||||
#include "toast.h"
|
||||
|
||||
#include "vector_.h"
|
||||
@@ -77,6 +78,7 @@ namespace anm2ed::imgui
|
||||
|
||||
constexpr auto FRAME_MULTIPLE = 5;
|
||||
constexpr auto FRAME_DRAG_PAYLOAD_ID = "Frame Drag Drop";
|
||||
constexpr auto FRAME_TOOLTIP_HOVER_DELAY = 0.75f; // Extra delay for frame info tooltip.
|
||||
|
||||
constexpr auto HELP_FORMAT = R"(- Press {} to decrement time.
|
||||
- Press {} to increment time.
|
||||
@@ -812,7 +814,83 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::PopStyleColor(4);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.WindowPadding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing);
|
||||
auto& imguiStyle = ImGui::GetStyle();
|
||||
auto previousTooltipFlags = imguiStyle.HoverFlagsForTooltipMouse;
|
||||
auto previousTooltipDelay = imguiStyle.HoverDelayNormal;
|
||||
imguiStyle.HoverFlagsForTooltipMouse = ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayNormal |
|
||||
ImGuiHoveredFlags_AllowWhenDisabled |
|
||||
ImGuiHoveredFlags_NoSharedDelay;
|
||||
imguiStyle.HoverDelayNormal = FRAME_TOOLTIP_HOVER_DELAY;
|
||||
bool showFrameTooltip = ImGui::BeginItemTooltip();
|
||||
imguiStyle.HoverFlagsForTooltipMouse = previousTooltipFlags;
|
||||
imguiStyle.HoverDelayNormal = previousTooltipDelay;
|
||||
|
||||
if (showFrameTooltip)
|
||||
{
|
||||
|
||||
if (type != anm2::TRIGGER)
|
||||
{
|
||||
ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE);
|
||||
ImGui::Text("%s Frame", anm2::TYPE_STRINGS[type]);
|
||||
ImGui::PopFont();
|
||||
|
||||
auto float_text = [&](std::string label, float& value)
|
||||
{
|
||||
std::string useFormat = math::float_format_get(value);
|
||||
std::string format(label + ": " + useFormat);
|
||||
ImGui::Text(format.c_str(), value);
|
||||
};
|
||||
|
||||
auto vec2_text = [&](std::string label, vec2& value)
|
||||
{
|
||||
std::string useFormat = math::vec2_format_get(value);
|
||||
std::string format(label + ": " + useFormat + ", " + useFormat);
|
||||
ImGui::Text(format.c_str(), value.x, value.y);
|
||||
};
|
||||
|
||||
ImGui::Text("Index: %i", (int)i);
|
||||
|
||||
if (type == anm2::LAYER)
|
||||
{
|
||||
vec2_text("Crop", frame.crop);
|
||||
vec2_text("Size", frame.size);
|
||||
}
|
||||
|
||||
vec2_text("Position", frame.size);
|
||||
|
||||
if (type == anm2::LAYER) vec2_text("Pivot", frame.pivot);
|
||||
|
||||
vec2_text("Scale", frame.scale);
|
||||
float_text("Rotation", frame.rotation);
|
||||
ImGui::Text("Duration: %i", frame.duration);
|
||||
ImGui::Text("Tint: %i, %i, %i, %i", math::float_to_uint8(frame.tint.r),
|
||||
math::float_to_uint8(frame.tint.g), math::float_to_uint8(frame.tint.b),
|
||||
math::float_to_uint8(frame.tint.a));
|
||||
ImGui::Text("Color Offset: %i, %i, %i", math::float_to_uint8(frame.tint.r),
|
||||
math::float_to_uint8(frame.tint.g), math::float_to_uint8(frame.tint.b));
|
||||
ImGui::Text("Visible: %s", frame.isVisible ? "true" : "false");
|
||||
ImGui::Text("Interpolated: %s", frame.isInterpolated ? "true" : "false");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE);
|
||||
ImGui::Text("%s", anm2::TYPE_STRINGS[type]);
|
||||
ImGui::PopFont();
|
||||
|
||||
ImGui::Text("At Frame: %i", frame.atFrame);
|
||||
ImGui::Text("Event: %s", document.event.labels[frame.eventID + 1]);
|
||||
ImGui::Text("Sound: %s", document.sound.labels[frame.soundID + 1]);
|
||||
}
|
||||
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Left))
|
||||
{
|
||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Left))
|
||||
{
|
||||
if (type == anm2::TRIGGER || ImGui::IsKeyDown(ImGuiMod_Ctrl))
|
||||
{
|
||||
@@ -822,6 +900,7 @@ namespace anm2ed::imgui
|
||||
if (type != anm2::TRIGGER) draggedFrameStartDuration = draggedFrame->duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type != anm2::TRIGGER)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,6 @@ Alternatively, if you have subscribed to the mod, you can find the latest releas
|
||||
[h3]Happy animating![/h3]
|
||||
[img]https://files.catbox.moe/4auc1c.gif[/img]
|
||||
</description>
|
||||
<version>2.4</version>
|
||||
<version>2.5</version>
|
||||
<visibility>Public</visibility>
|
||||
</metadata>
|
||||
|
||||
Reference in New Issue
Block a user