[nostalgia/core/studio] Add ability to select pixels for copy/paste

This commit is contained in:
2022-03-10 02:39:22 -06:00
parent 3486734b50
commit b502b8cc30
9 changed files with 147 additions and 33 deletions

View File

@@ -54,15 +54,28 @@ void TileSheetEditorImGui::draw(core::Context*) noexcept {
ImGui::SameLine();
ImGui::BeginChild("Controls", ImVec2(m_palViewWidth - 8, paneSize.y), true);
{
ImGui::BeginChild("ToolBox", ImVec2(m_palViewWidth - 24, 30), true);
{
const auto btnSz = ImVec2(40, 14);
if (ImGui::Selectable("Draw", m_tool == Tool::Draw, 0, btnSz)) {
m_tool = Tool::Draw;
}
ImGui::SameLine();
if (ImGui::Selectable("Select", m_tool == Tool::Select, 0, btnSz)) {
m_tool = Tool::Select;
}
}
ImGui::EndChild();
const auto ySize = paneSize.y - 36;
// draw palette/color picker
ImGui::BeginChild("child1", ImVec2(m_palViewWidth - 24, paneSize.y / 2.07f), true);
ImGui::BeginChild("Palette", ImVec2(m_palViewWidth - 24, ySize / 2.07f), true);
{
drawPalettePicker();
}
ImGui::EndChild();
ImGui::BeginChild("child2", ImVec2(m_palViewWidth - 24, paneSize.y / 2.07f), true);
ImGui::BeginChild("SubSheets", ImVec2(m_palViewWidth - 24, ySize / 2.07f), true);
{
constexpr auto btnHeight = 18;
static constexpr auto btnHeight = 18;
const auto btnSize = ImVec2(18, btnHeight);
if (ImGui::Button("+", btnSize)) {
auto insertOnIdx = model()->activeSubSheetIdx();
@@ -88,7 +101,7 @@ void TileSheetEditorImGui::draw(core::Context*) noexcept {
}
}
TileSheet::SubSheetIdx path;
constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
static constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
if (ImGui::BeginTable("Subsheets", 3, flags)) {
ImGui::TableSetupColumn("Subsheet", ImGuiTableColumnFlags_NoHide);
ImGui::TableSetupColumn("Columns", ImGuiTableColumnFlags_WidthFixed, 50);
@@ -193,7 +206,16 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
const auto &winPos = ImGui::GetWindowPos();
clickPos.x -= winPos.x + 10;
clickPos.y -= winPos.y + 10;
m_tileSheetEditor.click(fbSize, clickPos);
switch (m_tool) {
case Tool::Draw:
m_tileSheetEditor.clickDraw(fbSize, clickPos);
break;
case Tool::Fill:
case Tool::None:
case Tool::Select:
m_tileSheetEditor.clickSelect(fbSize, clickPos);
break;
}
}
}
if (io.MouseReleased[0]) {