#include <canvas_context_menu.h>
Public Types | |
enum class | Command { kNone , kResetView , kZoomToFit , kZoomIn , kZoomOut , kToggleGrid , kToggleHexLabels , kToggleCustomLabels , kToggleContextMenu , kToggleAutoResize , kToggleDraggable , kOpenAdvancedProperties , kOpenScalingControls , kSetGridStep , kSetScale } |
using | CanvasMenuItem = gui::CanvasMenuItem |
Public Member Functions | |
CanvasContextMenu ()=default | |
void | Initialize (const std::string &canvas_id) |
void | SetUsageMode (CanvasUsage usage) |
void | AddMenuItem (const CanvasMenuItem &item) |
void | AddMenuItem (const CanvasMenuItem &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 CanvasConfig &)> &command_handler, CanvasConfig current_config, Canvas *canvas) |
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 CanvasMenuItem &item, std::function< void(const std::string &, std::function< void()>)> popup_callback) |
void | RenderMenuSection (const std::string &title, const std::vector< CanvasMenuItem > &items, std::function< void(const std::string &, std::function< void()>)> popup_callback) |
void | RenderUsageSpecificMenu (std::function< void(const std::string &, std::function< void()>)> popup_callback) |
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 () |
CanvasMenuItem | CreateViewMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback) |
CanvasMenuItem | CreateBitmapMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback) |
CanvasMenuItem | CreatePaletteMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback) |
CanvasMenuItem | CreateBppMenuItem (const std::string &label, const std::string &icon, std::function< void()> callback) |
CanvasMenuItem | 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< PaletteEditorWidget > | palette_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< CanvasMenuItem > > | usage_specific_items_ |
std::vector< CanvasMenuItem > | global_items_ |
Definition at line 24 of file canvas_context_menu.h.
Definition at line 47 of file canvas_context_menu.h.
|
strong |
Definition at line 26 of file canvas_context_menu.h.
|
default |
void yaze::gui::CanvasContextMenu::Initialize | ( | const std::string & | canvas_id | ) |
Definition at line 25 of file canvas_context_menu.cc.
References auto_resize_, canvas_id_, canvas_size_, content_size_, CreateDefaultMenuItems(), current_usage_, enable_context_menu_, enable_custom_labels_, enable_grid_, enable_hex_labels_, enabled_, global_scale_, grid_step_, is_draggable_, yaze::gui::kTilePainting, palette_editor_, and scrolling_.
void yaze::gui::CanvasContextMenu::SetUsageMode | ( | CanvasUsage | usage | ) |
Definition at line 48 of file canvas_context_menu.cc.
References current_usage_.
void yaze::gui::CanvasContextMenu::AddMenuItem | ( | const CanvasMenuItem & | item | ) |
Definition at line 52 of file canvas_context_menu.cc.
References global_items_.
void yaze::gui::CanvasContextMenu::AddMenuItem | ( | const CanvasMenuItem & | item, |
CanvasUsage | usage | ||
) |
Definition at line 56 of file canvas_context_menu.cc.
References usage_specific_items_.
void yaze::gui::CanvasContextMenu::ClearMenuItems | ( | ) |
Definition at line 60 of file canvas_context_menu.cc.
References global_items_, and usage_specific_items_.
void yaze::gui::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 CanvasConfig &)> & | command_handler, | ||
CanvasConfig | current_config, | ||
Canvas * | canvas | ||
) |
Definition at line 65 of file canvas_context_menu.cc.
References current_usage_, yaze::gui::Canvas::editor_menu(), enable_context_menu_, enabled_, yaze::gui::Canvas::GetPopupRegistry(), global_items_, yaze::gui::PopupRegistry::Open(), RenderBitmapOperationsMenu(), RenderBppOperationsMenu(), yaze::gui::RenderCanvasMenu(), RenderCanvasPropertiesMenu(), RenderGridControlsMenu(), RenderMenuSection(), RenderPaletteOperationsMenu(), RenderPerformanceMenu(), RenderScalingControlsMenu(), RenderUsageSpecificMenu(), RenderViewControlsMenu(), yaze::gui::CanvasMenuDefinition::sections, and usage_specific_items_.
bool yaze::gui::CanvasContextMenu::ShouldShowContextMenu | ( | ) | const |
Definition at line 139 of file canvas_context_menu.cc.
References enable_context_menu_, and enabled_.
|
inline |
Definition at line 66 of file canvas_context_menu.h.
References enabled_.
|
inline |
Definition at line 67 of file canvas_context_menu.h.
References enabled_.
|
inline |
Definition at line 68 of file canvas_context_menu.h.
References current_usage_.
void yaze::gui::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 | ||
) |
Definition at line 143 of file canvas_context_menu.cc.
References auto_resize_, canvas_size_, content_size_, enable_context_menu_, enable_custom_labels_, enable_grid_, enable_hex_labels_, global_scale_, grid_step_, is_draggable_, and scrolling_.
|
private |
Definition at line 376 of file canvas_context_menu.cc.
References palette_editor_.
|
private |
Definition at line 167 of file canvas_context_menu.cc.
References yaze::gui::RenderMenuItem().
Referenced by RenderMenuSection(), and RenderUsageSpecificMenu().
|
private |
Definition at line 173 of file canvas_context_menu.cc.
References RenderMenuItem().
Referenced by Render().
|
private |
Definition at line 184 of file canvas_context_menu.cc.
References current_usage_, GetUsageModeColor(), GetUsageModeName(), ICON_MD_COLOR_LENS, RenderMenuItem(), and usage_specific_items_.
Referenced by Render().
|
private |
Definition at line 202 of file canvas_context_menu.cc.
References yaze::gui::CanvasConfig::enable_custom_labels, enable_custom_labels_, yaze::gui::CanvasConfig::enable_grid, enable_grid_, yaze::gui::CanvasConfig::enable_hex_labels, enable_hex_labels_, yaze::gui::CanvasConfig::global_scale, kResetView, kSetScale, kToggleCustomLabels, kToggleGrid, kToggleHexLabels, and kZoomToFit.
Referenced by Render().
|
private |
Definition at line 242 of file canvas_context_menu.cc.
References yaze::gui::CanvasConfig::auto_resize, auto_resize_, yaze::gui::CanvasConfig::canvas_size, canvas_size_, yaze::gui::CanvasConfig::content_size, content_size_, yaze::gui::CanvasConfig::enable_context_menu, enable_context_menu_, yaze::gui::CanvasConfig::enable_custom_labels, enable_custom_labels_, yaze::gui::CanvasConfig::enable_grid, enable_grid_, yaze::gui::CanvasConfig::enable_hex_labels, enable_hex_labels_, global_scale_, yaze::gui::CanvasConfig::grid_step, grid_step_, ICON_MD_SETTINGS, yaze::gui::CanvasConfig::is_draggable, is_draggable_, kOpenAdvancedProperties, yaze::gui::CanvasConfig::scrolling, and scrolling_.
Referenced by Render().
|
private |
Definition at line 271 of file canvas_context_menu.cc.
References yaze::gfx::Arena::Get(), yaze::gfx::Bitmap::height(), ICON_MD_IMAGE, yaze::gfx::k4bpp, yaze::gfx::k8bpp, yaze::gfx::kIndexed, yaze::gfx::Arena::QueueTextureCommand(), yaze::gfx::Bitmap::Reformat(), yaze::gfx::Bitmap::surface(), yaze::gfx::Arena::UPDATE, and yaze::gfx::Bitmap::width().
Referenced by Render().
|
private |
Definition at line 305 of file canvas_context_menu.cc.
References yaze::gui::DisplayEditablePalette(), edit_palette_group_name_index_, edit_palette_index_, ICON_MD_HELP, ICON_MD_PALETTE, yaze::gfx::Bitmap::metadata(), yaze::gfx::Bitmap::mutable_palette(), yaze::gfx::Bitmap::palette(), palette_editor_, and yaze::gfx::SnesPalette::size().
Referenced by Render().
|
private |
Definition at line 382 of file canvas_context_menu.cc.
References ICON_MD_SWAP_HORIZ.
Referenced by Render().
|
private |
Definition at line 398 of file canvas_context_menu.cc.
References yaze::gfx::PerformanceDashboard::Get(), yaze::gfx::PerformanceProfiler::Get(), ICON_MD_TRENDING_UP, and yaze::gfx::PerformanceDashboard::SetVisible().
Referenced by Render().
|
private |
Definition at line 418 of file canvas_context_menu.cc.
References yaze::gui::CanvasConfig::grid_step, grid_step_, ICON_MD_GRID_ON, and kSetGridStep.
Referenced by Render().
|
private |
Definition at line 441 of file canvas_context_menu.cc.
References yaze::gui::CanvasConfig::global_scale, ICON_MD_ZOOM_IN, and kSetScale.
Referenced by Render().
|
private |
Definition at line 463 of file canvas_context_menu.cc.
References ICON_MD_DRAG_INDICATOR, ICON_MD_EDIT, ICON_MD_FIT_SCREEN, ICON_MD_FUNCTIONS, ICON_MD_GRID_ON, ICON_MD_IMAGE, ICON_MD_INFO, ICON_MD_LABEL, ICON_MD_MENU, ICON_MD_PALETTE, ICON_MD_REFRESH, ICON_MD_SCHEDULE, ICON_MD_SETTINGS, ICON_MD_SPEED, ICON_MD_SWAP_HORIZ, ICON_MD_TIMER, ICON_MD_TRENDING_UP, ICON_MD_VISIBILITY, and ICON_MD_ZOOM_IN.
|
private |
Definition at line 480 of file canvas_context_menu.cc.
References yaze::gui::kBitmapEditing, yaze::gui::kBppConversion, yaze::gui::kColorPainting, yaze::gui::kEntityManipulation, yaze::gui::kPaletteEditing, yaze::gui::kPerformanceMode, yaze::gui::kSelectRectangle, yaze::gui::kTilePainting, yaze::gui::kTileSelecting, and yaze::gui::kUnknown.
Referenced by RenderUsageSpecificMenu().
|
private |
Definition at line 496 of file canvas_context_menu.cc.
References yaze::gui::kBitmapEditing, yaze::gui::kBppConversion, yaze::gui::kColorPainting, yaze::gui::kEntityManipulation, yaze::gui::kPaletteEditing, yaze::gui::kPerformanceMode, yaze::gui::kSelectRectangle, yaze::gui::kTilePainting, yaze::gui::kTileSelecting, and yaze::gui::kUnknown.
Referenced by RenderUsageSpecificMenu().
|
private |
Definition at line 512 of file canvas_context_menu.cc.
References yaze::gui::kBitmapEditing, yaze::gui::kBppConversion, yaze::gui::kColorPainting, yaze::gui::kPaletteEditing, yaze::gui::kPerformanceMode, yaze::gui::kSelectRectangle, yaze::gui::kTilePainting, yaze::gui::kTileSelecting, and usage_specific_items_.
Referenced by Initialize().
|
private |
Definition at line 564 of file canvas_context_menu.cc.
|
private |
Definition at line 569 of file canvas_context_menu.cc.
|
private |
Definition at line 574 of file canvas_context_menu.cc.
|
private |
Definition at line 579 of file canvas_context_menu.cc.
|
private |
Definition at line 584 of file canvas_context_menu.cc.
|
private |
Definition at line 83 of file canvas_context_menu.h.
Referenced by Initialize().
|
private |
Definition at line 84 of file canvas_context_menu.h.
Referenced by Initialize(), IsEnabled(), Render(), SetEnabled(), and ShouldShowContextMenu().
|
private |
Definition at line 85 of file canvas_context_menu.h.
Referenced by GetUsageMode(), Initialize(), Render(), RenderUsageSpecificMenu(), and SetUsageMode().
|
private |
Definition at line 87 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 88 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 89 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 90 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), RenderGridControlsMenu(), and SetCanvasState().
|
private |
Definition at line 91 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), RenderViewControlsMenu(), and SetCanvasState().
|
private |
Definition at line 92 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), RenderViewControlsMenu(), and SetCanvasState().
|
private |
Definition at line 93 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), RenderViewControlsMenu(), and SetCanvasState().
|
private |
Definition at line 94 of file canvas_context_menu.h.
Referenced by Initialize(), Render(), RenderCanvasPropertiesMenu(), SetCanvasState(), and ShouldShowContextMenu().
|
private |
Definition at line 95 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 96 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 97 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 99 of file canvas_context_menu.h.
Referenced by DrawROMPaletteSelector(), Initialize(), and RenderPaletteOperationsMenu().
|
private |
Definition at line 100 of file canvas_context_menu.h.
Referenced by RenderPaletteOperationsMenu().
|
private |
Definition at line 101 of file canvas_context_menu.h.
Referenced by RenderPaletteOperationsMenu().
|
private |
Definition at line 102 of file canvas_context_menu.h.
|
private |
Definition at line 103 of file canvas_context_menu.h.
|
private |
Definition at line 107 of file canvas_context_menu.h.
Referenced by AddMenuItem(), ClearMenuItems(), CreateDefaultMenuItems(), Render(), and RenderUsageSpecificMenu().
|
private |
Definition at line 108 of file canvas_context_menu.h.
Referenced by AddMenuItem(), ClearMenuItems(), and Render().