yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
canvas_interaction.h File Reference

Free functions for canvas interaction handling. More...

#include "app/gui/canvas/canvas_events.h"
#include "app/gui/canvas/canvas_state.h"
#include "app/gfx/core/bitmap.h"
#include "app/gfx/render/tilemap.h"
#include "imgui/imgui.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  yaze
 Main namespace for the application.
 
namespace  yaze::gui
 Graphical User Interface (GUI) components for the application.
 

Functions

RectSelectionEvent yaze::gui::HandleRectangleSelection (const CanvasGeometry &geometry, int current_map, float tile_size, ImDrawList *draw_list, ImGuiMouseButton mouse_button=ImGuiMouseButton_Right)
 Handle rectangle selection interaction.
 
TileSelectionEvent yaze::gui::HandleTileSelection (const CanvasGeometry &geometry, int current_map, float tile_size, ImGuiMouseButton mouse_button=ImGuiMouseButton_Right)
 Handle single tile selection (right-click)
 
TilePaintEvent yaze::gui::HandleTilePaint (const CanvasGeometry &geometry, int tile_id, float tile_size, ImGuiMouseButton mouse_button=ImGuiMouseButton_Left)
 Handle tile painting interaction.
 
TilePaintEvent yaze::gui::HandleTilePaintWithPreview (const CanvasGeometry &geometry, const gfx::Bitmap &bitmap, float tile_size, ImDrawList *draw_list, ImGuiMouseButton mouse_button=ImGuiMouseButton_Left)
 Handle tile painter with bitmap preview.
 
TilePaintEvent yaze::gui::HandleTilemapPaint (const CanvasGeometry &geometry, const gfx::Tilemap &tilemap, int current_tile, ImDrawList *draw_list, ImGuiMouseButton mouse_button=ImGuiMouseButton_Left)
 Handle tilemap painting interaction.
 
HoverEvent yaze::gui::HandleHover (const CanvasGeometry &geometry, float tile_size)
 Update hover state for canvas.
 
void yaze::gui::RenderHoverPreview (const CanvasGeometry &geometry, const HoverEvent &hover, float tile_size, ImDrawList *draw_list, ImU32 color=IM_COL32(255, 255, 255, 80))
 Render hover preview overlay.
 
EntityInteractionEvent yaze::gui::HandleEntityInteraction (const CanvasGeometry &geometry, int entity_id, ImVec2 entity_position)
 Handle entity interaction (hover, click, drag)
 
ImVec2 yaze::gui::AlignToGrid (ImVec2 pos, float grid_step)
 Align position to grid.
 
ImVec2 yaze::gui::GetMouseInCanvasSpace (const CanvasGeometry &geometry)
 Get mouse position in canvas space.
 
bool yaze::gui::IsMouseInCanvas (const CanvasGeometry &geometry)
 Check if mouse is in canvas bounds.
 
ImVec2 yaze::gui::CanvasToTileGrid (ImVec2 canvas_pos, float tile_size, float global_scale)
 Calculate tile grid indices from canvas position.
 

Detailed Description

Free functions for canvas interaction handling.

Phase 2 of Canvas refactoring: Extract interaction logic into event-driven free functions. These functions replace the stateful CanvasInteractionHandler methods with pure functions that return event payloads.

Design Pattern:

  • Input: Canvas geometry, mouse state, interaction parameters
  • Output: Event payload struct (TilePaintEvent, RectSelectionEvent, etc.)
  • No hidden state, fully testable
  • Editors consume events and respond accordingly

Definition in file canvas_interaction.h.