Add option to enable the Snap to Grid option for the brush preview (fix #4137)

This commit is contained in:
David Capello 2023-11-15 20:30:58 -03:00
parent edb2393690
commit 1311944667
4 changed files with 7 additions and 1 deletions

View File

@ -212,6 +212,7 @@
<option id="cursor_color" type="app::Color" default="app::Color::fromMask()" />
<option id="painting_cursor_type" type="PaintingCursorType" default="PaintingCursorType::CROSSHAIR_ON_SPRITE" />
<option id="brush_preview" type="BrushPreview" default="BrushPreview::FULL" />
<option id="snap_to_grid" type="bool" default="false" />
</section>
<section id="preview" text="Preview">
<option id="play_once" type="bool" default="false" />

View File

@ -1701,6 +1701,7 @@ brush_preview_fullnedges = Full Preview and Edges
cursor_color_type = Crosshair && Brush Edges Color:
cursor_neg_bw = Negative Black and White
cursor_specific_color = Specific Color
snap_cursor_to_grid = Snap To Grid when the option is enabled
bg_checkered = Checkered Background
bg_size = Size:
bg_custom_size = Custom

View File

@ -346,6 +346,9 @@
<boxfiller />
<colorpicker id="cursor_color" rgba="true" />
<check text="@.snap_cursor_to_grid"
pref="cursor.snap_to_grid" cell_hspan="2" />
</grid>
</vbox>

View File

@ -176,7 +176,8 @@ void BrushPreview::show(const gfx::Point& screenPos)
// Get cursor position in the editor
gfx::Point spritePos = m_editor->screenToEditor(screenPos);
if (m_editor->docPref().grid.snap()) {
if (pref.cursor.snapToGrid() &&
m_editor->docPref().grid.snap()) {
spritePos = snap_to_grid(m_editor->docPref().grid.bounds(),
spritePos,
PreferSnapTo::ClosestGridVertex) +