improve pointer cursor management
* cross cursor for geometric shapes * 'hand' cursor for 'ctrl' actions * default cursor in menu
This commit is contained in:
parent
fb8e46bb45
commit
1af3554f5c
25
draw.js
25
draw.js
|
|
@ -326,6 +326,7 @@ var DrawingArea = new Lang.Class({
|
||||||
this._updateCursorTimeout();
|
this._updateCursorTimeout();
|
||||||
this.textHasCursor = true;
|
this.textHasCursor = true;
|
||||||
this._redisplay();
|
this._redisplay();
|
||||||
|
this.updatePointerCursor();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,6 +335,7 @@ var DrawingArea = new Lang.Class({
|
||||||
|
|
||||||
this.currentElement = null;
|
this.currentElement = null;
|
||||||
this._redisplay();
|
this._redisplay();
|
||||||
|
this.updatePointerCursor();
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateDrawing: function(x, y, controlPressed) {
|
_updateDrawing: function(x, y, controlPressed) {
|
||||||
|
|
@ -349,7 +351,9 @@ var DrawingArea = new Lang.Class({
|
||||||
this.currentElement.transformLine(x, y);
|
this.currentElement.transformLine(x, y);
|
||||||
else
|
else
|
||||||
this.currentElement.points[1] = [x, y];
|
this.currentElement.points[1] = [x, y];
|
||||||
|
|
||||||
this._redisplay();
|
this._redisplay();
|
||||||
|
this.updatePointerCursor(controlPressed);
|
||||||
},
|
},
|
||||||
|
|
||||||
_stopWriting: function() {
|
_stopWriting: function() {
|
||||||
|
|
@ -360,6 +364,20 @@ var DrawingArea = new Lang.Class({
|
||||||
this._redisplay();
|
this._redisplay();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setPointerCursor: function(pointerCursorName) {
|
||||||
|
if (!this.currentPointerCursorName || this.currentPointerCursorName != pointerCursorName) {
|
||||||
|
this.currentPointerCursorName = pointerCursorName;
|
||||||
|
ExtensionJs.setCursor(pointerCursorName);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
updatePointerCursor: function(controlPressed) {
|
||||||
|
if (!this.currentElement || (this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.WRITING))
|
||||||
|
this.setPointerCursor(this.currentShape == Shapes.NONE ? 'POINTING_HAND' : 'CROSSHAIR');
|
||||||
|
else if (this.currentElement.shape != Shapes.NONE && controlPressed)
|
||||||
|
this.setPointerCursor('MOVE_OR_RESIZE_WINDOW');
|
||||||
|
},
|
||||||
|
|
||||||
_stopCursorTimeout: function() {
|
_stopCursorTimeout: function() {
|
||||||
if (this.cursorTimeoutId) {
|
if (this.cursorTimeoutId) {
|
||||||
Mainloop.source_remove(this.cursorTimeoutId);
|
Mainloop.source_remove(this.cursorTimeoutId);
|
||||||
|
|
@ -456,6 +474,7 @@ var DrawingArea = new Lang.Class({
|
||||||
selectShape: function(shape) {
|
selectShape: function(shape) {
|
||||||
this.currentShape = shape;
|
this.currentShape = shape;
|
||||||
this.emitter.emit('show-osd', _(ShapeNames[shape]), null);
|
this.emitter.emit('show-osd', _(ShapeNames[shape]), null);
|
||||||
|
this.updatePointerCursor();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleFill: function() {
|
toggleFill: function() {
|
||||||
|
|
@ -1047,9 +1066,13 @@ var DrawingMenu = new Lang.Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMenuOpenStateChanged: function(menu, open) {
|
_onMenuOpenStateChanged: function(menu, open) {
|
||||||
if (!open)
|
if (open) {
|
||||||
|
this.area.setPointerCursor('DEFAULT');
|
||||||
|
} else {
|
||||||
|
this.area.updatePointerCursor();
|
||||||
// actionMode has changed, set previous actionMode in order to keep internal shortcuts working
|
// actionMode has changed, set previous actionMode in order to keep internal shortcuts working
|
||||||
Main.actionMode = ExtensionJs.DRAWING_ACTION_MODE | Shell.ActionMode.NORMAL;
|
Main.actionMode = ExtensionJs.DRAWING_ACTION_MODE | Shell.ActionMode.NORMAL;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
popup: function() {
|
popup: function() {
|
||||||
|
|
|
||||||
21
extension.js
21
extension.js
|
|
@ -279,11 +279,7 @@ var AreaManager = new Lang.Class({
|
||||||
if (!this.settings.get_boolean("drawing-on-desktop"))
|
if (!this.settings.get_boolean("drawing-on-desktop"))
|
||||||
activeContainer.hide();
|
activeContainer.hide();
|
||||||
|
|
||||||
// check display or screen (API changes)
|
setCursor('DEFAULT');
|
||||||
if (global.display.set_cursor)
|
|
||||||
global.display.set_cursor(Meta.Cursor.DEFAULT);
|
|
||||||
else if (global.screen && global.screen.set_cursor)
|
|
||||||
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
|
||||||
if (!this.osdDisabled)
|
if (!this.osdDisabled)
|
||||||
Main.osdWindowManager.show(activeIndex, this.leaveGicon, _("Leaving drawing mode"), null);
|
Main.osdWindowManager.show(activeIndex, this.leaveGicon, _("Leaving drawing mode"), null);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -302,12 +298,7 @@ var AreaManager = new Lang.Class({
|
||||||
this.activeArea.reactive = true;
|
this.activeArea.reactive = true;
|
||||||
this.activeArea.enterDrawingMode();
|
this.activeArea.enterDrawingMode();
|
||||||
|
|
||||||
// check display or screen (API changes)
|
setCursor('POINTING_HAND');
|
||||||
if (global.display.set_cursor)
|
|
||||||
global.display.set_cursor(Meta.Cursor.POINTING_HAND);
|
|
||||||
else if (global.screen && global.screen.set_cursor)
|
|
||||||
global.screen.set_cursor(Meta.Cursor.POINTING_HAND);
|
|
||||||
|
|
||||||
this.osdDisabled = this.settings.get_boolean('osd-disabled');
|
this.osdDisabled = this.settings.get_boolean('osd-disabled');
|
||||||
if (!this.osdDisabled) {
|
if (!this.osdDisabled) {
|
||||||
// increase OSD display time
|
// increase OSD display time
|
||||||
|
|
@ -414,4 +405,12 @@ var DrawingIndicator = new Lang.Class({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function setCursor(cursorName) {
|
||||||
|
// check display or screen (API changes)
|
||||||
|
if (global.display.set_cursor)
|
||||||
|
global.display.set_cursor(Meta.Cursor[cursorName]);
|
||||||
|
else if (global.screen && global.screen.set_cursor)
|
||||||
|
global.screen.set_cursor(Meta.Cursor[cursorName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue