Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
ComponentNodeRenderer.h
Go to the documentation of this file.
1#pragma once
2
3#include "./../../vector.h"
4#include "ComponentNodeData.h"
5#include "./../../third_party/imgui/imgui.h"
6
7namespace Olympe
8{
9 // Forward declarations
10 class EntityPrefabGraphDocument;
11
13 {
14 public:
17
18 void Initialize();
19 void Shutdown();
20
21 // Canvas transformation context
22 void SetCanvasTransform(const Vector& offset, float zoom);
23 Vector GetCanvasOffset() const;
24 float GetCanvasZoom() const;
27
28 // Rendering
29 void RenderNode(const ComponentNode& node);
32
33 // Port rendering
35 bool IsPointInPort(const Vector& point, const ComponentNode& node, PortId& outPortId) const;
36
37 // Node styling
38 void SetNodeStyle(const ComponentNodeStyle& style);
39 const ComponentNodeStyle& GetNodeStyle() const;
40
41 // Individual style components
42 void SetNormalColor(const Vector& color);
43 void SetSelectedColor(const Vector& color);
44 void SetHoverColor(const Vector& color);
45 void SetDisabledColor(const Vector& color);
46 void SetTextColor(const Vector& color);
47 void SetBorderWidth(float width);
48 void SetCornerRadius(float radius);
49
50 // Hit testing
51 bool IsPointInNode(const Vector& point, const ComponentNode& node) const;
53
54 // Connection hit detection
56 const Vector& testPoint,
57 const Vector& connectionStart,
58 const Vector& connectionEnd,
59 Vector* outClosestPoint = nullptr
60 ) const;
61
62 // Display options
63 void SetShowLabels(bool show);
64 bool GetShowLabels() const;
65
66 void SetShowProperties(bool show);
67 bool GetShowProperties() const;
68
69 void SetNodeScale(float scale);
70 float GetNodeScale() const;
71
72 private:
74 bool m_showLabels = true;
75 bool m_showProperties = true;
76 float m_nodeScale = 1.0f;
78 float m_canvasZoom = 1.0f;
80
81 void RenderNodeBox(const ComponentNode& node);
83 void RenderConnectionLine(const Vector& from, const Vector& to, bool isHovered = false);
84 void RenderPort(const ComponentNode& node, const NodePort& port);
86 Vector CanvasToScreen(const Vector& canvasPos) const;
88 };
89}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
void SetTextColor(const Vector &color)
float GetDistanceToConnection(const Vector &testPoint, const Vector &connectionStart, const Vector &connectionEnd, Vector *outClosestPoint=nullptr) const
const ComponentNodeStyle & GetNodeStyle() const
void RenderConnectionLine(const Vector &from, const Vector &to, bool isHovered=false)
void SetNodeStyle(const ComponentNodeStyle &style)
void SetCanvasScreenPos(const ImVec2 &screenPos)
void RenderNodeLabel(const ComponentNode &node)
void RenderNodePorts(const ComponentNode &node)
void SetNormalColor(const Vector &color)
Vector CanvasToScreen(const Vector &canvasPos) const
bool GetNodeBounds(const ComponentNode &node, Vector &outMin, Vector &outMax) const
void RenderConnections(const EntityPrefabGraphDocument *document, int hoveredConnectionIndex=-1)
bool IsPointInNode(const Vector &point, const ComponentNode &node) const
void SetCanvasTransform(const Vector &offset, float zoom)
void RenderPort(const ComponentNode &node, const NodePort &port)
void SetDisabledColor(const Vector &color)
void UpdatePortPositions(ComponentNode &node) const
Vector GetNodeColor(const ComponentNode &node) const
void RenderNodes(const EntityPrefabGraphDocument *document)
void RenderNode(const ComponentNode &node)
void RenderNodeBox(const ComponentNode &node)
bool IsPointInPort(const Vector &point, const ComponentNode &node, PortId &outPortId) const
void SetSelectedColor(const Vector &color)
void SetHoverColor(const Vector &color)
< Provides AssetID and INVALID_ASSET_ID
uint32_t PortId