[lg] Use scroll wheel in inspector to select parent actors
scroll-up selects the parent actor, then grandparent, etc. scroll-down moves the selection back towards the frontmost actor. https://bugzilla.gnome.org/show_bug.cgi?id=624940
This commit is contained in:
parent
1a50b94b19
commit
09edf4ba59
@ -382,11 +382,24 @@ Inspector.prototype = {
|
|||||||
this._borderPaintTarget = null;
|
this._borderPaintTarget = null;
|
||||||
this._borderPaintId = null;
|
this._borderPaintId = null;
|
||||||
eventHandler.connect('destroy', Lang.bind(this, this._onDestroy));
|
eventHandler.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||||
|
|
||||||
eventHandler.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
|
eventHandler.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
|
||||||
|
eventHandler.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
|
||||||
eventHandler.connect('motion-event', Lang.bind(this, this._onMotionEvent));
|
eventHandler.connect('motion-event', Lang.bind(this, this._onMotionEvent));
|
||||||
Clutter.grab_pointer(eventHandler);
|
Clutter.grab_pointer(eventHandler);
|
||||||
|
|
||||||
|
// this._target is the actor currently shown by the inspector.
|
||||||
|
// this._pointerTarget is the actor directly under the pointer.
|
||||||
|
// Normally these are the same, but if you use the scroll wheel
|
||||||
|
// to drill down, they'll diverge until you either scroll back
|
||||||
|
// out, or move the pointer outside of _pointerTarget.
|
||||||
|
this._target = null;
|
||||||
|
this._pointerTarget = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
_close: function() {
|
||||||
|
Clutter.ungrab_pointer(this._eventHandler);
|
||||||
|
this._eventHandler.destroy();
|
||||||
|
this.emit('closed');
|
||||||
},
|
},
|
||||||
|
|
||||||
_onDestroy: function() {
|
_onDestroy: function() {
|
||||||
@ -395,31 +408,70 @@ Inspector.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onButtonPressEvent: function (actor, event) {
|
_onButtonPressEvent: function (actor, event) {
|
||||||
Clutter.ungrab_pointer(this._eventHandler);
|
if (this._target) {
|
||||||
|
let [stageX, stageY] = event.get_coords();
|
||||||
|
this.emit('target', this._target, stageX, stageY);
|
||||||
|
}
|
||||||
|
this._close();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
let [stageX, stageY] = event.get_coords();
|
_onScrollEvent: function (actor, event) {
|
||||||
let target = global.stage.get_actor_at_pos(Clutter.PickMode.ALL,
|
switch (event.get_scroll_direction()) {
|
||||||
stageX,
|
case Clutter.ScrollDirection.UP:
|
||||||
stageY);
|
// select parent
|
||||||
this.emit('target', target, stageX, stageY);
|
let parent = this._target.get_parent();
|
||||||
this._eventHandler.destroy();
|
if (parent != null) {
|
||||||
this.emit('closed');
|
this._target = parent;
|
||||||
|
this._update(event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Clutter.ScrollDirection.DOWN:
|
||||||
|
// select child
|
||||||
|
if (this._target != this._pointerTarget) {
|
||||||
|
let child = this._pointerTarget;
|
||||||
|
while (child) {
|
||||||
|
let parent = child.get_parent();
|
||||||
|
if (parent == this._target)
|
||||||
|
break;
|
||||||
|
child = parent;
|
||||||
|
}
|
||||||
|
if (child) {
|
||||||
|
this._target = child;
|
||||||
|
this._update(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMotionEvent: function (actor, event) {
|
_onMotionEvent: function (actor, event) {
|
||||||
|
this._update(event);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
_update: function(event) {
|
||||||
let [stageX, stageY] = event.get_coords();
|
let [stageX, stageY] = event.get_coords();
|
||||||
let target = global.stage.get_actor_at_pos(Clutter.PickMode.ALL,
|
let target = global.stage.get_actor_at_pos(Clutter.PickMode.ALL,
|
||||||
stageX,
|
stageX,
|
||||||
stageY);
|
stageY);
|
||||||
|
|
||||||
|
if (target != this._pointerTarget)
|
||||||
|
this._target = target;
|
||||||
|
this._pointerTarget = target;
|
||||||
|
|
||||||
let position = '[inspect x: ' + stageX + ' y: ' + stageY + ']';
|
let position = '[inspect x: ' + stageX + ' y: ' + stageY + ']';
|
||||||
this._displayText.text = '';
|
this._displayText.text = '';
|
||||||
this._displayText.text = position + ' ' + target;
|
this._displayText.text = position + ' ' + this._target;
|
||||||
if (this._borderPaintTarget != null)
|
if (this._borderPaintTarget != null)
|
||||||
this._borderPaintTarget.disconnect(this._borderPaintId);
|
this._borderPaintTarget.disconnect(this._borderPaintId);
|
||||||
this._borderPaintTarget = target;
|
this._borderPaintTarget = this._target;
|
||||||
this._borderPaintId = Shell.add_hook_paint_red_border(target);
|
this._borderPaintId = Shell.add_hook_paint_red_border(this._target);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user