VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
elementInput.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Created by Arnis Lektauers on 13.10.2025.
5//
6#pragma once
7
8#include <SDL3/SDL_render.h>
9
10#include <memory>
11#include <string>
12#include <unordered_map>
13
14#include "core/math/vector2.h"
16
17namespace visutwin::canvas
18{
19 class Engine;
20 class ElementComponent;
21 class Entity;
22 class Mesh;
23 class RenderComponent;
24 class StandardMaterial;
25
31 {
32 public:
33 void setEngine(const std::shared_ptr<Engine>& engine) { _engine = engine; }
34 void setSdlRenderer(SDL_Renderer* renderer) { _sdlRenderer = renderer; }
35
36 void detach();
37 bool handleMouseButtonDown(float x, float y);
38 void renderElements();
39 void syncTextElements();
40
41 private:
42 struct TextVisual
43 {
44 Entity* entity = nullptr;
45 RenderComponent* render = nullptr;
46 std::shared_ptr<Mesh> mesh;
47 std::shared_ptr<StandardMaterial> material;
48 std::string cachedText;
49 int cachedFontSize = 0;
50 float cachedWidth = 0.0f;
51 float cachedHeight = 0.0f;
52 Vector2 cachedPivot = Vector2(0.5f, 0.5f);
54 bool cachedWrap = false;
55 FontResource* cachedFont = nullptr;
56 bool activeFrame = false;
57 };
58
59 bool computeElementRect(const ElementComponent* element, SDL_FRect& outRect) const;
60
61 std::shared_ptr<Engine> _engine;
62 SDL_Renderer* _sdlRenderer = nullptr;
63 std::unordered_map<ElementComponent*, TextVisual> _textVisuals;
64 };
65}
void setSdlRenderer(SDL_Renderer *renderer)
void setEngine(const std::shared_ptr< Engine > &engine)
bool handleMouseButtonDown(float x, float y)
Central application orchestrator managing scenes, rendering, input, and resource loading.
Definition engine.h:38
ECS entity — a GraphNode that hosts components defining its behavior.
Definition entity.h:32
GPU-resident geometry defined by vertex/index buffers and one or more Primitives.
Definition mesh.h:79
Full PBR material with metalness/roughness workflow and advanced surface features.
2D vector for UV coordinates, screen positions, and 2D math.
Definition vector2.h:18