From d97824c575542bf806725aa26fd845a5d8b799ed Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 10 May 2025 11:00:08 -0400 Subject: [PATCH] Update DrawTileSelector to support variable tile height - Modified DrawTileSelector function to accept an additional parameter for tile height, defaulting to the original size if not provided. - Adjusted the logic for calculating the second point in the tile selection to use the new height parameter, improving flexibility in tile rendering. --- src/app/gui/canvas.cc | 7 +++++-- src/app/gui/canvas.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/gui/canvas.cc b/src/app/gui/canvas.cc index 00af8ffc..9e7c169c 100644 --- a/src/app/gui/canvas.cc +++ b/src/app/gui/canvas.cc @@ -394,11 +394,14 @@ void Canvas::DrawTileOnBitmap(int tile_size, gfx::Bitmap *bitmap, } } -bool Canvas::DrawTileSelector(int size) { +bool Canvas::DrawTileSelector(int size, int size_y) { const ImGuiIO &io = GetIO(); const bool is_hovered = IsItemHovered(); const ImVec2 origin(canvas_p0_.x + scrolling_.x, canvas_p0_.y + scrolling_.y); const ImVec2 mouse_pos(io.MousePos.x - origin.x, io.MousePos.y - origin.y); + if (size_y == 0) { + size_y = size; + } if (is_hovered && IsMouseClicked(ImGuiMouseButton_Left)) { if (!points_.empty()) { @@ -409,7 +412,7 @@ bool Canvas::DrawTileSelector(int size) { painter_pos.y = std::floor((double)mouse_pos.y / size) * size; points_.push_back(painter_pos); - points_.push_back(ImVec2(painter_pos.x + size, painter_pos.y + size)); + points_.push_back(ImVec2(painter_pos.x + size, painter_pos.y + size_y)); mouse_pos_in_canvas_ = painter_pos; } diff --git a/src/app/gui/canvas.h b/src/app/gui/canvas.h index 5d5b44eb..61c74b9d 100644 --- a/src/app/gui/canvas.h +++ b/src/app/gui/canvas.h @@ -103,7 +103,7 @@ class Canvas : public SharedRom { // Dictates which tile is currently selected based on what the user clicks // in the canvas window. Represented and split apart into a grid of tiles. - bool DrawTileSelector(int size); + bool DrawTileSelector(int size, int size_y = 0); // Draws the selection rectangle when the user is selecting multiple tiles void DrawSelectRect(int current_map, int tile_size = 0x10,