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

Represents a canvas for drawing and manipulating graphics. More...

#include <canvas.h>

Inheritance diagram for yaze::gui::Canvas:
Collaboration diagram for yaze::gui::Canvas:

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< Romshared_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< Romshared_rom_ = nullptr
 

Detailed Description

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.

Definition at line 34 of file canvas.h.

Constructor & Destructor Documentation

◆ Canvas() [1/5]

yaze::gui::Canvas::Canvas ( )
default

◆ Canvas() [2/5]

yaze::gui::Canvas::Canvas ( const std::string & id)
inlineexplicit

Definition at line 37 of file canvas.h.

References canvas_id_, and context_id_.

◆ Canvas() [3/5]

yaze::gui::Canvas::Canvas ( const std::string & id,
ImVec2 canvas_size )
inlineexplicit

Definition at line 40 of file canvas.h.

References canvas_id_, canvas_size(), canvas_sz_, context_id_, and custom_canvas_size_.

Here is the call graph for this function:

◆ Canvas() [4/5]

yaze::gui::Canvas::Canvas ( const std::string & id,
ImVec2 canvas_size,
CanvasGridSize grid_size )
inlineexplicit

Definition at line 44 of file canvas.h.

References canvas_id_, canvas_size(), canvas_sz_, context_id_, custom_canvas_size_, and SetCanvasGridSize().

Here is the call graph for this function:

◆ Canvas() [5/5]

yaze::gui::Canvas::Canvas ( const std::string & id,
ImVec2 canvas_size,
CanvasGridSize grid_size,
float global_scale )
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().

Here is the call graph for this function:

Member Function Documentation

◆ SetCanvasGridSize()

void yaze::gui::Canvas::SetCanvasGridSize ( CanvasGridSize grid_size)
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.

Referenced by Canvas(), and Canvas().

◆ UpdateColorPainter()

void yaze::gui::Canvas::UpdateColorPainter ( gfx::Bitmap & bitmap,
const ImVec4 & color,
const std::function< void()> & event,
int tile_size,
float scale = 1.0f )

◆ UpdateInfoGrid()

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_.

Here is the call graph for this function:

◆ DrawBackground()

void yaze::gui::Canvas::DrawBackground ( ImVec2 canvas_size = ImVec2(0, 0),
bool drag = false )

◆ DrawContextMenu()

◆ DrawTilePainter()

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().

Here is the call graph for this function:

◆ DrawSolidTilePainter()

bool yaze::gui::Canvas::DrawSolidTilePainter ( const ImVec4 & color,
int size )

◆ DrawTileOnBitmap()

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().

Here is the call graph for this function:

◆ DrawTileSelector()

bool yaze::gui::Canvas::DrawTileSelector ( int size)

◆ DrawSelectRect()

void yaze::gui::Canvas::DrawSelectRect ( int current_map,
int tile_size = 0x10,
float scale = 1.0f )

◆ DrawBitmap() [1/3]

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().

Here is the call graph for this function:

◆ DrawBitmap() [2/3]

void yaze::gui::Canvas::DrawBitmap ( const Bitmap & bitmap,
int border_offset,
float scale )

◆ DrawBitmap() [3/3]

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().

Here is the call graph for this function:

◆ DrawBitmapTable()

void yaze::gui::Canvas::DrawBitmapTable ( const BitmapTable & gfx_bin)
Todo
Add parameters for sizing and positioning

Definition at line 497 of file canvas.cc.

References canvas_p0_, and draw_list_.

◆ DrawBitmapGroup()

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_.

Here is the call graph for this function:

◆ DrawOutline()

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_.

◆ DrawOutlineWithColor() [1/2]

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_.

◆ DrawOutlineWithColor() [2/2]

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_.

◆ DrawRect()

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_.

◆ DrawText()

void yaze::gui::Canvas::DrawText ( std::string text,
int x,
int y )

◆ DrawGridLines()

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().

◆ DrawGrid()

void yaze::gui::Canvas::DrawGrid ( float grid_step = 64.0f,
int tile_id_offset = 8 )

◆ DrawOverlay()

◆ DrawInfoGrid()

void yaze::gui::Canvas::DrawInfoGrid ( float grid_step = 64.0f,
int tile_id_offset = 8,
int label_id = 0 )

◆ DrawLayeredElements()

void yaze::gui::Canvas::DrawLayeredElements ( )

Definition at line 759 of file canvas.cc.

References draw_list().

Here is the call graph for this function:

◆ GetTileIdFromMousePos()

int yaze::gui::Canvas::GetTileIdFromMousePos ( )
inline

Definition at line 133 of file canvas.h.

References canvas_sz_, custom_step_, global_scale_, and mouse_pos_in_canvas_.

◆ SetCanvasSize()

void yaze::gui::Canvas::SetCanvasSize ( ImVec2 canvas_size)
inline

Definition at line 145 of file canvas.h.

References canvas_size(), canvas_sz_, and custom_canvas_size_.

Here is the call graph for this function:

◆ DrawCustomHighlight()

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().

◆ IsMouseHovering()

bool yaze::gui::Canvas::IsMouseHovering ( ) const
inline

