/* 移动滑块 */ void move_pic_btn(LCUI_Widget *widget, LCUI_WidgetEvent *event) { LCUI_Size size; LCUI_Rect des, rect; LCUI_Pos pos, parent; need_move_pic_btn = FALSE; parent = Widget_GetGlobalPos(widget->parent); pos = Pos_Sub(event->drag.new_pos, parent); Widget_Move(widget, pos); if(event->drag.end_click) {/* 如果拖动已经结束 */ rect = Widget_GetRect(widget); size = Widget_GetSize(widget->parent); des = Rect(size.w-10, 0, 30, 30);/* 目标区域 */ /* 如果部件区域与目标区域重叠,则退出程序 */ if(LCUIRect_Overlay(rect, des)) { LCUI_MainLoop_Quit(NULL); } else {/* 否则,让部件回到起始位置,这个使用的是匀速移动 */ need_move_pic_btn = TRUE; } } }
static void ActiveBox_ExecUpdate(LCUI_Widget *widget) /* 功能:更新ActiveBox部件内显示的图像 */ { LCUI_Rect rect; LCUI_Frames *frames; LCUI_Graph *frame_graph; LCUI_Pos pos; frames = ActiveBox_GetFrames( widget ); frame_graph = Frames_GetGraphSlot( frames ); pos = Align_Get_Pos( Widget_GetSize(widget), frames->size, ALIGN_MIDDLE_CENTER); Widget_SetBackgroundTransparent( widget, TRUE ); Widget_SetBackgroundImage( widget, frame_graph ); Widget_SetBackgroundLayout( widget, LAYOUT_NONE ); rect.x = pos.x; rect.y = pos.y; rect.width = frame_graph->width; rect.height = frame_graph->height; Widget_InvalidArea( widget, rect ); }