yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gui::canvas::CanvasContextMenu Class Reference

#include <canvas_context_menu.h>

Classes

struct  ContextMenuItem
 

Public Types

enum class  Command {
  kNone , kResetView , kZoomToFit , kZoomIn ,
  kZoomOut , kToggleGrid , kToggleHexLabels , kToggleCustomLabels ,
  kToggleContextMenu , kToggleAutoResize , kToggleDraggable , kOpenAdvancedProperties ,
  kOpenScalingControls , kSetGridStep , kSetScale
}
 

Public Member Functions

 CanvasContextMenu ()=default
 
void Initialize (const std::string &canvas_id)
 
void SetUsageMode (CanvasUsage usage)
 
void AddMenuItem (const ContextMenuItem &item)
 
void AddMenuItem (const ContextMenuItem &item, CanvasUsage usage)
 
void ClearMenuItems ()
 
void Render (const std::string &context_id, const ImVec2 &mouse_pos, Rom *rom, const gfx::Bitmap *bitmap, const gfx::SnesPalette *palette, const std::function< void(Command, const canvas::CanvasConfig &)> &command_handler, CanvasConfig current_config)
 
bool ShouldShowContextMenu () const
 
void SetEnabled (bool enabled)
 
bool IsEnabled () const
 
CanvasUsage GetUsageMode () const
 
void SetCanvasState (const ImVec2 &canvas_size, const ImVec2 &content_size, float global_scale, float grid_step, bool enable_grid, bool enable_hex_labels, bool enable_custom_labels, bool enable_context_menu, bool is_draggable, bool auto_resize, const ImVec2 &scrolling)
 

Private Member Functions

void DrawROMPaletteSelector ()
 
void RenderMenuItem (const ContextMenuItem &item)
 
void RenderMenuSection (const std::string &title, const std::vector< ContextMenuItem > &items)
 
void RenderUsageSpecificMenu ()
 
void RenderViewControlsMenu (const std::function< void(Command, const CanvasConfig &)> &command_handler, CanvasConfig current_config)
 
void RenderCanvasPropertiesMenu (const std::function< void(Command, const CanvasConfig &)> &command_handler, CanvasConfig current_config)
 
void RenderBitmapOperationsMenu (gfx::Bitmap *bitmap)
 
void RenderPaletteOperationsMenu (Rom *rom, gfx::Bitmap *bitmap)
 
void RenderBppOperationsMenu (const gfx::Bitmap *bitmap)
 
void RenderPerformanceMenu ()
 
void RenderGridControlsMenu (const std::function< void(Command, const CanvasConfig &)> &command_handler, CanvasConfig current_config)
 
void RenderScalingControlsMenu (const std::function< void(Command, const CanvasConfig &)> &command_handler, CanvasConfig current_config)
 
void RenderMaterialIcon (const std::string &icon_name, const ImVec4 &color=ImVec4(1, 1, 1, 1))
 
std::string GetUsageModeName (CanvasUsage usage) const
 
ImVec4 GetUsageModeColor (CanvasUsage usage) const
 
void CreateDefaultMenuItems ()
 
ContextMenuItem CreateViewMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback)
 
ContextMenuItem CreateBitmapMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback)
 
ContextMenuItem CreatePaletteMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback)
 
ContextMenuItem CreateBppMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback)
 
ContextMenuItem CreatePerformanceMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback)
 

Private Attributes

std::string canvas_id_
 
bool enabled_ = true
 
CanvasUsage current_usage_ = CanvasUsage::kTilePainting
 
ImVec2 canvas_size_
 
ImVec2 content_size_
 
float global_scale_ = 1.0f
 
float grid_step_ = 32.0f
 
bool enable_grid_ = true
 
bool enable_hex_labels_ = false
 
bool enable_custom_labels_ = false
 
bool enable_context_menu_ = true
 
bool is_draggable_ = false
 
bool auto_resize_ = false
 
ImVec2 scrolling_
 
std::unique_ptr< PaletteWidgetpalette_editor_
 
