yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gui::CanvasAutomationAPI Class Reference

Programmatic interface for controlling canvas operations. More...

#include <canvas_automation_api.h>

Collaboration diagram for yaze::gui::CanvasAutomationAPI:

Classes

struct  Dimensions
 Canvas dimensions in logical tile units. More...
 
struct  SelectionState
 Selection state returned by GetSelection(). More...
 
struct  VisibleRegion
 Visible region in logical tile coordinates. More...
 

Public Types

using TilePaintCallback = std::function< bool(int x, int y, int tile_id)>
 Set callback for tile painting operations. Allows external systems (CLI, AI agents) to implement custom tile logic.
 
using TileQueryCallback = std::function< int(int x, int y)>
 Set callback for tile querying operations. Allows external systems to provide tile data.
 

Public Member Functions

 CanvasAutomationAPI (Canvas *canvas)
 
bool SetTileAt (int x, int y, int tile_id)
 Paint a single tile at logical coordinates.
 
int GetTileAt (int x, int y) const
 Query tile ID at logical coordinates.
 
bool SetTiles (const std::vector< std::tuple< int, int, int > > &tiles)
 Paint multiple tiles in a batch operation.
 
void SelectTile (int x, int y)
 Select a single tile.
 
void SelectTileRect (int x1, int y1, int x2, int y2)
 Select a rectangular region of tiles.
 
SelectionState GetSelection () const
 Query current selection state.
 
void ClearSelection ()
 Clear current selection.
 
void ScrollToTile (int x, int y, bool center=false)
 Scroll canvas to make tile visible.
 
void CenterOn (int x, int y)
 Center canvas view on a specific tile.
 
void SetZoom (float zoom)
 Set canvas zoom level.
 
float GetZoom () const
 Get current zoom level.
 
Dimensions GetDimensions () const
 Get canvas dimensions in logical tile units.
 
VisibleRegion GetVisibleRegion () const
 Get currently visible tile region.
 
bool IsTileVisible (int x, int y) const
 Check if a tile is currently visible.
 
bool IsInBounds (int x, int y) const
 Check if coordinates are within canvas bounds.
 
ImVec2 TileToCanvas (int x, int y) const
 Convert logical tile coordinates to canvas pixel coordinates.
 
ImVec2 CanvasToTile (ImVec2 canvas_pos) const
 Convert canvas pixel coordinates to logical tile coordinates.
 
void SetTilePaintCallback (TilePaintCallback callback)
 
void SetTileQueryCallback (TileQueryCallback callback)
 

Private Attributes

Canvascanvas_
 
TilePaintCallback tile_paint_callback_
 
TileQueryCallback tile_query_callback_
 

Detailed Description

Programmatic interface for controlling canvas operations.

Enables z3ed CLI, AI agents, GUI automation, and remote control via gRPC. All operations work with logical tile coordinates, independent of zoom/scroll.

Definition at line 22 of file canvas_automation_api.h.

Member Typedef Documentation

◆ TilePaintCallback

using yaze::gui::CanvasAutomationAPI::TilePaintCallback = std::function<bool(int x, int y, int tile_id)>

Set callback for tile painting operations. Allows external systems (CLI, AI agents) to implement custom tile logic.

Definition at line 204 of file canvas_automation_api.h.

◆ TileQueryCallback

using yaze::gui::CanvasAutomationAPI::TileQueryCallback = std::function<int(int x, int y)>

Set callback for tile querying operations. Allows external systems to provide tile data.

Definition at line 211 of file canvas_automation_api.h.

Constructor & Destructor Documentation

◆ CanvasAutomationAPI()

yaze::gui::CanvasAutomationAPI::CanvasAutomationAPI ( Canvas canvas)
explicit

Definition at line 11 of file canvas_automation_api.cc.

Member Function Documentation

◆ SetTileAt()

bool yaze::gui::CanvasAutomationAPI::SetTileAt ( int  x,
int  y,
int  tile_id 
)

Paint a single tile at logical coordinates.

