1#ifndef YAZE_GUI_CANVAS_H
2#define YAZE_GUI_CANVAS_H
5#define IMGUI_DEFINE_MATH_OPERATORS
28#include "imgui/imgui.h"
39class CanvasAutomationAPI;
66 explicit Canvas(
const std::string&
id);
111 const std::function<
void()> &event,
int tile_size,
180 void OpenPersistentPopup(
const std::string& popup_id, std::function<
void()> render_callback);
249 bool WasClicked(ImGuiMouseButton button = ImGuiMouseButton_Left)
const;
250 bool WasDoubleClicked(ImGuiMouseButton button = ImGuiMouseButton_Left)
const;
262 void DrawRect(
int x,
int y,
int w,
int h, ImVec4 color);
264 void DrawText(
const std::string& text,
int x,
int y);
267 void DrawInfoGrid(
float grid_step = 64.0f,
int tile_id_offset = 8,
279 if (tile_id >= num_columns * num_rows) {
340 void DrawBitmap(
Bitmap &bitmap,
int x_offset,
int y_offset,
float scale = 1.0f,
int alpha = 255);
341 void DrawBitmap(
Bitmap &bitmap, ImVec2 dest_pos, ImVec2 dest_size, ImVec2 src_pos, ImVec2 src_size);
353 int tile_size,
float scale = 1.0f,
354 int local_map_size = 0x200,
355 ImVec2 total_map_size = ImVec2(0x1000, 0x1000));
357 void DrawSelectRect(
int current_map,
int tile_size = 0x10,
float scale = 1.0f);
359 void DrawGrid(
float grid_step = 64.0f,
int tile_id_offset = 8);
363 labels_.push_back(ImVector<std::string>());
371 labels_.push_back(ImVector<std::string>());
374 labels_.push_back(ImVector<std::string>());
465 int num_sheets_to_load,
int canvas_id,
466 bool is_loaded, BitmapTable &graphics_bin);
469 int height,
int tile_size,
bool is_loaded,
470 bool scrollbar,
int canvas_id);
474 const std::string& label =
"",
bool auto_resize =
true);
508 explicit ScopedCanvas(
const std::string&
id, ImVec2 canvas_size = ImVec2(0, 0))
547 other.active_ =
false;
548 other.canvas_ =
nullptr;
The Rom class is used to load, save, and modify Rom data.
Represents a bitmap image optimized for SNES ROM hacking.
Defines an abstract interface for all rendering operations.
Programmatic interface for controlling canvas operations.
Handles all tile-based interactions for Canvas.
Modern, robust canvas for drawing and manipulating graphics.
void set_scrolling(ImVec2 scroll)
const CanvasInteractionHandler & GetInteractionHandler() const
auto selected_tile_pos() const
ImVector< ImVec2 > points_
void DrawBitmap(Bitmap &bitmap, int border_offset, float scale)
PopupRegistry popup_registry_
const CanvasMenuDefinition & editor_menu() const
float GetCanvasWidth() const
void ShowScalingControls()
auto set_current_labels(int i)
bool WasDoubleClicked(ImGuiMouseButton button=ImGuiMouseButton_Left) const
ImVec2 selected_tile_pos_
auto global_scale() const
gfx::IRenderer * renderer_
gfx::IRenderer * renderer() const
void DrawOutlineWithColor(int x, int y, int w, int h, ImVec4 color)
auto select_rect_active() const
void SetUsageMode(CanvasUsage usage)
uint64_t edit_palette_group_name_index_
auto selected_tiles() const
std::unique_ptr< gui::BppComparisonTool > bpp_comparison_tool_
void DrawBitmapGroup(std::vector< int > &group, gfx::Tilemap &tilemap, int tile_size, float scale=1.0f, int local_map_size=0x200, ImVec2 total_map_size=ImVec2(0x1000, 0x1000))
Draw group of bitmaps for multi-tile selection preview.
bool BeginTableCanvas(const std::string &label="")
void InitializeEnhancedComponents()
void ShowBppConversionDialog()
CanvasAutomationAPI * GetAutomationAPI()
bool GetClampRectToLocalMaps() const
auto hover_mouse_pos() const
void ShowAdvancedCanvasProperties()
void ApplyScaleSnapshot(const CanvasConfig &snapshot)
ImVector< ImVec2 > * mutable_points()
void UpdateInfoGrid(ImVec2 bg_size, float grid_size=64.0f, int label_id=0)
std::unique_ptr< gui::BppFormatUI > bpp_format_ui_
auto push_back(ImVec2 pos)
ImVec2 mouse_pos_in_canvas_
int GetTileIdFromMousePos()
auto drawn_tile_position() const
const CanvasSelection & GetSelection() const
bool DrawTilemapPainter(gfx::Tilemap &tilemap, int current_tile)
bool DrawSolidTilePainter(const ImVec4 &color, int size)
bool enable_context_menu_
CanvasMenuDefinition editor_menu_
std::unique_ptr< CanvasModals > modals_
void ApplyConfigSnapshot(const CanvasConfig &snapshot)
void DrawLayeredElements()
float GetCanvasHeight() const
const CanvasConfig & GetConfig() const
void ReserveTableSpace(const std::string &label="")
bool enable_custom_labels_
const PopupRegistry & GetPopupRegistry() const
bool IsSelectRectActive() const
CanvasInteractionHandler & GetInteractionHandler()
auto mutable_selected_points()
void SetRenderer(gfx::IRenderer *renderer)
ImVec2 GetMinimumSize() const
bool DrawTileSelector(int size, int size_y=0)
bool ConvertBitmapFormat(gfx::BppFormat target_format)
void DrawGridLines(float grid_step)
uint64_t edit_palette_sub_index_
void ClearContextMenuItems()
void DrawRect(int x, int y, int w, int h, ImVec4 color)
bool HasValidSelection() const
bool DrawTilePainter(const Bitmap &bitmap, int size, float scale=1.0f)
PopupRegistry & GetPopupRegistry()
auto custom_labels_enabled()
ImVector< ImVec2 > selected_points_
ImVec2 GetCurrentSize() const
void SetCanvasSize(ImVec2 canvas_size)
void UpdateColorPainter(gfx::IRenderer *renderer, gfx::Bitmap &bitmap, const ImVec4 &color, const std::function< void()> &event, int tile_size, float scale=1.0f)
void DrawTileOnBitmap(int tile_size, gfx::Bitmap *bitmap, ImVec4 color)
void DrawCustomHighlight(float grid_step)
auto mutable_selected_tiles()
auto mutable_labels(int i)
void SetCanvasGridSize(CanvasGridSize grid_size)
CanvasGridSize grid_size() const
void AddContextMenuItem(const gui::CanvasMenuItem &item)
uint16_t edit_palette_index_
ImVec2 GetPreferredSize() const
float GetGridStep() const
CanvasInteractionHandler interaction_handler_
void InitializePaletteEditor(Rom *rom)
void Begin(ImVec2 canvas_size=ImVec2(0, 0))
Begin canvas rendering (ImGui-style)
void set_selected_tile_pos(ImVec2 pos)
void SetZoomToFit(const gfx::Bitmap &bitmap)
bool WasClicked(ImGuiMouseButton button=ImGuiMouseButton_Left) const
ImVector< ImVector< std::string > > labels_
void set_draggable(bool draggable)
void SetContextMenuEnabled(bool enabled)
gfx::BppFormat GetCurrentBppFormat() const
void ClosePersistentPopup(const std::string &popup_id)
void ShowBppFormatSelector()
CanvasMenuDefinition & editor_menu()
void RecordCanvasOperation(const std::string &operation_name, double time_ms)
void RenderPersistentPopups()
void set_global_scale(float scale)
ImVec2 GetSelectedTilePos() const
void SetGridSize(CanvasGridSize grid_size)
bool IsAutoResize() const
std::shared_ptr< CanvasUsageTracker > usage_tracker_
void End()
End canvas rendering (ImGui-style)
float GetGlobalScale() const
void SetSelectedTilePos(ImVec2 pos)
std::unique_ptr< gui::BppConversionDialog > bpp_conversion_dialog_
void DrawSelectRect(int current_map, int tile_size=0x10, float scale=1.0f)
CanvasConfig & GetConfig()
bool IsMouseHovering() const
const std::vector< ImVec2 > & GetSelectedTiles() const
std::unique_ptr< CanvasContextMenu > context_menu_
ImVec2 GetLastClickPosition() const
CanvasSelection & GetSelection()
void DrawOutline(int x, int y, int w, int h)
std::unique_ptr< PaletteEditorWidget > palette_editor_
void SetClampRectToLocalMaps(bool clamp)
bool context_menu_enabled_
void DrawInfoGrid(float grid_step=64.0f, int tile_id_offset=8, int label_id=0)
CanvasSelection selection_
bool enable_hex_tile_labels_
void OpenPersistentPopup(const std::string &popup_id, std::function< void()> render_callback)
void DrawBitmapTable(const BitmapTable &gfx_bin)
void DrawBackground(ImVec2 canvas_size=ImVec2(0, 0))
void InitializeDefaults()
const ImVector< ImVec2 > & points() const
std::unique_ptr< CanvasAutomationAPI > automation_api_
std::shared_ptr< CanvasPerformanceIntegration > performance_integration_
void SetAutoResize(bool auto_resize)
void SetGlobalScale(float scale)
void DrawGrid(float grid_step=64.0f, int tile_id_offset=8)
void DrawContextMenuItem(const gui::CanvasMenuItem &item)
void DrawText(const std::string &text, int x, int y)
bool * GetCustomLabelsEnabled()
auto selected_points() const
std::vector< ImVec2 > selected_tiles_
bool ApplyROMPalette(int group_index, int palette_index)
auto set_highlight_tile_id(int i)
RAII wrapper for Canvas (ImGui-style)
ScopedCanvas(const std::string &id, ImVec2 canvas_size=ImVec2(0, 0))
Construct and begin a new canvas (legacy constructor without renderer)
~ScopedCanvas()
Destructor automatically calls End()
ScopedCanvas(ScopedCanvas &&other) noexcept
const Canvas * get() const
Canvas & operator*()
Dereference operator for direct access: (*scoped).DrawBitmap(...)
ScopedCanvas(gfx::IRenderer *renderer, const std::string &id, ImVec2 canvas_size=ImVec2(0, 0))
Construct and begin a new canvas (with optional renderer)
ScopedCanvas(const ScopedCanvas &)=delete
Canvas * operator->()
Arrow operator for clean syntax: scoped->DrawBitmap(...)
const Canvas * operator->() const
Canvas * get()
Get underlying canvas.
ScopedCanvas(Canvas &canvas)
Wrap existing canvas with RAII.
ScopedCanvas & operator=(const ScopedCanvas &)=delete
const Canvas & operator*() const
BppFormat
BPP format enumeration for SNES graphics.
std::unordered_map< int, gfx::Bitmap > BitmapTable
void BitmapCanvasPipeline(gui::Canvas &canvas, gfx::Bitmap &bitmap, int width, int height, int tile_size, bool is_loaded, bool scrollbar, int canvas_id)
CanvasUsage
Canvas usage patterns and tracking.
void EndCanvas(Canvas &canvas)
void BeginCanvas(Canvas &canvas, ImVec2 child_size)
void GraphicsBinCanvasPipeline(int width, int height, int tile_size, int num_sheets_to_load, int canvas_id, bool is_loaded, gfx::BitmapTable &graphics_bin)
void TableCanvasPipeline(gui::Canvas &canvas, gfx::Bitmap &bitmap, const std::string &label, bool auto_resize)
Main namespace for the application.
Tilemap structure for SNES tile-based graphics management.
Unified configuration for canvas display and interaction.
bool clamp_rect_to_local_maps
bool enable_custom_labels
Selection state for canvas interactions.
Complete canvas state snapshot.