示例#1
0
文件: window.c 项目: gateslu/LCUI
/* 处理鼠标移动事件 */
static void 
Window_ExecMove(LCUI_Widget *titlebar, LCUI_WidgetEvent *event)
{
	LCUI_Pos pos, offset;
	LCUI_Widget *window;
	
	window = titlebar->parent;
	if( !window ) {
		return;
	}
	//_DEBUG_MSG( "new:%d,%d, cursor:%d,%d\n", 
	//event->drag.new_pos.x, event->drag.new_pos.y, 
	//event->drag.cursor_pos.x, event->drag.cursor_pos.y );
	/* 将新全局坐标减去标题栏的全局坐标,得到偏移坐标 */
	pos = Widget_GetGlobalPos( titlebar );
	offset = Pos_Sub( event->drag.new_pos, pos );
	pos = Widget_GetGlobalPos( window );
	/* 将偏移坐标加在窗口全局坐标上,得出窗口的新全局坐标 */
	pos = Pos_Add( pos, offset );
	/* 转换成在容器区域内的相对坐标 */
	pos = Widget_ToRelPos( window->parent, pos );
	/* 解除之前设定的align */
	Widget_SetAlign( window, ALIGN_NONE, Pos(0,0) );
	/* 移动窗口的位置 */
	Widget_Move( window, pos );
}
示例#2
0
static void 
_DragEvent_Start( LCUI_Widget *widget, LCUI_MouseButtonEvent *event )
{
	LCUI_WidgetEvent buff;
	buff.type = EVENT_DRAG;
	buff.drag.cursor_pos.x = event->x;
	buff.drag.cursor_pos.y = event->y;
	buff.drag.new_pos = Widget_GetGlobalPos( widget );
	__offset_pos.x = buff.drag.cursor_pos.x - buff.drag.new_pos.x;
	__offset_pos.y = buff.drag.cursor_pos.y - buff.drag.new_pos.y;
	buff.drag.first_click = TRUE;
	buff.drag.end_click = FALSE;
	/* 处理部件的拖动事件 */
	Widget_DispatchEvent( widget, &buff );
}
示例#3
0
文件: screenlock.c 项目: FrankHB/LCUI
/* 移动滑块 */
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;
		}
	}
}
示例#4
0
static void 
ScrollBar_Drag( LCUI_Widget *widget, LCUI_WidgetEvent *event )
{
	static LCUI_Pos pos, offset;
	static LCUI_ScrollBar *scrollbar;
	if( !widget->parent ) {
		return;
	}
	
	scrollbar = Widget_GetPrivData( widget->parent );
	pos = Widget_GetGlobalPos( widget );
	offset = Pos_Sub( event->drag.new_pos, pos ); 
	pos = Pos_Add( pos, offset ); 
	pos = GlobalPos_ConvTo_RelativePos( widget, pos );
	
	Move_ScrollBar( widget, pos );
	/* 若函数指针有效,则调用回调函数 */
	if( scrollbar->callback_func ) {
		//_DEBUG_MSG("current_num: %d, max_num: %d\n", 
		//scrollbar->data.current_num, scrollbar->data.max_num);
		scrollbar->callback_func( scrollbar->data, scrollbar->arg );
	}
}