Compare commits
2 Commits
9c8a7134eb
...
38b498e841
| Author | SHA1 | Date | |
|---|---|---|---|
| 38b498e841 | |||
| 0814aaaf17 |
@ -4,4 +4,8 @@
|
||||
// 主窗体标题
|
||||
#define MAIN_FRAME_TITTLE L"DLT Splitter —— Dev by : LuChiChick"
|
||||
|
||||
// 主窗体最小面积
|
||||
#define MAIN_FRAME_SIZE_WIDTH_MIN 350
|
||||
#define MAIN_FRAME_SIZE_HEIGHT_MIN 350 * 1.5
|
||||
|
||||
#endif
|
||||
@ -11,6 +11,8 @@ extern "C"
|
||||
#include "d3d11.h"
|
||||
}
|
||||
|
||||
#include "Type_Descriptions.hpp"
|
||||
|
||||
// D3D11 相关
|
||||
extern ID3D11Device *g_pd3dDevice; // D3D11 设备句柄
|
||||
extern ID3D11DeviceContext *g_pd3dDeviceContext; // D3D11 设备上下文句柄
|
||||
@ -20,4 +22,8 @@ extern bool g_SwapChainOccluded; // 交换链是否阻塞
|
||||
|
||||
extern ID3D11RenderTargetView *g_mainRenderTargetView; // D3D11 渲染目标
|
||||
|
||||
// 文件输入相关
|
||||
extern Input_File_Node *input_dlt_file_list_head;
|
||||
extern size_t input_dlt_file_count;
|
||||
|
||||
#endif
|
||||
11
Inc/Type_Descriptions.hpp
Normal file
11
Inc/Type_Descriptions.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __TYPE_DESCRIPTIONS_HPP__
|
||||
#define __TYPE_DESCRIPTIONS_HPP__
|
||||
|
||||
// 文件节点
|
||||
typedef struct Input_File_Node
|
||||
{
|
||||
char *file_name_str;
|
||||
Input_File_Node *p_next;
|
||||
} Input_File_Node;
|
||||
|
||||
#endif
|
||||
@ -6,5 +6,17 @@
|
||||
|
||||
// UI布局
|
||||
void UI_Layout();
|
||||
// 组件
|
||||
namespace Widgets
|
||||
{
|
||||
// 拖拽输入区域
|
||||
void Drag_Input_Area(const ImVec2 &size = ImVec2(0, 0));
|
||||
|
||||
// 文件列表区域
|
||||
void File_List_Area(const ImVec2 &size = ImVec2(0, 0));
|
||||
|
||||
// 工作流区域
|
||||
void Workflow_Area(const ImVec2 &size = ImVec2(0, 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -8,3 +8,7 @@ IDXGISwapChain *g_pSwapChain = nullptr; // DXGI 交换链句柄
|
||||
bool g_SwapChainOccluded = false; // 交换链是否阻塞
|
||||
|
||||
ID3D11RenderTargetView *g_mainRenderTargetView = nullptr; // D3D11 渲染目标
|
||||
|
||||
// 文件输入相关
|
||||
Input_File_Node *input_dlt_file_list_head;
|
||||
size_t input_dlt_file_count;
|
||||
69
Src/Main.cpp
69
Src/Main.cpp
@ -66,8 +66,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
WS_OVERLAPPEDWINDOW, // 窗体风格为标准可重叠的顶层窗口
|
||||
100, // 起始坐标x
|
||||
100, // 起始坐标y
|
||||
(int)(1280 * main_scale), // 窗体长
|
||||
(int)(720 * main_scale), // 窗体宽
|
||||
(int)(MAIN_FRAME_SIZE_WIDTH_MIN * main_scale), // 窗体长
|
||||
(int)(MAIN_FRAME_SIZE_HEIGHT_MIN * main_scale), // 窗体宽
|
||||
nullptr, // 父窗体句柄
|
||||
nullptr, // 菜单句柄
|
||||
wc.hInstance, // 创建实例句柄
|
||||
@ -84,6 +84,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 启用文件拖拽输入
|
||||
DragAcceptFiles(hwnd, TRUE);
|
||||
|
||||
// 显示窗体并强制更新一次窗体
|
||||
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hwnd);
|
||||
@ -333,6 +336,68 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
// 筛查并处理余下的消息事件
|
||||
switch (msg)
|
||||
{
|
||||
case WM_DROPFILES: // 文件拖拽事件
|
||||
{
|
||||
HDROP hDrop = (HDROP)wParam; // 拖拽数据句柄
|
||||
// 获取拖拽的文件总数
|
||||
UINT fileCount = DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
|
||||
|
||||
// 添加到文件列表
|
||||
for (UINT count = 0; count < fileCount; count++)
|
||||
{
|
||||
wchar_t filePath[MAX_PATH] = {L'\0'};
|
||||
DragQueryFileW(
|
||||
hDrop, // 拖拽句柄
|
||||
count, // 文件索引(0 表示第一个文件)
|
||||
filePath, // 存储路径的缓冲区
|
||||
MAX_PATH // 缓冲区大小
|
||||
);
|
||||
|
||||
char file_path_multi_byte[MAX_PATH] = {'\0'};
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, filePath, -1, NULL, 0, NULL, NULL);
|
||||
WideCharToMultiByte(CP_UTF8, 0, filePath, -1, file_path_multi_byte, size_needed, NULL, NULL);
|
||||
|
||||
/**
|
||||
* @todo 文件类型筛选
|
||||
*/
|
||||
|
||||
// 重复文件剔除
|
||||
bool duplicated = false;
|
||||
for (Input_File_Node *p_file_node = input_dlt_file_list_head; p_file_node != nullptr; p_file_node = p_file_node->p_next)
|
||||
if (!strcmp(p_file_node->file_name_str, file_path_multi_byte))
|
||||
{
|
||||
duplicated = true;
|
||||
break;
|
||||
}
|
||||
if (duplicated)
|
||||
continue;
|
||||
|
||||
// 开辟新文件节点
|
||||
Input_File_Node *p_new_file_node = (Input_File_Node *)malloc(sizeof(Input_File_Node));
|
||||
p_new_file_node->file_name_str = (char *)malloc(strlen(file_path_multi_byte) + 1);
|
||||
memset(p_new_file_node->file_name_str, '\0', strlen(file_path_multi_byte) + 1);
|
||||
memcpy(p_new_file_node->file_name_str, file_path_multi_byte, strlen(file_path_multi_byte));
|
||||
p_new_file_node->p_next = nullptr;
|
||||
|
||||
// 插入文件列表
|
||||
if (input_dlt_file_list_head == nullptr)
|
||||
input_dlt_file_list_head = p_new_file_node;
|
||||
else
|
||||
{
|
||||
Input_File_Node *p_target_node = input_dlt_file_list_head;
|
||||
for (size_t count = 1; count < input_dlt_file_count; count++)
|
||||
p_target_node = p_target_node->p_next;
|
||||
|
||||
p_target_node->p_next = p_new_file_node;
|
||||
}
|
||||
|
||||
input_dlt_file_count++;
|
||||
}
|
||||
|
||||
// 释放拖拽资源(必须调用,否则内存泄漏)
|
||||
DragFinish(hDrop);
|
||||
return 0;
|
||||
}
|
||||
case WM_SIZE: // 窗体大小变事件
|
||||
if (wParam != SIZE_MINIMIZED) // 窗体未处于最小化时进行重绘
|
||||
{
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
#include "UI_Layout.hpp"
|
||||
extern "C"
|
||||
{
|
||||
#include "windows.h"
|
||||
}
|
||||
|
||||
// UI布局
|
||||
void UI_Layout()
|
||||
@ -24,10 +28,63 @@ void UI_Layout()
|
||||
// 设置窗体相关属性,不允许停靠
|
||||
window_flags |= ImGuiWindowFlags_NoDocking;
|
||||
|
||||
ImGui::Begin("Main Panel", NULL, window_flags); // 创建Label
|
||||
ImGui::Begin("Main Panel", NULL, window_flags); // 创建主面板
|
||||
ImGui::PopStyleVar(2); // 退出绘制风格栈中的设置项
|
||||
{
|
||||
|
||||
// 拖拽输入区域
|
||||
Widgets::Drag_Input_Area(ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().x / 2));
|
||||
|
||||
// 文件列表组件
|
||||
Widgets::File_List_Area();
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
ImGui::ShowDemoWindow(nullptr);
|
||||
}
|
||||
|
||||
void Widgets::Drag_Input_Area(const ImVec2 &size)
|
||||
{
|
||||
ImGui::BeginChild("Drag_Drop_Area", size);
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f); // 绘制风格栈压入窗口圆角为0
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||
// 显示一个按钮,作为拖拽源
|
||||
static bool pressed_hover = false;
|
||||
ImGui::Button(pressed_hover ? u8"松开左键以添加" : u8"拖拽文件到此处", ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y));
|
||||
// 仅在外部拖拽入内时触发,内部拖拽不触发
|
||||
pressed_hover = (ImGui::IsItemHovered() && (GetAsyncKeyState(VK_LBUTTON) < 0) && (!ImGui::IsMouseDown(ImGuiMouseButton_Left)));
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void Widgets::File_List_Area(const ImVec2 &size)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||
ImGui::BeginChild("File_List_Area", ImVec2(size.x, size.y), ImGuiChildFlags_Border);
|
||||
ImGui::PopStyleVar();
|
||||
{
|
||||
|
||||
ImGui::Dummy(ImVec2(ImGui::GetContentRegionAvail().x - 30, ImGui::GetContentRegionAvail().y));
|
||||
|
||||
const float spacing = 4;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(spacing, spacing));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f); // 绘制风格栈压入窗口圆角为10
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, 10.0f); // 抓取条圆角
|
||||
static int int_value = 0;
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::VSliderInt("int", ImVec2(30, ImGui::GetContentRegionAvail().y), &int_value, 0, 5);
|
||||
|
||||
ImGui::PopStyleVar(3);
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void Widgets::Workflow_Area(const ImVec2 &size)
|
||||
{
|
||||
ImNodes::BeginNodeEditor();
|
||||
{
|
||||
|
||||
@ -49,7 +106,3 @@ void UI_Layout()
|
||||
}
|
||||
ImNodes::EndNodeEditor();
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
ImGui::ShowDemoWindow(nullptr);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user