17 ImDrawList* draw_list,
26 ImDrawList* draw_list,
29 int highlight_tile_id) {
51 ImDrawList* draw_list,
54 const ImVector<ImVec2>& points,
55 const ImVector<ImVec2>& selected_points) {
73 ImDrawList* draw_list,
76 const ImVector<ImVector<std::string>>& labels,
101 draw_list->PopClipRect();
105 ImDrawList* draw_list,
117 (ImTextureID)(intptr_t)bitmap.
texture(),
125 ImDrawList* draw_list,
140 ImVec2 rendered_size(bitmap.
width() * scale, bitmap.
height() * scale);
146 (ImTextureID)(intptr_t)bitmap.
texture(),
151 ImVec2(0, 0), ImVec2(1, 1), IM_COL32(255, 255, 255, alpha));
155 ImDrawList* draw_list,
169 (ImTextureID)(intptr_t)bitmap.
texture(),
171 ImVec2(geometry.
canvas_p0.x + dest_pos.x + dest_size.x,
172 geometry.
canvas_p0.y + dest_pos.y + dest_size.y),
173 ImVec2(src_pos.x / bitmap.
width(), src_pos.y / bitmap.
height()),
174 ImVec2((src_pos.x + src_size.x) / bitmap.
width(),
175 (src_pos.y + src_size.y) / bitmap.
height()));
179 ImDrawList* draw_list,
181 std::vector<int>& group,
186 ImVec2 total_map_size) {
196 bool use_optimized_rendering = group.size() > 128;
199 const float tile_scale = tile_size * scale;
207 for (
const auto tile_id : group) {
209 int tiles_per_row = 32;
210 int x = i % tiles_per_row;
211 int y = i / tiles_per_row;
213 int tile_pos_x = x * tile_size * scale;
214 int tile_pos_y = y * tile_size * scale;
218 if (tile_id >= 0 && tile_id < tilemap_size) {
220 atlas_tiles_per_row > 0) {
221 int atlas_tile_x = (tile_id % atlas_tiles_per_row) * tilemap.
tile_size.
x;
222 int atlas_tile_y = (tile_id / atlas_tiles_per_row) * tilemap.
tile_size.
y;
225 if (atlas_tile_x >= 0 && atlas_tile_x < tilemap.
atlas.
width() &&
226 atlas_tile_y >= 0 && atlas_tile_y < tilemap.
atlas.
height()) {
229 const float atlas_width =
static_cast<float>(tilemap.
atlas.
width());
230 const float atlas_height =
static_cast<float>(tilemap.
atlas.
height());
231 ImVec2 uv0 = ImVec2(atlas_tile_x / atlas_width, atlas_tile_y / atlas_height);
232 ImVec2 uv1 = ImVec2((atlas_tile_x + tilemap.
tile_size.
x) / atlas_width,
233 (atlas_tile_y + tilemap.
tile_size.
y) / atlas_height);
242 uint32_t alpha_color = use_optimized_rendering
243 ? IM_COL32(255, 255, 255, 200)
244 : IM_COL32(255, 255, 255, 150);
249 ImVec2(screen_x, screen_y),
250 ImVec2(screen_x + screen_w, screen_y + screen_h),
251 uv0, uv1, alpha_color);
Represents a bitmap image optimized for SNES ROM hacking.
TextureHandle texture() const
void DrawCanvasLabels(const CanvasRenderContext &ctx, const ImVector< ImVector< std::string > > &labels, int current_labels, int tile_id_offset)
void DrawCanvasOverlay(const CanvasRenderContext &ctx, const ImVector< ImVec2 > &points, const ImVector< ImVec2 > &selected_points)
void DrawCanvasGrid(const CanvasRenderContext &ctx, int highlight_tile_id)
constexpr uint32_t kWhiteColor
constexpr uint32_t kRectangleColor
void RenderBitmapGroup(ImDrawList *draw_list, const CanvasGeometry &geometry, std::vector< int > &group, gfx::Tilemap &tilemap, int tile_size, float scale, int local_map_size, ImVec2 total_map_size)
Render group of bitmaps from tilemap.
void RenderCanvasLabels(ImDrawList *draw_list, const CanvasGeometry &geometry, const CanvasConfig &config, const ImVector< ImVector< std::string > > &labels, int current_labels, int tile_id_offset)
Render canvas labels on grid.
void RenderCanvasBackground(ImDrawList *draw_list, const CanvasGeometry &geometry)
Render canvas background and border.
void RenderCanvasGrid(ImDrawList *draw_list, const CanvasGeometry &geometry, const CanvasConfig &config, int highlight_tile_id)
Render canvas grid with optional highlighting.
void RenderBitmapOnCanvas(ImDrawList *draw_list, const CanvasGeometry &geometry, gfx::Bitmap &bitmap, int, float scale)
Render bitmap on canvas (border offset variant)
void RenderCanvasOverlay(ImDrawList *draw_list, const CanvasGeometry &geometry, const CanvasConfig &config, const ImVector< ImVec2 > &points, const ImVector< ImVec2 > &selected_points)
Render canvas overlay (hover and selection points)
Main namespace for the application.
int y
Y coordinate or height.
int x
X coordinate or width.
Tilemap structure for SNES tile-based graphics management.
Pair tile_size
Size of individual tiles (8x8 or 16x16)
Pair map_size
Size of tilemap in tiles.
Bitmap atlas
Master bitmap containing all tiles.
Unified configuration for canvas display and interaction.
bool enable_custom_labels
Canvas geometry calculated per-frame.