拖拽动画特别指服务端在拖拽各环节发起的动画效果,功能将集中在拖拽框架 MSDP 子系统 DragDrawing 中实现。
Graphic-2D 库[^graphic_2d]提供了强大的图片绘制、动画增强服务,该子系统调用了其对外服务的能力。
1. DrawingInfo 绘图信息
绘图数据来源拖拽数据 DragData,包括阴影缩略图 ShadowInfo 以及绘制各种动画需要的节点信息
struct DrawingInfo {
std::atomic_bool isRunning { false }; // 发起拖拽时为true,拖拽完成后为false
std::atomic_bool isPreviousDefaultStyle { false }; // 前一个默认拖拽光标状态
std::atomic_bool isCurrentDefaultStyle { false }; // 是否采用默认拖拽光标风格
bool isInitUiDirector { true }; // Rosen::RSUIDirector::Create() 系统仅被create一次标志
bool isExistScalingVallue { false }; // 缩放系数是否存在标志,不存在需计算, 判断 scalingValue 的有效性
int32_t sourceType { -1 }; // 输入设备源类型(鼠标、触屏等)
int32_t currentDragNum { -1 }; // 拖拽的对象个数
DragCursorStyle currentStyle { DragCursorStyle::DEFAULT }; // 设置默认拖拽光标,和isCurrentDefaultStyle状态联合使用,此时状态为 true
int32_t displayId { -1 }; // 显示的应用ID
int32_t pixelMapX { -1 }; // 图片相对于画布边缘x向距离,在文本编辑器内偏移负的一半宽度
int32_t pixelMapY { -1 }; // 图片相对于画布边缘y向距离
int32_t displayX { -1 }; // 动态的显示位置 x坐标
int32_t displayY { -1 }; // 动态的显示位置 y坐标
int32_t mouseWidth { 0 }; // 鼠标圆环、箭头图形的宽度,由pixelMap->GetWidth()获取
int32_t mouseHeight { 0 }; // 鼠标圆环、箭头图形的高度,由pixelMap->GetHeight()获取
int32_t rootNodeWidth { -1 }; // 没有用到
int32_t rootNodeHeight { -1 }; // 没有用到
float scalingValue { 0.0 }; // scalingValue = (1.0 * deviceDpi * DEVICE_INDEPENDENT_PIXEL / BASELINE_DENSITY) / SVG_ORIGINAL_SIZE;
std::vector<std::shared_ptr<Rosen::RSCanvasNode>> nodes; // 当前画图节点,包括 BACKGROUND_FILTER_INDEX { 0 }; PIXEL_MAP_INDEX { 1 }; DRAG_STYLE_INDEX { 2 };MOUSE_ICON_INDEX { 3 };
std::vector<std::shared_ptr<Rosen::RSCanvasNode>> mutilSelectedNodes; // 多选节点,和 mutilSelectedPixelMaps 一起使用
std::shared_ptr<Rosen::RSNode> rootNode { nullptr }; // 根节点
std::shared_ptr<Rosen::RSNode> parentNode { nullptr }; // 父节点
std::shared_ptr<Ro