hide container when area is empty
This commit is contained in:
parent
4e15c42b86
commit
72292c41f6
10
draw.js
10
draw.js
|
|
@ -171,9 +171,9 @@ var DrawingArea = new Lang.Class({
|
||||||
|
|
||||||
_onKeyPressed: function(actor, event) {
|
_onKeyPressed: function(actor, event) {
|
||||||
if (event.get_key_symbol() == Clutter.Escape) {
|
if (event.get_key_symbol() == Clutter.Escape) {
|
||||||
this.hide();
|
this.emitter.emit('stop-drawing', true);
|
||||||
this.emitter.emit('stop-drawing');
|
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
|
|
||||||
} else if (this.currentElement && this.currentElement.shape == Shapes.TEXT) {
|
} else if (this.currentElement && this.currentElement.shape == Shapes.TEXT) {
|
||||||
if (event.get_key_symbol() == Clutter.KEY_BackSpace) {
|
if (event.get_key_symbol() == Clutter.KEY_BackSpace) {
|
||||||
this.currentElement.text = this.currentElement.text.slice(0, -1);
|
this.currentElement.text = this.currentElement.text.slice(0, -1);
|
||||||
|
|
@ -197,6 +197,7 @@ var DrawingArea = new Lang.Class({
|
||||||
}
|
}
|
||||||
this._redisplay();
|
this._redisplay();
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
@ -463,8 +464,11 @@ var DrawingArea = new Lang.Class({
|
||||||
this.helper.showHelp();
|
this.helper.showHelp();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get isEmpty() {
|
||||||
|
return this.elements.length == 0;
|
||||||
|
},
|
||||||
|
|
||||||
enterDrawingMode: function() {
|
enterDrawingMode: function() {
|
||||||
this.show();
|
|
||||||
this.keyPressedHandler = this.connect('key-press-event', this._onKeyPressed.bind(this));
|
this.keyPressedHandler = this.connect('key-press-event', this._onKeyPressed.bind(this));
|
||||||
this.buttonPressedHandler = this.connect('button-press-event', this._onButtonPressed.bind(this));
|
this.buttonPressedHandler = this.connect('button-press-event', this._onButtonPressed.bind(this));
|
||||||
this.scrollHandler = this.connect('scroll-event', this._onScroll.bind(this));
|
this.scrollHandler = this.connect('scroll-event', this._onScroll.bind(this));
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ var AreaManager = new Lang.Class({
|
||||||
container.set_position(monitor.x, monitor.y);
|
container.set_position(monitor.x, monitor.y);
|
||||||
container.set_size(monitor.width, monitor.height);
|
container.set_size(monitor.width, monitor.height);
|
||||||
area.set_size(monitor.width, monitor.height);
|
area.set_size(monitor.width, monitor.height);
|
||||||
|
if (area.isEmpty)
|
||||||
|
container.hide();
|
||||||
area.emitter.stopDrawingHandler = area.emitter.connect('stop-drawing', this.toggleDrawing.bind(this));
|
area.emitter.stopDrawingHandler = area.emitter.connect('stop-drawing', this.toggleDrawing.bind(this));
|
||||||
area.emitter.showOsdHandler = area.emitter.connect('show-osd', this.showOsd.bind(this));
|
area.emitter.showOsdHandler = area.emitter.connect('show-osd', this.showOsd.bind(this));
|
||||||
this.areas.push(area);
|
this.areas.push(area);
|
||||||
|
|
@ -183,6 +185,7 @@ var AreaManager = new Lang.Class({
|
||||||
eraseDrawing: function() {
|
eraseDrawing: function() {
|
||||||
for (let i = 0; i < this.areas.length; i++) {
|
for (let i = 0; i < this.areas.length; i++) {
|
||||||
this.areas[i].erase();
|
this.areas[i].erase();
|
||||||
|
this.areas[i].get_parent().hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -220,11 +223,12 @@ var AreaManager = new Lang.Class({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleDrawing: function() {
|
toggleDrawing: function(emitter, hide) {
|
||||||
if (this.activeArea) {
|
if (this.activeArea) {
|
||||||
let activeIndex = this.areas.indexOf(this.activeArea);
|
let activeIndex = this.areas.indexOf(this.activeArea);
|
||||||
let activeContainer = this.activeArea.get_parent();
|
let activeContainer = this.activeArea.get_parent();
|
||||||
let save = activeIndex == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing');
|
let save = activeIndex == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing');
|
||||||
|
hide = hide || this.activeArea.isEmpty;
|
||||||
|
|
||||||
if (this.hiddenList)
|
if (this.hiddenList)
|
||||||
this.togglePanelAndDockOpacity();
|
this.togglePanelAndDockOpacity();
|
||||||
|
|
@ -241,6 +245,9 @@ var AreaManager = new Lang.Class({
|
||||||
else
|
else
|
||||||
Main.uiGroup.insert_child_above(activeContainer, global.window_group);
|
Main.uiGroup.insert_child_above(activeContainer, global.window_group);
|
||||||
|
|
||||||
|
if (hide)
|
||||||
|
activeContainer.hide();
|
||||||
|
|
||||||
// check display or screen (API changes)
|
// check display or screen (API changes)
|
||||||
if (global.display.set_cursor)
|
if (global.display.set_cursor)
|
||||||
global.display.set_cursor(Meta.Cursor.DEFAULT);
|
global.display.set_cursor(Meta.Cursor.DEFAULT);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue