Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Olympe::ICanvasEditor Class Referenceabstract

Abstract interface for canvas editors with unified pan/zoom/grid management. More...

#include <ICanvasEditor.h>

+ Inheritance diagram for Olympe::ICanvasEditor:

Public Member Functions

virtual ~ICanvasEditor ()=default
 
virtual void BeginRender ()=0
 Begin rendering cycle for this canvas.
 
virtual void EndRender ()=0
 End rendering cycle for this canvas.
 
virtual ImVec2 ScreenToCanvas (const ImVec2 &screenPos) const =0
 Transform screen space coordinates to canvas space.
 
virtual ImVec2 CanvasToScreen (const ImVec2 &canvasPos) const =0
 Transform canvas space coordinates to screen space.
 
virtual ImVec2 EditorToGrid (const ImVec2 &editorPos) const =0
 Transform editor space to grid space.
 
virtual ImVec2 GridToEditor (const ImVec2 &gridPos) const =0
 Transform grid space to editor space.
 
virtual ImVec2 GetPan () const =0
 Get current pan offset.
 
virtual void SetPan (const ImVec2 &offset)=0
 Set pan offset directly.
 
virtual void PanBy (const ImVec2 &delta)=0
 Pan by delta amount.
 
virtual void ResetPan ()=0
 Reset pan to origin (0, 0)
 
virtual float GetZoom () const =0
 Get current zoom level.
 
virtual void SetZoom (float scale, const ImVec2 *zoomCenter=nullptr)=0
 Set zoom level directly.
 
virtual void ZoomBy (float factor, const ImVec2 *zoomCenter=nullptr)=0
 Zoom by multiplier.
 
virtual ImVec2 GetZoomLimits () const =0
 Get zoom limits (min, max)
 
virtual void ResetZoom ()=0
 Reset zoom to 1.0x.
 
virtual void ResetView ()=0
 Reset both pan and zoom to defaults.
 
virtual CanvasGridRenderer::GridConfig GetGridConfig () const =0
 Get current grid configuration.
 
virtual void RenderGrid (CanvasGridRenderer::GridStylePreset preset)=0
 Render grid using current configuration.
 
virtual void SetGridVisible (bool enabled)=0
 Enable/disable grid rendering.
 
virtual bool IsGridVisible () const =0
 Check if grid is visible.
 
virtual ImVec2 GetCanvasScreenPos () const =0
 Get canvas position on screen.
 
virtual ImVec2 GetCanvasSize () const =0
 Get canvas size in screen space.
 
virtual void SetCanvasScreenPos (const ImVec2 &screenPos)=0
 Set canvas screen position (call each frame to update)
 
virtual void SetCanvasSize (const ImVec2 &size)=0
 Set canvas size (call each frame to update)
 
virtual void GetCanvasVisibleBounds (ImVec2 &outMin, ImVec2 &outMax) const =0
 Get canvas visible area as AABB in canvas space.
 
virtual bool IsPointInCanvas (const ImVec2 &screenPos) const =0
 Check if point in screen space is within canvas bounds.
 
virtual bool IsCanvasHovered () const =0
 Check if canvas is being hovered by mouse.
 
virtual const charGetCanvasName () const =0
 Get the name/identifier of this canvas.
 
virtual void RenderMinimap ()=0
 Render minimap overlay.
 
virtual void SetMinimapVisible (bool enabled)=0
 Enable/disable minimap rendering.
 
virtual bool IsMinimapVisible () const =0
 Check if minimap is visible.
 
virtual void SetMinimapSize (float scale)=0
 Set minimap size scale.
 
virtual float GetMinimapSize () const =0
 Get minimap size scale.
 
virtual void SetMinimapPosition (int position)=0
 Set minimap position.
 
virtual int GetMinimapPosition () const =0
 Get minimap position.
 
virtual void UpdateMinimapNodes (const std::vector< std::tuple< int, float, float, float, float > > &nodes, float graphMinX, float graphMaxX, float graphMinY, float graphMaxY)=0
 Update minimap with current graph node data.
 
virtual void UpdateMinimapViewport (float viewMinX, float viewMaxX, float viewMinY, float viewMaxY, float graphMinX, float graphMaxX, float graphMinY, float graphMaxY)=0
 Update minimap with current viewport bounds.
 

Detailed Description

Abstract interface for canvas editors with unified pan/zoom/grid management.

Implementations:

Key contract:

  1. BeginRender() must be called once per frame at start of canvas rendering
  2. EndRender() must be called once per frame at end of canvas rendering
  3. All coordinate transformations maintain consistency across pan/zoom states
  4. Pan/zoom state is persistent across frames (for smooth interaction)

Definition at line 47 of file ICanvasEditor.h.

Constructor & Destructor Documentation

◆ ~ICanvasEditor()

virtual Olympe::ICanvasEditor::~ICanvasEditor ( )
virtualdefault

Member Function Documentation

◆ BeginRender()

virtual void Olympe::ICanvasEditor::BeginRender ( )
pure virtual

Begin rendering cycle for this canvas.

Must be called at the start of each frame's canvas rendering

  • Initializes draw state
  • Updates pan/zoom from input
  • Prepares coordinate systems

Implementations:

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ CanvasToScreen()

virtual ImVec2 Olympe::ICanvasEditor::CanvasToScreen ( const ImVec2 canvasPos) const
pure virtual

Transform canvas space coordinates to screen space.

Parameters
canvasPosCoordinates in canvas space (logical coordinates)
Returns
Coordinates in screen space (pixels on screen)

Inverse of ScreenToCanvas: screen = canvasPos * zoom + pan + canvasOrigin

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::CanvasToScreen().

+ Here is the caller graph for this function:

◆ EditorToGrid()

virtual ImVec2 Olympe::ICanvasEditor::EditorToGrid ( const ImVec2 editorPos) const
pure virtual

Transform editor space to grid space.

Parameters
editorPosCoordinates in editor space
Returns
Coordinates in grid space (pan-independent)

Grid space removes the pan offset, allowing positions to be stored pan-independently. Useful for serialization.

For imnodes: grid space = SetNodeGridSpacePos (pan-independent storage) For custom: grid space = editorPos - pan offset

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ EndRender()

virtual void Olympe::ICanvasEditor::EndRender ( )
pure virtual

End rendering cycle for this canvas.

Must be called at the end of each frame's canvas rendering

  • Finalizes draw state
  • Captures post-render input events (hover detection, selection, etc.)

Implementations:

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ GetCanvasName()

virtual const char * Olympe::ICanvasEditor::GetCanvasName ( ) const
pure virtual

Get the name/identifier of this canvas.

Returns
String identifier for debugging and logging

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ GetCanvasScreenPos()

virtual ImVec2 Olympe::ICanvasEditor::GetCanvasScreenPos ( ) const
pure virtual

Get canvas position on screen.

Returns
Top-left corner of canvas in screen space (pixels)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ GetCanvasSize()

virtual ImVec2 Olympe::ICanvasEditor::GetCanvasSize ( ) const
pure virtual

Get canvas size in screen space.

Returns
Width and height of canvas rendering area (pixels)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ GetCanvasVisibleBounds()

virtual void Olympe::ICanvasEditor::GetCanvasVisibleBounds ( ImVec2 outMin,
ImVec2 outMax 
) const
pure virtual

Get canvas visible area as AABB in canvas space.

Returns
{minCorner, maxCorner} in canvas logical coordinates

Useful for culling: which nodes are visible on screen?

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ GetGridConfig()

virtual CanvasGridRenderer::GridConfig Olympe::ICanvasEditor::GetGridConfig ( ) const
pure virtual

Get current grid configuration.

Returns
GridConfig struct with all grid parameters
Note
Reflects current zoom state in scaledSpacing

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ GetMinimapPosition()

virtual int Olympe::ICanvasEditor::GetMinimapPosition ( ) const
pure virtual

Get minimap position.

Returns
Current position enum value

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ GetMinimapSize()

virtual float Olympe::ICanvasEditor::GetMinimapSize ( ) const
pure virtual

Get minimap size scale.

Returns
Current size multiplier

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ GetPan()

virtual ImVec2 Olympe::ICanvasEditor::GetPan ( ) const
pure virtual

Get current pan offset.

Returns
Offset vector representing where canvas origin is panned to
Note
For imnodes: reads EditorContextGetPanning()
For custom: returns m_canvasOffset

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::AcceptComponentDropAtScreenPos(), Olympe::PrefabCanvas::GetCanvasOffset(), Olympe::PrefabCanvas::HandlePanStart(), Olympe::PrefabCanvas::RenderConnections(), Olympe::PrefabCanvas::RenderDebugInfo(), Olympe::PrefabCanvas::RenderGrid(), and Olympe::PrefabCanvas::RenderNodes().

+ Here is the caller graph for this function:

◆ GetZoom()

virtual float Olympe::ICanvasEditor::GetZoom ( ) const
pure virtual

Get current zoom level.

