Layer Properties source layout, Add as Library on drop, library animations in tooltips
Layer Properties puts Source under its own separator with the radio buttons on one line (scoped so they no longer clash with the combos' ids), and the library combo calls this file "Self". Dropping an .anm2 offers Add as Library. A library's animations are listed in its tooltip instead of a dropdown under its card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d1a6d89d14
commit
e8372ca149
6 files changed
+57
-55
No files matched your search
@@ -454,6 +454,14 @@ namespace anm2ed::imgui
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem(localize.get(LABEL_DOCUMENTS_ADD_AS_LIBRARY), nullptr, false, document))
|
||||
{
|
||||
manager.command_push({manager.selected, [paths = manager.anm2DragDropPaths](Manager&, Document& document)
|
||||
{ document.libraries_add(paths); }});
|
||||
drag_drop_reset();
|
||||
}
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LIBRARY_ADD));
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem(localize.get(BASIC_CANCEL))) drag_drop_reset();
|
||||
|
||||
@@ -10,7 +10,7 @@ using namespace anm2ed::types;
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
constexpr int NULL_PROPERTIES_ROWS = 2;
|
||||
constexpr int LAYER_PROPERTIES_ROWS = 4;
|
||||
constexpr int LAYER_PROPERTIES_ROWS = 6;
|
||||
|
||||
auto& layers_get(model::Model& model) { return model.content.layers; }
|
||||
auto& nulls_get(model::Model& model) { return model.content.nulls; }
|
||||
@@ -147,15 +147,17 @@ namespace anm2ed::imgui
|
||||
EDIT_SET_LAYER_PROPERTIES, layers_get,
|
||||
[&](Manager::ItemEdit& layer)
|
||||
{
|
||||
ImGui::TextUnformatted(localize.get(LABEL_LAYER_SOURCE));
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LAYER_SOURCE));
|
||||
ImGui::SeparatorText(localize.get(LABEL_LAYER_SOURCE));
|
||||
ImGui::PushID("##Source");
|
||||
for (auto [label, isAnimation] : {std::pair{LABEL_SPRITESHEET, false}, std::pair{LABEL_ANIMATION, true}})
|
||||
{
|
||||
ImGui::SameLine();
|
||||
if (isAnimation) ImGui::SameLine();
|
||||
if (ImGui::RadioButton(localize.get(label), layer.isAnimation == isAnimation))
|
||||
layer.isAnimation = isAnimation;
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LAYER_SOURCE));
|
||||
}
|
||||
ImGui::PopID();
|
||||
ImGui::Separator();
|
||||
|
||||
if (!layer.isAnimation)
|
||||
{
|
||||
@@ -167,7 +169,7 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
auto libraries = document.choices_get(SelectionKind::LIBRARIES);
|
||||
libraries.labels.front() = localize.get(TEXT_THIS_FILE);
|
||||
libraries.labels.front() = localize.get(TEXT_SELF);
|
||||
combo_id_mapped(localize.get(LABEL_LIBRARY), &layer.libraryId, libraries.ids, libraries.labels);
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LAYER_LIBRARY));
|
||||
auto names = document.animation_names_get(layer.libraryId);
|
||||
|
||||
@@ -79,53 +79,46 @@ namespace anm2ed::imgui
|
||||
items_clipboard_actions_add<model::Library>(actions, panel, SelectionKind::LIBRARIES, EDIT_PASTE_LIBRARIES,
|
||||
TOAST_DESERIALIZE_LIBRARIES_FAILED, libraries_get);
|
||||
|
||||
ListRows rows{.label_get =
|
||||
[&](int id)
|
||||
{
|
||||
auto pathString = path::to_utf8(model::item_get(libraries, id)->path);
|
||||
return std::vformat(localize.get(FORMAT_SOUND), std::make_format_args(id, pathString));
|
||||
},
|
||||
.tooltip_draw =
|
||||
[&](int id)
|
||||
{
|
||||
auto loaded = loaded_get(id);
|
||||
tooltip_name_draw(resources, path::to_utf8(model::item_get(libraries, id)->path));
|
||||
ImGui::Text("%s: %d", localize.get(BASIC_ID), id);
|
||||
if (loaded && loaded->model.isValid)
|
||||
ImGui::TextUnformatted(localize.get(TOOLTIP_LIBRARY_OPEN));
|
||||
else
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("%s", localize.get(TOOLTIP_LIBRARY_INVALID));
|
||||
}
|
||||
},
|
||||
.image_get =
|
||||
[&](int id)
|
||||
{
|
||||
auto loaded = loaded_get(id);
|
||||
auto isValid = loaded && loaded->model.isValid;
|
||||
auto& texture = resources.icons[isValid ? icon::ANIMATION : icon::NONE];
|
||||
return CardImage{.texture = &texture, .size = glm::vec2(texture.size), .isValid = isValid};
|
||||
},
|
||||
.activate = open,
|
||||
.children_draw =
|
||||
[&](int id)
|
||||
{
|
||||
auto loaded = loaded_get(id);
|
||||
if (!loaded || !loaded->model.isValid) return;
|
||||
auto animations = loaded->model.animations_get();
|
||||
auto count = animations.size();
|
||||
auto label = std::vformat(localize.get(FORMAT_LIBRARY_ANIMATIONS), std::make_format_args(count));
|
||||
ImGui::PushID(id);
|
||||
if (ImGui::TreeNodeEx(label.c_str(), ImGuiTreeNodeFlags_SpanAvailWidth))
|
||||
{
|
||||
for (auto [index, animation] : animations)
|
||||
ImGui::BulletText("%s", animation->name.c_str());
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::PopID();
|
||||
},
|
||||
.cardLines = LIBRARY_CARD_LINES};
|
||||
ListRows rows{
|
||||
.label_get =
|
||||
[&](int id)
|
||||
{
|
||||
auto pathString = path::to_utf8(model::item_get(libraries, id)->path);
|
||||
return std::vformat(localize.get(FORMAT_SOUND), std::make_format_args(id, pathString));
|
||||
},
|
||||
.tooltip_draw =
|
||||
[&](int id)
|
||||
{
|
||||
auto loaded = loaded_get(id);
|
||||
tooltip_name_draw(resources, path::to_utf8(model::item_get(libraries, id)->path));
|
||||
ImGui::Text("%s: %d", localize.get(BASIC_ID), id);
|
||||
if (loaded && loaded->model.isValid)
|
||||
{
|
||||
auto animations = loaded->model.animations_get();
|
||||
auto count = animations.size();
|
||||
ImGui::SeparatorText(
|
||||
std::vformat(localize.get(FORMAT_LIBRARY_ANIMATIONS), std::make_format_args(count)).c_str());
|
||||
for (auto [index, animation] : animations)
|
||||
ImGui::BulletText("%s", animation->name.c_str());
|
||||
ImGui::Separator();
|
||||
ImGui::TextUnformatted(localize.get(TOOLTIP_LIBRARY_OPEN));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("%s", localize.get(TOOLTIP_LIBRARY_INVALID));
|
||||
}
|
||||
},
|
||||
.image_get =
|
||||
[&](int id)
|
||||
{
|
||||
auto loaded = loaded_get(id);
|
||||
auto isValid = loaded && loaded->model.isValid;
|
||||
auto& texture = resources.icons[isValid ? icon::ANIMATION : icon::NONE];
|
||||
return CardImage{.texture = &texture, .size = glm::vec2(texture.size), .isValid = isValid};
|
||||
},
|
||||
.activate = open,
|
||||
.cardLines = LIBRARY_CARD_LINES};
|
||||
list_panel_draw(
|
||||
panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD, ACTION_OPEN}},
|
||||
[&]() { content_list_draw(panel, SelectionKind::LIBRARIES, item_ids_get(libraries), rows); }, true);
|
||||
|
||||
@@ -254,7 +254,6 @@ namespace anm2ed::imgui
|
||||
else
|
||||
isBreak = row_draw(panel, selection, focus, rows, keys[i], i, arrowKey);
|
||||
if (isBreak) break;
|
||||
if (rows.children_draw) rows.children_draw(keys[i]);
|
||||
}
|
||||
if (isCards) ImGui::PopStyleVar();
|
||||
list_select_end(panel, selection, focus, rows, arrowKey);
|
||||
|
||||
@@ -77,7 +77,6 @@ namespace anm2ed::imgui
|
||||
std::function<void(int)> select{};
|
||||
std::function<void(int)> activate{};
|
||||
std::function<bool(int, int)> drag_drop_update{};
|
||||
std::function<void(int)> children_draw{};
|
||||
int cardLines{};
|
||||
bool isFocusItalic{};
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user