#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< PaletteWidget > | 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< ContextMenuItem > > | usage_specific_items_ |
std::vector< ContextMenuItem > | global_items_ |
Definition at line 24 of file canvas_context_menu.h.
|
strong |
Definition at line 26 of file canvas_context_menu.h.
|
default |
void yaze::gui::canvas::CanvasContextMenu::Initialize | ( | const std::string & | canvas_id | ) |
Definition at line 26 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::canvas::kTilePainting, palette_editor_, and scrolling_.
void yaze::gui::canvas::CanvasContextMenu::SetUsageMode | ( | CanvasUsage | usage | ) |
Definition at line 49 of file canvas_context_menu.cc.
References current_usage_.
void yaze::gui::canvas::CanvasContextMenu::AddMenuItem | ( | const ContextMenuItem & | item | ) |
Definition at line 53 of file canvas_context_menu.cc.
References global_items_.
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_.
void yaze::gui::canvas::CanvasContextMenu::ClearMenuItems | ( | ) |
Definition at line 61 of file canvas_context_menu.cc.
References global_items_, and usage_specific_items_.
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 | ||
) |
Definition at line 66 of file canvas_context_menu.cc.
References current_usage_, enable_context_menu_, enabled_, global_items_, RenderBitmapOperationsMenu(), RenderBppOperationsMenu(), RenderCanvasPropertiesMenu(), RenderGridControlsMenu(), RenderMenuSection(), RenderPaletteOperationsMenu(), RenderPerformanceMenu(), RenderScalingControlsMenu(), RenderUsageSpecificMenu(), RenderViewControlsMenu(), and usage_specific_items_.
bool yaze::gui::canvas::CanvasContextMenu::ShouldShowContextMenu | ( | ) | const |
Definition at line 131 of file canvas_context_menu.cc.
References enable_context_menu_, and enabled_.
|
inline |
Definition at line 78 of file canvas_context_menu.h.
References enabled_.
|
inline |
Definition at line 79 of file canvas_context_menu.h.
References enabled_.
|
inline |
Definition at line 80 of file canvas_context_menu.h.
References current_usage_.
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 | ||
) |
Definition at line 135 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 357 of file canvas_context_menu.cc.
References palette_editor_.
|
private |
Definition at line 159 of file canvas_context_menu.cc.
References yaze::gui::canvas::CanvasContextMenu::ContextMenuItem::callback, yaze::gui::canvas::CanvasContextMenu::ContextMenuItem::enabled_condition, yaze::gui::canvas::CanvasContextMenu::ContextMenuItem::label, RenderMenuItem(), yaze::gui::canvas::CanvasContextMenu::ContextMenuItem::separator_after, yaze::gui::canvas::CanvasContextMenu::ContextMenuItem::shortcut, yaze::gui::canvas::CanvasContextMenu::ContextMenuItem::subitems, and yaze::gui::canvas::CanvasContextMenu::ContextMenuItem::visible_condition.
Referenced by RenderMenuItem(), RenderMenuSection(), and RenderUsageSpecificMenu().
|
private |
Definition at line 193 of file canvas_context_menu.cc.
References RenderMenuItem().
Referenced by Render().
|
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().
|
private |
Definition at line 220 of file canvas_context_menu.cc.
References yaze::gui::canvas::CanvasConfig::enable_custom_labels, enable_custom_labels_, yaze::gui::canvas::CanvasConfig::enable_grid, enable_grid_, yaze::gui::canvas::CanvasConfig::enable_hex_labels, enable_hex_labels_, yaze::gui::canvas::CanvasConfig::global_scale, kResetView, kSetScale, kToggleCustomLabels, kToggleGrid, kToggleHexLabels, and kZoomToFit.
Referenced by Render().
|
private |
Definition at line 260 of file canvas_context_menu.cc.
References yaze::gui::canvas::CanvasConfig::auto_resize, auto_resize_, yaze::gui::canvas::CanvasConfig::canvas_size, canvas_size_, yaze::gui::canvas::CanvasConfig::content_size, content_size_, yaze::gui::canvas::CanvasConfig::enable_context_menu, enable_context_menu_, yaze::gui::canvas::CanvasConfig::enable_custom_labels, enable_custom_labels_, yaze::gui::canvas::CanvasConfig::enable_grid, enable_grid_, yaze::gui::canvas::CanvasConfig::enable_hex_labels, enable_hex_labels_, global_scale_, yaze::gui::canvas::CanvasConfig::grid_step, grid_step_, ICON_MD_SETTINGS, yaze::gui::canvas::CanvasConfig::is_draggable, is_draggable_, kOpenAdvancedProperties, yaze::gui::canvas::CanvasConfig::scrolling, and scrolling_.
Referenced by Render().
|
private |
Definition at line 289 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 323 of file canvas_context_menu.cc.
References yaze::gui::DisplayEditablePalette(), edit_palette_group_name_index_, edit_palette_index_, ICON_MD_PALETTE, yaze::gfx::Bitmap::mutable_palette(), and palette_editor_.
Referenced by Render().
|
private |
Definition at line 363 of file canvas_context_menu.cc.
References ICON_MD_SWAP_HORIZ.
Referenced by Render().
|
private |
Definition at line 379 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 399 of file canvas_context_menu.cc.
References yaze::gui::canvas::CanvasConfig::grid_step, grid_step_, ICON_MD_GRID_ON, and kSetGridStep.
Referenced by Render().
|
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().
|
private |
Definition at line 444 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 461 of file canvas_context_menu.cc.
References yaze::gui::canvas::kBitmapEditing, yaze::gui::canvas::kBppConversion, yaze::gui::canvas::kColorPainting, yaze::gui::canvas::kPaletteEditing, yaze::gui::canvas::kPerformanceMode, yaze::gui::canvas::kSelectRectangle, yaze::gui::canvas::kTilePainting, yaze::gui::canvas::kTileSelecting, and yaze::gui::canvas::kUnknown.
Referenced by RenderUsageSpecificMenu().
|
private |
Definition at line 476 of file canvas_context_menu.cc.
References yaze::gui::canvas::kBitmapEditing, yaze::gui::canvas::kBppConversion, yaze::gui::canvas::kColorPainting, yaze::gui::canvas::kPaletteEditing, yaze::gui::canvas::kPerformanceMode, yaze::gui::canvas::kSelectRectangle, yaze::gui::canvas::kTilePainting, yaze::gui::canvas::kTileSelecting, and yaze::gui::canvas::kUnknown.
Referenced by RenderUsageSpecificMenu().
|
private |
Definition at line 491 of file canvas_context_menu.cc.
References yaze::gui::canvas::kBitmapEditing, yaze::gui::canvas::kBppConversion, yaze::gui::canvas::kColorPainting, yaze::gui::canvas::kPaletteEditing, yaze::gui::canvas::kPerformanceMode, yaze::gui::canvas::kSelectRectangle, yaze::gui::canvas::kTilePainting, yaze::gui::canvas::kTileSelecting, and usage_specific_items_.
Referenced by Initialize().
|
private |
Definition at line 543 of file canvas_context_menu.cc.
|
private |
Definition at line 549 of file canvas_context_menu.cc.
|
private |
Definition at line 555 of file canvas_context_menu.cc.
|
private |
Definition at line 561 of file canvas_context_menu.cc.
|
private |
Definition at line 567 of file canvas_context_menu.cc.
|
private |
Definition at line 95 of file canvas_context_menu.h.
Referenced by Initialize().
|
private |
Definition at line 96 of file canvas_context_menu.h.
Referenced by Initialize(), IsEnabled(), Render(), SetEnabled(), and ShouldShowContextMenu().
|
private |
Definition at line 97 of file canvas_context_menu.h.
Referenced by GetUsageMode(), Initialize(), Render(), RenderUsageSpecificMenu(), and SetUsageMode().
|
private |
Definition at line 99 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 100 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 101 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 102 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), RenderGridControlsMenu(), and SetCanvasState().
|
private |
Definition at line 103 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), RenderViewControlsMenu(), and SetCanvasState().
|
private |
Definition at line 104 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), RenderViewControlsMenu(), and SetCanvasState().
|
private |
Definition at line 105 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), RenderViewControlsMenu(), and SetCanvasState().
|
private |
Definition at line 106 of file canvas_context_menu.h.
Referenced by Initialize(), Render(), RenderCanvasPropertiesMenu(), SetCanvasState(), and ShouldShowContextMenu().
|
private |
Definition at line 107 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 108 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 109 of file canvas_context_menu.h.
Referenced by Initialize(), RenderCanvasPropertiesMenu(), and SetCanvasState().
|
private |
Definition at line 111 of file canvas_context_menu.h.
Referenced by DrawROMPaletteSelector(), Initialize(), and RenderPaletteOperationsMenu().
|
private |
Definition at line 112 of file canvas_context_menu.h.
Referenced by RenderPaletteOperationsMenu().
|
private |
Definition at line 113 of file canvas_context_menu.h.
Referenced by RenderPaletteOperationsMenu().
|
private |
Definition at line 114 of file canvas_context_menu.h.
|
private |
Definition at line 115 of file canvas_context_menu.h.
|
private |
Definition at line 119 of file canvas_context_menu.h.
Referenced by AddMenuItem(), ClearMenuItems(), CreateDefaultMenuItems(), Render(), and RenderUsageSpecificMenu().
|
private |
Definition at line 120 of file canvas_context_menu.h.
Referenced by AddMenuItem(), ClearMenuItems(), and Render().