#include <canvas_navigation_manager.h>

Public Member Functions | |
| CanvasNavigationManager ()=default | |
| void | Initialize (const CanvasNavigationContext &context, const CanvasNavigationCallbacks &callbacks) |
| Initialize with shared state and callbacks. | |
| absl::Status | CheckForCurrentMap () |
| Detect which map the mouse is over, trigger lazy loading, draw the selection outline, and refresh textures if modified. | |
| std::optional< int > | TrackMapAtCanvasPosition (ImVec2 scaled_position) |
| void | HandleMapInteraction () |
| Click selection (see IsMapSelectClick) and double-click to open properties. The paint-tool right-click sample itself happens in TilePaintingManager. Middle-drag only pans. | |
| bool | SelectMapUnderCursor () |
| Make the map under the cursor the current map, ignoring the pin (the pin, if on, then holds this map). Large areas: any quadrant selects its parent area's properties. Returns false when no map is under it. | |
| void | BeginCanvasViewport () |
| void | EndCanvasViewport (bool canvas_item_hovered) |
| void | ZoomIn () |
| Increase canvas zoom by one step, keeping the view center fixed. | |
| void | ZoomOut () |
| Decrease canvas zoom by one step, keeping the view center fixed. | |
| void | ZoomToFit () |
| Scale so the whole current world fits the viewport. | |
| void | ResetOverworldView () |
| Reset scroll to top-left and scale to 1.0. | |
| void | CenterOverworldView () |
| Center the viewport on the current map. | |
| void | CenterOnMap (int map_id) |
Center the viewport on map_id (same world grid). | |
| void | CenterOnWorldTile (int world_x, int world_y) |
| bool | is_panning () const |
| void | SuspendHoverFollowUntilMouseMoves () |
| void | ScrollBlocksetCanvasToCurrentTile () |
| Scroll the blockset (tile16 selector) to show the currently selected tile16. | |
| void | UpdateBlocksetSelectorState () |
| Push current tile count and selection into the blockset widget. | |
| void | QueueAdjacentMapsForPreload (int center_map) |
Queue the 4-connected neighbors of center_map for lazy build. | |
| void | ProcessPreloadQueue () |
| Process one map from the preload queue (call once per frame). | |
Private Member Functions | |
| std::optional< int > | MapUnderCursor () const |
| void | ZoomBySteps (int steps, ImVec2 anchor) |
| void | SetScaleAboutAnchor (float new_scale, ImVec2 anchor) |
| ImVec2 | ClampScroll (ImVec2 scroll) const |
| ImVec2 | ContentSize () const |
Private Attributes | |
| CanvasNavigationContext | ctx_ |
| CanvasNavigationCallbacks | callbacks_ |
| double | left_press_time_ = -1.0 |
| std::optional< int > | left_press_map_ |
| int | last_hovered_map_ = -1 |
| float | hover_time_ = 0.0f |
| std::vector< int > | preload_queue_ |
| ImVec2 | viewport_min_ {0.0f, 0.0f} |
| ImVec2 | viewport_size_ {0.0f, 0.0f} |
| ImVec2 | last_scroll_ {0.0f, 0.0f} |
| bool | canvas_item_hovered_ = false |
| bool | canvas_window_hovered_ = false |
| bool | viewport_known_ = false |
| std::optional< ImVec2 > | hover_follow_suspended_at_ |
| std::optional< ImVec2 > | pending_scroll_ |
| std::optional< int > | pending_center_map_ |
| StickyWheelPan | wheel_pan_ |
| float | zoom_residual_ = 0.0f |
| float | zoom_idle_seconds_ = 0.0f |
| int | pan_button_ = -1 |
| bool | pan_active_ = false |
| ImVec2 | pan_anchor_mouse_ {0.0f, 0.0f} |
| ImVec2 | pan_anchor_scroll_ {0.0f, 0.0f} |
Static Private Attributes | |
| static constexpr float | kHoverBuildDelay = 0.15f |
| static constexpr float | kPreloadStartDelay = 0.3f |
Definition at line 126 of file canvas_navigation_manager.h.
|
default |
| void yaze::editor::CanvasNavigationManager::Initialize | ( | const CanvasNavigationContext & | context, |
| const CanvasNavigationCallbacks & | callbacks ) |
Initialize with shared state and callbacks.
Definition at line 90 of file canvas_navigation_manager.cc.
References callbacks_, and ctx_.
| absl::Status yaze::editor::CanvasNavigationManager::CheckForCurrentMap | ( | ) |
Detect which map the mouse is over, trigger lazy loading, draw the selection outline, and refresh textures if modified.
Definition at line 122 of file canvas_navigation_manager.cc.
References yaze::gfx::Tilemap::atlas, callbacks_, ctx_, yaze::editor::CanvasNavigationContext::current_map, yaze::editor::CanvasNavigationContext::current_map_lock, yaze::editor::CanvasNavigationContext::current_mode, yaze::editor::CanvasNavigationContext::current_parent, yaze::editor::CanvasNavigationContext::current_world, yaze::gui::Canvas::DrawOutline(), yaze::editor::CanvasNavigationCallbacks::ensure_map_texture, yaze::zelda3::Overworld::EnsureMapBuilt(), yaze::editor::FormatOverworldMapStatusSegment(), yaze::gfx::Arena::Get(), yaze::zelda3::OverworldVersionHelper::GetVersion(), yaze::gui::Canvas::hover_mouse_pos(), hover_time_, yaze::zelda3::Overworld::inspected_map_count(), yaze::gfx::Bitmap::is_active(), yaze::gui::Canvas::IsMouseHovering(), kHoverBuildDelay, yaze::editor::kOverworldMapSize, kPreloadStartDelay, last_hovered_map_, yaze::editor::CanvasNavigationContext::maps_bmp, yaze::editor::CanvasNavigationContext::overworld, yaze::zelda3::Overworld::overworld_map(), yaze::editor::CanvasNavigationContext::ow_map_canvas, preload_queue_, ProcessPreloadQueue(), QueueAdjacentMapsForPreload(), yaze::gfx::Arena::QueueTextureCommand(), yaze::editor::CanvasNavigationCallbacks::refresh_overworld_map, yaze::editor::CanvasNavigationCallbacks::refresh_tile16_blockset, RETURN_IF_ERROR, yaze::editor::CanvasNavigationContext::rom, yaze::zelda3::OverworldVersionHelper::SupportsAreaEnum(), yaze::editor::CanvasNavigationContext::tile16_blockset, TrackMapAtCanvasPosition(), and yaze::gfx::Arena::UPDATE.
| std::optional< int > yaze::editor::CanvasNavigationManager::TrackMapAtCanvasPosition | ( | ImVec2 | scaled_position | ) |
Definition at line 101 of file canvas_navigation_manager.cc.
References callbacks_, ctx_, yaze::editor::CanvasNavigationContext::current_map, yaze::editor::CanvasNavigationContext::current_map_lock, hover_follow_suspended_at_, and yaze::editor::CanvasNavigationContext::is_dragging_entity.
Referenced by CheckForCurrentMap().
| void yaze::editor::CanvasNavigationManager::HandleMapInteraction | ( | ) |
Click selection (see IsMapSelectClick) and double-click to open properties. The paint-tool right-click sample itself happens in TilePaintingManager. Middle-drag only pans.
Definition at line 352 of file canvas_navigation_manager.cc.
References callbacks_, ctx_, yaze::editor::CanvasNavigationContext::current_map, yaze::editor::CanvasNavigationContext::current_map_lock, yaze::editor::CanvasNavigationContext::current_mode, yaze::editor::MapClickInput::entity_hovered, yaze::editor::CanvasNavigationCallbacks::is_entity_hovered, yaze::editor::IsMapSelectClick(), yaze::gui::Canvas::IsMouseHovering(), yaze::editor::MapClickInput::left_dragged, left_press_map_, yaze::editor::MapClickInput::left_press_owned, left_press_time_, yaze::editor::MapClickInput::left_released, MapUnderCursor(), yaze::editor::MapClickInput::mode, yaze::editor::MOUSE, yaze::editor::CanvasNavigationCallbacks::open_map_properties, yaze::editor::CanvasNavigationContext::ow_map_canvas, yaze::editor::MapClickInput::right_clicked, SelectMapUnderCursor(), and yaze::editor::MapClickInput::shift.

| bool yaze::editor::CanvasNavigationManager::SelectMapUnderCursor | ( | ) |
Make the map under the cursor the current map, ignoring the pin (the pin, if on, then holds this map). Large areas: any quadrant selects its parent area's properties. Returns false when no map is under it.
Definition at line 338 of file canvas_navigation_manager.cc.
References callbacks_, ctx_, yaze::editor::CanvasNavigationContext::current_map, MapUnderCursor(), and yaze::editor::CanvasNavigationContext::ow_map_canvas.
Referenced by HandleMapInteraction().

| void yaze::editor::CanvasNavigationManager::BeginCanvasViewport | ( | ) |
Definition at line 490 of file canvas_navigation_manager.cc.
References callbacks_, canvas_item_hovered_, canvas_window_hovered_, ClampScroll(), yaze::editor::StickyWheelPan::Consume(), ContentSize(), ctx_, yaze::editor::CanvasNavigationContext::current_mode, yaze::gui::Canvas::global_scale(), yaze::editor::CanvasNavigationContext::is_dragging_entity, yaze::editor::CanvasNavigationCallbacks::is_entity_hovered, yaze::gui::IsMacPlatform(), yaze::editor::kOverworldPanSnapMapPx, yaze::editor::kOverworldWheelIdleResetSec, yaze::editor::kOverworldWheelPanPx, yaze::editor::kOverworldWheelZoomUnitsPerStep, last_scroll_, yaze::editor::MOUSE, yaze::editor::CanvasNavigationContext::ow_map_canvas, pan_active_, pan_anchor_mouse_, pan_anchor_scroll_, pan_button_, pending_scroll_, viewport_known_, viewport_min_, wheel_pan_, zoom_idle_seconds_, zoom_residual_, and ZoomBySteps().
| void yaze::editor::CanvasNavigationManager::EndCanvasViewport | ( | bool | canvas_item_hovered | ) |
Definition at line 595 of file canvas_navigation_manager.cc.
References canvas_item_hovered_, canvas_window_hovered_, CenterOnMap(), last_scroll_, pending_center_map_, viewport_known_, viewport_min_, and viewport_size_.

| void yaze::editor::CanvasNavigationManager::ZoomIn | ( | ) |
Increase canvas zoom by one step, keeping the view center fixed.
Definition at line 625 of file canvas_navigation_manager.cc.
References viewport_size_, and ZoomBySteps().

| void yaze::editor::CanvasNavigationManager::ZoomOut | ( | ) |
Decrease canvas zoom by one step, keeping the view center fixed.
Definition at line 629 of file canvas_navigation_manager.cc.
References viewport_size_, and ZoomBySteps().

| void yaze::editor::CanvasNavigationManager::ZoomToFit | ( | ) |
Scale so the whole current world fits the viewport.
Definition at line 633 of file canvas_navigation_manager.cc.
References ctx_, yaze::editor::CanvasNavigationContext::current_world, yaze::zelda3::Overworld::is_lyra_preview(), yaze::editor::kOverworldMapSize, yaze::editor::kOverworldMaxZoom, yaze::editor::kOverworldMinZoom, yaze::editor::CanvasNavigationContext::overworld, yaze::editor::CanvasNavigationContext::ow_map_canvas, pending_scroll_, yaze::gui::Canvas::set_global_scale(), viewport_known_, and viewport_size_.

| void yaze::editor::CanvasNavigationManager::ResetOverworldView | ( | ) |
Reset scroll to top-left and scale to 1.0.
Definition at line 650 of file canvas_navigation_manager.cc.
References ctx_, yaze::editor::CanvasNavigationContext::ow_map_canvas, pending_center_map_, pending_scroll_, and yaze::gui::Canvas::set_global_scale().

| void yaze::editor::CanvasNavigationManager::CenterOverworldView | ( | ) |
Center the viewport on the current map.
Definition at line 658 of file canvas_navigation_manager.cc.
References CenterOnMap(), ctx_, and yaze::editor::CanvasNavigationContext::current_map.

| void yaze::editor::CanvasNavigationManager::CenterOnMap | ( | int | map_id | ) |
Center the viewport on map_id (same world grid).
Definition at line 664 of file canvas_navigation_manager.cc.
References ctx_, yaze::gui::Canvas::global_scale(), yaze::zelda3::Overworld::inspected_map_count(), yaze::zelda3::kNumOverworldMaps, yaze::editor::kOverworldMapSize, yaze::editor::CanvasNavigationContext::overworld, yaze::editor::CanvasNavigationContext::ow_map_canvas, pending_center_map_, pending_scroll_, viewport_known_, and viewport_size_.
Referenced by CenterOverworldView(), and EndCanvasViewport().

| void yaze::editor::CanvasNavigationManager::CenterOnWorldTile | ( | int | world_x, |
| int | world_y ) |
Definition at line 690 of file canvas_navigation_manager.cc.
References ctx_, yaze::gui::Canvas::global_scale(), yaze::editor::CanvasNavigationContext::ow_map_canvas, pending_scroll_, viewport_known_, and viewport_size_.

|
inline |
Definition at line 195 of file canvas_navigation_manager.h.
References pan_active_.
| void yaze::editor::CanvasNavigationManager::SuspendHoverFollowUntilMouseMoves | ( | ) |
After keyboard map navigation: do not let the (unpinned) hover follow replace the keyboard choice until the mouse actually moves.
Definition at line 620 of file canvas_navigation_manager.cc.
References hover_follow_suspended_at_.
| void yaze::editor::CanvasNavigationManager::ScrollBlocksetCanvasToCurrentTile | ( | ) |
Scroll the blockset (tile16 selector) to show the currently selected tile16.
Definition at line 704 of file canvas_navigation_manager.cc.
References yaze::editor::CanvasNavigationContext::blockset_selector, ctx_, and yaze::editor::CanvasNavigationContext::current_tile16.
| void yaze::editor::CanvasNavigationManager::UpdateBlocksetSelectorState | ( | ) |
Push current tile count and selection into the blockset widget.
Definition at line 721 of file canvas_navigation_manager.cc.
References yaze::editor::CanvasNavigationContext::blockset_selector, ctx_, yaze::editor::CanvasNavigationContext::current_tile16, and yaze::zelda3::kNumTile16Individual.
| void yaze::editor::CanvasNavigationManager::QueueAdjacentMapsForPreload | ( | int | center_map | ) |
Queue the 4-connected neighbors of center_map for lazy build.
Definition at line 734 of file canvas_navigation_manager.cc.
References ctx_, yaze::zelda3::Overworld::inspected_map_count(), yaze::zelda3::Overworld::is_lyra_preview(), yaze::zelda3::kSpecialWorldMapIdStart, yaze::editor::CanvasNavigationContext::overworld, yaze::zelda3::Overworld::overworld_map(), and preload_queue_.
Referenced by CheckForCurrentMap().

| void yaze::editor::CanvasNavigationManager::ProcessPreloadQueue | ( | ) |
Process one map from the preload queue (call once per frame).
Definition at line 779 of file canvas_navigation_manager.cc.
References ctx_, yaze::zelda3::Overworld::EnsureMapBuilt(), LOG_DEBUG, yaze::editor::CanvasNavigationContext::overworld, and preload_queue_.
Referenced by CheckForCurrentMap().

|
private |
Definition at line 328 of file canvas_navigation_manager.cc.
References ctx_, yaze::gui::Canvas::hover_mouse_pos(), yaze::editor::CanvasNavigationContext::hovered_map, and yaze::editor::CanvasNavigationContext::ow_map_canvas.
Referenced by HandleMapInteraction(), and SelectMapUnderCursor().

|
private |
Definition at line 483 of file canvas_navigation_manager.cc.
References ctx_, yaze::gui::Canvas::global_scale(), yaze::editor::kOverworldZoomStep, yaze::editor::CanvasNavigationContext::ow_map_canvas, and SetScaleAboutAnchor().
Referenced by BeginCanvasViewport(), ZoomIn(), and ZoomOut().

|
private |
Definition at line 470 of file canvas_navigation_manager.cc.
References ctx_, yaze::gui::Canvas::global_scale(), yaze::editor::kOverworldMaxZoom, yaze::editor::kOverworldMinZoom, last_scroll_, yaze::editor::CanvasNavigationContext::ow_map_canvas, pending_scroll_, yaze::editor::ScrollForZoomAtAnchor(), and yaze::gui::Canvas::set_global_scale().
Referenced by ZoomBySteps().

|
private |
Definition at line 461 of file canvas_navigation_manager.cc.
References ContentSize(), and viewport_size_.
Referenced by BeginCanvasViewport().

|
private |
Definition at line 454 of file canvas_navigation_manager.cc.
References ctx_, yaze::gui::Canvas::global_scale(), yaze::editor::kOverworldMapSize, and yaze::editor::CanvasNavigationContext::ow_map_canvas.
Referenced by BeginCanvasViewport(), and ClampScroll().

|
private |
Definition at line 223 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), CenterOnMap(), CenterOnWorldTile(), CenterOverworldView(), CheckForCurrentMap(), ContentSize(), HandleMapInteraction(), Initialize(), MapUnderCursor(), ProcessPreloadQueue(), QueueAdjacentMapsForPreload(), ResetOverworldView(), ScrollBlocksetCanvasToCurrentTile(), SelectMapUnderCursor(), SetScaleAboutAnchor(), TrackMapAtCanvasPosition(), UpdateBlocksetSelectorState(), ZoomBySteps(), and ZoomToFit().
|
private |
Definition at line 224 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), CheckForCurrentMap(), HandleMapInteraction(), Initialize(), SelectMapUnderCursor(), and TrackMapAtCanvasPosition().
|
private |
Definition at line 231 of file canvas_navigation_manager.h.
Referenced by HandleMapInteraction().
|
private |
Definition at line 232 of file canvas_navigation_manager.h.
Referenced by HandleMapInteraction().
|
private |
Definition at line 235 of file canvas_navigation_manager.h.
Referenced by CheckForCurrentMap().
|
private |
Definition at line 236 of file canvas_navigation_manager.h.
Referenced by CheckForCurrentMap().
|
staticconstexprprivate |
Definition at line 237 of file canvas_navigation_manager.h.
Referenced by CheckForCurrentMap().
|
private |
Definition at line 240 of file canvas_navigation_manager.h.
Referenced by CheckForCurrentMap(), ProcessPreloadQueue(), and QueueAdjacentMapsForPreload().
|
staticconstexprprivate |
Definition at line 241 of file canvas_navigation_manager.h.
Referenced by CheckForCurrentMap().
|
private |
Definition at line 250 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), and EndCanvasViewport().
|
private |
Definition at line 251 of file canvas_navigation_manager.h.
Referenced by CenterOnMap(), CenterOnWorldTile(), ClampScroll(), EndCanvasViewport(), ZoomIn(), ZoomOut(), and ZoomToFit().
|
private |
Definition at line 252 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), EndCanvasViewport(), and SetScaleAboutAnchor().
|
private |
Definition at line 253 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), and EndCanvasViewport().
|
private |
Definition at line 254 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), and EndCanvasViewport().
|
private |
Definition at line 255 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), CenterOnMap(), CenterOnWorldTile(), EndCanvasViewport(), and ZoomToFit().
|
private |
Definition at line 257 of file canvas_navigation_manager.h.
Referenced by SuspendHoverFollowUntilMouseMoves(), and TrackMapAtCanvasPosition().
|
private |
Definition at line 260 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), CenterOnMap(), CenterOnWorldTile(), ResetOverworldView(), SetScaleAboutAnchor(), and ZoomToFit().
|
private |
Definition at line 261 of file canvas_navigation_manager.h.
Referenced by CenterOnMap(), EndCanvasViewport(), and ResetOverworldView().
|
private |
Definition at line 264 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport().
|
private |
Definition at line 265 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport().
|
private |
Definition at line 266 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport().
|
private |
Definition at line 269 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport().
|
private |
Definition at line 270 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport(), and is_panning().
|
private |
Definition at line 271 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport().
|
private |
Definition at line 272 of file canvas_navigation_manager.h.
Referenced by BeginCanvasViewport().