Definition at line 150 of file canvas.h.

References is_hovered_.

◆ ZoomIn()

void yaze::gui::Canvas::ZoomIn ( )
inline

Definition at line 151 of file canvas.h.

References global_scale_.

◆ ZoomOut()

void yaze::gui::Canvas::ZoomOut ( )
inline

Definition at line 152 of file canvas.h.

References global_scale_.

◆ points()

auto yaze::gui::Canvas::points ( ) const
inline

Definition at line 154 of file canvas.h.

References points_.

◆ mutable_points()

auto yaze::gui::Canvas::mutable_points ( )
inline

Definition at line 155 of file canvas.h.

References points_.

◆ push_back()

auto yaze::gui::Canvas::push_back ( ImVec2 pos)
inline

Definition at line 156 of file canvas.h.

References points_.

◆ draw_list()

auto yaze::gui::Canvas::draw_list ( ) const
inline

Definition at line 157 of file canvas.h.

References draw_list_.

Referenced by DrawLayeredElements(), and yaze::gui::GraphicsBinCanvasPipeline().

◆ zero_point()

auto yaze::gui::Canvas::zero_point ( ) const
inline

Definition at line 158 of file canvas.h.

References canvas_p0_.

Referenced by yaze::gui::GraphicsBinCanvasPipeline().

◆ scrolling()

auto yaze::gui::Canvas::scrolling ( ) const
inline

Definition at line 159 of file canvas.h.

References scrolling_.

◆ drawn_tile_position()

auto yaze::gui::Canvas::drawn_tile_position ( ) const
inline

Definition at line 160 of file canvas.h.

References drawn_tile_pos_.

◆ canvas_size()

auto yaze::gui::Canvas::canvas_size ( ) const
inline

Definition at line 161 of file canvas.h.

References canvas_sz_.

Referenced by Canvas(), Canvas(), Canvas(), DrawBackground(), and SetCanvasSize().

◆ set_global_scale()

void yaze::gui::Canvas::set_global_scale ( float scale)
inline

Definition at line 162 of file canvas.h.

References global_scale_.

◆ global_scale()

auto yaze::gui::Canvas::global_scale ( ) const
inline

Definition at line 163 of file canvas.h.

References global_scale_.

Referenced by Canvas().

◆ custom_labels_enabled()

auto yaze::gui::Canvas::custom_labels_enabled ( )
inline

Definition at line 164 of file canvas.h.

References enable_custom_labels_.

◆ custom_step()

auto yaze::gui::Canvas::custom_step ( ) const
inline

Definition at line 165 of file canvas.h.

References custom_step_.

◆ width()

auto yaze::gui::Canvas::width ( ) const
inline

Definition at line 166 of file canvas.h.

References canvas_sz_.

◆ height()

auto yaze::gui::Canvas::height ( ) const
inline

Definition at line 167 of file canvas.h.

References canvas_sz_.

◆ set_draggable()

auto yaze::gui::Canvas::set_draggable ( bool value)
inline

Definition at line 168 of file canvas.h.

References draggable_.

◆ labels()

auto yaze::gui::Canvas::labels ( int i)
inline

Definition at line 170 of file canvas.h.

References labels_.

◆ mutable_labels()

auto yaze::gui::Canvas::mutable_labels ( int i)
inline

Definition at line 176 of file canvas.h.

References labels_.

◆ set_current_labels()

auto yaze::gui::Canvas::set_current_labels ( int i)
inline

Definition at line 188 of file canvas.h.

References current_labels_.

◆ set_highlight_tile_id()

auto yaze::gui::Canvas::set_highlight_tile_id ( int i)
inline

Definition at line 189 of file canvas.h.

References highlight_tile_id.

◆ selected_tiles()

auto yaze::gui::Canvas::selected_tiles ( ) const
inline

Definition at line 191 of file canvas.h.

References selected_tiles_.

◆ mutable_selected_tiles()

auto yaze::gui::Canvas::mutable_selected_tiles ( )
inline

Definition at line 192 of file canvas.h.

References selected_tiles_.

◆ selected_tile_pos()

auto yaze::gui::Canvas::selected_tile_pos ( ) const
inline

Definition at line 194 of file canvas.h.

References selected_tile_pos_.

◆ set_selected_tile_pos()

auto yaze::gui::Canvas::set_selected_tile_pos ( ImVec2 pos)
inline

Definition at line 195 of file canvas.h.

References selected_tile_pos_.

◆ select_rect_active()

bool yaze::gui::Canvas::select_rect_active ( ) const
inline

Definition at line 196 of file canvas.h.

References select_rect_active_.

◆ selected_points()

auto yaze::gui::Canvas::selected_points ( ) const
inline

Definition at line 197 of file canvas.h.

References selected_points_.

◆ hover_mouse_pos()

auto yaze::gui::Canvas::hover_mouse_pos ( ) const
inline

Definition at line 199 of file canvas.h.

References mouse_pos_in_canvas_.

Member Data Documentation

◆ draggable_

bool yaze::gui::Canvas::draggable_ = false
private

Definition at line 202 of file canvas.h.

Referenced by DrawBackground(), and set_draggable().