Returns
Zoom scale (1.0 = 100%, 2.0 = 200%, 0.5 = 50%)
Note
For imnodes: always returns 1.0f (no zoom support)
For custom: returns m_canvasZoom (0.1f to 3.0f)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::AcceptComponentDropAtScreenPos(), Olympe::PrefabCanvas::GetCanvasZoom(), Olympe::PrefabCanvas::RenderConnectionPreview(), Olympe::PrefabCanvas::RenderConnections(), Olympe::PrefabCanvas::RenderDebugInfo(), Olympe::PrefabCanvas::RenderGrid(), Olympe::PrefabCanvas::RenderNodes(), Olympe::PrefabCanvas::SetCanvasZoom(), and Olympe::PrefabCanvas::ZoomCanvas().

+ Here is the caller graph for this function:

◆ GetZoomLimits()

virtual ImVec2 Olympe::ICanvasEditor::GetZoomLimits ( ) const
pure virtual

Get zoom limits (min, max)

Returns
{minZoom, maxZoom}
Note
For imnodes: {1.0f, 1.0f} (no zoom support)
For custom: {0.1f, 3.0f}

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::SetCanvasZoom().

+ Here is the caller graph for this function:

◆ GridToEditor()

virtual ImVec2 Olympe::ICanvasEditor::GridToEditor ( const ImVec2 gridPos) const
pure virtual

Transform grid space to editor space.

Parameters
gridPosCoordinates in grid space
Returns
Coordinates in editor space

Inverse of EditorToGrid, adds back the pan offset.

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ IsCanvasHovered()

virtual bool Olympe::ICanvasEditor::IsCanvasHovered ( ) const
pure virtual

Check if canvas is being hovered by mouse.

Returns
True if mouse is over canvas and canvas has focus

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ IsGridVisible()

virtual bool Olympe::ICanvasEditor::IsGridVisible ( ) const
pure virtual

Check if grid is visible.

Returns
True if grid will be rendered

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ IsMinimapVisible()

virtual bool Olympe::ICanvasEditor::IsMinimapVisible ( ) const
pure virtual

Check if minimap is visible.

Returns
True if minimap will be rendered

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ IsPointInCanvas()

virtual bool Olympe::ICanvasEditor::IsPointInCanvas ( const ImVec2 screenPos) const
pure virtual

Check if point in screen space is within canvas bounds.

Parameters
screenPosPosition in screen space
Returns
True if point is inside canvas area

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ PanBy()

virtual void Olympe::ICanvasEditor::PanBy ( const ImVec2 delta)
pure virtual

Pan by delta amount.

Parameters
deltaRelative pan movement
Note
Convenience method: SetPan(GetPan() + delta)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::PanCanvas().

+ Here is the caller graph for this function:

◆ RenderGrid()

virtual void Olympe::ICanvasEditor::RenderGrid ( CanvasGridRenderer::GridStylePreset  preset)
pure virtual

Render grid using current configuration.

Parameters
presetStyle preset to use

Delegates to CanvasGridRenderer::RenderGrid()

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ RenderMinimap()

virtual void Olympe::ICanvasEditor::RenderMinimap ( )
pure virtual

Render minimap overlay.

Renders minimap showing current viewport relative to full graph

Implementations:

Note: Must be called BEFORE EndRender() for imnodes

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::Render().

+ Here is the caller graph for this function:

◆ ResetPan()

virtual void Olympe::ICanvasEditor::ResetPan ( )
pure virtual

Reset pan to origin (0, 0)

Note
Convenience method: SetPan(ImVec2(0, 0))

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ ResetView()

virtual void Olympe::ICanvasEditor::ResetView ( )
pure virtual

Reset both pan and zoom to defaults.

Note
Convenience: ResetPan(); ResetZoom();

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::ResetView().

+ Here is the caller graph for this function:

◆ ResetZoom()

virtual void Olympe::ICanvasEditor::ResetZoom ( )
pure virtual

Reset zoom to 1.0x.

Note
Convenience: SetZoom(1.0f)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ ScreenToCanvas()

virtual ImVec2 Olympe::ICanvasEditor::ScreenToCanvas ( const ImVec2 screenPos) const
pure virtual

Transform screen space coordinates to canvas space.

Parameters
screenPosCoordinates in screen space (pixels from top-left of window)
Returns
Coordinates in canvas space (logical coordinates after pan/zoom)

Canvas space = screen space transformed by:

  • Subtract canvas origin (where canvas starts on screen)
  • Subtract pan offset (where user panned to)
  • Divide by zoom level (scale to logical units)

Formula: canvas = (screen - canvasOrigin - pan) / zoom

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::Render(), and Olympe::PrefabCanvas::ScreenToCanvas().

+ Here is the caller graph for this function:

◆ SetCanvasScreenPos()

virtual void Olympe::ICanvasEditor::SetCanvasScreenPos ( const ImVec2 screenPos)
pure virtual

Set canvas screen position (call each frame to update)

Parameters
screenPosTop-left corner position in screen space

