Extend minimum/maximum zoom level of TextureRegion editor

This also applies a similar change to the SpriteFrames editor.
This commit is contained in:
Hugo Locurcio 2023-07-13 20:29:47 +02:00
parent fa48a51183
commit 085629a7c9
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
3 changed files with 9 additions and 2 deletions

View File

@ -2178,7 +2178,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
min_thumbnail_zoom = 0.1f * MAX(1.0f, EDSCALE); min_thumbnail_zoom = 0.1f * MAX(1.0f, EDSCALE);
// Default the zoom to match the editor scale, but don't dezoom on editor scales below 100% to prevent pixel art from looking bad. // Default the zoom to match the editor scale, but don't dezoom on editor scales below 100% to prevent pixel art from looking bad.
sheet_zoom = MAX(1.0f, EDSCALE); sheet_zoom = MAX(1.0f, EDSCALE);
max_sheet_zoom = 16.0f * MAX(1.0f, EDSCALE); max_sheet_zoom = 128.0f * MAX(1.0f, EDSCALE);
min_sheet_zoom = 0.01f * MAX(1.0f, EDSCALE); min_sheet_zoom = 0.01f * MAX(1.0f, EDSCALE);
_zoom_reset(); _zoom_reset();

View File

@ -698,7 +698,7 @@ void TextureRegionEditor::_set_snap_sep_y(float p_val) {
} }
void TextureRegionEditor::_zoom_on_position(float p_zoom, Point2 p_position) { void TextureRegionEditor::_zoom_on_position(float p_zoom, Point2 p_position) {
if (p_zoom < 0.25 || p_zoom > 8) { if (p_zoom < min_draw_zoom || p_zoom > max_draw_zoom) {
return; return;
} }
@ -1166,6 +1166,11 @@ TextureRegionEditor::TextureRegionEditor() {
hb_grid->hide(); hb_grid->hide();
// Default the zoom to match the editor scale, but don't dezoom on editor scales below 100% to prevent pixel art from looking bad.
draw_zoom = MAX(1.0f, EDSCALE);
max_draw_zoom = 128.0f * MAX(1.0f, EDSCALE);
min_draw_zoom = 0.01f * MAX(1.0f, EDSCALE);
texture_preview = memnew(PanelContainer); texture_preview = memnew(PanelContainer);
vb->add_child(texture_preview); vb->add_child(texture_preview);
texture_preview->set_v_size_flags(Control::SIZE_EXPAND_FILL); texture_preview->set_v_size_flags(Control::SIZE_EXPAND_FILL);

View File

@ -76,6 +76,8 @@ class TextureRegionEditor : public AcceptDialog {
Vector2 draw_ofs; Vector2 draw_ofs;
float draw_zoom = 1.0; float draw_zoom = 1.0;
float min_draw_zoom = 1.0;
float max_draw_zoom = 1.0;
bool updating_scroll = false; bool updating_scroll = false;
SnapMode snap_mode = SNAP_NONE; SnapMode snap_mode = SNAP_NONE;