uint64_t edit_palette_group_name_index_ = 0
 
uint64_t edit_palette_index_ = 0
 
uint64_t edit_palette_sub_index_ = 0
 
bool refresh_graphics_ = false
 
std::unordered_map< CanvasUsage, std::vector< ContextMenuItem > > usage_specific_items_
 
std::vector< ContextMenuItemglobal_items_
 

Detailed Description

Definition at line 24 of file canvas_context_menu.h.

Member Enumeration Documentation

◆ Command

Enumerator
kNone 
kResetView 
kZoomToFit 
kZoomIn 
kZoomOut 
kToggleGrid 
kToggleHexLabels 
kToggleCustomLabels 
kToggleContextMenu 
kToggleAutoResize 
kToggleDraggable 
kOpenAdvancedProperties 
kOpenScalingControls 
kSetGridStep 
kSetScale 

Definition at line 26 of file canvas_context_menu.h.

Constructor & Destructor Documentation

◆ CanvasContextMenu()

yaze::gui::canvas::CanvasContextMenu::CanvasContextMenu ( )
default

Member Function Documentation

◆ Initialize()

void yaze::gui::canvas::CanvasContextMenu::Initialize ( const std::string &  canvas_id)

◆ SetUsageMode()

void yaze::gui::canvas::CanvasContextMenu::SetUsageMode ( CanvasUsage  usage)

Definition at line 49 of file canvas_context_menu.cc.

References current_usage_.

◆ AddMenuItem() [1/2]

void yaze::gui::canvas::CanvasContextMenu::AddMenuItem ( const ContextMenuItem item)

Definition at line 53 of file canvas_context_menu.cc.

References global_items_.

◆ AddMenuItem() [2/2]

void yaze::gui::canvas::CanvasContextMenu::AddMenuItem ( const ContextMenuItem item,
CanvasUsage  usage 
)

Definition at line 57 of file canvas_context_menu.cc.

References usage_specific_items_.

◆ ClearMenuItems()

void yaze::gui::canvas::CanvasContextMenu::ClearMenuItems ( )

Definition at line 61 of file canvas_context_menu.cc.

References global_items_, and usage_specific_items_.

◆ Render()

void yaze::gui::canvas::CanvasContextMenu::Render ( const std::string &  context_id,
const ImVec2 &  mouse_pos,
Rom rom,
const gfx::Bitmap bitmap,
const gfx::SnesPalette palette,
const std::function< void(Command, const canvas::CanvasConfig &)> &  command_handler,
CanvasConfig  current_config 
)

◆ ShouldShowContextMenu()

bool yaze::gui::canvas::CanvasContextMenu::ShouldShowContextMenu ( ) const

Definition at line 131 of file canvas_context_menu.cc.

References enable_context_menu_, and enabled_.

◆ SetEnabled()

void yaze::gui::canvas::CanvasContextMenu::SetEnabled ( bool  enabled)
inline

Definition at line 78 of file canvas_context_menu.h.

References enabled_.

◆ IsEnabled()

bool yaze::gui::canvas::CanvasContextMenu::IsEnabled ( ) const
inline

Definition at line 79 of file canvas_context_menu.h.

References enabled_.

◆ GetUsageMode()

CanvasUsage yaze::gui::canvas::CanvasContextMenu::GetUsageMode ( ) const
inline

Definition at line 80 of file canvas_context_menu.h.

References current_usage_.

◆ SetCanvasState()

void yaze::gui::canvas::CanvasContextMenu::SetCanvasState ( const ImVec2 &  canvas_size,
const ImVec2 &  content_size,
float  global_scale,
float  grid_step,
bool  enable_grid,
bool  enable_hex_labels,
bool  enable_custom_labels,
bool  enable_context_menu,
bool  is_draggable,
bool  auto_resize,
const ImVec2 &  scrolling 
)

◆ DrawROMPaletteSelector()

void yaze::gui::canvas::CanvasContextMenu::DrawROMPaletteSelector ( )
private