Required for minimap coordinate calculations each frame

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::Render().

+ Here is the caller graph for this function:

◆ SetCanvasSize()

virtual void Olympe::ICanvasEditor::SetCanvasSize ( const ImVec2 size)
pure virtual

Set canvas size (call each frame to update)

Parameters
sizeWidth and height in screen space

Required for minimap rendering calculations each frame

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::Render().

+ Here is the caller graph for this function:

◆ SetGridVisible()

virtual void Olympe::ICanvasEditor::SetGridVisible ( bool  enabled)
pure virtual

Enable/disable grid rendering.

Parameters
enabledTrue to show grid, false to hide

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ SetMinimapPosition()

virtual void Olympe::ICanvasEditor::SetMinimapPosition ( int  position)
pure virtual

Set minimap position.

Parameters
positionPosition enum value (TopLeft, TopRight, BottomLeft, BottomRight)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ SetMinimapSize()

virtual void Olympe::ICanvasEditor::SetMinimapSize ( float  scale)
pure virtual

Set minimap size scale.

Parameters
scaleSize multiplier (0.1f = 10%, 0.3f = 30% of canvas)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ SetMinimapVisible()

virtual void Olympe::ICanvasEditor::SetMinimapVisible ( bool  enabled)
pure virtual

Enable/disable minimap rendering.

Parameters
enabledTrue to show minimap, false to hide

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

◆ SetPan()

virtual void Olympe::ICanvasEditor::SetPan ( const ImVec2 offset)
pure virtual

Set pan offset directly.

Parameters
offsetNew pan offset

Used for programmatic pan (keyboard shortcut, reset view, etc.)

Note
For imnodes: calls EditorContextResetPanning()
For custom: updates m_canvasOffset directly

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::HandlePan(), and Olympe::PrefabCanvas::SetCanvasOffset().

+ Here is the caller graph for this function:

◆ SetZoom()

virtual void Olympe::ICanvasEditor::SetZoom ( float  scale,
const ImVec2 zoomCenter = nullptr 
)
pure virtual

Set zoom level directly.

Parameters
scaleNew zoom scale
zoomCenterOptional center point for zoom (in screen space)

If zoomCenter provided, zoom maintains visual position of that point

Note
For imnodes: this is a no-op (returns without change)
For custom: updates m_canvasZoom with zoom-center adjustment

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::SetCanvasZoom(), and Olympe::PrefabCanvas::ZoomCanvas().

+ Here is the caller graph for this function:

◆ UpdateMinimapNodes()

virtual void Olympe::ICanvasEditor::UpdateMinimapNodes ( const std::vector< std::tuple< int, float, float, float, float > > &  nodes,
float  graphMinX,
float  graphMaxX,
float  graphMinY,
float  graphMaxY 
)
pure virtual

Update minimap with current graph node data.

Parameters
nodesVector of (nodeId, posX, posY, width, height) tuples representing graph nodes
graphMinXGraph bounds left edge
graphMaxXGraph bounds right edge
graphMinYGraph bounds top edge
graphMaxYGraph bounds bottom edge

Required for custom minimap rendering (CustomCanvasEditor) ImNodes minimap ignores this (uses internal ImNodes node positions)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::Render().

+ Here is the caller graph for this function:

◆ UpdateMinimapViewport()

virtual void Olympe::ICanvasEditor::UpdateMinimapViewport ( float  viewMinX,
float  viewMaxX,
float  viewMinY,
float  viewMaxY,
float  graphMinX,
float  graphMaxX,
float  graphMinY,
float  graphMaxY 
)
pure virtual

Update minimap with current viewport bounds.

Parameters
viewMinXVisible area left edge
viewMaxXVisible area right edge
viewMinYVisible area top edge
viewMaxYVisible area bottom edge
graphMinXGraph bounds left edge
graphMaxXGraph bounds right edge
graphMinYGraph bounds top edge
graphMaxYGraph bounds bottom edge

Required for custom minimap rendering (CustomCanvasEditor) Normalizes viewport bounds relative to graph bounds for minimap display

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.

Referenced by Olympe::PrefabCanvas::Render().

+ Here is the caller graph for this function:

◆ ZoomBy()

virtual void Olympe::ICanvasEditor::ZoomBy ( float  factor,
const ImVec2 zoomCenter = nullptr 
)
pure virtual

Zoom by multiplier.

Parameters
factorZoom multiplier (1.1 = 10% zoom in, 0.9 = 10% zoom out)
zoomCenterOptional center point for zoom
Note
Convenience: SetZoom(GetZoom() * factor, zoomCenter)

Implemented in Olympe::CustomCanvasEditor, and Olympe::ImNodesCanvasEditor.


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