LCOV - code coverage report
Current view: top level - src/gui/state - gui_graph_state.h (source / functions) Coverage Total Hit
Test: merged.info Lines: 94.4 % 18 17
Test Date: 2026-06-07 15:51:50 Functions: 100.0 % 1 1

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

Generated by: LCOV version 2.0-1