Line data Source code
1 : #pragma once
2 :
3 : #include <imgui.h>
4 : #include <unordered_map>
5 : #include <vector>
6 :
7 : namespace Amplitron {
8 :
9 70 : struct NodeLayoutState {
10 : ImVec2 position;
11 35 : bool is_dragging = false;
12 : ImVec2 drag_start_pos;
13 : };
14 :
15 1 : class GuiGraphState {
16 : public:
17 723 : static GuiGraphState& get_instance() {
18 724 : static GuiGraphState instance;
19 723 : return instance;
20 0 : }
21 :
22 : // Canvas panning and zoom/grid configurations
23 1 : ImVec2 scrolling = ImVec2(0.0f, 0.0f);
24 1 : ImVec2 target_scrolling = ImVec2(0.0f, 0.0f);
25 1 : bool show_grid = true;
26 1 : bool is_fullscreen = false;
27 1 : float zoom = 1.0f;
28 1 : float target_zoom = 1.0f;
29 1 : float dpi_scale = 1.0f;
30 1 : ImVec2 last_canvas_pos = ImVec2(0.0f, 0.0f);
31 1 : bool canvas_hovered = false;
32 :
33 : // Node positioning registry mapped by Node ID
34 : std::unordered_map<int, NodeLayoutState> node_positions;
35 :
36 : // State tracking for wire connections currently being dragged
37 1 : int active_src_pin_id = -1;
38 1 : ImVec2 active_src_pin_pos = ImVec2(0.0f, 0.0f);
39 :
40 : void set_default_position_if_missing(int node_id, float default_x, float default_y) {
41 : if (node_positions.find(node_id) == node_positions.end()) {
42 : node_positions[node_id] = { ImVec2(default_x, default_y), false, ImVec2(0, 0) };
43 : }
44 : }
45 : };
46 :
47 : } // namespace Amplitron
|