28 return "selection-source";
30 return "composite-output";
38 "Skipped %s: bitmap purpose=%s active=%d size=%dx%d (no texture)",
50 draw_list->AddRectFilled(
55 if (theme.enable_glow_effects) {
56 const float dot_spacing = 32.0f;
57 const uint32_t dot_color =
62 x < geometry.
canvas_p1.x; x += dot_spacing) {
65 y < geometry.
canvas_p1.y; y += dot_spacing) {
66 draw_list->AddCircleFilled(ImVec2(x, y), 1.0f, dot_color);
75 theme.window_border_size > 0 ? theme.window_border_size : 1.0f);
102 const ImVector<ImVec2>& points,
103 const ImVector<ImVec2>& selected_points) {
122 const ImVector<ImVector<std::string>>& labels,
123 int current_labels,
int tile_id_offset) {
145 draw_list->PopClipRect();
152 LogBitmapDropIfDebug(bitmap,
"RenderBitmapOnCanvas(border)");
157 draw_list->AddImage((ImTextureID)(intptr_t)bitmap.
texture(),
161 ImVec2(0, 0), ImVec2(1, 1),
162 ImGui::GetColorU32(ImVec4(1, 1, 1, 1)));
170 float scale,
int alpha) {
172 LogBitmapDropIfDebug(bitmap,
"RenderBitmapOnCanvas(offset)");
179 ImVec2 rendered_size(bitmap.
width() * scale, bitmap.
height() * scale);
185 (ImTextureID)(intptr_t)bitmap.
texture(),
192 ImVec2(0, 0), ImVec2(1, 1),
193 ImGui::GetColorU32(IM_COL32(255, 255, 255, alpha)));
198 ImVec2 dest_size, ImVec2 src_pos, ImVec2 src_size) {
200 LogBitmapDropIfDebug(bitmap,
"RenderBitmapOnCanvas(custom-uv)");
206 (ImTextureID)(intptr_t)bitmap.
texture(),
207 ImVec2(geometry.
canvas_p0.x + dest_pos.x,
209 ImVec2(geometry.
canvas_p0.x + dest_pos.x + dest_size.x,
210 geometry.
canvas_p0.y + dest_pos.y + dest_size.y),
211 ImVec2(src_pos.x / bitmap.
width(), src_pos.y / bitmap.
height()),
212 ImVec2((src_pos.x + src_size.x) / bitmap.
width(),
213 (src_pos.y + src_size.y) / bitmap.
height()),
214 ImGui::GetColorU32(ImVec4(1, 1, 1, 1)));
219 int tile_size,
float scale,
int local_map_size,
220 ImVec2 total_map_size) {
230 bool use_optimized_rendering = group.size() > 128;
233 const float tile_scale = tile_size * scale;
241 for (
const auto tile_id : group) {
243 int tiles_per_row = 32;
244 int x = i % tiles_per_row;
245 int y = i / tiles_per_row;
247 int tile_pos_x = x * tile_size * scale;
248 int tile_pos_y = y * tile_size * scale;
252 if (tile_id >= 0 && tile_id < tilemap_size) {
254 atlas_tiles_per_row > 0) {
256 (tile_id % atlas_tiles_per_row) * tilemap.
tile_size.
x;
258 (tile_id / atlas_tiles_per_row) * tilemap.
tile_size.
y;
261 if (atlas_tile_x >= 0 && atlas_tile_x < tilemap.
atlas.
width() &&
262 atlas_tile_y >= 0 && atlas_tile_y < tilemap.
atlas.
height()) {
264 const float atlas_width =
static_cast<float>(tilemap.
atlas.
width());
265 const float atlas_height =
static_cast<float>(tilemap.
atlas.
height());
267 ImVec2(atlas_tile_x / atlas_width, atlas_tile_y / atlas_height);
269 ImVec2((atlas_tile_x + tilemap.
tile_size.
x) / atlas_width,
270 (atlas_tile_y + tilemap.
tile_size.
y) / atlas_height);
281 uint32_t alpha_color = use_optimized_rendering
282 ? IM_COL32(255, 255, 255, 200)
283 : IM_COL32(255, 255, 255, 150);
286 draw_list->AddImage((ImTextureID)(intptr_t)tilemap.
atlas.
texture(),
287 ImVec2(screen_x, screen_y),
288 ImVec2(screen_x + screen_w, screen_y + screen_h),
289 uv0, uv1, ImGui::GetColorU32(alpha_color));
Represents a bitmap image optimized for SNES ROM hacking.
TextureHandle texture() const
BitmapPurpose
How a bitmap is used in the editor pipeline.
BitmapMetadata & metadata()
const Theme & GetCurrentTheme() const
static ThemeManager & Get()
#define LOG_DEBUG(category, format,...)
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)
void LogBitmapDropIfDebug(const gfx::Bitmap &bitmap, const char *site)
const char * PurposeLabel(gfx::Bitmap::BitmapPurpose purpose)
ImVec4 ConvertColorToImVec4(const Color &color)
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)
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.