draw.js -> area.js
This commit is contained in:
parent
ca96e76d12
commit
96efac1e3f
|
|
@ -26,10 +26,6 @@ const Lang = imports.lang;
|
||||||
const Pango = imports.gi.Pango;
|
const Pango = imports.gi.Pango;
|
||||||
const PangoCairo = imports.gi.PangoCairo;
|
const PangoCairo = imports.gi.PangoCairo;
|
||||||
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
|
||||||
const Me = ExtensionUtils.getCurrentExtension();
|
|
||||||
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
|
|
||||||
|
|
||||||
const reverseEnumeration = function(obj) {
|
const reverseEnumeration = function(obj) {
|
||||||
let reversed = {};
|
let reversed = {};
|
||||||
Object.keys(obj).forEach(key => {
|
Object.keys(obj).forEach(key => {
|
||||||
|
|
|
||||||
24
extension.js
24
extension.js
|
|
@ -35,7 +35,7 @@ const PanelMenu = imports.ui.panelMenu;
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
const Me = ExtensionUtils.getCurrentExtension();
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience;
|
const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience;
|
||||||
const Draw = Me.imports.draw;
|
const Area = Me.imports.area;
|
||||||
const Helper = Me.imports.helper;
|
const Helper = Me.imports.helper;
|
||||||
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
|
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ var AreaManager = new Lang.Class({
|
||||||
let container = new St.Widget({ name: 'drawOnYourSreenContainer' + i });
|
let container = new St.Widget({ name: 'drawOnYourSreenContainer' + i });
|
||||||
let helper = new Helper.DrawingHelper({ name: 'drawOnYourSreenHelper' + i }, monitor);
|
let helper = new Helper.DrawingHelper({ name: 'drawOnYourSreenHelper' + i }, monitor);
|
||||||
let loadPersistent = i == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing');
|
let loadPersistent = i == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing');
|
||||||
let area = new Draw.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, loadPersistent);
|
let area = new Area.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, loadPersistent);
|
||||||
container.add_child(area);
|
container.add_child(area);
|
||||||
container.add_child(helper);
|
container.add_child(helper);
|
||||||
|
|
||||||
|
|
@ -191,16 +191,16 @@ var AreaManager = new Lang.Class({
|
||||||
'toggle-fill-rule': this.activeArea.toggleFillRule.bind(this.activeArea),
|
'toggle-fill-rule': this.activeArea.toggleFillRule.bind(this.activeArea),
|
||||||
'toggle-dash' : this.activeArea.toggleDash.bind(this.activeArea),
|
'toggle-dash' : this.activeArea.toggleDash.bind(this.activeArea),
|
||||||
'toggle-fill' : this.activeArea.toggleFill.bind(this.activeArea),
|
'toggle-fill' : this.activeArea.toggleFill.bind(this.activeArea),
|
||||||
'select-none-shape': () => this.activeArea.selectTool(Draw.Tools.NONE),
|
'select-none-shape': () => this.activeArea.selectTool(Area.Tools.NONE),
|
||||||
'select-line-shape': () => this.activeArea.selectTool(Draw.Tools.LINE),
|
'select-line-shape': () => this.activeArea.selectTool(Area.Tools.LINE),
|
||||||
'select-ellipse-shape': () => this.activeArea.selectTool(Draw.Tools.ELLIPSE),
|
'select-ellipse-shape': () => this.activeArea.selectTool(Area.Tools.ELLIPSE),
|
||||||
'select-rectangle-shape': () => this.activeArea.selectTool(Draw.Tools.RECTANGLE),
|
'select-rectangle-shape': () => this.activeArea.selectTool(Area.Tools.RECTANGLE),
|
||||||
'select-text-shape': () => this.activeArea.selectTool(Draw.Tools.TEXT),
|
'select-text-shape': () => this.activeArea.selectTool(Area.Tools.TEXT),
|
||||||
'select-polygon-shape': () => this.activeArea.selectTool(Draw.Tools.POLYGON),
|
'select-polygon-shape': () => this.activeArea.selectTool(Area.Tools.POLYGON),
|
||||||
'select-polyline-shape': () => this.activeArea.selectTool(Draw.Tools.POLYLINE),
|
'select-polyline-shape': () => this.activeArea.selectTool(Area.Tools.POLYLINE),
|
||||||
'select-move-tool': () => this.activeArea.selectTool(Draw.Tools.MOVE),
|
'select-move-tool': () => this.activeArea.selectTool(Area.Tools.MOVE),
|
||||||
'select-resize-tool': () => this.activeArea.selectTool(Draw.Tools.RESIZE),
|
'select-resize-tool': () => this.activeArea.selectTool(Area.Tools.RESIZE),
|
||||||
'select-mirror-tool': () => this.activeArea.selectTool(Draw.Tools.MIRROR)
|
'select-mirror-tool': () => this.activeArea.selectTool(Area.Tools.MIRROR)
|
||||||
};
|
};
|
||||||
|
|
||||||
// available when writing
|
// available when writing
|
||||||
|
|
|
||||||
16
menu.js
16
menu.js
|
|
@ -36,7 +36,7 @@ const Slider = imports.ui.slider;
|
||||||
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
const Me = ExtensionUtils.getCurrentExtension();
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
const Draw = Me.imports.draw;
|
const Area = Me.imports.area;
|
||||||
const Elements = Me.imports.elements;
|
const Elements = Me.imports.elements;
|
||||||
const Extension = Me.imports.extension;
|
const Extension = Me.imports.extension;
|
||||||
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
|
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
|
||||||
|
|
@ -154,7 +154,7 @@ var DrawingMenu = new Lang.Class({
|
||||||
this.menu.addAction(_("Smooth"), this.area.smoothLastElement.bind(this.area), 'format-text-strikethrough-symbolic');
|
this.menu.addAction(_("Smooth"), this.area.smoothLastElement.bind(this.area), 'format-text-strikethrough-symbolic');
|
||||||
this._addSeparator(this.menu);
|
this._addSeparator(this.menu);
|
||||||
|
|
||||||
this._addSubMenuItem(this.menu, 'document-edit-symbolic', Draw.ToolNames, this.area, 'currentTool', this._updateSectionVisibility.bind(this));
|
this._addSubMenuItem(this.menu, 'document-edit-symbolic', Area.ToolNames, this.area, 'currentTool', this._updateSectionVisibility.bind(this));
|
||||||
this._addColorSubMenuItem(this.menu);
|
this._addColorSubMenuItem(this.menu);
|
||||||
this.fillItem = this._addSwitchItem(this.menu, _("Fill"), this.strokeIcon, this.fillIcon, this.area, 'fill', this._updateSectionVisibility.bind(this));
|
this.fillItem = this._addSwitchItem(this.menu, _("Fill"), this.strokeIcon, this.fillIcon, this.area, 'fill', this._updateSectionVisibility.bind(this));
|
||||||
this.fillSection = new PopupMenu.PopupMenuSection();
|
this.fillSection = new PopupMenu.PopupMenuSection();
|
||||||
|
|
@ -174,7 +174,7 @@ var DrawingMenu = new Lang.Class({
|
||||||
this.lineSection = lineSection;
|
this.lineSection = lineSection;
|
||||||
|
|
||||||
let fontSection = new PopupMenu.PopupMenuSection();
|
let fontSection = new PopupMenu.PopupMenuSection();
|
||||||
let FontGenericNamesCopy = Object.create(Draw.FontGenericNames);
|
let FontGenericNamesCopy = Object.create(Area.FontGenericNames);
|
||||||
FontGenericNamesCopy[0] = this.area.currentThemeFontFamily;
|
FontGenericNamesCopy[0] = this.area.currentThemeFontFamily;
|
||||||
this._addSubMenuItem(fontSection, 'font-x-generic-symbolic', FontGenericNamesCopy, this.area, 'currentFontGeneric');
|
this._addSubMenuItem(fontSection, 'font-x-generic-symbolic', FontGenericNamesCopy, this.area, 'currentFontGeneric');
|
||||||
this._addSubMenuItem(fontSection, 'format-text-bold-symbolic', Elements.FontWeightNames, this.area, 'currentFontWeight');
|
this._addSubMenuItem(fontSection, 'format-text-bold-symbolic', Elements.FontWeightNames, this.area, 'currentFontWeight');
|
||||||
|
|
@ -204,7 +204,7 @@ var DrawingMenu = new Lang.Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateSectionVisibility: function() {
|
_updateSectionVisibility: function() {
|
||||||
if (this.area.currentTool != Draw.Tools.TEXT) {
|
if (this.area.currentTool != Area.Tools.TEXT) {
|
||||||
this.lineSection.actor.show();
|
this.lineSection.actor.show();
|
||||||
this.fontSection.actor.hide();
|
this.fontSection.actor.hide();
|
||||||
this.fillItem.setSensitive(true);
|
this.fillItem.setSensitive(true);
|
||||||
|
|
@ -320,9 +320,9 @@ var DrawingMenu = new Lang.Class({
|
||||||
subItem.label.get_clutter_text().set_use_markup(true);
|
subItem.label.get_clutter_text().set_use_markup(true);
|
||||||
|
|
||||||
// change the display order of tools
|
// change the display order of tools
|
||||||
if (obj == Draw.ToolNames && i == Draw.Tools.POLYGON)
|
if (obj == Area.ToolNames && i == Area.Tools.POLYGON)
|
||||||
item.menu.moveMenuItem(subItem, 4);
|
item.menu.moveMenuItem(subItem, 4);
|
||||||
else if (obj == Draw.ToolNames && i == Draw.Tools.POLYLINE)
|
else if (obj == Area.ToolNames && i == Area.Tools.POLYLINE)
|
||||||
item.menu.moveMenuItem(subItem, 5);
|
item.menu.moveMenuItem(subItem, 5);
|
||||||
}
|
}
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
|
|
@ -394,7 +394,7 @@ var DrawingMenu = new Lang.Class({
|
||||||
|
|
||||||
_populateOpenDrawingSubMenu: function() {
|
_populateOpenDrawingSubMenu: function() {
|
||||||
this.openDrawingSubMenu.removeAll();
|
this.openDrawingSubMenu.removeAll();
|
||||||
let jsonFiles = Draw.getJsonFiles();
|
let jsonFiles = Area.getJsonFiles();
|
||||||
jsonFiles.forEach(file => {
|
jsonFiles.forEach(file => {
|
||||||
let item = this.openDrawingSubMenu.addAction(`<i>${file.displayName}</i>`, () => {
|
let item = this.openDrawingSubMenu.addAction(`<i>${file.displayName}</i>`, () => {
|
||||||
this.area.loadJson(file.name);
|
this.area.loadJson(file.name);
|
||||||
|
|
@ -450,7 +450,7 @@ var DrawingMenu = new Lang.Class({
|
||||||
|
|
||||||
_populateSaveDrawingSubMenu: function() {
|
_populateSaveDrawingSubMenu: function() {
|
||||||
this.saveDrawingSubMenu.removeAll();
|
this.saveDrawingSubMenu.removeAll();
|
||||||
let saveEntry = new DrawingMenuEntry({ initialTextGetter: Draw.getDateString,
|
let saveEntry = new DrawingMenuEntry({ initialTextGetter: Area.getDateString,
|
||||||
entryActivateCallback: (text) => {
|
entryActivateCallback: (text) => {
|
||||||
this.area.saveAsJsonWithName(text);
|
this.area.saveAsJsonWithName(text);
|
||||||
this.saveDrawingSubMenu.toggle();
|
this.saveDrawingSubMenu.toggle();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue