diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/deletetilescommand.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/deletetilescommand.cpp index 9e7afd48..ab2bc2e2 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/deletetilescommand.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/deletetilescommand.cpp @@ -2,6 +2,8 @@ * Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved. */ +#include + #include "deletetilescommand.hpp" namespace nostalgia::core { @@ -20,11 +22,9 @@ core::DeleteTilesCommand::DeleteTilesCommand( // copy pixels to be erased { auto &s = getSubSheet(m_img, m_idx); - auto &p = s.pixels; - auto dst = m_deletedPixels.data(); - auto src = &p[m_deletePos]; - const auto sz = m_deleteSz * sizeof(decltype(p[0])); - ox::memcpy(dst, src, sz); + auto dst = m_deletedPixels.begin(); + auto src = s.pixels.begin() + m_deletePos; + ox::copy_n(src, m_deleteSz, dst); } } @@ -32,9 +32,9 @@ ox::Error core::DeleteTilesCommand::redo() noexcept { auto &s = getSubSheet(m_img, m_idx); auto &p = s.pixels; auto srcPos = m_deletePos + m_deleteSz; - const auto src = &p[srcPos]; - const auto dst1 = &p[m_deletePos]; - const auto dst2 = &p[(p.size() - m_deleteSz)]; + auto const src = &p[srcPos]; + auto const dst1 = &p[m_deletePos]; + auto const dst2 = &p[(p.size() - m_deleteSz)]; ox::memmove(dst1, src, p.size() - srcPos); ox::memset(dst2, 0, m_deleteSz * sizeof(decltype(p[0]))); return {}; @@ -43,10 +43,10 @@ ox::Error core::DeleteTilesCommand::redo() noexcept { ox::Error DeleteTilesCommand::undo() noexcept { auto &s = getSubSheet(m_img, m_idx); auto &p = s.pixels; - const auto src = &p[m_deletePos]; - const auto dst1 = &p[m_deletePos + m_deleteSz]; - const auto dst2 = src; - const auto sz = p.size() - m_deletePos - m_deleteSz; + auto const src = &p[m_deletePos]; + auto const dst1 = &p[m_deletePos + m_deleteSz]; + auto const dst2 = src; + auto const sz = p.size() - m_deletePos - m_deleteSz; ox::memmove(dst1, src, sz); ox::memcpy(dst2, m_deletedPixels.data(), m_deletedPixels.size()); return {}; diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/inserttilescommand.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/inserttilescommand.cpp index 025cd3c8..99d0d52d 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/inserttilescommand.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/inserttilescommand.cpp @@ -21,10 +21,9 @@ core::InsertTilesCommand::InsertTilesCommand( { auto &s = getSubSheet(m_img, m_idx); auto &p = s.pixels; - auto dst = m_deletedPixels.data(); - auto src = &p[p.size() - m_insertCnt]; - const auto sz = m_insertCnt * sizeof(decltype(p[0])); - ox::memcpy(dst, src, sz); + auto dst = m_deletedPixels.begin(); + auto src = p.begin() + p.size() - m_insertCnt; + ox::copy_n(src, m_insertCnt, dst); } } diff --git a/src/nostalgia/modules/core/test/tests.cpp b/src/nostalgia/modules/core/test/tests.cpp index fbe6e228..48b2825e 100644 --- a/src/nostalgia/modules/core/test/tests.cpp +++ b/src/nostalgia/modules/core/test/tests.cpp @@ -27,7 +27,7 @@ static std::map tests = { int main(int argc, const char **argv) { int retval = -1; if (argc > 0) { - auto const args = ox::SpanView{argv, static_cast(argc)}; + auto const args = ox::Span{argv, static_cast(argc)}; auto const testName = ox::StringView(args[1]); if (tests.find(testName) != tests.end()) { retval = static_cast(tests[testName]()); diff --git a/src/olympic/keel/test/tests.cpp b/src/olympic/keel/test/tests.cpp index 08532792..f6768a36 100644 --- a/src/olympic/keel/test/tests.cpp +++ b/src/olympic/keel/test/tests.cpp @@ -28,7 +28,7 @@ static std::map tests = { int main(int argc, const char **argv) { int retval = -1; if (argc > 0) { - auto const args = ox::SpanView{argv, static_cast(argc)}; + auto const args = ox::Span{argv, static_cast(argc)}; auto testName = args[1]; if (tests.find(testName) != tests.end()) { retval = static_cast(tests[testName]()); diff --git a/src/olympic/studio/modlib/include/studio/imguiutil.hpp b/src/olympic/studio/modlib/include/studio/imguiutil.hpp index cc343bf1..05772691 100644 --- a/src/olympic/studio/modlib/include/studio/imguiutil.hpp +++ b/src/olympic/studio/modlib/include/studio/imguiutil.hpp @@ -189,7 +189,7 @@ bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, Im * @param selectedIdx * @return true if new value selected, false otherwise */ -bool ComboBox(ox::CStringView lbl, ox::SpanView list, size_t &selectedIdx) noexcept; +bool ComboBox(ox::CStringView lbl, ox::Span list, size_t &selectedIdx) noexcept; /** * @@ -223,7 +223,7 @@ bool ListBox( * @param selIdx * @return true if new value selected, false otherwise */ -bool ListBox(ox::CStringView name, ox::SpanView const&list, size_t &selIdx) noexcept; +bool ListBox(ox::CStringView name, ox::Span const&list, size_t &selIdx) noexcept; class FilePicker { private: diff --git a/src/olympic/studio/modlib/src/imguiutil.cpp b/src/olympic/studio/modlib/src/imguiutil.cpp index 72c98988..76505503 100644 --- a/src/olympic/studio/modlib/src/imguiutil.cpp +++ b/src/olympic/studio/modlib/src/imguiutil.cpp @@ -87,7 +87,7 @@ bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, Im bool ComboBox( ox::CStringView lbl, - ox::SpanView list, + ox::Span list, size_t &selectedIdx) noexcept { bool out{}; auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : ""; @@ -155,7 +155,7 @@ bool ListBox( return out; } -bool ListBox(ox::CStringView name, ox::SpanView const&list, size_t &selIdx) noexcept { +bool ListBox(ox::CStringView name, ox::Span const&list, size_t &selIdx) noexcept { return ListBox(name, [list](size_t i) -> ox::CStringView { return list[i]; }, list.size(), selIdx);