},
{
"$ xns" : "Gtk",
- "* init" : [
- " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
- " "
- ],
+ "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
+ "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
"bool has_frame" : true,
"bool hexpand" : true,
"bool vexpand" : true,
"items" : [
{
"# bool blockChanges" : false,
+ "$ JsRender.Node? dragNode" : "null",
"$ string lastEventSource" : "\"\"",
"$ xns" : "Gtk",
"* init" : [
"\tGLib.debug(\"SOURCE: drag-begin\");",
"\t ",
" // find what is selected in our tree...",
- " var data = _this.selmodel.getSelectedNode();",
+ " var data = _this.selmodel.getSelectedNode();",
"\tif (data == null) {",
"\t\treturn ;",
"\t}",
- "\t ",
+ "\t_this.view.dragNode = data;",
" var xname = data.fqn();",
" GLib.debug (\"XNAME IS %s\", xname);",
"",
" ",
"}"
],
+ "drag_cancel" : [
+ "(drag, reason) => {",
+ "",
+ "\t_this.view.dragNode = null;",
+ "\treturn true;",
+ "}",
+ ""
+ ],
+ "drag_end" : [
+ "(drag, delete_data) => {",
+ "",
+ "_this.view.dragNode = null;",
+ "}",
+ ""
+ ],
"prepare" : [
"(x, y) => {",
"",
"\t",
"\tthis.addHighlight(null,\"\");",
" ",
- " ",
+ " \tvar is_shift = _this.keystate.is_shift > 0;",
" ",
" \tvar pos = \"\";",
" \t// -- get position..",
"\t\t\t\tpos = \"over\";",
" \t\t\t} else {",
"\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
+ "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
+ "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
+ "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
+ " \t\t\t\t\t\treturn false;\t",
+ "\t\t \t\t\t}",
+ "\t\t \t\t\t",
+ "\t\t \t\t}",
+ "\t\t\t\t",
+ "\t\t\t\t",
"\t\t\t}",
" \t\t}",
" \t\t",
"\t\t\treturn false;",
"",
"\t\t}",
+ "\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
+ " \t\t\tGLib.debug(\"shift drop not self not allowed\");",
+ "\t\t\treturn false;\t",
+ "\t\t}",
"\t}",
" \t",
" \tswitch(pos) {",
" \t\tcase \"over\":",
"\t \t\tnode.appendChild(dropNode);",
+ "\t \t\tif (is_shift && _this.view.dragNode != null) {",
+ "\t\t \t\t_this.model.selectNode(null); ",
+ "\t\t \t\t_this.view.dragNode.remove();",
+ "\t \t\t}",
+ "\t \t\t\t",
+ "\t \t\t",
" \t\t\t_this.model.selectNode(dropNode); ",
+ " \t\t\t",
" \t\t\t_this.changed();\t\t\t\t \t\t",
"\t \t\treturn true;",
"\t \t\t",
" \t\tcase \"above\":",
" \t\t\tGLib.debug(\"Above - insertBefore\");",
" \t\t",
- " \t\t\tnode.parent.insertBefore(dropNode, node);",
+ "\t\t\tnode.parent.insertBefore(dropNode, node);",
+ "\t \t\tif (is_shift && _this.view.dragNode != null) {",
+ "\t\t \t\t_this.model.selectNode(null); \t \t\t",
+ "\t\t \t\t_this.view.dragNode.remove();",
+ "\t \t\t}",
+ "\t",
" \t\t\t_this.model.selectNode(dropNode); \t\t\t",
" \t\t\t_this.changed();",
" \t\t\treturn true;",
" \t\t\t",
" \t\tcase \"below\":",
" \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
+ "\t \t\tif (is_shift && _this.view.dragNode != null) {",
+ "\t\t \t\t_this.model.selectNode(null); \t \t\t",
+ "\t\t \t\t_this.view.dragNode.remove();",
+ "\t \t\t}",
+ "\t",
+ " \t\t\t",
" \t\t\tnode.parent.insertAfter(dropNode, node);",
" \t\t\t_this.model.selectNode(dropNode);\t",
" \t\t\t_this.changed();",
"motion" : [
"( x, y) => {",
" ",
+ "\tvar is_shift = _this.keystate.is_shift > 0;",
+ "\t",
+ "\tGLib.debug(\"shift is %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
"\tstring pos; // over / before / after..",
"",
- " GLib.debug(\"got drag motion\");",
+ " //GLib.debug(\"got drag motion\");",
"",
" GLib.Value v = GLib.Value(typeof(string));",
" \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
"\t\treturn Gdk.DragAction.COPY;\t ",
"\t",
"\t}",
- "",
- "\tGLib.debug(\"got %s\", v.get_string());",
+ " ",
+ "\t//GLib.debug(\"got %s\", v.get_string());",
"\t ",
"\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
"\t\t// still dragging same node",
"\t \t\t\tpos = \"over\";",
" \t\t\t} else {",
"\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
+ "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
+ "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
+ "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
+ "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
+ "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
+ "\t\t \t\t\t}",
+ "\t\t \t\t\t",
+ "\t\t \t\t}",
+ "\t\t\t\t",
"\t\t\t}",
+ "\t\t\t",
+ "\t\t\t",
+ "\t\t\t",
" \t\t}",
" \t\t",
+ " \t\t",
" \t}",
" \tif (pos == \"over\") {",
"\t \tif (!drop_on_to.contains(node.fqn())) {",
"\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
"\t\t\tthis.addHighlight(null, \"\"); ",
- "\t\t\treturn Gdk.DragAction.COPY;\t\t",
+ "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
"\t\t}",
+ "\t\tif (_this.view.dragNode != null && is_shift) {",
+ " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
+ "\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
+ " \t\t\t\tthis.addHighlight(null, \"\");",
+ " \t\t\t\treturn Gdk.DragAction.COPY;\t",
+ " \t\t\t}",
+ "\t\t}",
+ " \t\t\t",
"\t}",
" \t",
" \t",
" \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
"\tvar w = _this.view.getWidgetAt(x,y);",
"\tthis.addHighlight(w, pos); ",
- " return Gdk.DragAction.COPY;\t\t\t",
+ "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
"}"
]
},
],
"string title" : "Add",
"xtype" : "ColumnViewColumn"
+ },
+ {
+ "$ xns" : "Gtk",
+ "id" : "keystate",
+ "int is_shift" : 0,
+ "listeners" : {
+ "key_pressed" : [
+ "(keyval, keycode, state) => {",
+ "",
+ " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
+ " \t\tthis.is_shift = 1;",
+ "\t}",
+ "\treturn true;",
+ "}",
+ ""
+ ],
+ "key_released" : [
+ "(keyval, keycode, state) => {",
+ "\tGLib.debug(\"key release %d, %d, %d\" , (int) keyval, (int) keycode, state);",
+ " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
+ " \t\tthis.is_shift = 0;",
+ "\t}",
+ "\t//GLib.debug(\"set state %d , shift = %d\", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);",
+ "",
+ "",
+ " ",
+ "}"
+ ]
+ },
+ "xtype" : "EventControllerKey"
}
],
"string name" : "left-tree-view",
public Xcls_selmodel selmodel;
public Xcls_model model;
public Xcls_maincol maincol;
+ public Xcls_keystate keystate;
public Xcls_LeftTreeMenu LeftTreeMenu;
// my vars (def)
// my vars (dec)
// set gobject values
+ this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
this.el.has_frame = true;
this.el.hexpand = true;
this.el.vexpand = true;
+ this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
new Xcls_view( _this );
this.el.child = _this.view.el;
new Xcls_LeftTreeMenu( _this );
-
- // init method
-
- this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
}
// user defined functions
public string lastEventSource;
public bool button_is_pressed;
public Gtk.CssProvider css;
+ public JsRender.Node? dragNode;
// ctor
public Xcls_view(Xcls_WindowLeftTree _owner )
this.headers_visible = false;
this.lastEventSource = "";
this.button_is_pressed = false;
+ this.dragNode = null;
// set gobject values
this.el.name = "left-tree-view";
var child_8 = new Xcls_ColumnViewColumn15( _this );
child_8.ref();
this.el.append_column ( child_8.el );
+ new Xcls_keystate( _this );
+ this.el.add_controller( _this.keystate.el );
// init method
this.el.actions = Gdk.DragAction.COPY | Gdk.DragAction.MOVE ;
//listeners
+ this.el.drag_cancel.connect( (drag, reason) => {
+
+ _this.view.dragNode = null;
+ return true;
+ });
this.el.prepare.connect( (x, y) => {
GLib.debug("SOURCE: drag-begin");
// find what is selected in our tree...
- var data = _this.selmodel.getSelectedNode();
+ var data = _this.selmodel.getSelectedNode();
if (data == null) {
return ;
}
-
+ _this.view.dragNode = data;
var xname = data.fqn();
GLib.debug ("XNAME IS %s", xname);
this.el.set_icon(paintable, 0,0);
+ });
+ this.el.drag_end.connect( (drag, delete_data) => {
+
+ _this.view.dragNode = null;
});
}
});
this.el.motion.connect( ( x, y) => {
+ var is_shift = _this.keystate.is_shift > 0;
+
+ GLib.debug("shift is %s", _this.keystate.is_shift > 0 ? "SHIFT" : "-");
string pos; // over / before / after..
- GLib.debug("got drag motion");
+ //GLib.debug("got drag motion");
GLib.Value v = GLib.Value(typeof(string));
//var str = drop.read_text( [ "text/plain" ] 0);
return Gdk.DragAction.COPY;
}
-
- GLib.debug("got %s", v.get_string());
+
+ //GLib.debug("got %s", v.get_string());
if (this.lastDragString != v.get_string() || this.lastDragNode == null) {
// still dragging same node
pos = "over";
} else {
GLib.debug("drop contains %s - using %s" , node.parent.fqn(), pos);
+ if (_this.view.dragNode != null && is_shift) {
+ if (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {
+ GLib.debug("shift drop not self not allowed");
+ this.addHighlight(null, "");
+ return Gdk.DragAction.COPY;
+ }
+
+ }
+
}
+
+
+
}
+
}
if (pos == "over") {
if (!drop_on_to.contains(node.fqn())) {
GLib.debug("drop on does not contain %s - try center" , node.fqn());
this.addHighlight(null, "");
- return Gdk.DragAction.COPY;
+ return is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;
+ }
+ if (_this.view.dragNode != null && is_shift) {
+ if (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {
+ GLib.debug("shift drop not self not allowed");
+ this.addHighlight(null, "");
+ return Gdk.DragAction.COPY;
+ }
}
+
}
// _this.view.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
var w = _this.view.getWidgetAt(x,y);
this.addHighlight(w, pos);
- return Gdk.DragAction.COPY;
+ return is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;
});
this.el.leave.connect( ( ) => {
this.addHighlight(null,"");
this.addHighlight(null,"");
-
+ var is_shift = _this.keystate.is_shift > 0;
var pos = "";
// -- get position..
pos = "over";
} else {
GLib.debug("drop contains %s - using %s" , node.parent.fqn(), pos);
+ if (_this.view.dragNode != null && is_shift) {
+ if (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {
+ GLib.debug("shift drop not self not allowed");
+ return false;
+ }
+
+ }
+
+
}
}
return false;
}
+ if (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {
+ GLib.debug("shift drop not self not allowed");
+ return false;
+ }
}
switch(pos) {
case "over":
node.appendChild(dropNode);
+ if (is_shift && _this.view.dragNode != null) {
+ _this.model.selectNode(null);
+ _this.view.dragNode.remove();
+ }
+
+
_this.model.selectNode(dropNode);
+
_this.changed();
return true;
case "above":
GLib.debug("Above - insertBefore");
- node.parent.insertBefore(dropNode, node);
+ node.parent.insertBefore(dropNode, node);
+ if (is_shift && _this.view.dragNode != null) {
+ _this.model.selectNode(null);
+ _this.view.dragNode.remove();
+ }
+
_this.model.selectNode(dropNode);
_this.changed();
return true;
case "below":
GLib.debug("Below - insertAfter");
+ if (is_shift && _this.view.dragNode != null) {
+ _this.model.selectNode(null);
+ _this.view.dragNode.remove();
+ }
+
+
node.parent.insertAfter(dropNode, node);
_this.model.selectNode(dropNode);
_this.changed();
}
+ public class Xcls_keystate : Object
+ {
+ public Gtk.EventControllerKey el;
+ private Xcls_WindowLeftTree _this;
+
+
+ // my vars (def)
+ public int is_shift;
+
+ // ctor
+ public Xcls_keystate(Xcls_WindowLeftTree _owner )
+ {
+ _this = _owner;
+ _this.keystate = this;
+ this.el = new Gtk.EventControllerKey();
+
+ // my vars (dec)
+ this.is_shift = 0;
+
+ // set gobject values
+
+ //listeners
+ this.el.key_released.connect( (keyval, keycode, state) => {
+ GLib.debug("key release %d, %d, %d" , (int) keyval, (int) keycode, state);
+ if (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {
+ this.is_shift = 0;
+ }
+ //GLib.debug("set state %d , shift = %d", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);
+
+
+
+ });
+ this.el.key_pressed.connect( (keyval, keycode, state) => {
+
+ if (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {
+ this.is_shift = 1;
+ }
+ return true;
+ });
+ }
+
+ // user defined functions
+ }
+
public class Xcls_LeftTreeMenu : Object
{
// my vars (dec)
// set gobject values
- var child_1 = new Xcls_Box18( _this );
+ var child_1 = new Xcls_Box19( _this );
this.el.child = child_1.el;
}
// user defined functions
}
- public class Xcls_Box18 : Object
+ public class Xcls_Box19 : Object
{
public Gtk.Box el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_Box18(Xcls_WindowLeftTree _owner )
+ public Xcls_Box19(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
// my vars (dec)
// set gobject values
- var child_1 = new Xcls_Button19( _this );
+ var child_1 = new Xcls_Button20( _this );
child_1.ref();
this.el.append( child_1.el );
- var child_2 = new Xcls_Button20( _this );
+ var child_2 = new Xcls_Button21( _this );
child_2.ref();
this.el.append( child_2.el );
- var child_3 = new Xcls_Button21( _this );
+ var child_3 = new Xcls_Button22( _this );
child_3.ref();
this.el.append( child_3.el );
}
// user defined functions
}
- public class Xcls_Button19 : Object
+ public class Xcls_Button20 : Object
{
public Gtk.Button el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_Button19(Xcls_WindowLeftTree _owner )
+ public Xcls_Button20(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.Button();
// user defined functions
}
- public class Xcls_Button20 : Object
+ public class Xcls_Button21 : Object
{
public Gtk.Button el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_Button20(Xcls_WindowLeftTree _owner )
+ public Xcls_Button21(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.Button();
// user defined functions
}
- public class Xcls_Button21 : Object
+ public class Xcls_Button22 : Object
{
public Gtk.Button el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_Button21(Xcls_WindowLeftTree _owner )
+ public Xcls_Button22(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.Button();