Skip to content

Commit

Permalink
Enable row in Treegrid can be linked to xui.svg.connector
Browse files Browse the repository at this point in the history
  • Loading branch information
linb committed Nov 21, 2024
1 parent 0ea7949 commit 6c3f5cb
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 37 deletions.
4 changes: 2 additions & 2 deletions API/App/js/xui-raw.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions runtime/xui/js/xui-all.js

Large diffs are not rendered by default.

72 changes: 56 additions & 16 deletions runtime/xui/js/xui-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -12020,6 +12020,10 @@ xui.Class('xui.Dom','xui.absBox',{

boundary=boundary?xui(boundary).get(0):doc;

if(node===boundary || !xui(boundary).contains(node)){
parent = op = null;
}

if(pos){
//all null, return dir
if(pos.left===null&&pos.top===null)return ns;
Expand Down Expand Up @@ -12051,7 +12055,7 @@ xui.Class('xui.Dom','xui.absBox',{
}
}else{
pos = {left :0, top :0};
add(pos, node.offsetLeft, node.offsetTop );
if(op) add(pos, node.offsetLeft, node.offsetTop );
//get offset, stop by boundary or boundary.offsetParent
while(op && op!=boundary && op!=boundary.offsetParent){
add(pos, op.offsetLeft, op.offsetTop);
Expand Down Expand Up @@ -20912,21 +20916,25 @@ xui.Class('xui.UIProfile','xui.Profile', {
return (itemId=this.getSubIdByItemId(itemId)) ? this.getSubNode(key, itemId, tag) : xui();
},
getItemByItemId:function(itemId){
var prf=this,t;
if(xui.isNumb(itemId))itemId=xui.get(prf.properties.items,[itemId,"id"]);
if((t=prf.ItemIdMapSubSerialId) && (t=t[itemId]))
return prf.SubSerialIdMapItem[t];
t=prf.queryItems(prf.properties.items, function(v,k){
return v.id===itemId;
}, 1,1);
return t&&t[0];
if(this.box.KEY=='xui.UI.TreeGrid'){
return this.boxing().getRowbyRowId(itemId);
}else{
var prf=this,t;
if(xui.isNumb(itemId))itemId=xui.get(prf.properties.items,[itemId,"id"]);
if((t=prf.ItemIdMapSubSerialId) && (t=t[itemId]))
return prf.SubSerialIdMapItem[t];
t=prf.queryItems(prf.properties.items, function(v,k){
return v.id===itemId;
}, 1,1);
return t&&t[0];
}
},
getSubIdByItemId:function(itemId){
var prf=this,t;
if(xui.isNumb(itemId))itemId=xui.get(prf.properties.items,[itemId,"id"]);
if(xui.isNumb(itemId))itemId=xui.get(prf.properties.items || prf.properties.rows,[itemId,"id"]);
// to ignore null/undefined
// 0=>"0", false=>"false"
return (t=this.ItemIdMapSubSerialId) && xui.isSet(itemId)?t[itemId]:null;
return (t=this.ItemIdMapSubSerialId||this.rowMap2) && xui.isSet(itemId)?t[itemId]:null;
},

getItemByDom:function(src){
Expand Down Expand Up @@ -41745,6 +41753,7 @@ xui.Class("xui.UI.Panel", "xui.UI.Div",{
ClickEffected:{INFO:'INFO',OPT:'OPT', CLOSE:'CLOSE',POP:'POP', REFRESH:'REFRESH',CMD:'CMD',TOGGLE:'TOGGLE'},
TOGGLE:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
if(profile.properties.toggleBtn){
profile.box._toggle(profile, !profile.properties.toggle);
return false;
Expand All @@ -41753,6 +41762,7 @@ xui.Class("xui.UI.Panel", "xui.UI.Div",{
},
CAPTION:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
if(!profile.onClickBar || false===profile.boxing().onClickBar(profile,src))
return xui.Event.getKey(e).shiftKey;
}
Expand Down Expand Up @@ -41783,6 +41793,7 @@ xui.Class("xui.UI.Panel", "xui.UI.Div",{
},
CLOSE:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
var properties = profile.properties;
if(properties.disabled)return;
var instance = profile.boxing();
Expand All @@ -41794,6 +41805,7 @@ xui.Class("xui.UI.Panel", "xui.UI.Div",{
},
POP:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
var properties=profile.properties;
if(properties.disabled)return;
var pos = profile.getRoot().offset(), size=profile.getRoot().cssSize(),
Expand Down Expand Up @@ -48512,6 +48524,7 @@ xui.Class("xui.UI.Layout",["xui.UI", "xui.absList"],{
ClickEffected:{CMD:'CMD'},
MOVE:{
beforeMousedown:function(profile, e, src){
if(profile.$inDesign)return;
if(xui.Event.getBtn(e)!="left")return;
var itemId = profile.getSubId(src),
item = profile.getItemByDom(src);
Expand Down Expand Up @@ -48650,6 +48663,7 @@ xui.Class("xui.UI.Layout",["xui.UI", "xui.absList"],{
},
CMD:{
onMousedown:function(profile, e, src){
if(profile.$inDesign)return;
if(xui.Event.getBtn(e)!="left")return;
var t=profile.properties,
itemId = profile.getSubId(src),
Expand Down Expand Up @@ -52683,6 +52697,11 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
if(!xui(src).contains(xui.Event.getSrc(e)))
profile.box.$cancelHoverEditor(profile);
},
onContextmenu:function(profile, e, src){
if(profile.onContextmenu){
return profile.boxing().onContextmenu(profile, e, src)!==false;
}
},
HFMARK:{
onClick:function(profile,e,src){
var prop=profile.properties;
Expand Down Expand Up @@ -52801,6 +52820,7 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
//colomn resizer
HHANDLER:{
beforeMousedown:function(profile, e, src){
if(profile.$inDesign)return;
if(xui.Event.getBtn(e)!='left')return;
var p=profile.properties,
id = profile.getSubId(src),
Expand Down Expand Up @@ -52976,6 +52996,7 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
//row resizer
FHANDLER:{
beforeMousedown:function(profile, e, src){
if(profile.$inDesign)return;
if(xui.Event.getBtn(e)!='left')return;
var p=profile.properties,
row = profile.rowMap[profile.getSubId(src)],
Expand Down Expand Up @@ -53121,6 +53142,7 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
},
HCELLA:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
var p=profile.properties,
id = profile.getSubId(src),
col = profile.colMap[id];
Expand Down Expand Up @@ -53266,6 +53288,7 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
profile.boxing().afterColSorted(profile, col);
},
beforeMousedown:function(profile, e, src){
if(profile.$inDesign)return;
if(xui.Event.getBtn(e)!='left')return;

var p=profile.properties;
Expand Down Expand Up @@ -53585,6 +53608,13 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
if(eid && xui.UIProfile.getFromDom(eid)!=profile)return false;
if(profile.onClickRow)
profile.boxing().onClickRow(profile, row, e, src);
},
onContextmenu:function(profile, e, src){
if(profile.onContextmenu){
var sid=profile.getSubId(src);
// cell or row
return profile.boxing().onContextmenu(profile, e, src,sid?(profile.cellMap[sid]||profile.rowMap[sid]):null)!==false;
}
}
},
CELL:{
Expand Down Expand Up @@ -58223,6 +58253,7 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
},
PIN:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
var key=profile.keys.PIN, t=profile.properties,ins=profile.boxing();
if( profile.beforePin && false === profile.boxing().beforePin(profile, t.pinned))
return;
Expand All @@ -58249,16 +58280,19 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
},
MIN:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
profile.box._min(profile,null,null,true);
}
},
MAX:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
profile.box._max(profile,null,null,true);
}
},
RESTORE:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
profile.box._restore(profile);
}
},
Expand Down Expand Up @@ -58293,6 +58327,7 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
},
CLOSE:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
profile.boxing().close();
}
},
Expand Down Expand Up @@ -69617,7 +69652,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c)
if(locked && a[0] && (alias != a[0] || key!==((a[1]=="KEY"?"":a[1])||"") || sid!==(a[2]||"") )) {
tobj = getObjFromConf(prf, a);
if(tobj){
targetNode = tobj.getSubNode(a[1]||"KEY", a[2]);
targetNode = (a[1]&&a[2]) ? tobj. getSubNodeByItemId(a[1], a[2]) : tobj.getSubNode(a[1]||"KEY", a[2]);
if(targetNode.get(0)){
anchors = xui.svg._getConnectAnchors(tobj, prf, targetNode.get(0));
anchorPath = xui.svg._getConnectPath(tobj, prf, targetNode.get(0));
Expand Down Expand Up @@ -69655,7 +69690,8 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c)
// get the nearest anchor
tobj = getObjFromConf(prf, a);
if(tobj){
targetNode = tobj.getSubNode(a[1]||"KEY", a[2]);
targetNode = (a[1]&&a[2]) ? tobj. getSubNodeByItemId(a[1], a[2]) : tobj.getSubNode(a[1]||"KEY", a[2]);

if(targetNode){
anchors = xui.svg._getConnectAnchors(tobj, prf, targetNode.get(0));
anchorPath = xui.svg._getConnectPath(tobj, prf, targetNode.get(0));
Expand Down Expand Up @@ -72196,9 +72232,13 @@ xui.Class("xui.svg.connector","xui.svg.absComb",{
}
},
_getHotNode:function(prf, conf){
conf = conf.split(":");
if(conf[1] && conf[1]!="KEY"){
prf = prf.getSubNode(conf[1], conf[2]);
var a = conf.split(":");
if(a[1] && a[1]!="KEY"){
if(a[2]){
prf = prf.getSubNodeByItemId(a[1], a[2]);
}else{
prf = prf.getSubNode(a[1]);
}
return prf && prf.get(0);
}else{
return prf.getRootNode();
Expand Down
2 changes: 1 addition & 1 deletion runtime/xui/js/xui.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion xui/js/Dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,10 @@ xui.Class('xui.Dom','xui.absBox',{

boundary=boundary?xui(boundary).get(0):doc;

if(node===boundary || !xui(boundary).contains(node)){
parent = op = null;
}

if(pos){
//all null, return dir
if(pos.left===null&&pos.top===null)return ns;
Expand Down Expand Up @@ -1359,7 +1363,7 @@ xui.Class('xui.Dom','xui.absBox',{
}
}else{
pos = {left :0, top :0};
add(pos, node.offsetLeft, node.offsetTop );
if(op) add(pos, node.offsetLeft, node.offsetTop );
//get offset, stop by boundary or boundary.offsetParent
while(op && op!=boundary && op!=boundary.offsetParent){
add(pos, op.offsetLeft, op.offsetTop);
Expand Down
24 changes: 14 additions & 10 deletions xui/js/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -808,21 +808,25 @@ xui.Class('xui.UIProfile','xui.Profile', {
return (itemId=this.getSubIdByItemId(itemId)) ? this.getSubNode(key, itemId, tag) : xui();
},
getItemByItemId:function(itemId){
var prf=this,t;
if(xui.isNumb(itemId))itemId=xui.get(prf.properties.items,[itemId,"id"]);
if((t=prf.ItemIdMapSubSerialId) && (t=t[itemId]))
return prf.SubSerialIdMapItem[t];
t=prf.queryItems(prf.properties.items, function(v,k){
return v.id===itemId;
}, 1,1);
return t&&t[0];
if(this.box.KEY=='xui.UI.TreeGrid'){
return this.boxing().getRowbyRowId(itemId);
}else{
var prf=this,t;
if(xui.isNumb(itemId))itemId=xui.get(prf.properties.items,[itemId,"id"]);
if((t=prf.ItemIdMapSubSerialId) && (t=t[itemId]))
return prf.SubSerialIdMapItem[t];
t=prf.queryItems(prf.properties.items, function(v,k){
return v.id===itemId;
}, 1,1);
return t&&t[0];
}
},
getSubIdByItemId:function(itemId){
var prf=this,t;
if(xui.isNumb(itemId))itemId=xui.get(prf.properties.items,[itemId,"id"]);
if(xui.isNumb(itemId))itemId=xui.get(prf.properties.items || prf.properties.rows,[itemId,"id"]);
// to ignore null/undefined
// 0=>"0", false=>"false"
return (t=this.ItemIdMapSubSerialId) && xui.isSet(itemId)?t[itemId]:null;
return (t=this.ItemIdMapSubSerialId||this.rowMap2) && xui.isSet(itemId)?t[itemId]:null;
},

getItemByDom:function(src){
Expand Down
5 changes: 5 additions & 0 deletions xui/js/UI/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ xui.Class("xui.UI.Dialog","xui.UI.Widget",{
},
PIN:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
var key=profile.keys.PIN, t=profile.properties,ins=profile.boxing();
if( profile.beforePin && false === profile.boxing().beforePin(profile, t.pinned))
return;
Expand All @@ -562,16 +563,19 @@ xui.Class("xui.UI.Dialog","xui.UI.Widget",{
},
MIN:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
profile.box._min(profile,null,null,true);
}
},
MAX:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
profile.box._max(profile,null,null,true);
}
},
RESTORE:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
profile.box._restore(profile);
}
},
Expand Down Expand Up @@ -606,6 +610,7 @@ xui.Class("xui.UI.Dialog","xui.UI.Widget",{
},
CLOSE:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
profile.boxing().close();
}
},
Expand Down
2 changes: 2 additions & 0 deletions xui/js/UI/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ xui.Class("xui.UI.Layout",["xui.UI", "xui.absList"],{
ClickEffected:{CMD:'CMD'},
MOVE:{
beforeMousedown:function(profile, e, src){
if(profile.$inDesign)return;
if(xui.Event.getBtn(e)!="left")return;
var itemId = profile.getSubId(src),
item = profile.getItemByDom(src);
Expand Down Expand Up @@ -503,6 +504,7 @@ xui.Class("xui.UI.Layout",["xui.UI", "xui.absList"],{
},
CMD:{
onMousedown:function(profile, e, src){
if(profile.$inDesign)return;
if(xui.Event.getBtn(e)!="left")return;
var t=profile.properties,
itemId = profile.getSubId(src),
Expand Down
4 changes: 4 additions & 0 deletions xui/js/UI/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ xui.Class("xui.UI.Panel", "xui.UI.Div",{
ClickEffected:{INFO:'INFO',OPT:'OPT', CLOSE:'CLOSE',POP:'POP', REFRESH:'REFRESH',CMD:'CMD',TOGGLE:'TOGGLE'},
TOGGLE:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
if(profile.properties.toggleBtn){
profile.box._toggle(profile, !profile.properties.toggle);
return false;
Expand All @@ -220,6 +221,7 @@ xui.Class("xui.UI.Panel", "xui.UI.Div",{
},
CAPTION:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
if(!profile.onClickBar || false===profile.boxing().onClickBar(profile,src))
return xui.Event.getKey(e).shiftKey;
}
Expand Down Expand Up @@ -250,6 +252,7 @@ xui.Class("xui.UI.Panel", "xui.UI.Div",{
},
CLOSE:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
var properties = profile.properties;
if(properties.disabled)return;
var instance = profile.boxing();
Expand All @@ -261,6 +264,7 @@ xui.Class("xui.UI.Panel", "xui.UI.Div",{
},
POP:{
onClick:function(profile, e, src){
if(profile.$inDesign)return;
var properties=profile.properties;
if(properties.disabled)return;
var pos = profile.getRoot().offset(), size=profile.getRoot().cssSize(),
Expand Down
Loading

0 comments on commit 6c3f5cb

Please sign in to comment.