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

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

#include <canvas.h>

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

Public Member Functions

 Canvas ()=default
 
 Canvas (const std::string &id, ImVec2 canvas_size)
 
 Canvas (const std::string &id, ImVec2 canvas_size, 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::vector< gfx::Bitmap > &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::app::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
 
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
 
bool refresh_graphics_ = false
 
std::string canvas_id_ = "Canvas"
 
std::string context_id_ = "CanvasContext"
 
ImDrawList * draw_list_
 
ImVector< ImVec2 > points_
 
ImVector< ImVector< std::string > > labels_
 
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 > selected_points_
 
std::vector< ImVec2 > selected_tiles_
 

Additional Inherited Members

- Static Public Attributes inherited from yaze::app::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 36 of file canvas.h.

Constructor & Destructor Documentation

◆ Canvas() [1/3]

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

◆ Canvas() [2/3]

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

Definition at line 39 of file canvas.h.

References context_id_.

◆ Canvas() [3/3]

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

Member Function Documentation

◆ UpdateColorPainter()

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

Definition at line 47 of file canvas.cc.

References DrawBackground(), DrawBitmap(), DrawContextMenu(), DrawGrid(), DrawOverlay(), DrawSolidTilePainter(), and global_scale_.

Referenced by yaze::app::editor::GraphicsEditor::UpdateGfxTabView().

Here is the call graph for this function:

◆ UpdateInfoGrid()

void yaze::app::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 61 of file canvas.cc.

References DrawBackground(), DrawInfoGrid(), DrawOverlay(), and enable_custom_labels_.

Referenced by yaze::app::editor::OverworldEditor::DrawOverworldProperties().

Here is the call graph for this function:

◆ DrawBackground()

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

◆ DrawContextMenu()

void yaze::app::gui::Canvas::DrawContextMenu ( gfx::Bitmap * bitmap = nullptr)

Definition at line 104 of file canvas.cc.

References yaze::app::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::app::core::Renderer::GetInstance(), global_scale_, yaze::app::gui::InputHexWord(), yaze::app::gfx::k2bpp, yaze::app::gfx::k4bpp, yaze::app::gfx::k8bpp, yaze::app::gfx::kIndexed, yaze::app::gfx::kPaletteGroupAddressesKeys, yaze::app::gfx::Bitmap::Reformat(), refresh_graphics_, yaze::app::SharedRom::rom(), scrolling_, yaze::app::gui::SelectablePalettePipeline(), yaze::app::gfx::Bitmap::surface(), yaze::app::gui::TextWithSeparators(), and yaze::app::core::Renderer::UpdateBitmap().

Referenced by yaze::app::gui::BitmapCanvasPipeline(), yaze::app::editor::OverworldEditor::DrawAreaGraphics(), yaze::app::editor::MessageEditor::DrawCurrentMessage(), yaze::app::editor::SpriteEditor::DrawCurrentSheets(), yaze::app::editor::DungeonEditor::DrawDungeonCanvas(), yaze::app::editor::ScreenEditor::DrawDungeonMapsEditor(), yaze::app::editor::ScreenEditor::DrawInventoryMenuEditor(), yaze::app::editor::DungeonEditor::DrawObjectRenderer(), yaze::app::editor::OverworldEditor::DrawOverworldCanvas(), yaze::app::editor::DungeonEditor::DrawRoomGraphics(), yaze::app::editor::SpriteEditor::DrawSpriteCanvas(), yaze::app::editor::OverworldEditor::DrawTile16Selector(), yaze::app::editor::OverworldEditor::DrawTile8Selector(), yaze::app::gui::GraphicsBinCanvasPipeline(), yaze::app::gui::zeml::Render(), yaze::app::editor::Tile16Editor::UpdateBlockset(), UpdateColorPainter(), yaze::app::editor::GraphicsEditor::UpdateGfxSheetList(), yaze::app::editor::GraphicsEditor::UpdateLinkGfxView(), and yaze::app::editor::Tile16Editor::UpdateTile16Edit().

Here is the call graph for this function:

◆ DrawTilePainter()

bool yaze::app::gui::Canvas::DrawTilePainter ( const Bitmap & bitmap,
int size,
float scale = 1.0f )

◆ DrawSolidTilePainter()

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

◆ DrawTileOnBitmap()

void yaze::app::gui::Canvas::DrawTileOnBitmap ( int tile_size,
gfx::Bitmap * bitmap,
ImVec4 color )

Definition at line 322 of file canvas.cc.

References drawn_tile_pos_, global_scale_, yaze::app::gfx::Bitmap::width(), and yaze::app::gfx::Bitmap::WriteColor().

Referenced by yaze::app::editor::GraphicsEditor::UpdateGfxTabView().

Here is the call graph for this function:

◆ DrawTileSelector()

◆ DrawSelectRect()

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

◆ DrawBitmap() [1/3]

◆ DrawBitmap() [2/3]

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

◆ DrawBitmap() [3/3]

void yaze::app::gui::Canvas::DrawBitmap ( const Bitmap & bitmap,
int x_offset = 0,
int y_offset = 0,
float scale = 1.0f,
int alpha = 255 )

◆ DrawBitmapTable()

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

Definition at line 501 of file canvas.cc.

References canvas_p0_, and draw_list_.

Referenced by yaze::app::editor::ScreenEditor::DrawDungeonMapsEditor().

◆ DrawBitmapGroup()

void yaze::app::gui::Canvas::DrawBitmapGroup ( std::vector< int > & group,
std::vector< gfx::Bitmap > & tile16_individual_,
int tile_size,
float scale = 1.0f )

Definition at line 539 of file canvas.cc.

References canvas_p0_, DrawBitmap(), scrolling_, select_rect_active_, and selected_points_.

Referenced by yaze::app::editor::OverworldEditor::CheckForSelectRectangle().

Here is the call graph for this function:

◆ DrawOutline()

void yaze::app::gui::Canvas::DrawOutline ( int x,
int y,
int w,
int h )

◆ DrawOutlineWithColor() [1/2]

void yaze::app::gui::Canvas::DrawOutlineWithColor ( int x,
int y,
int w,
int h,
ImVec4 color )

Definition at line 522 of file canvas.cc.

References canvas_p0_, draw_list_, and scrolling_.

Referenced by yaze::app::editor::ScreenEditor::DrawDungeonMapsTabs().

◆ DrawOutlineWithColor() [2/2]

void yaze::app::gui::Canvas::DrawOutlineWithColor ( int x,
int y,
int w,
int h,
uint32_t color )

Definition at line 531 of file canvas.cc.

References canvas_p0_, draw_list_, and scrolling_.

◆ DrawRect()

◆ DrawText()

◆ DrawGridLines()

void yaze::app::gui::Canvas::DrawGridLines ( float grid_step)

Definition at line 627 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::app::gui::Canvas::DrawGrid ( float grid_step = 64.0f,
int tile_id_offset = 8 )

◆ DrawOverlay()

◆ DrawInfoGrid()

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

◆ DrawLayeredElements()

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

Definition at line 763 of file canvas.cc.

References draw_list().

Here is the call graph for this function:

◆ GetTileIdFromMousePos()

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

Definition at line 123 of file canvas.h.

References canvas_sz_, custom_step_, and mouse_pos_in_canvas_.

Referenced by yaze::app::editor::Tile16Editor::UpdateBlockset().

◆ SetCanvasSize()

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

Definition at line 134 of file canvas.h.

References canvas_size(), canvas_sz_, and custom_canvas_size_.

Referenced by yaze::app::editor::ScreenEditor::ScreenEditor().

Here is the call graph for this function:

◆ DrawCustomHighlight()

void yaze::app::gui::Canvas::DrawCustomHighlight ( float grid_step)

Definition at line 676 of file canvas.cc.

References canvas_p0_, draw_list_, highlight_tile_id, and scrolling_.

Referenced by DrawGrid(), and DrawInfoGrid().

◆ IsMouseHovering()

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

Definition at line 139 of file canvas.h.

References is_hovered_.

◆ ZoomIn()

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

Definition at line 140 of file canvas.h.

References global_scale_.

Referenced by yaze::app::editor::OverworldEditor::DrawToolset().

◆ ZoomOut()

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

Definition at line 141 of file canvas.h.

References global_scale_.

Referenced by yaze::app::editor::OverworldEditor::DrawToolset().

◆ points()

◆ mutable_points()

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

Definition at line 144 of file canvas.h.

References points_.

◆ push_back()

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

Definition at line 145 of file canvas.h.

References points_.

◆ draw_list()

◆ zero_point()

◆ scrolling()

◆ drawn_tile_position()

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

◆ canvas_size()

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

Definition at line 150 of file canvas.h.

References canvas_sz_.

Referenced by DrawBackground(), and SetCanvasSize().

◆ set_global_scale()

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

Definition at line 151 of file canvas.h.

References global_scale_.

◆ global_scale()

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

Definition at line 152 of file canvas.h.

References global_scale_.

Referenced by yaze::app::editor::OverworldEditor::DrawOverworldMaps().

◆ custom_labels_enabled()

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

◆ custom_step()

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

Definition at line 154 of file canvas.h.

References custom_step_.

◆ width()

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

Definition at line 155 of file canvas.h.

References canvas_sz_.

◆ height()

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

Definition at line 156 of file canvas.h.

References canvas_sz_.

◆ set_draggable()

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

◆ labels()

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

Definition at line 159 of file canvas.h.

References labels_.

◆ mutable_labels()

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

◆ set_current_labels()

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

Definition at line 177 of file canvas.h.

References current_labels_.

◆ set_highlight_tile_id()

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

Definition at line 178 of file canvas.h.

References highlight_tile_id.

Referenced by yaze::app::editor::OverworldEditor::UpdateUsageStats().

◆ selected_tiles()

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

◆ mutable_selected_tiles()

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

Definition at line 181 of file canvas.h.

References selected_tiles_.

◆ selected_tile_pos()

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

Definition at line 183 of file canvas.h.

References selected_tile_pos_.

Referenced by yaze::app::editor::OverworldEditor::CheckForSelectRectangle().

◆ set_selected_tile_pos()

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

Definition at line 184 of file canvas.h.

References selected_tile_pos_.

Referenced by yaze::app::editor::OverworldEditor::CheckForSelectRectangle().

◆ select_rect_active()

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

◆ selected_points()

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

Definition at line 186 of file canvas.h.

References selected_points_.

Referenced by yaze::app::editor::OverworldEditor::CheckForOverworldEdits().

◆ hover_mouse_pos()

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

Member Data Documentation

◆ draggable_

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

Definition at line 191 of file canvas.h.

Referenced by DrawBackground(), and set_draggable().

◆ is_hovered_

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

Definition at line 192 of file canvas.h.

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

◆ enable_grid_

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

Definition at line 193 of file canvas.h.

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

◆ enable_hex_tile_labels_

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

Definition at line 194 of file canvas.h.

Referenced by DrawContextMenu(), and DrawGrid().

◆ enable_custom_labels_

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

Definition at line 195 of file canvas.h.

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

◆ enable_context_menu_

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

Definition at line 196 of file canvas.h.

Referenced by DrawBackground(), and DrawContextMenu().

◆ custom_canvas_size_

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

Definition at line 197 of file canvas.h.

Referenced by DrawBackground(), and SetCanvasSize().

◆ select_rect_active_

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

Definition at line 198 of file canvas.h.

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

◆ custom_step_

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

◆ global_scale_

float yaze::app::gui::Canvas::global_scale_ = 1.0f
private

◆ current_labels_

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

Definition at line 203 of file canvas.h.

Referenced by DrawGrid(), and set_current_labels().

◆ highlight_tile_id

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

Definition at line 204 of file canvas.h.

Referenced by DrawCustomHighlight(), and set_highlight_tile_id().

◆ edit_palette_index_

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

Definition at line 206 of file canvas.h.

Referenced by DrawContextMenu().

◆ edit_palette_group_name_index_

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

Definition at line 207 of file canvas.h.

Referenced by DrawContextMenu().

◆ edit_palette_sub_index_

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

Definition at line 208 of file canvas.h.

Referenced by DrawContextMenu().

◆ refresh_graphics_

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

Definition at line 209 of file canvas.h.

Referenced by DrawContextMenu().

◆ canvas_id_

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

Definition at line 211 of file canvas.h.

Referenced by DrawBackground().

◆ context_id_

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

Definition at line 212 of file canvas.h.

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

◆ draw_list_

◆ points_

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

◆ labels_

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

Definition at line 216 of file canvas.h.

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

◆ scrolling_

◆ canvas_sz_

ImVec2 yaze::app::gui::Canvas::canvas_sz_
private

◆ canvas_p0_

◆ canvas_p1_

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

Definition at line 220 of file canvas.h.

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

◆ drawn_tile_pos_

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

◆ mouse_pos_in_canvas_

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

◆ selected_tile_pos_

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

Definition at line 223 of file canvas.h.

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

◆ selected_points_

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

Definition at line 224 of file canvas.h.

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

◆ selected_tiles_

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

Definition at line 225 of file canvas.h.

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


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