Definition at line 357 of file canvas_context_menu.cc.

References palette_editor_.

◆ RenderMenuItem()

◆ RenderMenuSection()

void yaze::gui::canvas::CanvasContextMenu::RenderMenuSection ( const std::string &  title,
const std::vector< ContextMenuItem > &  items 
)
private

Definition at line 193 of file canvas_context_menu.cc.

References RenderMenuItem().

Referenced by Render().

Here is the call graph for this function:

◆ RenderUsageSpecificMenu()

void yaze::gui::canvas::CanvasContextMenu::RenderUsageSpecificMenu ( )
private

Definition at line 203 of file canvas_context_menu.cc.

References current_usage_, GetUsageModeColor(), GetUsageModeName(), ICON_MD_COLOR_LENS, RenderMenuItem(), and usage_specific_items_.

Referenced by Render().

Here is the call graph for this function:

◆ RenderViewControlsMenu()

◆ RenderCanvasPropertiesMenu()

◆ RenderBitmapOperationsMenu()

◆ RenderPaletteOperationsMenu()

void yaze::gui::canvas::CanvasContextMenu::RenderPaletteOperationsMenu ( Rom rom,
gfx::Bitmap bitmap 
)
private

◆ RenderBppOperationsMenu()

void yaze::gui::canvas::CanvasContextMenu::RenderBppOperationsMenu ( const gfx::Bitmap bitmap)
private

Definition at line 363 of file canvas_context_menu.cc.

References ICON_MD_SWAP_HORIZ.

Referenced by Render().

◆ RenderPerformanceMenu()

void yaze::gui::canvas::CanvasContextMenu::RenderPerformanceMenu ( )
private

◆ RenderGridControlsMenu()

void yaze::gui::canvas::CanvasContextMenu::RenderGridControlsMenu ( const std::function< void(Command, const CanvasConfig &)> &  command_handler,
CanvasConfig  current_config 
)
private

◆ RenderScalingControlsMenu()

void yaze::gui::canvas::CanvasContextMenu::RenderScalingControlsMenu ( const std::function< void(Command, const CanvasConfig &)> &  command_handler,
CanvasConfig  current_config 
)
private

Definition at line 422 of file canvas_context_menu.cc.

References yaze::gui::canvas::CanvasConfig::global_scale, ICON_MD_ZOOM_IN, and kSetScale.

Referenced by Render().

◆ RenderMaterialIcon()

void yaze::gui::canvas::CanvasContextMenu::RenderMaterialIcon ( const std::string &  icon_name,
const ImVec4 &  color = ImVec4(1, 1, 1, 1) 
)
private

◆ GetUsageModeName()

◆ GetUsageModeColor()

◆ CreateDefaultMenuItems()

◆ CreateViewMenuItem()

canvas::CanvasContextMenu::ContextMenuItem yaze::gui::canvas::CanvasContextMenu::CreateViewMenuItem ( const std::string &  label,
const std::string &  icon,
std::function< void()>  callback 
)
private

Definition at line 543 of file canvas_context_menu.cc.

◆ CreateBitmapMenuItem()

canvas::CanvasContextMenu::ContextMenuItem yaze::gui::canvas::CanvasContextMenu::CreateBitmapMenuItem ( const std::string &  label,
const std::string &  icon,
std::function< void()>  callback 
)
private

Definition at line 549 of file canvas_context_menu.cc.

◆ CreatePaletteMenuItem()

canvas::CanvasContextMenu::ContextMenuItem yaze::gui::canvas::CanvasContextMenu::CreatePaletteMenuItem ( const std::string &  label,
const std::string &  icon,
std::function< void()>  callback 
)
private

Definition at line 555 of file canvas_context_menu.cc.

◆ CreateBppMenuItem()

canvas::CanvasContextMenu::ContextMenuItem yaze::gui::canvas::CanvasContextMenu::CreateBppMenuItem ( const std::string &  label,
const std::string &  icon,
std::function< void()>  callback 
)
private

