[nostalgia/gfx/studio/paletteeditor] Change move color mechanism to use drag/drop
Some checks failed
Build / build (push) Failing after 54s
Some checks failed
Build / build (push) Failing after 54s
This commit is contained in:
parent
7d53028faf
commit
695e7a4561
@ -4,10 +4,11 @@
|
||||
* Add PaletteV5 to accommodate namespace change.
|
||||
* Add TileSheetV5. TileSheetV5 retains the bpp field for the sake of
|
||||
CompactTileSheet, but always store it pixel as 8 bpp for itself.
|
||||
* Replace file picker combo boxes with support for dragging files from the
|
||||
project explorer.
|
||||
* Replace file picker combo boxes with a browse button and file picker, and
|
||||
support for dragging files from the project explorer.
|
||||
* Add ability to create directories.
|
||||
* Add ability to add files to specific directories.
|
||||
* Add ability to delete files from the project explorer.
|
||||
* Ctrl-<num key> keyboard shortcuts for jumping between tabs.
|
||||
* Fix Palette Editor to ignore keyboard input when popups are open.
|
||||
* Palette Editor move color mechanism now uses drag and drop.
|
||||
|
@ -9,7 +9,10 @@
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
MoveColorCommand::MoveColorCommand(
|
||||
Palette &pal, size_t page, size_t srcIdx, size_t dstIdx) noexcept:
|
||||
Palette &pal,
|
||||
size_t const page,
|
||||
size_t const srcIdx,
|
||||
size_t const dstIdx) noexcept:
|
||||
m_pal(pal),
|
||||
m_page(page),
|
||||
m_srcIdx(srcIdx),
|
||||
@ -29,10 +32,18 @@ ox::Error MoveColorCommand::undo() noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
void MoveColorCommand::moveColor(size_t srcIdx, size_t dstIdx) noexcept {
|
||||
auto const c = color(m_pal, m_page, srcIdx);
|
||||
std::ignore = colors(m_pal, m_page).erase(srcIdx);
|
||||
colors(m_pal, m_page).emplace(dstIdx, c);
|
||||
void MoveColorCommand::moveColor(
|
||||
size_t const srcIdx, size_t const dstIdx) noexcept {
|
||||
{
|
||||
auto const c = color(m_pal, m_page, srcIdx);
|
||||
std::ignore = colors(m_pal, m_page).erase(srcIdx);
|
||||
colors(m_pal, m_page).emplace(dstIdx, c);
|
||||
}
|
||||
{
|
||||
auto name = std::move(m_pal.colorNames[srcIdx]);
|
||||
std::ignore = m_pal.colorNames.erase(srcIdx);
|
||||
m_pal.colorNames.emplace(dstIdx, std::move(name));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,15 @@ namespace nostalgia::gfx {
|
||||
|
||||
namespace ig = studio::ig;
|
||||
|
||||
struct ColorDragDrop {
|
||||
static constexpr auto TypeName = "nostalgia.gfx.ColorDragDrop";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
uint32_t i{};
|
||||
};
|
||||
|
||||
OX_MODEL_BEGIN(ColorDragDrop)
|
||||
OX_MODEL_FIELD(i)
|
||||
OX_MODEL_END()
|
||||
|
||||
void PaletteEditorImGui::PageRenameDialog::draw(turbine::Context &tctx) noexcept {
|
||||
if (!m_show) {
|
||||
@ -125,26 +134,6 @@ void PaletteEditorImGui::drawColorsEditor() noexcept {
|
||||
m_selectedColorRow = ox::min(colorCnt(m_pal, m_page) - 1, m_selectedColorRow);
|
||||
colorEditor = m_selectedColorRow < colorCnt(m_pal, m_page);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginDisabled(m_selectedColorRow <= 0);
|
||||
{
|
||||
if (ImGui::Button("Move Up", sz)) {
|
||||
std::ignore = pushCommand<MoveColorCommand>(
|
||||
m_pal, m_page, m_selectedColorRow, m_selectedColorRow - 1);
|
||||
--m_selectedColorRow;
|
||||
}
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginDisabled(m_selectedColorRow >= colorCnt(m_pal, m_page) - 1);
|
||||
{
|
||||
if (ImGui::Button("Move Down", sz)) {
|
||||
std::ignore = pushCommand<MoveColorCommand>(
|
||||
m_pal, m_page, m_selectedColorRow, m_selectedColorRow + 1);
|
||||
++m_selectedColorRow;
|
||||
}
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
@ -179,6 +168,16 @@ void PaletteEditorImGui::drawColorsEditor() noexcept {
|
||||
"##ColorRow", i == m_selectedColorRow, ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
m_selectedColorRow = i;
|
||||
}
|
||||
std::ignore = ig::dragDropSource([this, i] {
|
||||
ImGui::Text("%s", m_pal.colorNames[i].c_str());
|
||||
return ig::setDragDropPayload(ColorDragDrop{i});
|
||||
}, ImGuiDragDropFlags_SourceAllowNullID);
|
||||
if (ig::DragDropTarget const d; d) {
|
||||
auto const [src, err] = ig::getDragDropPayload<ColorDragDrop>();
|
||||
if (!err) {
|
||||
std::ignore = pushCommand<MoveColorCommand>(m_pal, m_page, src.i, i);
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user