Parameters
xLogical X coordinate (tile units)
yLogical Y coordinate (tile units)
tile_idTile ID to paint
Returns
true if successful, false if out of bounds

Definition at line 17 of file canvas_automation_api.cc.

References canvas_, IsInBounds(), yaze::gui::Canvas::mutable_points(), tile_paint_callback_, and TileToCanvas().

Referenced by SetTiles().

Here is the call graph for this function:

◆ GetTileAt()

int yaze::gui::CanvasAutomationAPI::GetTileAt ( int  x,
int  y 
) const

Query tile ID at logical coordinates.

Parameters
xLogical X coordinate
yLogical Y coordinate
Returns
Tile ID at position, or -1 if out of bounds

Definition at line 33 of file canvas_automation_api.cc.

References IsInBounds(), and tile_query_callback_.

Here is the call graph for this function:

◆ SetTiles()

bool yaze::gui::CanvasAutomationAPI::SetTiles ( const std::vector< std::tuple< int, int, int > > &  tiles)

Paint multiple tiles in a batch operation.

Parameters
tilesVector of (x, y, tile_id) tuples
Returns
true if all tiles painted successfully

Definition at line 46 of file canvas_automation_api.cc.

References SetTileAt().

Here is the call graph for this function:

◆ SelectTile()

void yaze::gui::CanvasAutomationAPI::SelectTile ( int  x,
int  y 
)

Select a single tile.

Parameters
xLogical X coordinate
yLogical Y coordinate

Definition at line 61 of file canvas_automation_api.cc.

References canvas_, IsInBounds(), yaze::gui::Canvas::mutable_selected_points(), and TileToCanvas().

Here is the call graph for this function:

◆ SelectTileRect()

void yaze::gui::CanvasAutomationAPI::SelectTileRect ( int  x1,
int  y1,
int  x2,
int  y2 
)

Select a rectangular region of tiles.

Parameters
x1Top-left X coordinate (logical)
y1Top-left Y coordinate (logical)
x2Bottom-right X coordinate (logical)
y2Bottom-right Y coordinate (logical)

Definition at line 72 of file canvas_automation_api.cc.

References canvas_, IsInBounds(), yaze::gui::Canvas::mutable_selected_points(), and TileToCanvas().

Here is the call graph for this function:

◆ GetSelection()

◆ ClearSelection()

void yaze::gui::CanvasAutomationAPI::ClearSelection ( )

Clear current selection.

Definition at line 124 of file canvas_automation_api.cc.

References canvas_, and yaze::gui::Canvas::mutable_selected_points().

Here is the call graph for this function:

◆ ScrollToTile()

void yaze::gui::CanvasAutomationAPI::ScrollToTile ( int  x,
int  y,
bool  center = false 
)

Scroll canvas to make tile visible.

Parameters
xLogical X coordinate
yLogical Y coordinate
centerIf true, center the tile; otherwise just ensure visibility

Definition at line 132 of file canvas_automation_api.cc.

References canvas_, yaze::gui::Canvas::canvas_size(), CenterOn(), IsInBounds(), IsTileVisible(), yaze::gui::Canvas::scrolling(), yaze::gui::Canvas::set_scrolling(), and TileToCanvas().

◆ CenterOn()

void yaze::gui::CanvasAutomationAPI::CenterOn ( int  x,
int  y 
)

Center canvas view on a specific tile.

Parameters
xLogical X coordinate
yLogical Y coordinate

Definition at line 161 of file canvas_automation_api.cc.

References canvas_, yaze::gui::Canvas::canvas_size(), IsInBounds(), yaze::gui::Canvas::set_scrolling(), and TileToCanvas().

Referenced by ScrollToTile().

Here is the call graph for this function:

◆ SetZoom()

void yaze::gui::CanvasAutomationAPI::SetZoom ( float  zoom)

Set canvas zoom level.

Parameters
zoomZoom factor (0.25 to 4.0, default 1.0)

Definition at line 176 of file canvas_automation_api.cc.

References canvas_, and yaze::gui::Canvas::set_global_scale().

Here is the call graph for this function:

◆ GetZoom()

