diff options
author | George L. Albany <Megacake1234@gmail.com> | 2024-10-23 19:57:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-23 19:57:42 +0000 |
commit | 3383574da59b5296023e547018d5b0d69cf605dc (patch) | |
tree | 00aadc86431cdae11880a09bb2d51f9184931f35 | |
parent | 5320e3b5d66e213a2107c76f94e32f91a7e87732 (diff) | |
parent | e8e8a88280e7a87fad98c852c04cafd963bbb065 (diff) | |
download | redot-engine-3383574da59b5296023e547018d5b0d69cf605dc.tar.gz |
Merge pull request #726 from valkyrienyanko/add-pixel-snap-to-tile-editor
Add One Pixel Snap Button to the Tile Data Editor
-rw-r--r-- | editor/icons/SnapHalf.svg (renamed from editor/icons/Snap.svg) | 0 | ||||
-rw-r--r-- | editor/icons/SnapOne.svg | 1 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_data_editors.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_data_editors.h | 1 |
4 files changed, 10 insertions, 2 deletions
diff --git a/editor/icons/Snap.svg b/editor/icons/SnapHalf.svg index 3c2f76e7a0..3c2f76e7a0 100644 --- a/editor/icons/Snap.svg +++ b/editor/icons/SnapHalf.svg diff --git a/editor/icons/SnapOne.svg b/editor/icons/SnapOne.svg new file mode 100644 index 0000000000..8e74e2e4b8 --- /dev/null +++ b/editor/icons/SnapOne.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#fff" fill-opacity=".8" d="M7,13h2v-2c0-1.1.9-2,2-2s2,.9,2,2v2h2v-2c0-2.2-1.8-4-4-4s-4,1.8-4,4v2Z"/><path fill="#e0e0e0" d="M8,2v3.9h3.9v-3.9h-3.9ZM2,2v3.9h3.9v-3.9h-3.9ZM2,8v3.9h3.9v-3.9h-3.9ZM7,13v2h2v-2h-2ZM13,13v2h2v-2h-2Z"/></svg>
\ No newline at end of file diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index d5d0b10c22..6d08b8ca80 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -498,6 +498,10 @@ void GenericTilePolygonEditor::_snap_point(Point2 &r_point) { r_point = r_point.snappedf(0.5); break; + case SNAP_ONE_PIXEL: + r_point = r_point.snappedf(1.0); + break; + case SNAP_GRID: { const Vector2 tile_size = tile_set->get_tile_size(); r_point = (r_point + tile_size / 2).snapped(tile_size / snap_subdivision->get_value()) - tile_size / 2; @@ -889,8 +893,9 @@ void GenericTilePolygonEditor::_notification(int p_what) { button_center_view->set_icon(get_editor_theme_icon(SNAME("CenterView"))); button_advanced_menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); button_pixel_snap->get_popup()->set_item_icon(0, get_editor_theme_icon(SNAME("SnapDisable"))); - button_pixel_snap->get_popup()->set_item_icon(1, get_editor_theme_icon(SNAME("Snap"))); - button_pixel_snap->get_popup()->set_item_icon(2, get_editor_theme_icon(SNAME("SnapGrid"))); + button_pixel_snap->get_popup()->set_item_icon(1, get_editor_theme_icon(SNAME("SnapHalf"))); + button_pixel_snap->get_popup()->set_item_icon(2, get_editor_theme_icon(SNAME("SnapOne"))); + button_pixel_snap->get_popup()->set_item_icon(3, get_editor_theme_icon(SNAME("SnapGrid"))); button_pixel_snap->set_icon(button_pixel_snap->get_popup()->get_item_icon(current_snap_option)); PopupMenu *p = button_advanced_menu->get_popup(); @@ -975,6 +980,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { button_pixel_snap->set_tooltip_text(TTR("Toggle Grid Snap")); button_pixel_snap->get_popup()->add_item(TTR("Disable Snap"), SNAP_NONE); button_pixel_snap->get_popup()->add_item(TTR("Half-Pixel Snap"), SNAP_HALF_PIXEL); + button_pixel_snap->get_popup()->add_item(TTR("Pixel Snap"), SNAP_ONE_PIXEL); button_pixel_snap->get_popup()->add_item(TTR("Grid Snap"), SNAP_GRID); button_pixel_snap->get_popup()->connect("index_pressed", callable_mp(this, &GenericTilePolygonEditor::_set_snap_option)); diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h index 2452e8ae48..0dc8160178 100644 --- a/editor/plugins/tiles/tile_data_editors.h +++ b/editor/plugins/tiles/tile_data_editors.h @@ -129,6 +129,7 @@ private: enum Snap { SNAP_NONE, SNAP_HALF_PIXEL, + SNAP_ONE_PIXEL, SNAP_GRID, }; int current_snap_option = SNAP_HALF_PIXEL; |