more slop with regions
This commit is contained in:
1 parent
80ef3f8597
commit
555caf9f4f
9 files changed
+369
-31
No files matched your search
+72
-6
@@ -13,6 +13,7 @@
|
||||
#include "strings.hpp"
|
||||
#include "toast.hpp"
|
||||
#include "types.hpp"
|
||||
#include "util/imgui/input.hpp"
|
||||
#include "util/imgui/layout.hpp"
|
||||
#include "util/imgui/shortcut.hpp"
|
||||
|
||||
@@ -23,6 +24,9 @@ using namespace glm;
|
||||
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
constexpr auto GENERATE_REGIONS_TARGET_SELECTION = 0;
|
||||
constexpr auto GENERATE_REGIONS_TARGET_ALL = 1;
|
||||
|
||||
Options save_options_get(Settings& settings)
|
||||
{
|
||||
Flags flags{};
|
||||
@@ -173,12 +177,9 @@ namespace anm2ed::imgui
|
||||
generatePopup.open();
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_WIZARD_GENERATE_ANIMATION_FROM_GRID));
|
||||
|
||||
bool isChangeAllFramesAvailable = frames && !frames->selection.empty() && itemType != ItemType::TRIGGER;
|
||||
bool isChangeAllAnimationsAvailable = document && !document->animation.selection.empty();
|
||||
if (ImGui::MenuItem(localize.get(LABEL_CHANGE_ALL_FRAME_PROPERTIES), nullptr, false,
|
||||
isChangeAllFramesAvailable || isChangeAllAnimationsAvailable))
|
||||
changePopup.open();
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_WIZARD_CHANGE_ALL_FRAME_PROPERTIES));
|
||||
if (ImGui::MenuItem(localize.get(LABEL_TASKBAR_GENERATE_REGIONS_FROM_ANIMATIONS), nullptr, false, document))
|
||||
generateRegionsPopup.open();
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_WIZARD_GENERATE_REGIONS_FROM_ANIMATIONS));
|
||||
|
||||
if (ImGui::MenuItem(localize.get(LABEL_SCAN_AND_SET_REGIONS), nullptr, false, document && hasRegions))
|
||||
{
|
||||
@@ -196,6 +197,15 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
bool isChangeAllFramesAvailable = frames && !frames->selection.empty() && itemType != ItemType::TRIGGER;
|
||||
bool isChangeAllAnimationsAvailable = document && !document->animation.selection.empty();
|
||||
if (ImGui::MenuItem(localize.get(LABEL_CHANGE_ALL_FRAME_PROPERTIES), nullptr, false,
|
||||
isChangeAllFramesAvailable || isChangeAllAnimationsAvailable))
|
||||
changePopup.open();
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_WIZARD_CHANGE_ALL_FRAME_PROPERTIES));
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem(localize.get(LABEL_TASKBAR_RENDER_ANIMATION), nullptr, false,
|
||||
animation && manager.isAbleToRecord))
|
||||
renderPopup.open();
|
||||
@@ -253,6 +263,62 @@ namespace anm2ed::imgui
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
generateRegionsPopup.trigger();
|
||||
if (ImGui::BeginPopupModal(generateRegionsPopup.label(), &generateRegionsPopup.isOpen, ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
if (document)
|
||||
{
|
||||
ImGui::RadioButton(localize.get(LABEL_CURRENT_SELECTION), &generateRegionsTarget,
|
||||
GENERATE_REGIONS_TARGET_SELECTION);
|
||||
ImGui::SameLine();
|
||||
ImGui::RadioButton(localize.get(LABEL_ALL), &generateRegionsTarget, GENERATE_REGIONS_TARGET_ALL);
|
||||
|
||||
input_text_string(localize.get(LABEL_FORMAT), &settings.generateRegionNameFormat);
|
||||
ImGui::Checkbox(localize.get(LABEL_MAP_FRAMES_TO_REGIONS), &isGenerateRegionsMapFrames);
|
||||
|
||||
auto widgetSize = widget_size_with_row_get(2);
|
||||
if (ImGui::Button(localize.get(LABEL_GENERATE), widgetSize))
|
||||
{
|
||||
std::set<int> animationIndices{};
|
||||
if (generateRegionsTarget == GENERATE_REGIONS_TARGET_ALL)
|
||||
{
|
||||
if (auto animations = document->anm2.element_get(ElementType::ANIMATIONS))
|
||||
for (auto [i, animation] : std::views::enumerate(animations->children))
|
||||
if (animation.type == ElementType::ANIMATION) animationIndices.insert((int)i);
|
||||
}
|
||||
else
|
||||
{
|
||||
animationIndices.insert(document->animation.selection.begin(), document->animation.selection.end());
|
||||
if (animationIndices.empty() && document->reference.animationIndex >= 0)
|
||||
animationIndices.insert(document->reference.animationIndex);
|
||||
}
|
||||
|
||||
auto queuedAnimationIndices = animationIndices;
|
||||
auto queuedFormat = settings.generateRegionNameFormat;
|
||||
auto queuedMapping = isGenerateRegionsMapFrames ? Document::RegionFrameMapping::SET
|
||||
: Document::RegionFrameMapping::PRESERVE;
|
||||
manager.command_push({manager.selected,
|
||||
[=](Manager&, Document& document)
|
||||
{
|
||||
if (queuedAnimationIndices.empty()) return;
|
||||
document.snapshot(localize.get(EDIT_GENERATE_REGIONS_FROM_ANIMATIONS));
|
||||
if (document.regions_generate_from_animations(queuedAnimationIndices, queuedFormat,
|
||||
queuedMapping))
|
||||
document.anm2_change(queuedMapping == Document::RegionFrameMapping::SET
|
||||
? Document::ALL
|
||||
: Document::SPRITESHEETS);
|
||||
}});
|
||||
generateRegionsPopup.close();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(localize.get(BASIC_CANCEL), widgetSize)) generateRegionsPopup.close();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
generateRegionsPopup.end();
|
||||
|
||||
changePopup.trigger();
|
||||
|
||||
if (ImGui::BeginPopupModal(changePopup.label(), &changePopup.isOpen, ImGuiWindowFlags_NoResize))
|
||||
|
||||
@@ -35,12 +35,16 @@ namespace anm2ed::imgui
|
||||
|
||||
Canvas generate;
|
||||
PopupHelper generatePopup{PopupHelper(LABEL_TASKBAR_GENERATE_ANIMATION_FROM_GRID)};
|
||||
PopupHelper generateRegionsPopup{
|
||||
PopupHelper(LABEL_TASKBAR_GENERATE_REGIONS_FROM_ANIMATIONS, imgui::POPUP_SMALL_NO_HEIGHT)};
|
||||
PopupHelper changePopup{PopupHelper(LABEL_CHANGE_ALL_FRAME_PROPERTIES, imgui::POPUP_NORMAL_NO_HEIGHT)};
|
||||
PopupHelper overwritePopup{PopupHelper(LABEL_TASKBAR_OVERWRITE_FILE, imgui::POPUP_SMALL_NO_HEIGHT)};
|
||||
PopupHelper renderPopup{PopupHelper(LABEL_TASKBAR_RENDER_ANIMATION, imgui::POPUP_SMALL_NO_HEIGHT)};
|
||||
PopupHelper configurePopup{PopupHelper(LABEL_TASKBAR_CONFIGURE)};
|
||||
PopupHelper aboutPopup{PopupHelper(LABEL_TASKBAR_ABOUT)};
|
||||
Settings editSettings{};
|
||||
int generateRegionsTarget{};
|
||||
bool isGenerateRegionsMapFrames{true};
|
||||
bool isQuittingMode{};
|
||||
|
||||
bool save_execute(Manager&, Settings&, const PendingSave&);
|
||||
|
||||
@@ -1807,6 +1807,24 @@ namespace anm2ed::imgui
|
||||
});
|
||||
};
|
||||
|
||||
auto make_many_regions = [&]()
|
||||
{
|
||||
auto targetFrames = frame_references_for_current_get();
|
||||
std::erase_if(targetFrames,
|
||||
[&](const Reference& frameReference)
|
||||
{
|
||||
if (frameReference.itemType != LAYER || frameReference.frameIndex < 0) return true;
|
||||
auto item = item_get(frameReference.itemType, frameReference.itemID);
|
||||
auto frame = item ? track_frame_get(*item, frameReference.frameIndex) : nullptr;
|
||||
auto layer = layer_get(frameReference.itemID);
|
||||
return !frame || frame->regionId != -1 || !layer || !spritesheet_get(layer->spritesheetId);
|
||||
});
|
||||
if (targetFrames.size() < 2) return;
|
||||
|
||||
makeManyRegionReferences = targetFrames;
|
||||
makeManyRegionsPopup.open();
|
||||
};
|
||||
|
||||
auto item = item_get(reference.itemType, reference.itemID);
|
||||
auto frame = frame_get();
|
||||
auto selectedFrames = frame_references_for_current_get();
|
||||
@@ -1814,6 +1832,17 @@ namespace anm2ed::imgui
|
||||
std::erase_if(selectedBakeFrames,
|
||||
[](const Reference& frameReference) { return frameReference.itemType == TRIGGER; });
|
||||
auto isReverseFrames = is_frames_reverse_available(selectedFrames);
|
||||
auto selectedRegionFrames = selectedFrames;
|
||||
std::erase_if(selectedRegionFrames,
|
||||
[&](const Reference& frameReference)
|
||||
{
|
||||
if (frameReference.itemType != LAYER || frameReference.frameIndex < 0) return true;
|
||||
auto item = item_get(frameReference.itemType, frameReference.itemID);
|
||||
auto frame = item ? track_frame_get(*item, frameReference.frameIndex) : nullptr;
|
||||
auto layer = layer_get(frameReference.itemID);
|
||||
return !frame || frame->regionId != -1 || !layer || !spritesheet_get(layer->spritesheetId);
|
||||
});
|
||||
bool isMakeManyRegions = selectedRegionFrames.size() > 1;
|
||||
auto selectedRootFrames = selected_root_frame_references_get();
|
||||
bool isMakeRegion = frame && reference.itemType == LAYER && reference.itemID != -1 && frame->regionId == -1 &&
|
||||
layer_get(reference.itemID) && spritesheet_get(layer_get(reference.itemID)->spritesheetId);
|
||||
@@ -1848,10 +1877,16 @@ namespace anm2ed::imgui
|
||||
.isEnabled = [&]() { return animation && animation->frameNum != animation_length_get(*animation); },
|
||||
.run = [&]() { fit_animation_length(); }});
|
||||
actions.separator();
|
||||
actions.add({.label = LABEL_MAKE_REGION,
|
||||
actions.add({.label = isMakeManyRegions ? LABEL_MAKE_MANY_REGIONS : LABEL_MAKE_REGION,
|
||||
.shortcut = -1,
|
||||
.isEnabled = [&]() { return isMakeRegion; },
|
||||
.run = [&]() { make_region(); }});
|
||||
.isEnabled = [=]() { return isMakeManyRegions || isMakeRegion; },
|
||||
.run = [&]()
|
||||
{
|
||||
if (isMakeManyRegions)
|
||||
make_many_regions();
|
||||
else
|
||||
make_region();
|
||||
}});
|
||||
actions.separator();
|
||||
actions.add({.label = LABEL_DELETE,
|
||||
.shortcut = SHORTCUT_REMOVE,
|
||||
@@ -3717,6 +3752,33 @@ namespace anm2ed::imgui
|
||||
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 widgetSize = widget_size_with_row_get(2);
|
||||
if (ImGui::Button(localize.get(LABEL_MAKE_MANY_REGIONS), widgetSize))
|
||||
{
|
||||
auto targetFrames = makeManyRegionReferences;
|
||||
auto format = settings.generateRegionNameFormat;
|
||||
auto mapping = isMakeManyRegionsMapFrames ? Document::RegionFrameMapping::SET
|
||||
: Document::RegionFrameMapping::PRESERVE;
|
||||
edit_command_push(EDIT_GENERATE_REGIONS_FROM_ANIMATIONS, Document::ALL,
|
||||
[=](Manager&, Document& document) mutable
|
||||
{ document.regions_generate_from_frames(targetFrames, format, mapping); });
|
||||
makeManyRegionsPopup.close();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(localize.get(BASIC_CANCEL), widgetSize)) makeManyRegionsPopup.close();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
makeManyRegionsPopup.end();
|
||||
|
||||
bakePopup.trigger();
|
||||
|
||||
if (ImGui::BeginPopupModal(bakePopup.label(), &bakePopup.isOpen, ImGuiWindowFlags_NoResize))
|
||||
|
||||
@@ -58,9 +58,12 @@ namespace anm2ed::imgui
|
||||
popup::ItemProperties itemProperties{};
|
||||
PopupHelper bakePopup{PopupHelper(LABEL_TIMELINE_BAKE_POPUP, POPUP_SMALL_NO_HEIGHT)};
|
||||
PopupHelper bakeIntoOtherFramesPopup{PopupHelper(LABEL_BAKE_INTO_OTHER_FRAMES, POPUP_SMALL_NO_HEIGHT)};
|
||||
PopupHelper makeManyRegionsPopup{PopupHelper(LABEL_MAKE_MANY_REGIONS, POPUP_SMALL_NO_HEIGHT)};
|
||||
BakeIntoOtherFramesTarget bakeIntoOtherFramesTarget{BakeIntoOtherFramesTarget::CURRENT_SELECTION};
|
||||
bool isBakeIntoOtherFramesLayers{true};
|
||||
bool isBakeIntoOtherFramesNulls{true};
|
||||
bool isMakeManyRegionsMapFrames{true};
|
||||
std::set<Reference> makeManyRegionReferences{};
|
||||
int hoveredTime{};
|
||||
bool isFrameBoxPending{};
|
||||
bool isFrameBoxSelecting{};
|
||||
|
||||
+83
-21
@@ -600,10 +600,30 @@ namespace anm2ed::imgui
|
||||
auto container = window_container_get(window, document.anm2);
|
||||
auto& storage = window.storage_get(document);
|
||||
auto& selection = storage.selection;
|
||||
auto count = window_element_count_get(window, container);
|
||||
std::vector<int> ids{};
|
||||
if (container)
|
||||
for (auto& element : container->children)
|
||||
if (element.type == window.elementType)
|
||||
{
|
||||
auto key = window.element_key_get ? window.element_key_get(element, (int)ids.size()) : element.id;
|
||||
ids.push_back(key);
|
||||
}
|
||||
auto count = (int)ids.size();
|
||||
int index{};
|
||||
int scrollTargetId = -1;
|
||||
int arrowSelectionId = -1;
|
||||
|
||||
selection.start(count);
|
||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
|
||||
(ImGui::IsKeyPressed(ImGuiKey_UpArrow, true) || ImGui::IsKeyPressed(ImGuiKey_DownArrow, true)))
|
||||
{
|
||||
auto nextId = window_arrow_selection_get(ids, storage.reference, selection);
|
||||
if (nextId != -1)
|
||||
{
|
||||
arrowSelectionId = nextId;
|
||||
scrollTargetId = nextId;
|
||||
}
|
||||
}
|
||||
|
||||
if (container)
|
||||
{
|
||||
@@ -611,8 +631,9 @@ namespace anm2ed::imgui
|
||||
{
|
||||
if (element.type != window.elementType) continue;
|
||||
auto key = window.element_key_get ? window.element_key_get(element, index) : element.id;
|
||||
auto isSelected = selection.contains(key);
|
||||
auto isReferenced = window_flag_has(window.flags, WINDOW_REFERENCE_ITALIC) && storage.reference == key;
|
||||
auto isSelected = selection.contains(key) || arrowSelectionId == key;
|
||||
auto isReferenced = window_flag_has(window.flags, WINDOW_REFERENCE_ITALIC) &&
|
||||
(storage.reference == key || arrowSelectionId == key);
|
||||
auto font = window.row_font_get ? window.row_font_get(document, element, key)
|
||||
: isReferenced ? resource::font::ITALICS
|
||||
: resource::font::REGULAR;
|
||||
@@ -622,6 +643,7 @@ namespace anm2ed::imgui
|
||||
ImGui::SetNextItemSelectionUserData(key);
|
||||
auto label = window.row_label_get ? window.row_label_get(document, element) : element.name;
|
||||
if (isFontPushed) ImGui::PushFont(resources.fonts[font].get(), resource::font::SIZE);
|
||||
if (scrollTargetId == key) ImGui::SetKeyboardFocusHere();
|
||||
|
||||
if (window_flag_has(window.flags, WINDOW_RENAME))
|
||||
{
|
||||
@@ -658,7 +680,7 @@ namespace anm2ed::imgui
|
||||
|
||||
if (isFontPushed) ImGui::PopFont();
|
||||
|
||||
if (window.newElementId == key || window.scrollQueued == key)
|
||||
if (window.newElementId == key || window.scrollQueued == key || scrollTargetId == key)
|
||||
{
|
||||
ImGui::SetScrollHereY(0.5f);
|
||||
if (window.newElementId == key) window.newElementId = -1;
|
||||
@@ -693,6 +715,15 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
selection.finish();
|
||||
if (arrowSelectionId != -1)
|
||||
{
|
||||
selection = {arrowSelectionId};
|
||||
storage.reference = arrowSelectionId;
|
||||
if (window.row_select) window.row_select(window, document, arrowSelectionId);
|
||||
}
|
||||
if (shortcut(manager.chords[SHORTCUT_CONFIRM], shortcut::FOCUSED) &&
|
||||
window_flag_has(window.flags, WINDOW_PROPERTIES) && selection.size() == 1)
|
||||
window_properties(window, manager, *selection.begin());
|
||||
}
|
||||
|
||||
void window_update(Window& window, Manager& manager, Settings& settings, Resources& resources, Dialog& dialog,
|
||||
@@ -1407,17 +1438,14 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
int scrollTargetId = -1;
|
||||
int arrowSelectionId = -1;
|
||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
|
||||
(ImGui::IsKeyPressed(ImGuiKey_UpArrow, true) || ImGui::IsKeyPressed(ImGuiKey_DownArrow, true)))
|
||||
{
|
||||
auto nextId = window_arrow_selection_get(window.order, reference, selection);
|
||||
if (nextId != -1)
|
||||
{
|
||||
selection = {nextId};
|
||||
reference = nextId;
|
||||
document.reference = {document.reference.animationIndex};
|
||||
frame.reference = -1;
|
||||
frame.selection.clear();
|
||||
arrowSelectionId = nextId;
|
||||
scrollTargetId = nextId;
|
||||
}
|
||||
}
|
||||
@@ -1436,12 +1464,13 @@ namespace anm2ed::imgui
|
||||
if (!region) continue;
|
||||
auto isNewRegion = window.newElementId == id;
|
||||
auto nameCStr = region->name.c_str();
|
||||
auto isSelected = selection.contains(id);
|
||||
auto isReferenced = id == reference;
|
||||
auto isSelected = selection.contains(id) || arrowSelectionId == id;
|
||||
auto isReferenced = id == reference || arrowSelectionId == id;
|
||||
|
||||
ImGui::PushID(id);
|
||||
|
||||
window_scroll_to_item(regionChildSize.y, scrollTargetId == id);
|
||||
if (scrollTargetId == id) ImGui::SetNextWindowFocus();
|
||||
|
||||
if (ImGui::BeginChild("##Region Child", regionChildSize, ImGuiChildFlags_Borders))
|
||||
{
|
||||
@@ -1452,6 +1481,7 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::SetNextItemSelectionUserData(i);
|
||||
ImGui::SetNextItemStorageID(id);
|
||||
if (scrollTargetId == id) ImGui::SetKeyboardFocusHere();
|
||||
if (ImGui::Selectable("##Region Selectable", isSelected, 0, regionChildSize))
|
||||
{
|
||||
document.editTarget = Document::EditTarget::REGION;
|
||||
@@ -1666,6 +1696,15 @@ namespace anm2ed::imgui
|
||||
ImGui::PopStyleVar();
|
||||
selection.finish();
|
||||
selection.set_index_map(nullptr);
|
||||
if (arrowSelectionId != -1)
|
||||
{
|
||||
document.editTarget = Document::EditTarget::REGION;
|
||||
selection = {arrowSelectionId};
|
||||
reference = arrowSelectionId;
|
||||
document.reference = {document.reference.animationIndex};
|
||||
frame.reference = -1;
|
||||
frame.selection.clear();
|
||||
}
|
||||
|
||||
if (shortcut(manager.chords[SHORTCUT_ADD], shortcut::FOCUSED) && window.add)
|
||||
window_command_run(window, manager, settings, document, clipboard, window.add);
|
||||
@@ -1675,6 +1714,8 @@ namespace anm2ed::imgui
|
||||
window_command_run(window, manager, settings, document, clipboard, window.copy);
|
||||
if (shortcut(manager.chords[SHORTCUT_PASTE], shortcut::FOCUSED) && window.paste)
|
||||
window_command_run(window, manager, settings, document, clipboard, window.paste);
|
||||
if (shortcut(manager.chords[SHORTCUT_CONFIRM], shortcut::FOCUSED) && selection.size() == 1 && window.properties)
|
||||
window_command_run(window, manager, settings, document, clipboard, window.properties);
|
||||
};
|
||||
window.context_update =
|
||||
[](Window& window, Manager& manager, Settings& settings, Resources&, Clipboard& clipboard, Document& document)
|
||||
@@ -2028,7 +2069,7 @@ namespace anm2ed::imgui
|
||||
}
|
||||
};
|
||||
window.rows_update =
|
||||
[](Window& window, Manager&, Settings&, Resources& resources, Clipboard&, Document& document, ImVec2)
|
||||
[](Window& window, Manager& manager, Settings&, Resources& resources, Clipboard&, Document& document, ImVec2)
|
||||
{
|
||||
auto& selection = document.spritesheet.selection;
|
||||
auto& reference = document.spritesheet.reference;
|
||||
@@ -2065,16 +2106,14 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
int scrollTargetId = -1;
|
||||
int arrowSelectionId = -1;
|
||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
|
||||
(ImGui::IsKeyPressed(ImGuiKey_UpArrow, true) || ImGui::IsKeyPressed(ImGuiKey_DownArrow, true)))
|
||||
{
|
||||
auto nextId = window_arrow_selection_get(ids, reference, selection);
|
||||
if (nextId != -1)
|
||||
{
|
||||
selection = {nextId};
|
||||
reference = nextId;
|
||||
region.reference = -1;
|
||||
region.selection.clear();
|
||||
arrowSelectionId = nextId;
|
||||
scrollTargetId = nextId;
|
||||
}
|
||||
}
|
||||
@@ -2089,11 +2128,12 @@ namespace anm2ed::imgui
|
||||
ImGui::PushID(id);
|
||||
|
||||
window_scroll_to_item(spritesheetChildSize.y, scrollTargetId == id);
|
||||
if (scrollTargetId == id) ImGui::SetNextWindowFocus();
|
||||
|
||||
if (ImGui::BeginChild("##Spritesheet Child", spritesheetChildSize, ImGuiChildFlags_Borders))
|
||||
{
|
||||
auto isSelected = selection.contains(id);
|
||||
auto isReferenced = id == reference;
|
||||
auto isSelected = selection.contains(id) || arrowSelectionId == id;
|
||||
auto isReferenced = id == reference || arrowSelectionId == id;
|
||||
auto cursorPos = ImGui::GetCursorPos();
|
||||
auto textureInfo = document.texture_get(id);
|
||||
bool isValid = textureInfo && textureInfo->is_valid();
|
||||
@@ -2104,6 +2144,7 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::SetNextItemSelectionUserData(id);
|
||||
ImGui::SetNextItemStorageID(id);
|
||||
if (scrollTargetId == id) ImGui::SetKeyboardFocusHere();
|
||||
if (ImGui::Selectable("##Spritesheet Selectable", isSelected, 0, spritesheetChildSize))
|
||||
{
|
||||
document.editTarget = Document::EditTarget::SPRITESHEET;
|
||||
@@ -2207,6 +2248,17 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
selection.finish();
|
||||
if (arrowSelectionId != -1)
|
||||
{
|
||||
document.editTarget = Document::EditTarget::SPRITESHEET;
|
||||
selection = {arrowSelectionId};
|
||||
reference = arrowSelectionId;
|
||||
region.reference = -1;
|
||||
region.selection.clear();
|
||||
}
|
||||
if (shortcut(manager.chords[SHORTCUT_CONFIRM], shortcut::FOCUSED) && reference != -1 && window.dialog)
|
||||
if (auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, reference))
|
||||
window_directory_open(*window.dialog, document, spritesheet->path);
|
||||
};
|
||||
window.context_update =
|
||||
[](Window& window, Manager& manager, Settings& settings, Resources&, Clipboard& clipboard, Document& document)
|
||||
@@ -2704,14 +2756,14 @@ namespace anm2ed::imgui
|
||||
if (ImGui::Shortcut(ImGuiKey_Escape, ImGuiInputFlags_RouteFocused)) selection.clear();
|
||||
|
||||
int scrollTargetId = -1;
|
||||
int arrowSelectionId = -1;
|
||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
|
||||
(ImGui::IsKeyPressed(ImGuiKey_UpArrow, true) || ImGui::IsKeyPressed(ImGuiKey_DownArrow, true)))
|
||||
{
|
||||
auto nextId = window_arrow_selection_get(ids, reference, selection);
|
||||
if (nextId != -1)
|
||||
{
|
||||
selection = {nextId};
|
||||
reference = nextId;
|
||||
arrowSelectionId = nextId;
|
||||
scrollTargetId = nextId;
|
||||
}
|
||||
}
|
||||
@@ -2726,10 +2778,11 @@ namespace anm2ed::imgui
|
||||
ImGui::PushID(id);
|
||||
|
||||
window_scroll_to_item(soundChildSize.y, scrollTargetId == id);
|
||||
if (scrollTargetId == id) ImGui::SetNextWindowFocus();
|
||||
|
||||
if (ImGui::BeginChild("##Sound Child", soundChildSize, ImGuiChildFlags_Borders))
|
||||
{
|
||||
auto isSelected = selection.contains(id);
|
||||
auto isSelected = selection.contains(id) || arrowSelectionId == id;
|
||||
auto cursorPos = ImGui::GetCursorPos();
|
||||
auto audio = document.sound_get(id);
|
||||
bool isValid = audio && audio->is_valid();
|
||||
@@ -2739,6 +2792,7 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::SetNextItemSelectionUserData(id);
|
||||
ImGui::SetNextItemStorageID(id);
|
||||
if (scrollTargetId == id) ImGui::SetKeyboardFocusHere();
|
||||
if (ImGui::Selectable("##Sound Selectable", isSelected, 0, soundChildSize))
|
||||
{
|
||||
reference = id;
|
||||
@@ -2799,6 +2853,14 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
selection.finish();
|
||||
if (arrowSelectionId != -1)
|
||||
{
|
||||
selection = {arrowSelectionId};
|
||||
reference = arrowSelectionId;
|
||||
}
|
||||
if (shortcut(manager.chords[SHORTCUT_CONFIRM], shortcut::FOCUSED) && reference != -1 && window.dialog)
|
||||
if (auto sound = document.anm2.element_get(ElementType::SOUND_ELEMENT, reference))
|
||||
window_directory_open(*window.dialog, document, sound->path);
|
||||
|
||||
if (shortcut(manager.chords[SHORTCUT_ADD], shortcut::FOCUSED) && window.add)
|
||||
window_command_run(window, manager, settings, document, clipboard, window.add);
|
||||
|
||||
Reference in new issue
Block a user