Cut grid size in half; tidied up the togglegrid lua plugin.

presentation
frohro 6 years ago committed by Fabian Keßler
parent 4c4cf510fb
commit db352f4f86
  1. 22
      plugins/ToggleGrid/togglegrid.lua
  2. 2
      src/control/tools/BaseStrokeHandler.cpp

@ -1,16 +1,18 @@
-- Register all Toolbar actions and intialize all UI stuff
function initUi()
app.registerUi({["menu"] = "Grid with snapping On", ["callback"] = "toggleGridOn"});
app.registerUi({["menu"] = "Grid with snapping Off", ["callback"] = "toggleGridOff"});
app.registerUi({["menu"] = "Toggle Grid Paper", ["callback"] = "toggleGridPaper"});
end
function toggleGridOn()
app.uiActionSelected("GROUP_GRID_SNAPPING", "ACTION_GRID_SNAPPING");
app.changeCurrentPageBackground("graph");
end
local toggleState = false
function toggleGridOff()
app.uiActionSelected("GROUP_GRID_SNAPPING", "ACTION_NONE");
app.changeCurrentPageBackground("plain");
end
function toggleGridPaper()
if toggleState == true then
app.uiActionSelected("GROUP_GRID_SNAPPING", "ACTION_GRID_SNAPPING");
app.changeCurrentPageBackground("graph");
else
app.uiActionSelected("GROUP_GRID_SNAPPING", "ACTION_NONE");
app.changeCurrentPageBackground("plain");
end
toggleState = not toggleState
end

@ -30,7 +30,7 @@ void BaseStrokeHandler::snapToGrid(double& x, double& y) {
* If x/y coordinates are under a certain tolerance,
* fix the point to the grid intersection value
*/
double gridSize = 14.17;
double gridSize = 14.17 / 2.0;
double t = xournal->getControl()->getSettings()->getSnapGridTolerance();
double tolerance = (gridSize / 2) - (1 / t);

Loading…
Cancel
Save