Skip to content

Commit 1e1cfcb

Browse files
committed
Click on zoom label in 2d view to set 100% zoom
1 parent 9072d34 commit 1e1cfcb

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

paint/sources/ui_view2d.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,29 @@ function ui_view2d_render() {
358358
ui._y = 2 + start_y;
359359
}
360360

361+
ui._w = math_floor(ew * 0.7 + 3);
361362
let h_tiled_show: ui_handle_t = ui_handle(__ID__);
362363
if (h_tiled_show.init) {
363364
h_tiled_show.b = ui_view2d_tiled_show;
364365
}
365366
ui_view2d_tiled_show = ui_check(h_tiled_show, tr("Tiled"));
366-
ui._x += ew * 0.7 + 3;
367+
ui._x += ew * 0.6 + 3;
367368
ui._y = 2 + start_y;
368369

370+
if (tex != null) {
371+
ui._w = math_floor(ew * 0.5 + 3);
372+
let scale_percent: i32 = math_round((tw / tex.width) * 100);
373+
if (ui_text(scale_percent + "%") == ui_state_t.STARTED) {
374+
ui_view2d_pan_scale = tex.width / (ui_view2d_ww * 0.95);
375+
}
376+
ui._x += ew * 0.5 + 3;
377+
ui._y = 2 + start_y;
378+
}
379+
369380
ui.enabled = false;
370381

371382
if ((ui_view2d_type == view_2d_type_t.ASSET || ui_view2d_type == view_2d_type_t.NODE) && tex != null) { // Texture resolution
383+
ui._w = math_floor(ew * 0.7 + 3);
372384
ui_text(tex.width + "x" + tex.height);
373385
ui._x += ew * 0.7 + 3;
374386
ui._y = 2 + start_y;
@@ -378,15 +390,11 @@ function ui_view2d_render() {
378390
: ui_view2d_type == view_2d_type_t.NODE ? "Node"
379391
: ui_view2d_type == view_2d_type_t.FONT ? "Font"
380392
: "Layer";
393+
ui._w = math_floor(ew * 0.5 + 3);
381394
ui_text(view_type);
382395
ui._x += ew * 0.5 + 3;
383396
ui._y = 2 + start_y;
384397

385-
if (tex != null) {
386-
let scale_percent: i32 = math_round((tw / tex.width) * 100);
387-
ui_text(scale_percent + "%");
388-
}
389-
390398
ui.enabled = true;
391399

392400
// Picked position

0 commit comments

Comments
 (0)