add selected tile outline for ow editor
This commit is contained in:
@@ -37,19 +37,6 @@ void Canvas::DrawContextMenu() {
|
||||
const ImVec2 mouse_pos_in_canvas(io.MousePos.x - origin.x,
|
||||
io.MousePos.y - origin.y);
|
||||
|
||||
// Add first and second point
|
||||
if (is_hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||
ImVec2 draw_tile_outline_pos;
|
||||
draw_tile_outline_pos.x =
|
||||
std::round((double)mouse_pos_in_canvas.x / 32) * 32;
|
||||
draw_tile_outline_pos.y =
|
||||
std::round((double)mouse_pos_in_canvas.y / 32) * 32;
|
||||
|
||||
points_.push_back(draw_tile_outline_pos);
|
||||
points_.push_back(
|
||||
ImVec2(draw_tile_outline_pos.x + 32, draw_tile_outline_pos.y + 32));
|
||||
}
|
||||
|
||||
// Pan (we use a zero mouse threshold when there's no context menu)
|
||||
const float mouse_threshold_for_pan = enable_context_menu_ ? -1.0f : 0.0f;
|
||||
if (is_active &&
|
||||
@@ -76,24 +63,27 @@ void Canvas::DrawContextMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::DrawTilesFromUser(app::ROM &rom, Bytes &tile,
|
||||
app::gfx::SNESPalette &pal) {
|
||||
ImVec2 draw_tile_outline_pos;
|
||||
|
||||
// Add rectangle
|
||||
if (is_hovered_ && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||
void Canvas::DrawTileSelector(int size) {
|
||||
const ImGuiIO &io = ImGui::GetIO();
|
||||
const bool is_hovered = ImGui::IsItemHovered(); // Hovered
|
||||
const ImVec2 origin(canvas_p0_.x + scrolling_.x,
|
||||
canvas_p0_.y + scrolling_.y); // Lock scrolled origin
|
||||
const ImVec2 mouse_pos_in_canvas(io.MousePos.x - origin.x,
|
||||
io.MousePos.y - origin.y);
|
||||
// Add first and second point
|
||||
if (is_hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||
if (!points_.empty()) {
|
||||
points_.clear();
|
||||
}
|
||||
ImVec2 draw_tile_outline_pos;
|
||||
draw_tile_outline_pos.x =
|
||||
std::round((double)mouse_pos_in_canvas_.x / 16) * 16;
|
||||
std::floor((double)mouse_pos_in_canvas.x / size) * size;
|
||||
draw_tile_outline_pos.y =
|
||||
std::round((double)mouse_pos_in_canvas_.y / 16) * 16;
|
||||
std::floor((double)mouse_pos_in_canvas.y / size) * size;
|
||||
|
||||
points_.push_back(draw_tile_outline_pos);
|
||||
points_.push_back(
|
||||
ImVec2(draw_tile_outline_pos.x + 16, draw_tile_outline_pos.y + 16));
|
||||
|
||||
changed_tiles_.emplace_back(app::gfx::Bitmap(16, 16, 64, tile.data()));
|
||||
changed_tiles_.back().ApplyPalette(pal);
|
||||
rom.RenderBitmap(&(changed_tiles_.back()));
|
||||
ImVec2(draw_tile_outline_pos.x + size, draw_tile_outline_pos.y + size));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,12 @@ using app::gfx::Bitmap;
|
||||
class Canvas {
|
||||
public:
|
||||
Canvas() = default;
|
||||
Canvas(ImVec2 canvas_size)
|
||||
explicit Canvas(ImVec2 canvas_size)
|
||||
: custom_canvas_size_(true), canvas_sz_(canvas_size) {}
|
||||
|
||||
void DrawBackground(ImVec2 canvas_size = ImVec2(0, 0));
|
||||
void DrawContextMenu();
|
||||
void DrawTilesFromUser(app::ROM& rom, Bytes& tile,
|
||||
app::gfx::SNESPalette& pal);
|
||||
void DrawTileSelector(int size);
|
||||
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0,
|
||||
bool ready = true);
|
||||
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
|
||||
@@ -33,6 +32,7 @@ class Canvas {
|
||||
void DrawGrid(float grid_step = 64.0f);
|
||||
void DrawOverlay(); // last
|
||||
|
||||
auto Points() const { return points_; }
|
||||
auto GetDrawList() const { return draw_list_; }
|
||||
auto GetZeroPoint() const { return canvas_p0_; }
|
||||
void SetCanvasSize(ImVec2 canvas_size) {
|
||||
|
||||
Reference in New Issue
Block a user