Skip to content

Commit 21cc44e

Browse files
authored
Merge pull request #291 from evolus/development
Release 3.0.1
2 parents d0c3199 + 51b8159 commit 21cc44e

26 files changed

+1090
-275
lines changed

app/app.xhtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<script type="text/javascript" src="views/collections/PrivateCollectionDialog.js"></script>
230230
<script type="text/javascript" src="views/collections/PrivateCollectionMenu.js"></script>
231231
<script type="text/javascript" src="views/collections/ShowAllCollectionMenu.js"></script>
232+
<script type="text/javascript" src="views/collections/CollectionResourceBrowserDialog.js"></script>
232233

233234
<script type="text/javascript" src="pencil-core/definition/collectionRepository.js"></script>
234235
<script type="text/javascript" src="views/collections/CollectionBrowserDialog.js"></script>

app/lib/loader.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@ function loadFontManager() {
99
fmPath = platform;
1010
}
1111

12-
return require(`./font-manager/${fmPath}/fontmanager`);
12+
try {
13+
return require(`./font-manager/${fmPath}/fontmanager`);
14+
} catch (e) {
15+
console.error("Failed to load pre-compiled font manager, returning a dummy version.");
16+
return {
17+
getAvailableFontsSync: function () {
18+
return [
19+
{ family: "Arial"}
20+
];
21+
}
22+
}
23+
}
1324
}
1425

1526
exports.fontManager = loadFontManager();

app/lib/widget/Common.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,15 @@ BaseWidget.signalOnAttachedRecursively = function (container) {
689689
}
690690
if (container.__widget && container.__widget.onAttached) container.__widget.onAttached();
691691
};
692-
692+
BaseWidget.signalOnSizeChangedRecursively = function (container) {
693+
if (container.__widget && container.__widget.onSizeChanged) {
694+
container.__widget.onSizeChanged();
695+
}
696+
for (var i = 0; i < container.childNodes.length; i++) {
697+
var child = container.childNodes[i];
698+
BaseWidget.signalOnSizeChangedRecursively(child);
699+
}
700+
};
693701
BaseWidget.prototype.bind = function (eventName, f, node) {
694702
var n = node || this.__node;
695703
var thiz = this;

app/lib/widget/SplitView.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ widget.SplitView = function () {
2828
var margin = Math.round(W / 10);
2929
p = Math.min(Math.max(p, margin), W - margin);
3030
currentSplitView.setSplitViewPosition(p);
31+
BaseWidget.signalOnSizeChangedRecursively(currentSplitView.node());
32+
3133
currentSplitView.moved = true;
3234
}
3335

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Pencil",
33
"productName": "Pencil",
44
"description": "An open-source GUI prototyping tool that is available for ALL platforms.",
5-
"version": "3.0.0",
5+
"version": "3.0.1",
66
"author": {
77
"name": "Evolus",
88
"url": "http://evolus.vn",

app/pencil-core/behavior/SVGTextLayout.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ SVGHTMLRenderer.prototype.isInline = function (node) {
1818
return (display == "inline" || display == "inline-block");
1919
};
2020
SVGHTMLRenderer.prototype.layout = function (nodes, view, outmost) {
21-
console.log("NODES" , nodes);
2221
var layouts = [];
2322
var inlines = [];
2423
for (var i = 0; i < nodes.length; i ++) {
@@ -283,7 +282,6 @@ SVGHTMLRenderer.prototype.renderHTML = function (html, container, view) {
283282
}
284283

285284
div.innerHTML = html;
286-
console.log("IMPORT HTML:", div);
287285
this.render(div.childNodes, container, view);
288286

289287
div.parentNode.removeChild(div);

app/pencil-core/behavior/commonBehaviors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ Pencil.behaviors.NPatchDomContent = function (nPatch, dim) {
643643
this.appendChild(buildNPatchDomFragment(nPatch, dim));
644644
};
645645

646-
Pencil.behaviors.NPatchDomContentFromImage = function (imageData, dim) {
646+
Pencil.behaviors.NPatchDomContentFromImage = function (imageData, dim, xAnchorMaps, yAnchorMaps) {
647647
//sorting
648648
var xCells = imageData.xCells;
649649
if (!xCells || xCells.length == 0) xCells = [{from: 0, to: imageData.w}];

app/pencil-core/common/controller.js

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,136 @@ Controller.prototype.prepareForEmbedding = function (node, onPreparingDoneCallba
12841284
});
12851285
};
12861286

1287+
Controller.prototype.exportAsLayout = function () {
1288+
var container = Pencil.activeCanvas.drawingLayer;
1289+
1290+
var pw = parseFloat(this.activePage.width);
1291+
var ph = parseFloat(this.activePage.height);
1292+
1293+
var items = [];
1294+
1295+
var outputPath = null;
1296+
var outputDir = null;
1297+
const IMAGE_FILE = "layout_image.png";
1298+
1299+
var devCollection = CollectionManager.getDeveloperStencil();
1300+
1301+
Dom.workOn("//svg:g[@p:type='Shape']", container, function (g) {
1302+
var dx = 0; //rect.left;
1303+
var dy = 0; //rect.top;
1304+
1305+
var owner = g.ownerSVGElement;
1306+
1307+
if (owner.parentNode && owner.parentNode.getBoundingClientRect) {
1308+
var rect = owner.parentNode.getBoundingClientRect();
1309+
dx = rect.left;
1310+
dy = rect.top;
1311+
}
1312+
1313+
debug("dx, dy: " + [dx, dy]);
1314+
1315+
rect = g.getBoundingClientRect();
1316+
1317+
var linkingInfo = {
1318+
node: g,
1319+
sc: g.getAttributeNS(PencilNamespaces.p, "sc"),
1320+
refId: g.getAttributeNS(PencilNamespaces.p, "def"),
1321+
geo: {
1322+
x: rect.left - dx,
1323+
y: rect.top - dy,
1324+
w: rect.width - 2,
1325+
h: rect.height - 2
1326+
}
1327+
};
1328+
1329+
if (devCollection) {
1330+
if (linkingInfo.sc) {
1331+
if (!devCollection.getShortcutByDisplayName(devCollection.id + ":" + linkingInfo.sc)) return;
1332+
} else if (linkingInfo.refId) {
1333+
if (!devCollection.getShapeDefById(linkingInfo.refId)) return;
1334+
}
1335+
}
1336+
// if (!linkingInfo.refId) return;
1337+
1338+
items.push(linkingInfo);
1339+
});
1340+
1341+
var current = 0;
1342+
var thiz = this;
1343+
var done = function () {
1344+
var html = document.createElementNS(PencilNamespaces.html, "html");
1345+
1346+
var body = document.createElementNS(PencilNamespaces.html, "body");
1347+
html.appendChild(body);
1348+
1349+
var div = document.createElementNS(PencilNamespaces.html, "div");
1350+
div.setAttribute("style", "position: relative; padding: 0px; margin: 0px; width: " + pw + "px; height: " + ph + "px;");
1351+
body.appendChild(div);
1352+
1353+
/*
1354+
var canvas = document.createElementNS(PencilNamespaces.html, "canvas");
1355+
canvas.setAttribute("width", pw);
1356+
canvas.setAttribute("height", ph);
1357+
1358+
*/
1359+
1360+
var bg = document.createElementNS(PencilNamespaces.html, "img");
1361+
bg.setAttribute("style", "width: " + pw + "px; height: " + ph + "px;");
1362+
bg.setAttribute("src", IMAGE_FILE + "?ts=" + (new Date().getTime()));
1363+
div.appendChild(bg);
1364+
1365+
for (var i = 0; i < items.length; i ++) {
1366+
var link = items[i];
1367+
var img = document.createElementNS(PencilNamespaces.html, "img");
1368+
img.setAttribute("src", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=");
1369+
if (link.sc) {
1370+
img.setAttribute("sc-ref", link.sc);
1371+
} else {
1372+
img.setAttribute("ref", link.refId);
1373+
}
1374+
img.setAttribute("id", link.refId);
1375+
var css = new CSS();
1376+
css.set("position", "absolute");
1377+
css.set("left", "" + link.geo.x + "px");
1378+
css.set("top", "" + link.geo.y + "px");
1379+
css.set("width", "" + link.geo.w + "px");
1380+
css.set("height", "" + link.geo.h + "px");
1381+
/*
1382+
css.set("left", "" + (100 * link.geo.x / pw) + "%");
1383+
css.set("top", "" + (100 * link.geo.y / ph) + "%");
1384+
css.set("width", "" + (100 * link.geo.w / pw) + "%");
1385+
css.set("height", "" + (100 * link.geo.h / ph) + "%");
1386+
*/
1387+
img.setAttribute("style", css.toString());
1388+
1389+
div.appendChild(img);
1390+
}
1391+
1392+
Dom.serializeNodeToFile(html, outputPath, "");
1393+
CollectionManager.reloadDeveloperStencil();
1394+
};
1395+
1396+
1397+
var defaultPath = "Layout.xhtml";
1398+
if (devCollection) {
1399+
defaultPath = path.join(devCollection.installDirPath, defaultPath);
1400+
}
1401+
1402+
dialog.showSaveDialog(remote.getCurrentWindow(), {
1403+
title: "Export Layout",
1404+
defaultPath: defaultPath,
1405+
filters: [{name: 'XHTML Layout', extensions: ["xhtml"]}]
1406+
}, function (filePath) {
1407+
if (filePath) {
1408+
outputPath = filePath;
1409+
outputImage = path.join(path.dirname(outputPath), IMAGE_FILE);
1410+
Pencil.rasterizer.rasterizePageToFile(thiz.activePage, outputImage, function (p, error) {
1411+
done();
1412+
});
1413+
}
1414+
});
1415+
};
1416+
12871417

12881418
window.onbeforeunload = function (event) {
12891419
// Due to a change of Chrome 51, returning non-empty strings or true in beforeunload handler now prevents the page to unload

0 commit comments

Comments
 (0)