// Copyright (C) 2018-2025, Tellusim Technologies Inc. All rights reserved
// https://tellusim.com/

#ifndef __TELLUSIM_PLUGINS_INTERFACE_CONTROL_FLOW_CPP_H__
#define __TELLUSIM_PLUGINS_INTERFACE_CONTROL_FLOW_CPP_H__

#include "TellusimControlFlow.h"

/*
 */
namespace Tellusim {
	
	/*
	 */
	class ControlFlowCPP : public ControlFlow {
			
		public:
			
			/// ControlFlow constructor
			explicit ControlFlowCPP(Control *parent, const char *variant = nullptr, uint32_t version = 0);
			virtual ~ControlFlowCPP();
			
			/// create flow
			virtual bool create(Control *controls_root = nullptr, Control *tooltip_root = nullptr);
			
			/// create source for the node
			String getSource(uint32_t node);
			
			/// type name
			const char *getCPPTypeName(uint32_t type) const;
			
			/// flow colors
			TS_INLINE const Color &getCPPColor() const { return cpp_color; }
			TS_INLINE const Color &getToolColor() const { return tool_color; }
			
			/// any types
			TS_INLINE uint32_t getIntType() const { return int_type; }
			TS_INLINE uint32_t getFloatType() const { return float_type; }
			TS_INLINE uint32_t getVectorType() const { return float_type; }
			
			/// cpp types
			TS_INLINE uint32_t getBoolType() const { return bool_type; }
			TS_INLINE uint32_t getInt32Type() const { return int32_type; }
			TS_INLINE uint32_t getInt64Type() const { return int64_type; }
			TS_INLINE uint32_t getFloat32Type() const { return float32_type; }
			TS_INLINE uint32_t getFloat64Type() const { return float64_type; }
			TS_INLINE uint32_t getVector2iType() const { return vector2i_type; }
			TS_INLINE uint32_t getVector2fType() const { return vector2f_type; }
			TS_INLINE uint32_t getVector2dType() const { return vector2d_type; }
			TS_INLINE uint32_t getVector3iType() const { return vector3i_type; }
			TS_INLINE uint32_t getVector3fType() const { return vector3f_type; }
			TS_INLINE uint32_t getVector3dType() const { return vector3d_type; }
			TS_INLINE uint32_t getVector4iType() const { return vector4i_type; }
			TS_INLINE uint32_t getVector4fType() const { return vector4f_type; }
			TS_INLINE uint32_t getVector4dType() const { return vector4d_type; }
			TS_INLINE uint32_t getMatrix3x2fType() const { return matrix3x2f_type; }
			TS_INLINE uint32_t getMatrix3x2dType() const { return matrix3x2d_type; }
			TS_INLINE uint32_t getMatrix4x3fType() const { return matrix4x3f_type; }
			TS_INLINE uint32_t getMatrix4x3dType() const { return matrix4x3d_type; }
			TS_INLINE uint32_t getMatrix4x4fType() const { return matrix4x4f_type; }
			TS_INLINE uint32_t getMatrix4x4dType() const { return matrix4x4d_type; }
			TS_INLINE uint32_t getQuaternionfType() const { return quaternionf_type; }
			TS_INLINE uint32_t getQuaterniondType() const { return quaterniond_type; }
			TS_INLINE uint32_t getColorType() const { return color_type; }
			
		protected:
			
			/// cpp types
	//		TS_INLINE bool is_vector_type(uint32_t type) const { return (type == vec2_type || type == vec3_type || type == vec4_type); }
	//		TS_INLINE bool is_matrix_type(uint32_t type) const { return (type == mat2_type || type == mat3_type || type == mat4_type || type == mat32_type || type == mat43_type); }
			
			/// create CPP
			void create_types();
			void create_protos();
			void create_tools();
			
			/// create editable slider
	//		ControlSlider create_slider(Control *root, const char *name = nullptr, uint32_t digits = 2, float64_t value = 0.0, float64_t min = 0.0, float64_t max = 1.0, float32_t width = 128.0f);
	//		static void expand_slider(ControlSlider &slider);
			
			/// create combo from items
	//		template <class VType, uint32_t Size> static ControlCombo create_combo(Control *root, const char * const (&items)[Size], VType (&values)[Size]);
			
			/// type callbacks
			static bool float_callback(ControlFlow *flow, uint32_t node, uint32_t input, uint32_t output_node, uint32_t output_index);
			static bool vector_callback(ControlFlow *flow, uint32_t node, uint32_t input, uint32_t output_node, uint32_t output_index);
			
			/// flow state
	//		static bool set_state(ControlCombo &combo, const String &name);
			
			/// matrix type
	//		uint32_t get_matrix_r_type(uint32_t type) const;
	//		uint32_t get_matrix_t_type(uint32_t type) const;
	//		uint32_t get_matrix_row_type(uint32_t type) const;
	//		uint32_t get_num_matrix_rows(uint32_t type) const;
			
			Color cpp_color = Color(1.0f, 1.0f, 1.0f, 0.75f);
			Color tool_color = Color(0.3f, 0.6f, 1.0f, 0.75f);
			
	//		float32_t matrix_width = 96.0f;			// matrix slider width
			
			uint32_t int_type = Maxu32;				// any integer type
			uint32_t float_type = Maxu32;			// any float type
			uint32_t vector_type = Maxu32;			// any vector type
			
			uint32_t bool_type = Maxu32;			// scalar types
			uint32_t int32_type = Maxu32;
			uint32_t int64_type = Maxu32;
			uint32_t float32_type = Maxu32;
			uint32_t float64_type = Maxu32;
			
			uint32_t vector2i_type = Maxu32;		// vector types
			uint32_t vector2f_type = Maxu32;
			uint32_t vector2d_type = Maxu32;
			uint32_t vector3i_type = Maxu32;
			uint32_t vector3f_type = Maxu32;
			uint32_t vector3d_type = Maxu32;
			uint32_t vector4i_type = Maxu32;
			uint32_t vector4f_type = Maxu32;
			uint32_t vector4d_type = Maxu32;
			
			uint32_t matrix3x2f_type = Maxu32;		// matrix types
			uint32_t matrix3x2d_type = Maxu32;
			uint32_t matrix4x3f_type = Maxu32;
			uint32_t matrix4x3d_type = Maxu32;
			uint32_t matrix4x4f_type = Maxu32;
			uint32_t matrix4x4d_type = Maxu32;
			
			uint32_t quaternionf_type = Maxu32;		// quaternion types
			uint32_t quaterniond_type = Maxu32;
			
			uint32_t color_type = Maxu32;			// color type
	};
}

#endif /* __TELLUSIM_PLUGINS_INTERFACE_CONTROL_FLOW_CPP_H__ */
