summaryrefslogtreecommitdiffstats
path: root/editor/plugins
diff options
context:
space:
mode:
authorGeorge L. Albany <Megacake1234@gmail.com>2024-10-23 19:57:42 +0000
committerGitHub <noreply@github.com>2024-10-23 19:57:42 +0000
commit3383574da59b5296023e547018d5b0d69cf605dc (patch)
tree00aadc86431cdae11880a09bb2d51f9184931f35 /editor/plugins
parent5320e3b5d66e213a2107c76f94e32f91a7e87732 (diff)
parente8e8a88280e7a87fad98c852c04cafd963bbb065 (diff)
downloadredot-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
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/tiles/tile_data_editors.cpp10
-rw-r--r--editor/plugins/tiles/tile_data_editors.h1
2 files changed, 9 insertions, 2 deletions
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;