#pragma once // ============================================================================ // block_editor.h - 编辑器主界面 // ============================================================================ #include "block_workspace.h" #include "block_renderer.h" #include "block_interaction.h" #include "block_palette.h" #include "block_executor.h" #include "block_serializer.h" typedef struct BlockEditor { BlockWorkspace* workspace; BlockRenderer renderer; BlockInteraction interaction; BlockPalette palette; BlockExecutor* executor; int width, height; int visible; // 工具栏 int toolbar_height; // 属性面板 int properties_width; Block* selected_block; } BlockEditor; // 初始化/销毁 int block_editor_init(BlockEditor* editor, void* device, void* context, int width, int height); void block_editor_shutdown(BlockEditor* editor); // 显示/隐藏 void block_editor_show(BlockEditor* editor); void block_editor_hide(BlockEditor* editor); int block_editor_is_visible(BlockEditor* editor); // 更新/渲染 void block_editor_update(BlockEditor* editor, double delta_time); void block_editor_render(BlockEditor* editor); // 输入处理 void block_editor_on_mouse_move(BlockEditor* editor, int x, int y); void block_editor_on_mouse_down(BlockEditor* editor, int button); void block_editor_on_mouse_up(BlockEditor* editor, int button); void block_editor_on_mouse_wheel(BlockEditor* editor, int delta); void block_editor_on_key(BlockEditor* editor, int key); void block_editor_on_resize(BlockEditor* editor, int width, int height); // 从面板拖拽创建积木 void block_editor_create_block_from_palette(BlockEditor* editor, BlockType type, float x, float y); // 保存/加载 int block_editor_save(BlockEditor* editor, const char* filepath); int block_editor_load(BlockEditor* editor, const char* filepath); // 运行控制 void block_editor_run(BlockEditor* editor); void block_editor_stop(BlockEditor* editor); void block_editor_pause(BlockEditor* editor);