Definition at line 561 of file canvas_context_menu.cc.

◆ CreatePerformanceMenuItem()

canvas::CanvasContextMenu::ContextMenuItem yaze::gui::canvas::CanvasContextMenu::CreatePerformanceMenuItem ( const std::string &  label,
const std::string &  icon,
std::function< void()>  callback 
)
private

Definition at line 567 of file canvas_context_menu.cc.

Member Data Documentation

◆ canvas_id_

std::string yaze::gui::canvas::CanvasContextMenu::canvas_id_
private

Definition at line 95 of file canvas_context_menu.h.

Referenced by Initialize().

◆ enabled_

bool yaze::gui::canvas::CanvasContextMenu::enabled_ = true
private

◆ current_usage_

CanvasUsage yaze::gui::canvas::CanvasContextMenu::current_usage_ = CanvasUsage::kTilePainting
private

◆ canvas_size_

ImVec2 yaze::gui::canvas::CanvasContextMenu::canvas_size_
private

Definition at line 99 of file canvas_context_menu.h.

Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().

◆ content_size_

ImVec2 yaze::gui::canvas::CanvasContextMenu::content_size_
private

Definition at line 100 of file canvas_context_menu.h.

Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().

◆ global_scale_

float yaze::gui::canvas::CanvasContextMenu::global_scale_ = 1.0f
private

Definition at line 101 of file canvas_context_menu.h.

Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().

◆ grid_step_

float yaze::gui::canvas::CanvasContextMenu::grid_step_ = 32.0f
private

◆ enable_grid_

bool yaze::gui::canvas::CanvasContextMenu::enable_grid_ = true
private

◆ enable_hex_labels_

bool yaze::gui::canvas::CanvasContextMenu::enable_hex_labels_ = false
private

◆ enable_custom_labels_

bool yaze::gui::canvas::CanvasContextMenu::enable_custom_labels_ = false
private

◆ enable_context_menu_

bool yaze::gui::canvas::CanvasContextMenu::enable_context_menu_ = true
private

◆ is_draggable_

bool yaze::gui::canvas::CanvasContextMenu::is_draggable_ = false
private

Definition at line 107 of file canvas_context_menu.h.

Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().

◆ auto_resize_

bool yaze::gui::canvas::CanvasContextMenu::auto_resize_ = false
private

Definition at line 108 of file canvas_context_menu.h.

Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().

◆ scrolling_

ImVec2 yaze::gui::canvas::CanvasContextMenu::scrolling_
private

Definition at line 109 of file canvas_context_menu.h.

Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().

◆ palette_editor_

std::unique_ptr<PaletteWidget> yaze::gui::canvas::CanvasContextMenu::palette_editor_
private

◆ edit_palette_group_name_index_

uint64_t yaze::gui::canvas::CanvasContextMenu::edit_palette_group_name_index_ = 0
private

Definition at line 112 of file canvas_context_menu.h.

Referenced by RenderPaletteOperationsMenu().

◆ edit_palette_index_

uint64_t yaze::gui::canvas::CanvasContextMenu::edit_palette_index_ = 0
private

Definition at line 113 of file canvas_context_menu.h.

Referenced by RenderPaletteOperationsMenu().

◆ edit_palette_sub_index_

uint64_t yaze::gui::canvas::CanvasContextMenu::edit_palette_sub_index_ = 0
private

Definition at line 114 of file canvas_context_menu.h.

◆ refresh_graphics_

bool yaze::gui::canvas::CanvasContextMenu::refresh_graphics_ = false
private

Definition at line 115 of file canvas_context_menu.h.

◆ usage_specific_items_

std::unordered_map<CanvasUsage, std::vector<ContextMenuItem> > yaze::gui::canvas::CanvasContextMenu::usage_specific_items_
private

◆ global_items_

std::vector<ContextMenuItem> yaze::gui::canvas::CanvasContextMenu::global_items_
private

Definition at line 120 of file canvas_context_menu.h.

Referenced by AddMenuItem(), ClearMenuItems(), and Render().


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