◆ is_hovered_

bool yaze::gui::Canvas::is_hovered_ = false
private

Definition at line 203 of file canvas.h.

Referenced by DrawSolidTilePainter(), DrawTilePainter(), and IsMouseHovering().

◆ enable_grid_

bool yaze::gui::Canvas::enable_grid_ = true
private

Definition at line 204 of file canvas.h.

Referenced by DrawContextMenu(), DrawGrid(), and DrawInfoGrid().

◆ enable_hex_tile_labels_

bool yaze::gui::Canvas::enable_hex_tile_labels_ = false
private

Definition at line 205 of file canvas.h.

Referenced by DrawContextMenu(), and DrawGrid().

◆ enable_custom_labels_

bool yaze::gui::Canvas::enable_custom_labels_ = false
private

Definition at line 206 of file canvas.h.

Referenced by custom_labels_enabled(), DrawGrid(), DrawInfoGrid(), and UpdateInfoGrid().

◆ enable_context_menu_

bool yaze::gui::Canvas::enable_context_menu_ = true
private

Definition at line 207 of file canvas.h.

Referenced by DrawBackground(), and DrawContextMenu().

◆ custom_canvas_size_

bool yaze::gui::Canvas::custom_canvas_size_ = false
private

Definition at line 208 of file canvas.h.

Referenced by Canvas(), Canvas(), Canvas(), DrawBackground(), and SetCanvasSize().

◆ select_rect_active_

bool yaze::gui::Canvas::select_rect_active_ = false
private

Definition at line 209 of file canvas.h.

Referenced by DrawBitmapGroup(), DrawSelectRect(), and select_rect_active().

◆ refresh_graphics_

bool yaze::gui::Canvas::refresh_graphics_ = false
private

Definition at line 210 of file canvas.h.

Referenced by DrawContextMenu().

◆ custom_step_

float yaze::gui::Canvas::custom_step_ = 0.0f
private

◆ global_scale_

◆ current_labels_

int yaze::gui::Canvas::current_labels_ = 0
private

Definition at line 215 of file canvas.h.

Referenced by DrawGrid(), and set_current_labels().

◆ highlight_tile_id

int yaze::gui::Canvas::highlight_tile_id = -1
private

Definition at line 216 of file canvas.h.

Referenced by DrawCustomHighlight(), and set_highlight_tile_id().

◆ edit_palette_index_

uint16_t yaze::gui::Canvas::edit_palette_index_ = 0
private

Definition at line 218 of file canvas.h.

Referenced by DrawContextMenu().

◆ edit_palette_group_name_index_

uint64_t yaze::gui::Canvas::edit_palette_group_name_index_ = 0
private

Definition at line 219 of file canvas.h.

Referenced by DrawContextMenu().

◆ edit_palette_sub_index_

uint64_t yaze::gui::Canvas::edit_palette_sub_index_ = 0
private

Definition at line 220 of file canvas.h.

Referenced by DrawContextMenu().

◆ draw_list_

◆ scrolling_

◆ canvas_sz_

◆ canvas_p0_

◆ canvas_p1_

ImVec2 yaze::gui::Canvas::canvas_p1_
private

Definition at line 227 of file canvas.h.

Referenced by DrawBackground(), DrawBitmap(), DrawGrid(), DrawGridLines(), and DrawInfoGrid().

◆ drawn_tile_pos_

ImVec2 yaze::gui::Canvas::drawn_tile_pos_
private

◆ mouse_pos_in_canvas_

ImVec2 yaze::gui::Canvas::mouse_pos_in_canvas_
private

◆ selected_tile_pos_

ImVec2 yaze::gui::Canvas::selected_tile_pos_ = ImVec2(-1, -1)
private

Definition at line 230 of file canvas.h.

Referenced by DrawSelectRect(), selected_tile_pos(), and set_selected_tile_pos().

◆ points_

ImVector<ImVec2> yaze::gui::Canvas::points_
private

◆ selected_points_

ImVector<ImVec2> yaze::gui::Canvas::selected_points_
private

Definition at line 233 of file canvas.h.

Referenced by DrawBitmapGroup(), DrawOverlay(), DrawSelectRect(), and selected_points().

◆ labels_

ImVector<ImVector<std::string> > yaze::gui::Canvas::labels_
private

Definition at line 234 of file canvas.h.

Referenced by DrawGrid(), DrawInfoGrid(), labels(), and mutable_labels().

◆ canvas_id_

std::string yaze::gui::Canvas::canvas_id_ = "Canvas"
private

Definition at line 236 of file canvas.h.

Referenced by Canvas(), Canvas(), Canvas(), Canvas(), and DrawBackground().

◆ context_id_

std::string yaze::gui::Canvas::context_id_ = "CanvasContext"
private

Definition at line 237 of file canvas.h.

Referenced by Canvas(), Canvas(), Canvas(), Canvas(), and DrawContextMenu().

◆ selected_tiles_

std::vector<ImVec2> yaze::gui::Canvas::selected_tiles_
private

Definition at line 238 of file canvas.h.

Referenced by DrawSelectRect(), mutable_selected_tiles(), and selected_tiles().


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