diff --git a/plugins/ToggleGrid/togglegrid.lua b/plugins/ToggleGrid/togglegrid.lua index ec3bfe2b..260164ad 100644 --- a/plugins/ToggleGrid/togglegrid.lua +++ b/plugins/ToggleGrid/togglegrid.lua @@ -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 \ No newline at end of file diff --git a/src/control/tools/BaseStrokeHandler.cpp b/src/control/tools/BaseStrokeHandler.cpp index 46b81c85..8b5c8fdb 100644 --- a/src/control/tools/BaseStrokeHandler.cpp +++ b/src/control/tools/BaseStrokeHandler.cpp @@ -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);