Stage 1: headless Image and AudioData; GPU and playback caches in the UI

- resource::Image (pixels, size, uid) replaces Texture in documents, undo and
  wizards; it lives in anm2ed_core with no GL. uid changes with the pixels.
- resource::texture::id_get uploads lazily and evicts textures not drawn in a frame
- resource::AudioData (bytes, uid) replaces Audio; resource::audio::play/stop/
  track_detach/is_playing cache decoded audio and tracks per uid
- Resources::icon_id_get shortens the icon call sites
- tests/assets.cpp covers Image png round trip, uid tracking, merge_append

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 14:52:34 -04:00
1 parent 5311c2835f
commit 26ab394fe4
37 files changed
+538 -614

No files matched your search

+20 -20
View File
@@ -31,7 +31,7 @@
using namespace anm2ed::types;
using namespace anm2ed::util;
using namespace anm2ed::resource;
using namespace anm2ed::resource::texture;
using namespace anm2ed::resource::image;
using namespace glm;
namespace anm2ed::imgui
@@ -210,7 +210,7 @@ namespace anm2ed::imgui
return document.sound_get(soundID) ? soundID : -1;
}
bool render_audio_stream_generate(AudioStream& audioStream, std::map<int, Audio>& sounds,
bool render_audio_stream_generate(AudioStream& audioStream, std::map<int, AudioData>& sounds,
const std::vector<int>& frameSoundIDs, int fps)
{
audioStream.stream.clear();
@@ -229,7 +229,7 @@ namespace anm2ed::imgui
for (auto soundID : frameSoundIDs)
{
if (soundID != -1 && sounds.contains(soundID)) sounds.at(soundID).play(false, mixer);
if (soundID != -1 && sounds.contains(soundID)) audio::play(sounds.at(soundID), false, mixer);
sampleFrameAccumulator += framesPerStep;
auto sampleFramesToGenerate = (int)std::floor(sampleFrameAccumulator);
@@ -240,7 +240,7 @@ namespace anm2ed::imgui
if (!MIX_Generate(mixer, frameBuffer.data(), (int)(frameBuffer.size() * sizeof(float))))
{
for (auto& [_, sound] : sounds)
sound.track_detach(mixer);
audio::track_detach(sound, mixer);
MIX_DestroyMixer(mixer);
audioStream.stream.clear();
return false;
@@ -250,7 +250,7 @@ namespace anm2ed::imgui
}
for (auto& [_, sound] : sounds)
sound.track_detach(mixer);
audio::track_detach(sound, mixer);
MIX_DestroyMixer(mixer);
return true;
}
@@ -269,7 +269,7 @@ namespace anm2ed::imgui
auto stop_all_sounds = [&]()
{
for (auto& [_, sound] : document.sounds)
sound.stop(mixer);
audio::stop(sound, mixer);
};
if (manager.isRecording)
@@ -320,7 +320,7 @@ namespace anm2ed::imgui
}
else
{
auto firstFrame = Texture(renderTempFrames.front());
auto firstFrame = Image(renderTempFrames.front());
if (firstFrame.size.x <= 0 || firstFrame.size.y <= 0 || firstFrame.pixels.empty())
{
toast_log(Level::ERROR, TOAST_SPRITESHEET_EMPTY);
@@ -335,7 +335,7 @@ namespace anm2ed::imgui
for (std::size_t index = 0; index < renderTempFrames.size(); ++index)
{
auto frame = Texture(renderTempFrames[index]);
auto frame = Image(renderTempFrames[index]);
auto row = (int)(index / columns);
auto column = (int)(index % columns);
if (row >= rows || column >= columns) break;
@@ -351,7 +351,7 @@ namespace anm2ed::imgui
}
}
Texture spritesheetTexture(spritesheet.data(), spritesheetSize);
Image spritesheetTexture(spritesheet.data(), spritesheetSize);
if (spritesheetTexture.write_png(path))
{
toast_log(Level::INFO, TOAST_EXPORT_SPRITESHEET, pathString);
@@ -430,7 +430,7 @@ namespace anm2ed::imgui
if (!manager.isRecording && !document.sounds.empty() && isSound)
{
if (auto soundID = trigger_sound_id_get(document, animation, playback.time); soundID != -1)
if (auto sound = document.sound_get(soundID)) sound->play(false, mixer);
if (auto sound = document.sound_get(soundID)) audio::play(*sound, false, mixer);
}
auto info = element_first_get(anm2.root, ElementType::INFO);
@@ -583,13 +583,13 @@ namespace anm2ed::imgui
overlayTransparency = glm::clamp(overlayTransparency, 0.0f, 100.0f);
ImGui::SameLine();
radio_button_icon("##Overlay Over", &overlayDrawOrder, overlay_draw_order::OVER, resources.icons[icon::OVER].id,
orderIconSize, overlayIconTint);
radio_button_icon("##Overlay Over", &overlayDrawOrder, overlay_draw_order::OVER,
resources.icon_id_get(icon::OVER), orderIconSize, overlayIconTint);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_OVERLAY_OVER));
ImGui::SameLine();
radio_button_icon("##Overlay Under", &overlayDrawOrder, overlay_draw_order::UNDER,
resources.icons[icon::UNDER].id, orderIconSize, overlayIconTint);
resources.icon_id_get(icon::UNDER), orderIconSize, overlayIconTint);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_OVERLAY_UNDER));
}
ImGui::EndChild();
@@ -886,7 +886,7 @@ namespace anm2ed::imgui
vec4 color = isOnion ? vec4(sampleColor, sampleAlpha) : color::GREEN;
auto icon = isAltIcons ? icon::TARGET_ALT : icon::TARGET;
texture_render(shaderTexture, resources.icons[icon].id, rootTransform, color);
texture_render(shaderTexture, resources.icon_id_get(icon), rootTransform, color);
};
if (layeredOnions && root)
@@ -921,7 +921,7 @@ namespace anm2ed::imgui
reference.groupType == groupType && reference.groupId == group.id;
vec4 color = isOnion ? vec4(sampleColor, sampleAlpha) : isSelected ? color::RED : ROOT_COLOR;
auto icon = isAltIcons ? icon::TARGET_ALT : icon::TARGET;
texture_render(shaderTexture, resources.icons[icon].id, rootTransform, color);
texture_render(shaderTexture, resources.icon_id_get(icon), rootTransform, color);
};
if (auto layerAnimations = child_first_get(*animation, ElementType::LAYER_ANIMATIONS))
@@ -1005,8 +1005,8 @@ namespace anm2ed::imgui
auto customShader = sampleDocument.shader_get(frame.shaderId);
auto& layerShader = customShader ? *customShader : shaderTexture;
texture_render(layerShader, texture.id, layerTransform, frameTint, frameColorOffset, vertices.data(),
vec2(texture.size), sampleTime);
texture_render(layerShader, resource::texture::id_get(texture), layerTransform, frameTint,
frameColorOffset, vertices.data(), vec2(texture.size), sampleTime);
auto color = isOnion ? vec4(sampleColor, 1.0f - sampleAlpha)
: is_layer_animation_selected(sampleDocument, id) ? SELECTED_LAYER_BORDER_COLOR
@@ -1021,7 +1021,7 @@ namespace anm2ed::imgui
math::percent_to_unit(frame.shear));
auto pivotTransform = itemTransform * pivotModel;
texture_render(shaderTexture, resources.icons[icon::PIVOT].id, pivotTransform, color);
texture_render(shaderTexture, resources.icon_id_get(icon::PIVOT), pivotTransform, color);
}
};
@@ -1093,7 +1093,7 @@ namespace anm2ed::imgui
group_transform_for_time(*nullAnimations, nullAnimation, sampleTime, sampleTransform);
auto nullTransform = itemTransform * nullModel;
texture_render(shaderTexture, resources.icons[icon].id, nullTransform, color);
texture_render(shaderTexture, resources.icon_id_get(icon), nullTransform, color);
if (isShowRect)
{
@@ -1182,7 +1182,7 @@ namespace anm2ed::imgui
if (isRenderPreviewOverridden) pixels_unpremultiply_alpha(pixels);
auto framePath =
renderTempDirectory / render_frame_filename(settings.renderFormat, renderFrameIndex, settings.renderType);
if (Texture::write_pixels_png(framePath, size, pixels.data()))
if (Image::write_pixels_png(framePath, size, pixels.data()))
{
renderTempFrames.push_back(framePath);
++renderFrameIndex;
+7 -7
View File
@@ -77,21 +77,21 @@ namespace anm2ed::imgui
.isValid = true};
}
bool region_pixels_get(const Element& region, const Texture& texture, std::vector<uint8_t>& pixels, ivec2& size)
bool region_pixels_get(const Element& region, const Image& texture, std::vector<uint8_t>& pixels, ivec2& size)
{
auto minPoint = ivec2(glm::min(region.crop, region.crop + region.size));
size = ivec2(glm::max(region.crop, region.crop + region.size)) - minPoint;
if (size.x <= 0 || size.y <= 0 || texture.size.x <= 0 || texture.size.y <= 0 || texture.pixels.empty())
return false;
pixels.assign((size_t)size.x * size.y * texture::CHANNELS, 0);
pixels.assign((size_t)size.x * size.y * image::CHANNELS, 0);
for (int y = 0; y < size.y; y++)
for (int x = 0; x < size.x; x++)
{
auto source = minPoint + ivec2(x, y);
if (source.x < 0 || source.y < 0 || source.x >= texture.size.x || source.y >= texture.size.y) continue;
std::copy_n(texture.pixels.data() + ((size_t)source.y * texture.size.x + source.x) * texture::CHANNELS,
texture::CHANNELS, pixels.data() + ((size_t)y * size.x + x) * texture::CHANNELS);
std::copy_n(texture.pixels.data() + ((size_t)source.y * texture.size.x + source.x) * image::CHANNELS,
image::CHANNELS, pixels.data() + ((size_t)y * size.x + x) * image::CHANNELS);
}
return true;
}
@@ -124,7 +124,7 @@ namespace anm2ed::imgui
pathString = path::to_utf8(outputPath);
WorkingDirectory workingDirectory(document.directory_get());
path::ensure_directory(outputPath.parent_path());
if (!Texture::write_pixels_png(outputPath, exportSize, pixels.data()))
if (!Image::write_pixels_png(outputPath, exportSize, pixels.data()))
{
toast_log(Level::ERROR, TOAST_EXPORT_REGION_FAILED, sourceRegion.name, pathString);
return false;
@@ -150,7 +150,7 @@ namespace anm2ed::imgui
exported.children.push_back(exportedRegion);
spritesheets->children.push_back(exported);
document.textures[exported.id] = Texture(pixels.data(), exportSize);
document.textures[exported.id] = Image(pixels.data(), exportSize);
document.texturePaths[exported.id] = exported.path;
document.spritesheet.reference = exported.id;
document.spritesheet.selection = {exported.id};
@@ -338,7 +338,7 @@ namespace anm2ed::imgui
if (ImGui::BeginChild("##Export Region Child", child_size_get(REGION_POPUP_ROWS), ImGuiChildFlags_Borders))
{
if (ImGui::ImageButton("##Export Region Path Set", resources.icons[icon::FOLDER].id, icon_size_get()) &&
if (ImGui::ImageButton("##Export Region Path Set", resources.icon_id_get(icon::FOLDER), icon_size_get()) &&
window.dialog)
window.dialog->file_save(Dialog::REGION_EXPORT_PATH_SET, settings.exportRegionPath);
ImGui::SameLine();
+4 -3
View File
@@ -97,8 +97,8 @@ namespace anm2ed::imgui
auto isDefault = shaderPath.empty();
auto displayPath = isDefault ? path::from_utf8(localize.get(BASIC_DEFAULT)) : shaderPath;
if (ImGui::ImageButton(std::format("##{} Path Set", localize.get(label)).c_str(), resources.icons[icon::FOLDER].id,
icon_size_get()))
if (ImGui::ImageButton(std::format("##{} Path Set", localize.get(label)).c_str(),
resources.icon_id_get(icon::FOLDER), icon_size_get()))
{
if (shader)
{
@@ -432,7 +432,8 @@ namespace anm2ed::imgui
ImGui::SetCursorPos(cursorPos);
auto imageSize = ImVec2(shaderChildSize.y, shaderChildSize.y);
ImGui::ImageWithBg(shaderIcon.id, imageSize, ImVec2(), ImVec2(1, 1), ImVec4(), tintColor);
ImGui::ImageWithBg(resource::texture::id_get(shaderIcon), imageSize, ImVec2(), ImVec2(1, 1), ImVec4(),
tintColor);
ImGui::SetCursorPos(ImVec2(shaderChildSize.y + style.ItemSpacing.x,
shaderChildSize.y - shaderChildSize.y / 2 - ImGui::GetTextLineHeight() / 2));
+3 -2
View File
@@ -41,7 +41,8 @@ namespace anm2ed::imgui
};
window.row_select = [](Window&, Document& document, int id)
{
if (auto audio = document.sound_get(id); audio && ImGui::IsItemClicked(ImGuiMouseButton_Left)) audio->play();
if (auto audio = document.sound_get(id); audio && ImGui::IsItemClicked(ImGuiMouseButton_Left))
resource::audio::play(*audio);
};
window.card_image_get = [](Document& document, Resources& resources, const Element& sound)
{
@@ -73,7 +74,7 @@ namespace anm2ed::imgui
};
window.play = [](Window&, Manager&, Settings&, Document& document, Clipboard&)
{
if (auto audio = document.sound_get(*document.sound.selection.begin())) audio->play();
if (auto audio = document.sound_get(*document.sound.selection.begin())) resource::audio::play(*audio);
};
window.open = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
{
+4 -4
View File
@@ -170,7 +170,7 @@ namespace anm2ed::imgui
auto spritesheetTransform = transform * spritesheetModel;
if (baseTexture && baseTexture->is_valid())
texture_render(shaderTexture, baseTexture->id, spritesheetTransform);
texture_render(shaderTexture, resource::texture::id_get(*baseTexture), spritesheetTransform);
if (isGrid) grid_render(shaderGrid, zoom, pan, gridSize, gridOffset, gridColor);
@@ -223,7 +223,7 @@ namespace anm2ed::imgui
auto pivotTransform =
transform * math::quad_model_get(PIVOT_SIZE, region.crop + region.pivot, PIVOT_SIZE * 0.5f);
texture_render(shaderTexture, resources.icons[icon::PIVOT].id, pivotTransform, color::WHITE);
texture_render(shaderTexture, resources.icon_id_get(icon::PIVOT), pivotTransform, color::WHITE);
}
if (highlightedRegionId != -1)
@@ -234,7 +234,7 @@ namespace anm2ed::imgui
auto pivotTransform =
transform * math::quad_model_get(PIVOT_SIZE, region->crop + region->pivot, PIVOT_SIZE * 0.5f);
texture_render(shaderTexture, resources.icons[icon::PIVOT].id, pivotTransform, PIVOT_COLOR);
texture_render(shaderTexture, resources.icon_id_get(icon::PIVOT), pivotTransform, PIVOT_COLOR);
}
}
@@ -247,7 +247,7 @@ namespace anm2ed::imgui
auto pivotTransform =
transform * math::quad_model_get(PIVOT_SIZE, frame->crop + frame->pivot, PIVOT_SIZE * 0.5f);
texture_render(shaderTexture, resources.icons[icon::PIVOT].id, pivotTransform, PIVOT_COLOR);
texture_render(shaderTexture, resources.icon_id_get(icon::PIVOT), pivotTransform, PIVOT_COLOR);
}
}
+4 -4
View File
@@ -327,13 +327,13 @@ namespace anm2ed::imgui
if (length > 0)
{
ImGui::SetCursorPos(ImVec2(cursorPos.x + frameSize.x * floorf(playback.time), cursorPos.y));
ImGui::Image(resources.icons[icon::PLAYHEAD].id, frameSize);
ImGui::Image(resources.icon_id_get(icon::PLAYHEAD), frameSize);
auto playheadMin = ImGui::GetItemRectMin();
auto playheadMax = ImGui::GetItemRectMax();
playheadLineCenterX = (playheadMin.x + playheadMax.x) * 0.5f;
playheadLineTopY = playheadMax.y;
isPlayheadLineSet = true;
overlay_icon(resources.icons[icon::PLAYHEAD].id, playheadIconTint, true);
overlay_icon(resources.icon_id_get(icon::PLAYHEAD), playheadIconTint, true);
}
}
else if (animation)
@@ -596,8 +596,8 @@ namespace anm2ed::imgui
auto iconPos = ImVec2(cursorPos.x + (frameTime * frameSize.x),
cursorPos.y + (frameSize.y / 2) - (icon_size_get().y / 2));
ImGui::SetCursorPos(iconPos);
ImGui::Image(resources.icons[icon].id, icon_size_get());
overlay_icon(resources.icons[icon].id, iconTintDefault, false);
ImGui::Image(resources.icon_id_get(icon), icon_size_get());
overlay_icon(resources.icon_id_get(icon), iconTintDefault, false);
if (type != TRIGGER) frameTime += frame.duration;
+14 -14
View File
@@ -115,10 +115,10 @@ namespace anm2ed::imgui
ImGui::SetCursorPos(cursorPos);
auto folderIcon = group->isExpanded ? icon::FOLDER_OPEN : icon::FOLDER;
ImGui::Image(resources.icons[folderIcon].id, icon_size_get());
ImGui::Image(resources.icon_id_get(folderIcon), icon_size_get());
auto iconMin = ImGui::GetItemRectMin();
auto iconMax = ImGui::GetItemRectMax();
overlay_icon(resources.icons[folderIcon].id, itemIconTint, false);
overlay_icon(resources.icon_id_get(folderIcon), itemIconTint, false);
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, itemTextColor);
@@ -134,7 +134,7 @@ namespace anm2ed::imgui
ImGui::SetCursorPos(ImVec2(itemSize.x - ImGui::GetTextLineHeightWithSpacing() - ImGui::GetStyle().ItemSpacing.x,
(itemSize.y - ImGui::GetTextLineHeightWithSpacing()) / 2));
int visibleIcon = isGroupVisible ? icon::VISIBLE : icon::INVISIBLE;
if (ImGui::ImageButton("##Group Visible Toggle", resources.icons[visibleIcon].id, icon_size_get()))
if (ImGui::ImageButton("##Group Visible Toggle", resources.icon_id_get(visibleIcon), icon_size_get()))
{
auto targetAnimationIndex = reference.animationIndex;
auto targetType = type;
@@ -154,7 +154,7 @@ namespace anm2ed::imgui
}
auto visibleButtonMin = ImGui::GetItemRectMin();
auto visibleButtonMax = ImGui::GetItemRectMax();
overlay_icon(resources.icons[visibleIcon].id, itemIconTint, false);
overlay_icon(resources.icon_id_get(visibleIcon), itemIconTint, false);
ImGui::SetItemTooltip("%s", isGroupVisible ? localize.get(TOOLTIP_ITEM_VISIBILITY_SHOWN)
: localize.get(TOOLTIP_ITEM_VISIBILITY_HIDDEN));
ImGui::PopStyleVar(2);
@@ -380,8 +380,8 @@ namespace anm2ed::imgui
contentCursorPos.x += (float)row.depth * ImGui::GetTextLineHeightWithSpacing();
ImGui::SetCursorPos(contentCursorPos);
ImGui::Image(resources.icons[icon].id, icon_size_get());
overlay_icon(resources.icons[icon].id, iconTintCurrent, false);
ImGui::Image(resources.icon_id_get(icon), icon_size_get());
overlay_icon(resources.icon_id_get(icon), iconTintCurrent, false);
ImGui::SameLine();
if (isReferenced) ImGui::PushFont(resources.fonts[font::ITALICS].get(), font::SIZE);
ImGui::PushStyleColor(ImGuiCol_Text, itemTextColor);
@@ -398,7 +398,7 @@ namespace anm2ed::imgui
ImGui::SetCursorPos(ImVec2(itemSize.x - ImGui::GetTextLineHeightWithSpacing() - ImGui::GetStyle().ItemSpacing.x,
(itemSize.y - ImGui::GetTextLineHeightWithSpacing()) / 2));
int visibleIcon = isItemVisible ? icon::VISIBLE : icon::INVISIBLE;
if (ImGui::ImageButton("##Visible Toggle", resources.icons[visibleIcon].id, icon_size_get()))
if (ImGui::ImageButton("##Visible Toggle", resources.icon_id_get(visibleIcon), icon_size_get()))
{
auto animationIndex = reference.animationIndex;
auto targetType = type;
@@ -414,7 +414,7 @@ namespace anm2ed::imgui
item->isVisible = !item->isVisible;
});
}
overlay_icon(resources.icons[visibleIcon].id, iconTintCurrent, false);
overlay_icon(resources.icon_id_get(visibleIcon), iconTintCurrent, false);
ImGui::SetItemTooltip("%s", isItemVisible ? localize.get(TOOLTIP_ITEM_VISIBILITY_SHOWN)
: localize.get(TOOLTIP_ITEM_VISIBILITY_HIDDEN));
@@ -427,7 +427,7 @@ namespace anm2ed::imgui
ImGui::SetCursorPos(
ImVec2(itemSize.x - (ImGui::GetTextLineHeightWithSpacing() * 2) - ImGui::GetStyle().ItemSpacing.x,
(itemSize.y - ImGui::GetTextLineHeightWithSpacing()) / 2));
if (ImGui::ImageButton("##Rect Toggle", resources.icons[rectIcon].id, icon_size_get()))
if (ImGui::ImageButton("##Rect Toggle", resources.icon_id_get(rectIcon), icon_size_get()))
{
auto nullID = id;
edit_command_push(EDIT_TOGGLE_NULL_RECT, Document::FRAMES,
@@ -439,7 +439,7 @@ namespace anm2ed::imgui
null->isShowRect = !null->isShowRect;
});
}
overlay_icon(resources.icons[rectIcon].id, iconTintCurrent, false);
overlay_icon(resources.icon_id_get(rectIcon), iconTintCurrent, false);
ImGui::SetItemTooltip("%s", isShowRect ? localize.get(TOOLTIP_NULL_RECT_SHOWN)
: localize.get(TOOLTIP_NULL_RECT_HIDDEN));
}
@@ -461,9 +461,9 @@ namespace anm2ed::imgui
auto& isShowUnused = settings.timelineIsShowUnused;
auto unusedIcon = isShowUnused ? icon::SHOW_UNUSED : icon::HIDE_UNUSED;
if (ImGui::ImageButton("##Unused Toggle", resources.icons[unusedIcon].id, icon_size_get()))
if (ImGui::ImageButton("##Unused Toggle", resources.icon_id_get(unusedIcon), icon_size_get()))
isShowUnused = !isShowUnused;
overlay_icon(resources.icons[unusedIcon].id, iconTintCurrent, false);
overlay_icon(resources.icon_id_get(unusedIcon), iconTintCurrent, false);
ImGui::SetItemTooltip("%s", isShowUnused ? localize.get(TOOLTIP_UNUSED_ITEMS_SHOWN)
: localize.get(TOOLTIP_UNUSED_ITEMS_HIDDEN));
@@ -472,9 +472,9 @@ namespace anm2ed::imgui
ImGui::SetCursorPos(
ImVec2(itemSize.x - (ImGui::GetTextLineHeightWithSpacing() * 2) - ImGui::GetStyle().ItemSpacing.x,
(itemSize.y - ImGui::GetTextLineHeightWithSpacing()) / 2));
if (ImGui::ImageButton("##Layers Toggle", resources.icons[layersIcon].id, icon_size_get()))
if (ImGui::ImageButton("##Layers Toggle", resources.icon_id_get(layersIcon), icon_size_get()))
showLayersOnly = !showLayersOnly;
overlay_icon(resources.icons[layersIcon].id, iconTintCurrent, false);
overlay_icon(resources.icon_id_get(layersIcon), iconTintCurrent, false);
ImGui::SetItemTooltip("%s", showLayersOnly ? localize.get(TOOLTIP_ONLY_LAYERS_VISIBLE)
: localize.get(TOOLTIP_ALL_ITEMS_VISIBLE));
ImGui::PopStyleVar(2);
+2 -2
View File
@@ -73,8 +73,8 @@ namespace anm2ed::imgui
{
if (i == tool::UNDO) ImGui::BeginDisabled(!document.is_able_to_undo());
if (i == tool::REDO) ImGui::BeginDisabled(!document.is_able_to_redo());
if (ImGui::ImageButton(labelText, resources.icons[info.icon].id, to_imvec2(size), ImVec2(0, 0), ImVec2(1, 1),
ImVec4(0, 0, 0, 0), iconTint))
if (ImGui::ImageButton(labelText, resources.icon_id_get(info.icon), to_imvec2(size), ImVec2(0, 0),
ImVec2(1, 1), ImVec4(0, 0, 0, 0), iconTint))
tool_use((tool::Type)i);
if (i == tool::UNDO) ImGui::EndDisabled();
if (i == tool::REDO) ImGui::EndDisabled();
+4 -4
View File
@@ -457,8 +457,8 @@ namespace anm2ed::imgui
auto noScrollFlags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
if (ImGui::BeginChild("##Tooltip Image Child", to_imvec2(previewSize), childFlags, noScrollFlags))
ImGui::ImageWithBg(image.texture->id, to_imvec2(previewSize), to_imvec2(image.uvMin), to_imvec2(image.uvMax),
ImVec4(), image.isValid ? CARD_TINT_VALID : CARD_TINT_INVALID);
ImGui::ImageWithBg(resource::texture::id_get(*image.texture), to_imvec2(previewSize), to_imvec2(image.uvMin),
to_imvec2(image.uvMax), ImVec4(), image.isValid ? CARD_TINT_VALID : CARD_TINT_INVALID);
ImGui::EndChild();
ImGui::PopStyleVar();
@@ -540,8 +540,8 @@ namespace anm2ed::imgui
else
imageSize.y = imageSize.x / aspectRatio;
ImGui::SetCursorPos(cursorPos);
ImGui::ImageWithBg(image.texture->id, imageSize, to_imvec2(image.uvMin), to_imvec2(image.uvMax), ImVec4(),
tint);
ImGui::ImageWithBg(resource::texture::id_get(*image.texture), imageSize, to_imvec2(image.uvMin),
to_imvec2(image.uvMax), ImVec4(), tint);
ImGui::SetCursorPos(
ImVec2(cardSize.y + style.ItemSpacing.x, cardSize.y - cardSize.y / 2 - ImGui::GetTextLineHeight() / 2));
+1 -1
View File
@@ -66,7 +66,7 @@ namespace anm2ed::imgui
struct WindowCardImage
{
resource::Texture* texture{};
resource::Image* texture{};
glm::vec2 size{};
glm::vec2 uvMin{};
glm::vec2 uvMax{1.0f};