float yaze::gui::CanvasAutomationAPI::GetZoom ( ) const

Get current zoom level.

Returns
Current zoom factor

Definition at line 182 of file canvas_automation_api.cc.

References canvas_, and yaze::gui::Canvas::global_scale().

Here is the call graph for this function:

◆ GetDimensions()

◆ GetVisibleRegion()

◆ IsTileVisible()

bool yaze::gui::CanvasAutomationAPI::IsTileVisible ( int  x,
int  y 
) const

Check if a tile is currently visible.

Parameters
xLogical X coordinate
yLogical Y coordinate
Returns
true if tile is visible on canvas

Definition at line 246 of file canvas_automation_api.cc.

References GetVisibleRegion(), IsInBounds(), yaze::gui::CanvasAutomationAPI::VisibleRegion::max_x, yaze::gui::CanvasAutomationAPI::VisibleRegion::max_y, yaze::gui::CanvasAutomationAPI::VisibleRegion::min_x, and yaze::gui::CanvasAutomationAPI::VisibleRegion::min_y.

Referenced by ScrollToTile().

Here is the call graph for this function:

◆ IsInBounds()

bool yaze::gui::CanvasAutomationAPI::IsInBounds ( int  x,
int  y 
) const

Check if coordinates are within canvas bounds.

Parameters
xLogical X coordinate
yLogical Y coordinate
Returns
true if coordinates are valid

Definition at line 256 of file canvas_automation_api.cc.

References GetDimensions(), yaze::gui::CanvasAutomationAPI::Dimensions::height_tiles, and yaze::gui::CanvasAutomationAPI::Dimensions::width_tiles.

Referenced by CenterOn(), GetTileAt(), IsTileVisible(), ScrollToTile(), SelectTile(), SelectTileRect(), and SetTileAt().

Here is the call graph for this function:

◆ TileToCanvas()

ImVec2 yaze::gui::CanvasAutomationAPI::TileToCanvas ( int  x,
int  y 
) const

Convert logical tile coordinates to canvas pixel coordinates.

Parameters
xLogical X coordinate
yLogical Y coordinate
Returns
Canvas pixel position

Definition at line 269 of file canvas_automation_api.cc.

References canvas_, GetDimensions(), yaze::gui::Canvas::global_scale(), and yaze::gui::CanvasAutomationAPI::Dimensions::tile_size.

Referenced by CenterOn(), ScrollToTile(), SelectTile(), SelectTileRect(), SetTileAt(), and yaze::test::TEST_F().

Here is the call graph for this function:

◆ CanvasToTile()

ImVec2 yaze::gui::CanvasAutomationAPI::CanvasToTile ( ImVec2  canvas_pos) const

Convert canvas pixel coordinates to logical tile coordinates.

Parameters
canvas_posCanvas pixel position
Returns
Logical tile position

Definition at line 279 of file canvas_automation_api.cc.

References canvas_, GetDimensions(), yaze::gui::Canvas::global_scale(), and yaze::gui::CanvasAutomationAPI::Dimensions::tile_size.

Referenced by GetSelection(), and GetVisibleRegion().

Here is the call graph for this function:

◆ SetTilePaintCallback()

void yaze::gui::CanvasAutomationAPI::SetTilePaintCallback ( TilePaintCallback  callback)

◆ SetTileQueryCallback()

void yaze::gui::CanvasAutomationAPI::SetTileQueryCallback ( TileQueryCallback  callback)

Definition at line 297 of file canvas_automation_api.cc.

References tile_query_callback_.

Member Data Documentation

◆ canvas_

◆ tile_paint_callback_

TilePaintCallback yaze::gui::CanvasAutomationAPI::tile_paint_callback_
private

Definition at line 216 of file canvas_automation_api.h.

Referenced by SetTileAt(), and SetTilePaintCallback().

◆ tile_query_callback_

TileQueryCallback yaze::gui::CanvasAutomationAPI::tile_query_callback_
private

Definition at line 217 of file canvas_automation_api.h.

Referenced by GetTileAt(), and SetTileQueryCallback().


The documentation for this class was generated from the following files: