![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
#include <CustomCanvasEditor.h>
Inheritance diagram for Olympe::CustomCanvasEditor:
Collaboration diagram for Olympe::CustomCanvasEditor:Private Member Functions | |
| void | UpdateInputState () |
| Update pan/zoom from current frame input. | |
| void | HandlePanning () |
| Handle middle-mouse panning. | |
| void | HandleZooming () |
| Handle scroll wheel zooming. | |
| float | ClampZoom (float zoom) const |
| Clamp zoom to valid range. | |
Private Attributes | |
| std::string | m_name |
| ImVec2 | m_canvasScreenPos |
| ImVec2 | m_canvasSize |
| ImVec2 | m_canvasOffset |
| float | m_canvasZoom |
| float | m_minZoom |
| float | m_maxZoom |
| bool | m_gridVisible |
| std::unique_ptr< CanvasMinimapRenderer > | m_minimapRenderer |
| ImVec2 | m_lastMousePos |
| bool | m_isPanning |
| bool | m_middleMousePanEnabled |
| bool | m_scrollZoomEnabled |
| float | m_scrollZoomSpeed |
Definition at line 36 of file CustomCanvasEditor.h.
| Olympe::CustomCanvasEditor::CustomCanvasEditor | ( | const char * | name, |
| ImVec2 | canvasScreenPos, | ||
| ImVec2 | canvasSize, | ||
| float | initialZoom = 1.0f, |
||
| float | minZoom = 0.1f, |
||
| float | maxZoom = 3.0f |
||
| ) |
Construct custom canvas editor with zoom support.
| name | Identifier for this editor (e.g., "ComponentCanvas") |
| canvasScreenPos | Top-left corner of canvas on screen (pixels) |
| canvasSize | Width/height of canvas area (pixels) |
| initialZoom | Initial zoom level (default 1.0f) |
| minZoom | Minimum zoom allowed (default 0.1f) |
| maxZoom | Maximum zoom allowed (default 3.0f) |
Definition at line 11 of file CustomCanvasEditor.cpp.
References ClampZoom(), and m_canvasZoom.
Here is the call graph for this function:
|
virtualdefault |
|
overridevirtual |
Begin rendering cycle.
Updates pan/zoom from input (mouse/scroll)
Implements Olympe::ICanvasEditor.
Definition at line 41 of file CustomCanvasEditor.cpp.
References UpdateInputState().
Here is the call graph for this function:Transform canvas space to screen space.
Includes zoom scaling: screen = canvas * zoom + pan + canvasScreenPos
Implements Olympe::ICanvasEditor.
Definition at line 66 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), m_canvasOffset, m_canvasScreenPos, and m_canvasZoom.
Here is the call graph for this function:Clamp zoom to valid range.
| zoom | Value to clamp |
Definition at line 123 of file CustomCanvasEditor.cpp.
References m_maxZoom, and m_minZoom.
Referenced by CustomCanvasEditor(), and SetZoom().
Here is the caller graph for this function:Transform editor space to grid space.
Grid space removes pan offset (but keeps zoom): grid = editor - pan
Implements Olympe::ICanvasEditor.
Definition at line 75 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), and m_canvasOffset.
Here is the call graph for this function:
|
overridevirtual |
End rendering cycle.
Finalizes input state for frame
Implements Olympe::ICanvasEditor.
Definition at line 47 of file CustomCanvasEditor.cpp.
Get canvas name.
Implements Olympe::ICanvasEditor.
Definition at line 266 of file CustomCanvasEditor.h.
References m_name.
Get canvas screen position.
Implements Olympe::ICanvasEditor.
Definition at line 218 of file CustomCanvasEditor.h.
References m_canvasScreenPos.
Get canvas size.
Implements Olympe::ICanvasEditor.
Definition at line 224 of file CustomCanvasEditor.h.
References m_canvasSize.
|
overridevirtual |
Get canvas visible bounds in canvas space.
| outMin | Top-left corner |
| outMax | Bottom-right corner |
Implements Olympe::ICanvasEditor.
Definition at line 176 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), m_canvasScreenPos, m_canvasSize, and ScreenToCanvas().
Here is the call graph for this function:
|
overridevirtual |
Get current grid configuration.
Implements Olympe::ICanvasEditor.
Definition at line 134 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), Olympe::CanvasGridRenderer::GetStylePreset(), m_canvasOffset, m_canvasScreenPos, m_canvasSize, m_canvasZoom, and Olympe::CanvasGridRenderer::Style_VisualScript.
Here is the call graph for this function:
|
overridevirtual |
Get minimap position.
Implements Olympe::ICanvasEditor.
Definition at line 258 of file CustomCanvasEditor.cpp.
References m_minimapRenderer.
|
overridevirtual |
Get minimap size ratio.
Implements Olympe::ICanvasEditor.
Definition at line 243 of file CustomCanvasEditor.cpp.
References m_minimapRenderer.
Get current pan offset.
Implements Olympe::ICanvasEditor.
Definition at line 115 of file CustomCanvasEditor.h.
References m_canvasOffset.
Get current zoom level.
Implements Olympe::ICanvasEditor.
Definition at line 144 of file CustomCanvasEditor.h.
References m_canvasZoom.
Get zoom limits.
Implements Olympe::ICanvasEditor.
Definition at line 166 of file CustomCanvasEditor.h.
References GetComponentTypeID_Static(), m_maxZoom, and m_minZoom.
Here is the call graph for this function:Transform grid space to editor space.
Adds pan offset back (keeps zoom): editor = grid + pan
Implements Olympe::ICanvasEditor.
Definition at line 81 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), and m_canvasOffset.
Here is the call graph for this function:
|
private |
Handle middle-mouse panning.
Definition at line 318 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), m_canvasOffset, m_isPanning, and m_lastMousePos.
Referenced by UpdateInputState().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Handle scroll wheel zooming.
Definition at line 341 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), m_scrollZoomSpeed, and ZoomBy().
Referenced by UpdateInputState().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Check if canvas is hovered.
Implements Olympe::ICanvasEditor.
Definition at line 199 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), and IsPointInCanvas().
Here is the call graph for this function:Check if grid is visible.
Implements Olympe::ICanvasEditor.
Definition at line 208 of file CustomCanvasEditor.h.
References m_gridVisible.
|
overridevirtual |
Check if minimap is visible.
Implements Olympe::ICanvasEditor.
Definition at line 232 of file CustomCanvasEditor.cpp.
References m_minimapRenderer.
Check if point is in canvas.
| screenPos | Position in screen space |
Implements Olympe::ICanvasEditor.
Definition at line 187 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), m_canvasScreenPos, and m_canvasSize.
Referenced by IsCanvasHovered(), and UpdateInputState().
Here is the call graph for this function:
Here is the caller graph for this function:Pan by delta.
Implements Olympe::ICanvasEditor.
Definition at line 126 of file CustomCanvasEditor.h.
References GetComponentTypeID_Static(), and m_canvasOffset.
Here is the call graph for this function:
|
overridevirtual |
Render grid.
| preset | Style preset |
Implements Olympe::ICanvasEditor.
Definition at line 150 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), Olympe::CanvasGridRenderer::GetStylePreset(), m_canvasOffset, m_canvasScreenPos, m_canvasSize, m_canvasZoom, m_gridVisible, and Olympe::CanvasGridRenderer::RenderGrid().
Here is the call graph for this function:
|
overridevirtual |
Render minimap overlay for custom canvas.
Uses CanvasMinimapRenderer for unified appearance
Implements Olympe::ICanvasEditor.
Definition at line 217 of file CustomCanvasEditor.cpp.
References m_canvasScreenPos, m_canvasSize, and m_minimapRenderer.
Reset pan to origin.
Implements Olympe::ICanvasEditor.
Definition at line 134 of file CustomCanvasEditor.h.
References GetComponentTypeID_Static(), and m_canvasOffset.
Referenced by ResetView().
Here is the call graph for this function:
Here is the caller graph for this function:Reset view (pan and zoom)
Implements Olympe::ICanvasEditor.
Definition at line 176 of file CustomCanvasEditor.h.
References ResetPan(), and ResetZoom().
Here is the call graph for this function:Reset zoom to 1.0x.
Implements Olympe::ICanvasEditor.
Definition at line 171 of file CustomCanvasEditor.h.
References m_canvasZoom.
Referenced by ResetView().
Here is the caller graph for this function:Transform screen space to canvas space.
Includes zoom scaling: canvas = (screen - canvasScreenPos - pan) / zoom
Implements Olympe::ICanvasEditor.
Definition at line 57 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), m_canvasOffset, m_canvasScreenPos, and m_canvasZoom.
Referenced by GetCanvasVisibleBounds().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineoverridevirtual |
Set canvas screen position (updates each frame)
| screenPos | New screen position |
Implements Olympe::ICanvasEditor.
Definition at line 230 of file CustomCanvasEditor.h.
References GetComponentTypeID_Static(), and m_canvasScreenPos.
Here is the call graph for this function:Set canvas size (updates each frame)
| size | New canvas size |
Implements Olympe::ICanvasEditor.
Definition at line 236 of file CustomCanvasEditor.h.
References m_canvasSize.
Set grid visibility.
| enabled | True to show grid |
Implements Olympe::ICanvasEditor.
Definition at line 167 of file CustomCanvasEditor.cpp.
References m_gridVisible.
Enable/disable middle-mouse panning.
| enabled | True to allow pan via middle mouse |
Definition at line 342 of file CustomCanvasEditor.h.
References m_middleMousePanEnabled.
Set minimap position (corner)
| position | Position enum (0=TopLeft, 1=TopRight, 2=BottomLeft, 3=BottomRight) |
Implements Olympe::ICanvasEditor.
Definition at line 248 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), and m_minimapRenderer.
Here is the call graph for this function:Set minimap size ratio.
| scale | Size ratio (0.05 - 0.5) |
Implements Olympe::ICanvasEditor.
Definition at line 237 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), and m_minimapRenderer.
Here is the call graph for this function:Enable/disable minimap.
| enabled | True to show minimap |
Implements Olympe::ICanvasEditor.
Definition at line 226 of file CustomCanvasEditor.cpp.
References m_minimapRenderer.
Set pan offset directly.
| offset | New pan offset |
Implements Olympe::ICanvasEditor.
Definition at line 121 of file CustomCanvasEditor.h.
References GetComponentTypeID_Static(), and m_canvasOffset.
Here is the call graph for this function:Enable/disable scroll wheel zooming.
| enabled | True to allow zoom via scroll wheel |
Definition at line 349 of file CustomCanvasEditor.h.
References m_scrollZoomEnabled.
Set scroll zoom speed (multiplier)
| speed | Zoom factor per scroll notch (default 1.1) |
Definition at line 356 of file CustomCanvasEditor.h.
References m_scrollZoomSpeed.
|
overridevirtual |
Set zoom level directly.
| scale | New zoom scale (clamped to min/max) |
| zoomCenter | Optional screen-space point to maintain visual position during zoom |
If zoomCenter is provided, adjusts pan so that the point at zoomCenter maintains its visual position on screen after zoom changes.
Implements Olympe::ICanvasEditor.
Definition at line 91 of file CustomCanvasEditor.cpp.
References ClampZoom(), GetComponentTypeID_Static(), m_canvasOffset, m_canvasScreenPos, and m_canvasZoom.
Referenced by ZoomBy().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Update pan/zoom from current frame input.
Called in BeginRender()
Definition at line 284 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), HandlePanning(), HandleZooming(), IsPointInCanvas(), m_isPanning, m_lastMousePos, m_middleMousePanEnabled, and m_scrollZoomEnabled.
Referenced by BeginRender().
Here is the call graph for this function:
Here is the caller graph for this function:
|
virtual |
Update minimap with current graph data.
| nodes | Vector of (nodeId, posX, posY, width, height) tuples |
| graphMinX | Graph bounds left |
| graphMaxX | Graph bounds right |
| graphMinY | Graph bounds top |
| graphMaxY | Graph bounds bottom |
Implements Olympe::ICanvasEditor.
Definition at line 263 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), and m_minimapRenderer.
Here is the call graph for this function:
|
virtual |
Update minimap viewport from visible canvas area.
Implements Olympe::ICanvasEditor.
Definition at line 271 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), and m_minimapRenderer.
Here is the call graph for this function:
|
overridevirtual |
Zoom by multiplier.
| factor | Zoom factor (1.1 = 10% zoom in, 0.9 = 10% zoom out) |
| zoomCenter | Optional screen-space point to maintain visual position |
Implements Olympe::ICanvasEditor.
Definition at line 118 of file CustomCanvasEditor.cpp.
References GetComponentTypeID_Static(), m_canvasZoom, and SetZoom().
Referenced by HandleZooming().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 365 of file CustomCanvasEditor.h.
Referenced by CanvasToScreen(), EditorToGrid(), GetGridConfig(), GetPan(), GridToEditor(), HandlePanning(), PanBy(), RenderGrid(), ResetPan(), ScreenToCanvas(), SetPan(), and SetZoom().
|
private |
Definition at line 361 of file CustomCanvasEditor.h.
Referenced by CanvasToScreen(), GetCanvasScreenPos(), GetCanvasVisibleBounds(), GetGridConfig(), IsPointInCanvas(), RenderGrid(), RenderMinimap(), ScreenToCanvas(), SetCanvasScreenPos(), and SetZoom().
|
private |
Definition at line 362 of file CustomCanvasEditor.h.
Referenced by GetCanvasSize(), GetCanvasVisibleBounds(), GetGridConfig(), IsPointInCanvas(), RenderGrid(), RenderMinimap(), and SetCanvasSize().
|
private |
Definition at line 366 of file CustomCanvasEditor.h.
Referenced by CanvasToScreen(), CustomCanvasEditor(), GetGridConfig(), GetZoom(), RenderGrid(), ResetZoom(), ScreenToCanvas(), SetZoom(), and ZoomBy().
|
private |
Definition at line 371 of file CustomCanvasEditor.h.
Referenced by IsGridVisible(), RenderGrid(), and SetGridVisible().
|
private |
Definition at line 378 of file CustomCanvasEditor.h.
Referenced by HandlePanning(), and UpdateInputState().
|
private |
Definition at line 377 of file CustomCanvasEditor.h.
Referenced by HandlePanning(), and UpdateInputState().
|
private |
Definition at line 368 of file CustomCanvasEditor.h.
Referenced by ClampZoom(), and GetZoomLimits().
|
private |
Definition at line 379 of file CustomCanvasEditor.h.
Referenced by SetMiddleMousePanEnabled(), and UpdateInputState().
|
private |
Definition at line 374 of file CustomCanvasEditor.h.
Referenced by GetMinimapPosition(), GetMinimapSize(), IsMinimapVisible(), RenderMinimap(), SetMinimapPosition(), SetMinimapSize(), SetMinimapVisible(), UpdateMinimapNodes(), and UpdateMinimapViewport().
|
private |
Definition at line 367 of file CustomCanvasEditor.h.
Referenced by ClampZoom(), and GetZoomLimits().
|
private |
Definition at line 360 of file CustomCanvasEditor.h.
Referenced by GetCanvasName().
|
private |
Definition at line 380 of file CustomCanvasEditor.h.
Referenced by SetScrollZoomEnabled(), and UpdateInputState().
|
private |
Definition at line 381 of file CustomCanvasEditor.h.
Referenced by HandleZooming(), and SetScrollZoomSpeed().