lae界面开发工具入门之介绍九--lua脚本组件篇
2019独角兽企业重金招聘Python工程师标准>>>
1、lua脚本组件,可以处理自己订阅的全局消息,或者本窗口所有接受的事件。下图可以接收OnClickItem全局事件,OnMouseEnterItem全局事件,其他事件OnLoad,OnLClickDown,OnLClickUp,OnMouseMove等自己可接收基本事件。
比如垂直滚动条控件
--
--down button
--up button
--slider
--lua代码
--父窗口为约束窗口,窗口在父窗口里移动。
local function HelperContrain(parent, child,offset, IsHorization)
local parentRc = LXZRect:new_local();
local childRc = LXZRect:new_local();
parent:GetRect(parentRc);
child:GetRect(childRc);
local pt = LXZPoint:new_local();
local parent_pt=parentRc:TopLeft();
local child_pt=childRc:TopLeft();
--reset to origin position.
if IsHorization then
pt.x = parent_pt.x-child_pt.x;
else
pt.y = parent_pt.y-child_pt.y;
end
childRc:OffsetPoint(pt);
if IsHorization then
pt.x = offset;
pt.y = 0;
else
pt.y=offset
pt.x = 0;
end
childRc:OffsetPoint(pt);
if IsHorization then
pt.y = 0;
if parentRc:Width()>=childRc:Width() then
if offset>0 then
if childRc.right> parentRc.right then
pt.x = parentRc.right-childRc.right;
childRc:OffsetPoint(pt);
LXZAPI_OutputDebugStr("1 offset x:"..pt.x.." y:"..pt.y.." offset:"..offset.." ("..childRc.left..","..childRc.top..","..childRc.right..","..childRc.bottom..")");
end
else
if childRc.left<parentRc.left then
pt.x = parentRc.left-childRc.left;
childRc:OffsetPoint(pt);
LXZAPI_OutputDebugStr("2 offset x:"..pt.x.." y:"..pt.y.." offset:"..offset.." ("..childRc.left..","..childRc.top..","..childRc.right..","..childRc.bottom..")");
end
end
else
if offset>0 then
if childRc.left> parentRc.left then
pt.x = parentRc.left-childRc.left;
childRc:OffsetPoint(pt);
LXZAPI_OutputDebugStr("3 offset x:"..pt.x.." y:"..pt.y.." offset:"..offset.." ("..childRc.left..","..childRc.top..","..childRc.right..","..childRc.bottom..")");
end
else
if childRc.right<parentRc.right then
pt.x = parentRc.right-childRc.right;
childRc:OffsetPoint(pt);
LXZAPI_OutputDebugStr("4 offset x:"..pt.x.." y:"..pt.y.." offset:"..offset.." ("..childRc.left..","..childRc.top..","..childRc.right..","..childRc.bottom..")");
end
end
end
child:SetHotPos(childRc:Center(),true);
return;
end
pt.x = 0;
if parentRc:Height()>=childRc:Height() then
if offset>0 then
if childRc.bottom> parentRc.bottom then
pt.y = parentRc.bottom-childRc.bottom;
childRc:OffsetPoint(pt);
end
else
if childRc.top<parentRc.top then
pt.y = parentRc.top-childRc.top;
childRc:OffsetPoint(pt);
end
end
else
if offset>0 then
if childRc.top> parentRc.top then
pt.y = parentRc.top-childRc.top;
childRc:OffsetPoint(pt);
end
else
if childRc.bottom<parentRc.bottom then
pt.y = parentRc.bottom-childRc.bottom;
childRc:OffsetPoint(pt);
end
end
end
child:SetHotPos(childRc:Center(),true);
end
--通过滑块位置控制窗口移动
local function VerticalScrollBySliderPosition(window, wnd)
local pt = window:GetChild("slider"):GetPos();
local size = HelperGetSliderHeight( wnd:GetParent(), wnd);
local len=window:GetHeight()-window:GetChild("slider"):GetHeight();
local stepmove = pt.y*size/len;
HelperContrain(wnd:GetParent(), wnd, -stepmove, false);
end
local function VerticalNormalizePosition(window, pt)
local len=window:GetHeight()-window:GetChild("slider"):GetHeight();
if pt.y<0 then
pt.y=0;
elseif pt.y>len then
pt.y=len;
end
window:GetChild("slider"):SetPos(pt);
end
--点击向上按钮
local function OnUp(window, msg, sender)
local cfg = window:GetCfg();
local step = cfg:GetInt("step");
local count = cfg:GetInt("count");
local wnd = window:GetParent():GetLXZWindow(window:GetAddString());
if wnd == nil then
return;
end
local size=window:GetHeight()-window:GetChild("slider"):GetHeight();
local offset = step*size/count;
local pt = window:GetChild("slider"):GetPos();
pt.y = pt.y-offset;
VerticalNormalizePosition(window,pt);
VerticalScrollBySliderPosition(window, wnd);
HelperPerioProc("OnUp", OnUp, window, msg, sender);
end
--点击向下按钮
local function OnDown(window, msg, sender)
local cfg = window:GetCfg();
local step = cfg:GetInt("step");
local count = cfg:GetInt("count");
local wnd = window:GetParent():GetLXZWindow(window:GetAddString());
if wnd == nil then
return;
end
local size=window:GetHeight()-window:GetChild("slider"):GetHeight();
local offset = step*size/count;
local pt = window:GetChild("slider"):GetPos();
pt.y = pt.y+offset;
LXZAPI_OutputDebugStr("OnDown step:"..step.." count:"..count.." offset:"..offset.." size:"..size);
VerticalNormalizePosition(window,pt);
VerticalScrollBySliderPosition(window, wnd);
HelperPerioProc("OnDown", OnDown, window, msg, sender);
end
--鼠标滚动
local function OnVertMouseWheel(window, msg, sender)
local x = msg:int();
local y = msg:int();
local delta = msg:int();
local corecfg = ICGuiGetLXZCoreCfg();
if corecfg.IsClickDown==true then
LXZAPI_OutputDebugStr("OnVertMouseWheel 0");
return;
end
local wnd = window:GetParent():GetLXZWindow(window:GetAddString());
if wnd == nil or wnd:IsVisible()==false then
LXZAPI_OutputDebugStr("OnVertMouseWheel 1");
return;
end
local rc = wnd:GetParent():GetRect();
if rc:IsIncludePoint(x,y)==false then
LXZAPI_OutputDebugStr("OnVertMouseWheel 2");
return;
end
local pt = window:GetChild("slider"):GetPos();
pt.y = pt.y-delta;
VerticalNormalizePosition(window,pt);
VerticalScrollBySliderPosition(window, wnd);
end
--滑条移动
local function OnVerticalSliderMove(window, msg, sender)
local wnd = window:GetParent():GetLXZWindow(window:GetAddString());
if wnd == nil then
return;
end
VerticalScrollBySliderPosition(window, wnd);
end
--点击滚动条
local function OnClickVerticalBar(window, msg, sender)
local x = msg:int();
local y = msg:int();
local wnd = window:GetParent():GetLXZWindow(window:GetAddString());
if wnd == nil then
return;
end
local rc = window:GetRect();
local size = HelperGetSliderHeight( wnd:GetParent(), wnd);
local len=window:GetHeight()-window:GetChild("slider"):GetHeight();
local stepmove = (y-rc.top)*size/len;
local pt = window:GetChild("slider"):GetPos();
pt.y = y-rc.top-window:GetChild("slider"):GetHeight()/2;
VerticalNormalizePosition(window,pt);
VerticalScrollBySliderPosition(window, wnd);
end
--滚动条加载
local function OnVerticalLoad(window, msg, sender)
local cfg = window:GetCfg();
local page = cfg:GetInt("page");
if page==0 then
cfg:SetInt("page", -1, 10);
cfg:SetInt("step", -1, 5);
cfg:SetInt("count",-1, 100);
end
end
local event_callback = {}
event_callback ["OnLoad"] = OnVerticalLoad;
event_callback ["OnUp"] = OnUp;
event_callback ["OnDown"] = OnDown;
event_callback ["OnVertMouseWheel"] =OnVertMouseWheel;
event_callback ["OnVerticalSliderMove"] = OnVerticalSliderMove;
event_callback ["OnClickVerticalBar"] = OnClickVerticalBar;
event_callback ["OnReset"] = OnVerticalSliderMove;
function vertical_scrollbar_main_dispacher(window, cmd, msg, sender)
--- LXZAPI_OutputDebugStr("cmd 1:"..cmd);
if(event_callback[cmd] ~= nil) then
-- LXZAPI_OutputDebugStr("cmd 2:"..cmd);
event_callback[cmd](window, msg, sender);
end
end
转载于:https://my.oschina.net/u/1030910/blog/704800
lae界面开发工具入门之介绍九--lua脚本组件篇相关推荐
- NC运维人员拓展知识 之 开发工具入门(一)
对于NC系统运维人员,通常情况下接触到较多的是NC前端问题处理,问题集中于业务之上.但是有时也会出现系统报错,例如,"****Exception",甚至出现"未知的错误& ...
- Xamarin Anroid开发教程之Anroid开发工具及应用介绍
Xamarin Anroid开发教程之Anroid开发工具及应用介绍 Xamarin开发Anroid应用介绍 如今智能手机已经盛行了好几年,而针对这些智能手机的软件开发也变得异常火热.但是在Andro ...
- Android界面开发工具DroidDraw
用Eclipes开发Android程序设计界面,如果界面的布局需要一行一行输入,那么将会使人很郁闷.现在有个工具可以帮你完成这些操作--Android界面开发工具DroidDraw.DroidDraw ...
- ASP.NET开发工具Web Matrix介绍
ASP.NET开发工具Web Matrix介绍 作者:arui 主页:http://blog.csdn.net/arui319 一.开篇语 通常,一说到ASP.NET编程,我们大多数人都会想到微软的V ...
- python界面开发哪个好用_python界面开发工具哪个好?
俗话说,好刃才能成好刀,找到适合自己的且功能全面的pytho界面开发工具也一样如此,满足项目使用,我们才能有效率,制作完美的项目工程,然而关于界面开发工具有很多,我们要怎么去选择呢?哪个才是最好的呢? ...
- 【无限互联】iOS开发视频教程—2.1 iPhone开发之开发工具安装及介绍
核心内容: 1. iPhone开发工具下载 2. Apple开发者网站如何阅读 3. Xcode的下载,模拟器和内存分析工具的使用 4. windows下如何开发iPhone程序,安装虚拟机 视频地址 ...
- PyQt5可视化编程-图形界面开发工具QtDesigner和PyUIC
一.概述 Qt库是跨平台的 C++库的集合,是最强大的 GUI库之一,可以实现高级 API来访问桌面和移动系统的各种服务.PyQt5是一套 Python绑定 Digia QT5应用的框架.PyQt5实 ...
- 【第3版emWin教程】第34章 emWin6.x的AppWizard界面开发工具使用方法
教程不断更新中:http://www.armbbs.cn/forum.php?mod=viewthread&tid=98429 第34章 emWin6.x的AppWizard界面开 ...
- 1、开发工具IDEA的介绍、安装、配置优化与快捷键
配套讲义.资料或源码等,敬请关注微信公众号"守护之王觉行"后,添加管理员微信获取. <凡人学Java>系列在线阅读地址 <凡人学Java> 一.编码神器-I ...
- python界面开发工具-python图形界面开发用什么
作为Python开发者,你迟早都会用到图形用户界面来开发应用.本文将推荐一些 Python GUI 框架,希望对你有所帮助. Python 的 UI 开发工具包 Kivy(推荐学习:Python视频教 ...
最新文章
- [置顶] HTML5 实现小车动画效果(Canvas/CSS3/JQuery)
- 搭建LVS_DR模型
- python socket recv超时_python使用多线程编写tcp客户端程序,你还没掌握吗?
- FAL风控培训「六大场景下,模型分数如何应用?」
- web编程 模块1 html,Web编程基础第1章HTML基础.ppt
- 微信小游戏排行榜设计技术梳理
- iso 绝对pe_深度 WinPE 4.2 维护光盘ISO(含U盘PE制作工具) 下载地址
- 100天python、github_GitHub - 1392792445/Python-100-Days: Python - 100天从新手到大师
- java基本数据类型存放在哪?
- 神经网络——torch.optim优化器的使用
- 在训练的时候loss增大怎么办
- 每节课都是一个项目 手把手用STM32打造联网气象站-9-用LCD显示中文英文和图片
- 解读小红书2022年母婴行业报告:心智种草的流量密码
- 网易mumu模拟器怎么清理缓存?
- Linux:netstat命令结果详解
- [已解决]mysql查询一周内的数据,解决一周的起始日期是从星期日(星期天|周日|周天)开始的问题
- React-Native 创建App项目
- 关于4G转wifi路由器模块与4G转有线模块的原理
- DBFS CLI : 02-文件操作相关常用命令
- Flood fill algorithm