Represents a canvas for drawing and manipulating graphics. More...
#include <canvas.h>
Public Member Functions | |
Canvas ()=default | |
Canvas (const std::string &id) | |
Canvas (const std::string &id, ImVec2 canvas_size) | |
Canvas (const std::string &id, ImVec2 canvas_size, CanvasGridSize grid_size) | |
Canvas (const std::string &id, ImVec2 canvas_size, CanvasGridSize grid_size, float global_scale) | |
void | SetCanvasGridSize (CanvasGridSize grid_size) |
void | UpdateColorPainter (gfx::Bitmap &bitmap, const ImVec4 &color, const std::function< void()> &event, int tile_size, float scale=1.0f) |
void | UpdateInfoGrid (ImVec2 bg_size, int tile_size, float scale=1.0f, float grid_size=64.0f, int label_id=0) |
void | DrawBackground (ImVec2 canvas_size=ImVec2(0, 0), bool drag=false) |
void | DrawContextMenu (gfx::Bitmap *bitmap=nullptr) |
bool | DrawTilePainter (const Bitmap &bitmap, int size, float scale=1.0f) |
bool | DrawSolidTilePainter (const ImVec4 &color, int size) |
void | DrawTileOnBitmap (int tile_size, gfx::Bitmap *bitmap, ImVec4 color) |
bool | DrawTileSelector (int size) |
void | DrawSelectRect (int current_map, int tile_size=0x10, float scale=1.0f) |
void | DrawBitmap (const Bitmap &bitmap, int border_offset=0, bool ready=true) |
void | DrawBitmap (const Bitmap &bitmap, int border_offset, float scale) |
void | DrawBitmap (const Bitmap &bitmap, int x_offset=0, int y_offset=0, float scale=1.0f, int alpha=255) |
void | DrawBitmapTable (const BitmapTable &gfx_bin) |
void | DrawBitmapGroup (std::vector< int > &group, std::array< gfx::Bitmap, 4096 > &tile16_individual_, int tile_size, float scale=1.0f) |
void | DrawOutline (int x, int y, int w, int h) |
void | DrawOutlineWithColor (int x, int y, int w, int h, ImVec4 color) |
void | DrawOutlineWithColor (int x, int y, int w, int h, uint32_t color) |
void | DrawRect (int x, int y, int w, int h, ImVec4 color) |
void | DrawText (std::string text, int x, int y) |
void | DrawGridLines (float grid_step) |
void | DrawGrid (float grid_step=64.0f, int tile_id_offset=8) |
void | DrawOverlay () |
void | DrawInfoGrid (float grid_step=64.0f, int tile_id_offset=8, int label_id=0) |
void | DrawLayeredElements () |
int | GetTileIdFromMousePos () |
void | SetCanvasSize (ImVec2 canvas_size) |
void | DrawCustomHighlight (float grid_step) |
bool | IsMouseHovering () const |
void | ZoomIn () |
void | ZoomOut () |
auto | points () const |
auto | mutable_points () |
auto | push_back (ImVec2 pos) |
auto | draw_list () const |
auto | zero_point () const |
auto | scrolling () const |
auto | drawn_tile_position () const |
auto | canvas_size () const |
void | set_global_scale (float scale) |
auto | global_scale () const |
auto | custom_labels_enabled () |
auto | custom_step () const |
auto | width () const |
auto | height () const |
auto | set_draggable (bool value) |
auto | labels (int i) |
auto | mutable_labels (int i) |
auto | set_current_labels (int i) |
auto | set_highlight_tile_id (int i) |
auto | selected_tiles () const |
auto | mutable_selected_tiles () |
auto | selected_tile_pos () const |
auto | set_selected_tile_pos (ImVec2 pos) |
bool | select_rect_active () const |
auto | selected_points () const |
auto | hover_mouse_pos () const |
Public Member Functions inherited from yaze::SharedRom | |
SharedRom ()=default | |
virtual | ~SharedRom ()=default |
std::shared_ptr< Rom > | shared_rom () |
auto | rom () |
Private Attributes | |
bool | draggable_ = false |
bool | is_hovered_ = false |
bool | enable_grid_ = true |
bool | enable_hex_tile_labels_ = false |
bool | enable_custom_labels_ = false |
bool | enable_context_menu_ = true |
bool | custom_canvas_size_ = false |
bool | select_rect_active_ = false |
bool | refresh_graphics_ = false |
float | custom_step_ = 0.0f |
float | global_scale_ = 1.0f |
int | current_labels_ = 0 |
int | highlight_tile_id = -1 |
uint16_t | edit_palette_index_ = 0 |
uint64_t | edit_palette_group_name_index_ = 0 |
uint64_t | edit_palette_sub_index_ = 0 |
ImDrawList * | draw_list_ = nullptr |
ImVec2 | scrolling_ |
ImVec2 | canvas_sz_ |
ImVec2 | canvas_p0_ |
ImVec2 | canvas_p1_ |
ImVec2 | drawn_tile_pos_ |
ImVec2 | mouse_pos_in_canvas_ |
ImVec2 | selected_tile_pos_ = ImVec2(-1, -1) |
ImVector< ImVec2 > | points_ |
ImVector< ImVec2 > | selected_points_ |
ImVector< ImVector< std::string > > | labels_ |
std::string | canvas_id_ = "Canvas" |
std::string | context_id_ = "CanvasContext" |
std::vector< ImVec2 > | selected_tiles_ |
Additional Inherited Members | |
Static Public Attributes inherited from yaze::SharedRom | |
static std::shared_ptr< Rom > | shared_rom_ = nullptr |
Represents a canvas for drawing and manipulating graphics.
The Canvas class provides various functions for updating and drawing graphics on a canvas. It supports features such as bitmap drawing, context menu handling, tile painting, custom grid, and more.
|
default |
|
inlineexplicit |
Definition at line 37 of file canvas.h.
References canvas_id_, and context_id_.
|
inlineexplicit |
Definition at line 40 of file canvas.h.
References canvas_id_, canvas_size(), canvas_sz_, context_id_, and custom_canvas_size_.
|
inlineexplicit |
Definition at line 44 of file canvas.h.
References canvas_id_, canvas_size(), canvas_sz_, context_id_, custom_canvas_size_, and SetCanvasGridSize().
|
inlineexplicit |
Definition at line 50 of file canvas.h.
References canvas_id_, canvas_size(), canvas_sz_, context_id_, custom_canvas_size_, global_scale(), global_scale_, and SetCanvasGridSize().
|
inline |
Definition at line 56 of file canvas.h.
References custom_step_, yaze::gui::k16x16, yaze::gui::k32x32, yaze::gui::k64x64, and yaze::gui::k8x8.
void yaze::gui::Canvas::UpdateColorPainter | ( | gfx::Bitmap & | bitmap, |
const ImVec4 & | color, | ||
const std::function< void()> & | event, | ||
int | tile_size, | ||
float | scale = 1.0f ) |
Definition at line 43 of file canvas.cc.
References DrawBackground(), DrawBitmap(), DrawContextMenu(), DrawGrid(), DrawOverlay(), DrawSolidTilePainter(), and global_scale_.
void yaze::gui::Canvas::UpdateInfoGrid | ( | ImVec2 | bg_size, |
int | tile_size, | ||
float | scale = 1.0f, | ||
float | grid_size = 64.0f, | ||
int | label_id = 0 ) |
Definition at line 57 of file canvas.cc.
References DrawBackground(), DrawInfoGrid(), DrawOverlay(), and enable_custom_labels_.
void yaze::gui::Canvas::DrawBackground | ( | ImVec2 | canvas_size = ImVec2(0, 0), |
bool | drag = false ) |
Definition at line 65 of file canvas.cc.
References canvas_id_, canvas_p0_, canvas_p1_, canvas_size(), canvas_sz_, custom_canvas_size_, draggable_, draw_list_, enable_context_menu_, global_scale_, yaze::gui::kMouseFlags, yaze::gui::kRectangleColor, yaze::gui::kWhiteColor, and scrolling_.
Referenced by yaze::gui::BitmapCanvasPipeline(), yaze::gui::GraphicsBinCanvasPipeline(), yaze::gui::zeml::Render(), UpdateColorPainter(), and UpdateInfoGrid().
void yaze::gui::Canvas::DrawContextMenu | ( | gfx::Bitmap * | bitmap = nullptr | ) |
Definition at line 100 of file canvas.cc.
References yaze::gfx::Bitmap::ApplyPaletteWithTransparent(), canvas_p0_, canvas_sz_, context_id_, custom_step_, edit_palette_group_name_index_, edit_palette_index_, edit_palette_sub_index_, enable_context_menu_, enable_grid_, enable_hex_tile_labels_, yaze::gui::Renderer::GetInstance(), global_scale_, yaze::gui::InputHexWord(), yaze::gfx::k2bpp, yaze::gfx::k4bpp, yaze::gfx::k8bpp, yaze::gfx::kIndexed, yaze::gfx::kPaletteGroupAddressesKeys, yaze::gfx::Bitmap::Reformat(), refresh_graphics_, yaze::SharedRom::rom(), scrolling_, yaze::gui::SelectablePalettePipeline(), yaze::gfx::Bitmap::surface(), yaze::gui::TextWithSeparators(), and yaze::core::Renderer::UpdateBitmap().
Referenced by yaze::gui::BitmapCanvasPipeline(), yaze::gui::GraphicsBinCanvasPipeline(), yaze::gui::zeml::Render(), and UpdateColorPainter().
bool yaze::gui::Canvas::DrawTilePainter | ( | const Bitmap & | bitmap, |
int | size, | ||
float | scale = 1.0f ) |
Definition at line 205 of file canvas.cc.
References canvas_p0_, draw_list_, drawn_tile_pos_, yaze::gfx::Bitmap::is_active(), is_hovered_, mouse_pos_in_canvas_, points_, scrolling_, and yaze::gfx::Bitmap::texture().
bool yaze::gui::Canvas::DrawSolidTilePainter | ( | const ImVec4 & | color, |
int | size ) |
Definition at line 259 of file canvas.cc.
References canvas_p0_, canvas_sz_, draw_list_, drawn_tile_pos_, global_scale_, is_hovered_, points_, and scrolling_.
Referenced by UpdateColorPainter().
void yaze::gui::Canvas::DrawTileOnBitmap | ( | int | tile_size, |
gfx::Bitmap * | bitmap, | ||
ImVec4 | color ) |
Definition at line 318 of file canvas.cc.
References drawn_tile_pos_, global_scale_, yaze::gfx::Bitmap::width(), and yaze::gfx::Bitmap::WriteColor().
bool yaze::gui::Canvas::DrawTileSelector | ( | int | size | ) |
Definition at line 339 of file canvas.cc.
References canvas_p0_, mouse_pos_in_canvas_, points_, and scrolling_.
Referenced by yaze::gui::BitmapCanvasPipeline(), and yaze::gui::GraphicsBinCanvasPipeline().
void yaze::gui::Canvas::DrawSelectRect | ( | int | current_map, |
int | tile_size = 0x10, | ||
float | scale = 1.0f ) |
Definition at line 372 of file canvas.cc.
References canvas_p0_, draw_list_, yaze::gui::kWhiteColor, scrolling_, select_rect_active_, selected_points_, selected_tile_pos_, and selected_tiles_.
void yaze::gui::Canvas::DrawBitmap | ( | const Bitmap & | bitmap, |
int | border_offset = 0, | ||
bool | ready = true ) |
Definition at line 460 of file canvas.cc.
References canvas_p0_, draw_list_, yaze::gfx::Bitmap::height(), yaze::gfx::Bitmap::texture(), and yaze::gfx::Bitmap::width().
Referenced by yaze::gui::BitmapCanvasPipeline(), DrawBitmapGroup(), and UpdateColorPainter().
void yaze::gui::Canvas::DrawBitmap | ( | const Bitmap & | bitmap, |
int | border_offset, | ||
float | scale ) |
Definition at line 470 of file canvas.cc.
References canvas_p0_, canvas_p1_, draw_list_, yaze::gfx::Bitmap::height(), yaze::gfx::Bitmap::is_active(), yaze::gui::kWhiteColor, yaze::gfx::Bitmap::texture(), and yaze::gfx::Bitmap::width().
void yaze::gui::Canvas::DrawBitmap | ( | const Bitmap & | bitmap, |
int | x_offset = 0, | ||
int | y_offset = 0, | ||
float | scale = 1.0f, | ||
int | alpha = 255 ) |
Definition at line 481 of file canvas.cc.
References canvas_p0_, draw_list_, yaze::gfx::Bitmap::height(), yaze::gfx::Bitmap::is_active(), scrolling_, yaze::gfx::Bitmap::texture(), and yaze::gfx::Bitmap::width().
void yaze::gui::Canvas::DrawBitmapTable | ( | const BitmapTable & | gfx_bin | ) |
Definition at line 497 of file canvas.cc.
References canvas_p0_, and draw_list_.
void yaze::gui::Canvas::DrawBitmapGroup | ( | std::vector< int > & | group, |
std::array< gfx::Bitmap, 4096 > & | tile16_individual_, | ||
int | tile_size, | ||
float | scale = 1.0f ) |
Definition at line 535 of file canvas.cc.
References canvas_p0_, DrawBitmap(), scrolling_, select_rect_active_, and selected_points_.
void yaze::gui::Canvas::DrawOutline | ( | int | x, |
int | y, | ||
int | w, | ||
int | h ) |
Definition at line 510 of file canvas.cc.
References canvas_p0_, draw_list_, yaze::gui::kOutlineRect, and scrolling_.
void yaze::gui::Canvas::DrawOutlineWithColor | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
ImVec4 | color ) |
Definition at line 518 of file canvas.cc.
References canvas_p0_, draw_list_, and scrolling_.
void yaze::gui::Canvas::DrawOutlineWithColor | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
uint32_t | color ) |
Definition at line 527 of file canvas.cc.
References canvas_p0_, draw_list_, and scrolling_.
void yaze::gui::Canvas::DrawRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
ImVec4 | color ) |
Definition at line 601 of file canvas.cc.
References canvas_p0_, draw_list_, yaze::gui::kBlackColor, and scrolling_.
void yaze::gui::Canvas::DrawText | ( | std::string | text, |
int | x, | ||
int | y ) |
Definition at line 614 of file canvas.cc.
References canvas_p0_, draw_list_, yaze::gui::kBlackColor, yaze::gui::kWhiteColor, and scrolling_.
void yaze::gui::Canvas::DrawGridLines | ( | float | grid_step | ) |
Definition at line 623 of file canvas.cc.
References canvas_p0_, canvas_p1_, canvas_sz_, draw_list_, global_scale_, and scrolling_.
Referenced by DrawGrid(), and DrawInfoGrid().
void yaze::gui::Canvas::DrawGrid | ( | float | grid_step = 64.0f, |
int | tile_id_offset = 8 ) |
Definition at line 685 of file canvas.cc.
References canvas_p0_, canvas_p1_, canvas_sz_, current_labels_, custom_step_, draw_list_, DrawCustomHighlight(), DrawGridLines(), enable_custom_labels_, enable_grid_, enable_hex_tile_labels_, global_scale_, yaze::gui::kWhiteColor, labels_, and scrolling_.
Referenced by yaze::gui::BitmapCanvasPipeline(), yaze::gui::GraphicsBinCanvasPipeline(), yaze::gui::zeml::Render(), and UpdateColorPainter().
void yaze::gui::Canvas::DrawOverlay | ( | ) |
Definition at line 736 of file canvas.cc.
References canvas_p0_, draw_list_, yaze::gui::kWhiteColor, points_, scrolling_, and selected_points_.
Referenced by yaze::gui::BitmapCanvasPipeline(), yaze::gui::GraphicsBinCanvasPipeline(), yaze::gui::zeml::Render(), UpdateColorPainter(), and UpdateInfoGrid().
void yaze::gui::Canvas::DrawInfoGrid | ( | float | grid_step = 64.0f, |
int | tile_id_offset = 8, | ||
int | label_id = 0 ) |
Definition at line 638 of file canvas.cc.
References canvas_p0_, canvas_p1_, canvas_sz_, custom_step_, draw_list_, DrawCustomHighlight(), DrawGridLines(), enable_custom_labels_, enable_grid_, global_scale_, yaze::gui::kWhiteColor, labels_, and scrolling_.
Referenced by UpdateInfoGrid().
void yaze::gui::Canvas::DrawLayeredElements | ( | ) |
Definition at line 759 of file canvas.cc.
References draw_list().
|
inline |
Definition at line 133 of file canvas.h.
References canvas_sz_, custom_step_, global_scale_, and mouse_pos_in_canvas_.
|
inline |
Definition at line 145 of file canvas.h.
References canvas_size(), canvas_sz_, and custom_canvas_size_.
void yaze::gui::Canvas::DrawCustomHighlight | ( | float | grid_step | ) |
Definition at line 672 of file canvas.cc.
References canvas_p0_, draw_list_, highlight_tile_id, and scrolling_.
Referenced by DrawGrid(), and DrawInfoGrid().
|
inline |
Definition at line 150 of file canvas.h.
References is_hovered_.
|
inline |
Definition at line 151 of file canvas.h.
References global_scale_.
|
inline |
Definition at line 152 of file canvas.h.
References global_scale_.
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 157 of file canvas.h.
References draw_list_.
Referenced by DrawLayeredElements(), and yaze::gui::GraphicsBinCanvasPipeline().
|
inline |
Definition at line 158 of file canvas.h.
References canvas_p0_.
Referenced by yaze::gui::GraphicsBinCanvasPipeline().
|
inline |
Definition at line 159 of file canvas.h.
References scrolling_.
|
inline |
Definition at line 160 of file canvas.h.
References drawn_tile_pos_.
|
inline |
Definition at line 161 of file canvas.h.
References canvas_sz_.
Referenced by Canvas(), Canvas(), Canvas(), DrawBackground(), and SetCanvasSize().
|
inline |
Definition at line 162 of file canvas.h.
References global_scale_.
|
inline |
|
inline |
Definition at line 164 of file canvas.h.
References enable_custom_labels_.
|
inline |
Definition at line 165 of file canvas.h.
References custom_step_.
|
inline |
Definition at line 166 of file canvas.h.
References canvas_sz_.
|
inline |
Definition at line 167 of file canvas.h.
References canvas_sz_.
|
inline |
Definition at line 168 of file canvas.h.
References draggable_.
|
inline |
|
inline |
|
inline |
Definition at line 188 of file canvas.h.
References current_labels_.
|
inline |
Definition at line 189 of file canvas.h.
References highlight_tile_id.
|
inline |
Definition at line 191 of file canvas.h.
References selected_tiles_.
|
inline |
Definition at line 192 of file canvas.h.
References selected_tiles_.
|
inline |
Definition at line 194 of file canvas.h.
References selected_tile_pos_.
|
inline |
Definition at line 195 of file canvas.h.
References selected_tile_pos_.
|
inline |
Definition at line 196 of file canvas.h.
References select_rect_active_.
|
inline |
Definition at line 197 of file canvas.h.
References selected_points_.
|
inline |
Definition at line 199 of file canvas.h.
References mouse_pos_in_canvas_.
|
private |
Definition at line 202 of file canvas.h.
Referenced by DrawBackground(), and set_draggable().
|
private |
Definition at line 203 of file canvas.h.
Referenced by DrawSolidTilePainter(), DrawTilePainter(), and IsMouseHovering().
|
private |
Definition at line 204 of file canvas.h.
Referenced by DrawContextMenu(), DrawGrid(), and DrawInfoGrid().
|
private |
Definition at line 205 of file canvas.h.
Referenced by DrawContextMenu(), and DrawGrid().
|
private |
Definition at line 206 of file canvas.h.
Referenced by custom_labels_enabled(), DrawGrid(), DrawInfoGrid(), and UpdateInfoGrid().
|
private |
Definition at line 207 of file canvas.h.
Referenced by DrawBackground(), and DrawContextMenu().
|
private |
Definition at line 208 of file canvas.h.
Referenced by Canvas(), Canvas(), Canvas(), DrawBackground(), and SetCanvasSize().
|
private |
Definition at line 209 of file canvas.h.
Referenced by DrawBitmapGroup(), DrawSelectRect(), and select_rect_active().
|
private |
Definition at line 210 of file canvas.h.
Referenced by DrawContextMenu().
|
private |
Definition at line 212 of file canvas.h.
Referenced by custom_step(), DrawContextMenu(), DrawGrid(), DrawInfoGrid(), GetTileIdFromMousePos(), and SetCanvasGridSize().
|
private |
Definition at line 213 of file canvas.h.
Referenced by Canvas(), DrawBackground(), DrawContextMenu(), DrawGrid(), DrawGridLines(), DrawInfoGrid(), DrawSolidTilePainter(), DrawTileOnBitmap(), GetTileIdFromMousePos(), global_scale(), set_global_scale(), UpdateColorPainter(), ZoomIn(), and ZoomOut().
|
private |
Definition at line 215 of file canvas.h.
Referenced by DrawGrid(), and set_current_labels().
|
private |
Definition at line 216 of file canvas.h.
Referenced by DrawCustomHighlight(), and set_highlight_tile_id().
|
private |
Definition at line 218 of file canvas.h.
Referenced by DrawContextMenu().
|
private |
Definition at line 219 of file canvas.h.
Referenced by DrawContextMenu().
|
private |
Definition at line 220 of file canvas.h.
Referenced by DrawContextMenu().
|
private |
Definition at line 222 of file canvas.h.
Referenced by draw_list(), DrawBackground(), DrawBitmap(), DrawBitmap(), DrawBitmap(), DrawBitmapTable(), DrawCustomHighlight(), DrawGrid(), DrawGridLines(), DrawInfoGrid(), DrawOutline(), DrawOutlineWithColor(), DrawOutlineWithColor(), DrawOverlay(), DrawRect(), DrawSelectRect(), DrawSolidTilePainter(), DrawText(), and DrawTilePainter().
|
private |
Definition at line 224 of file canvas.h.
Referenced by DrawBackground(), DrawBitmap(), DrawBitmapGroup(), DrawContextMenu(), DrawCustomHighlight(), DrawGrid(), DrawGridLines(), DrawInfoGrid(), DrawOutline(), DrawOutlineWithColor(), DrawOutlineWithColor(), DrawOverlay(), DrawRect(), DrawSelectRect(), DrawSolidTilePainter(), DrawText(), DrawTilePainter(), DrawTileSelector(), and scrolling().
|
private |
Definition at line 225 of file canvas.h.
Referenced by Canvas(), Canvas(), Canvas(), canvas_size(), DrawBackground(), DrawContextMenu(), DrawGrid(), DrawGridLines(), DrawInfoGrid(), DrawSolidTilePainter(), GetTileIdFromMousePos(), height(), SetCanvasSize(), and width().
|
private |
Definition at line 226 of file canvas.h.
Referenced by DrawBackground(), DrawBitmap(), DrawBitmap(), DrawBitmap(), DrawBitmapGroup(), DrawBitmapTable(), DrawContextMenu(), DrawCustomHighlight(), DrawGrid(), DrawGridLines(), DrawInfoGrid(), DrawOutline(), DrawOutlineWithColor(), DrawOutlineWithColor(), DrawOverlay(), DrawRect(), DrawSelectRect(), DrawSolidTilePainter(), DrawText(), DrawTilePainter(), DrawTileSelector(), and zero_point().
|
private |
Definition at line 227 of file canvas.h.
Referenced by DrawBackground(), DrawBitmap(), DrawGrid(), DrawGridLines(), and DrawInfoGrid().
|
private |
Definition at line 228 of file canvas.h.
Referenced by drawn_tile_position(), DrawSolidTilePainter(), DrawTileOnBitmap(), and DrawTilePainter().
|
private |
Definition at line 229 of file canvas.h.
Referenced by DrawTilePainter(), DrawTileSelector(), GetTileIdFromMousePos(), and hover_mouse_pos().
|
private |
Definition at line 230 of file canvas.h.
Referenced by DrawSelectRect(), selected_tile_pos(), and set_selected_tile_pos().
|
private |
Definition at line 232 of file canvas.h.
Referenced by DrawOverlay(), DrawSolidTilePainter(), DrawTilePainter(), DrawTileSelector(), mutable_points(), points(), and push_back().
|
private |
Definition at line 233 of file canvas.h.
Referenced by DrawBitmapGroup(), DrawOverlay(), DrawSelectRect(), and selected_points().
|
private |
Definition at line 234 of file canvas.h.
Referenced by DrawGrid(), DrawInfoGrid(), labels(), and mutable_labels().
|
private |
|
private |
|
private |
Definition at line 238 of file canvas.h.
Referenced by DrawSelectRect(), mutable_selected_tiles(), and selected_tiles().