diff --git a/src/imgui/taskbar.cpp b/src/imgui/taskbar.cpp index f5e14af..ace7e8c 100644 --- a/src/imgui/taskbar.cpp +++ b/src/imgui/taskbar.cpp @@ -264,7 +264,7 @@ namespace anm2ed::imgui auto& count = settings.generateCount; auto& delay = settings.generateDelay; auto& zoom = settings.generateZoom; - auto& zoomStep = settings.viewZoomStep; + auto& zoomStep = settings.inputZoomStep; auto childSize = ImVec2(row_widget_width_get(2), size_without_footer_get().y); @@ -396,15 +396,14 @@ namespace anm2ed::imgui ImGui::SetItemTooltip("If changed, will autosave documents using this interval."); ImGui::EndDisabled(); - ImGui::SeparatorText("Options"); - - ImGui::Checkbox("Overwrite Warning", &editSettings.fileIsWarnOverwrite); - ImGui::SetItemTooltip("A warning will be shown when saving a file."); - ImGui::SeparatorText("Snapshots"); input_int_range("Stack Size", editSettings.fileSnapshotStackSize, 0, 1000); - ImGui::SetItemTooltip("Set the maximum snapshot stack size of a document\n(i.e., how many undo/redos are " + ImGui::SetItemTooltip("Set the maximum snapshot stack size of a document (i.e., how many undo/redos are " "preserved at a time)."); + + ImGui::SeparatorText("Options"); + ImGui::Checkbox("Overwrite Warning", &editSettings.fileIsWarnOverwrite); + ImGui::SetItemTooltip("A warning will be shown when saving/overwriting a file."); } ImGui::EndChild(); @@ -427,8 +426,14 @@ namespace anm2ed::imgui ImGui::SeparatorText("Zoom"); - input_float_range("Step", editSettings.viewZoomStep, 10.0f, 250.0f, 10.0f, 10.0f, "%.0f%%"); + input_float_range("Step", editSettings.inputZoomStep, 10.0f, 250.0f, 10.0f, 10.0f, "%.0f%%"); ImGui::SetItemTooltip("When zooming in/out with mouse or shortcut, this value will be used."); + + ImGui::SeparatorText("Tool"); + + ImGui::Checkbox("Move Tool: Snap to Mouse", &editSettings.inputIsMoveToolSnapToMouse); + ImGui::SetItemTooltip("In Animation Preview, the Move tool will snap the frame's position right to the " + "cursor, instead of being moved at a distance."); } ImGui::EndChild(); diff --git a/src/imgui/window/animation_preview.cpp b/src/imgui/window/animation_preview.cpp index 41ee915..8afe7e0 100644 --- a/src/imgui/window/animation_preview.cpp +++ b/src/imgui/window/animation_preview.cpp @@ -195,7 +195,7 @@ namespace anm2ed::imgui auto& gridColor = settings.previewGridColor; auto& gridSize = settings.previewGridSize; auto& gridOffset = settings.previewGridOffset; - auto& zoomStep = settings.viewZoomStep; + auto& zoomStep = settings.inputZoomStep; auto& isGrid = settings.previewIsGrid; auto& overlayTransparency = settings.previewOverlayTransparency; auto& overlayIndex = document.overlayIndex; @@ -661,14 +661,11 @@ namespace anm2ed::imgui document.snapshot("Frame Position"); if (isMouseClicked) { - moveOffset = mousePos - frame->position; + moveOffset = settings.inputIsMoveToolSnapToMouse ? vec2() : mousePos - frame->position; isMoveDragging = true; } } - if (isMouseDown && isMoveDragging) - { - frame->position = ivec2(mousePos - moveOffset); - } + if (isMouseDown && isMoveDragging) frame->position = ivec2(mousePos - moveOffset); if (isLeftPressed) frame->position.x -= step; if (isRightPressed) frame->position.x += step; if (isUpPressed) frame->position.y -= step; diff --git a/src/imgui/window/spritesheet_editor.cpp b/src/imgui/window/spritesheet_editor.cpp index 0f2077c..e38391f 100644 --- a/src/imgui/window/spritesheet_editor.cpp +++ b/src/imgui/window/spritesheet_editor.cpp @@ -41,7 +41,7 @@ namespace anm2ed::imgui auto& toolColor = settings.toolColor; auto& isGrid = settings.editorIsGrid; auto& isGridSnap = settings.editorIsGridSnap; - auto& zoomStep = settings.viewZoomStep; + auto& zoomStep = settings.inputZoomStep; auto& isBorder = settings.editorIsBorder; auto& isTransparent = settings.editorIsTransparent; auto spritesheet = document.spritesheet_get(); diff --git a/src/imgui/window/spritesheets.cpp b/src/imgui/window/spritesheets.cpp index d8f07eb..c9ea32c 100644 --- a/src/imgui/window/spritesheets.cpp +++ b/src/imgui/window/spritesheets.cpp @@ -95,7 +95,11 @@ namespace anm2ed::imgui auto isSelected = selection.contains(id); auto isReferenced = id == reference; auto cursorPos = ImGui::GetCursorPos(); - auto& texture = spritesheet.texture.is_valid() ? spritesheet.texture : resources.icons[icon::NONE]; + bool isTextureValid = spritesheet.texture.is_valid(); + auto& texture = isTextureValid ? spritesheet.texture : resources.icons[icon::NONE]; + auto textureRef = ImTextureRef(texture.id); + auto tintColor = + !isTextureValid ? ImVec4(1.0f, 0.25f, 0.25f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); const std::string pathString = spritesheet.path.empty() ? std::string{anm2::NO_PATH} : spritesheet.path.string(); const char* pathCStr = pathString.c_str(); @@ -134,14 +138,14 @@ namespace anm2ed::imgui 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::ImageWithBg(textureRef, to_imvec2(textureSize), ImVec2(), ImVec2(1, 1), ImVec4(), tintColor); ImGui::EndChild(); ImGui::PopStyleVar(); ImGui::SameLine(); auto infoChildFlags = ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY; - if (ImGui::BeginChild("##Spritesheet Info Tooltip Child", ImVec2(0, 0), infoChildFlags, noScrollFlags)) + if (ImGui::BeginChild("##Spritesheet Info Tooltip Child", ImVec2(), infoChildFlags, noScrollFlags)) { ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE); ImGui::TextUnformatted(pathCStr); @@ -149,7 +153,7 @@ namespace anm2ed::imgui ImGui::Text("ID: %d", id); - if (!spritesheet.texture.is_valid()) + if (!isTextureValid) 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); @@ -169,7 +173,7 @@ namespace anm2ed::imgui imageSize.y = imageSize.x / aspectRatio; ImGui::SetCursorPos(cursorPos); - ImGui::Image(texture.id, imageSize); + ImGui::ImageWithBg(textureRef, imageSize, ImVec2(), ImVec2(1, 1), ImVec4(), tintColor); ImGui::SetCursorPos( ImVec2(spritesheetChildSize.y + style.ItemSpacing.x, diff --git a/src/resource/icon.h b/src/resource/icon.h index f627c6d..b98d604 100644 --- a/src/resource/icon.h +++ b/src/resource/icon.h @@ -10,7 +10,7 @@ namespace anm2ed::resource::icon constexpr auto SIZE_HUGE = glm::ivec2(512, 512); constexpr auto NONE_DATA = R"( - + )"; constexpr auto FILE_DATA = R"( diff --git a/src/settings.h b/src/settings.h index a284caf..98df22a 100644 --- a/src/settings.h +++ b/src/settings.h @@ -54,7 +54,8 @@ namespace anm2ed X(KEYBOARD_REPEAT_DELAY, keyboardRepeatDelay, "Repeat Delay", FLOAT, 0.300f) \ X(KEYBOARD_REPEAT_RATE, keyboardRepeatRate, "Repeat Rate", FLOAT, 0.050f) \ \ - X(VIEW_ZOOM_STEP, viewZoomStep, "Zoom Step", FLOAT, 50.0f) \ + X(INPUT_ZOOM_STEP, inputZoomStep, "Zoom Step", FLOAT, 50.0f) \ + X(INPUT_IS_MOVE_TOOL_SNAP_TO_MOUSE, inputIsMoveToolSnapToMouse, "Move Tool: Snap to Mouse", BOOL, false) \ \ X(PLAYBACK_IS_LOOP, playbackIsLoop, "Loop", BOOL, true) \ X(PLAYBACK_IS_CLAMP, playbackIsClamp, "Clamp", BOOL, true) \