Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Grid appearance setting #733

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions app/content/pencil/canvasHelper/canvasImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,35 @@ CanvasImpl.setupGrid = function () {
var grid = Pencil.getGridSize();
if (grid.w > 0 && grid.h > 0) {
var z = this.zoom ? this.zoom : 1;
for (var i = 1; i < this.width * z; i += grid.w * z) {
var line = document.createElementNS(PencilNamespaces.svg, "svg:line");
line.setAttribute("x1", i);
line.setAttribute("y1", 0);
line.setAttribute("x2", i);
line.setAttribute("y2", this.height * z);
line.setAttribute("style", "stroke-dasharray: 1," + (grid.h - 1) * z + ";");
this.gridContainer.appendChild(line);

if (Config.get("edit.gridAppearance") === 'dots') {
for (var i = 1; i < this.width * z; i += grid.w * z) {
var line = document.createElementNS(PencilNamespaces.svg, "svg:line");
line.setAttribute("x1", i);
line.setAttribute("y1", 0);
line.setAttribute("x2", i);
line.setAttribute("y2", this.height * z);
line.setAttribute("style", "stroke-dasharray: 1," + (grid.h - 1) * z + ";");
this.gridContainer.appendChild(line);
}
} else {
for (var i = 1; i < this.width * z; i += grid.w * z) {
var line = document.createElementNS(PencilNamespaces.svg, "svg:line");
line.setAttribute("x1", i);
line.setAttribute("y1", 0);
line.setAttribute("x2", i);
line.setAttribute("y2", this.height * z);
this.gridContainer.appendChild(line);
}

for (var i = 1; i < this.height * z; i += grid.h * z) {
var line = document.createElementNS(PencilNamespaces.svg, "svg:line");
line.setAttribute("x1", 0);
line.setAttribute("y1", i);
line.setAttribute("x2", this.width * z);
line.setAttribute("y2", i);
this.gridContainer.appendChild(line);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/content/pencil/settingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ handleOnLoad = function () {
document.getElementById("undoEnabled").checked = Config.get("view.undoLevel") > 0;
document.getElementById("labelGridSize").disabled = Config.get("grid.enabled") == false;
document.getElementById("textboxGridSize").disabled = Config.get("grid.enabled") == false;
document.getElementById("menuGridAppearance").disabled = Config.get("grid.enabled") == false;

document.getElementById("enableSnappingBackground").disabled = Config.get("object.snapping.enabled") == false;

Expand Down
8 changes: 8 additions & 0 deletions app/content/pencil/settingDialog.xul
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
name="pencil.config.edit.gridSize" type="int" instantApply="true" />
<preference id="pencil-snapToGrid"
name="pencil.config.edit.snap.grid" type="bool" instantApply="true" />
<preference id="pencil-gridAppearance"
name="pencil.config.edit.gridAppearance" type="string" instantApply="true" />
<preference id="pencil-objectSnappingEnabled"
name="pencil.config.object.snapping.enabled" type="bool" instantApply="true" />
<preference id="pencil-objectSnappingBackground"
Expand Down Expand Up @@ -91,6 +93,12 @@
preference="pencil-gridEnabled"/>
<label value="&label.grid.size.value;" id="labelGridSize"/>
<textbox id="textboxGridSize" size="1" type="number" min="1" max="256" preference="pencil-gridSize"/>
<menulist id="menuGridAppearance" preference="pencil-gridAppearance">
<menupopup>
<menuitem label="Dots" value="dots"/>
<menuitem label="Lines" value="lines"/>
</menupopup>
</menulist>
</hbox>
</row>
<row align="center">
Expand Down
1 change: 1 addition & 0 deletions app/defaults/preferences/pencil.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pref("pencil.config.grid.enabled", true);
pref("pencil.config.edit.gridSize", 8);
pref("pencil.config.edit.gridAppearance", "dots");
pref("pencil.config.edit.snap.grid", false);
pref("pencil.config.object.snapping.enabled", true);
pref("pencil.config.object.snapping.background", true);
Expand Down