Click on zoom label in 2d view to set 100% zoom

This commit is contained in:
luboslenco
2025-12-02 19:02:02 +01:00
parent 9072d340fd
commit 1e1cfcbfac
+14 -6
View File
@@ -358,17 +358,29 @@ function ui_view2d_render() {
ui._y = 2 + start_y;
}
ui._w = math_floor(ew * 0.7 + 3);
let h_tiled_show: ui_handle_t = ui_handle(__ID__);
if (h_tiled_show.init) {
h_tiled_show.b = ui_view2d_tiled_show;
}
ui_view2d_tiled_show = ui_check(h_tiled_show, tr("Tiled"));
ui._x += ew * 0.7 + 3;
ui._x += ew * 0.6 + 3;
ui._y = 2 + start_y;
if (tex != null) {
ui._w = math_floor(ew * 0.5 + 3);
let scale_percent: i32 = math_round((tw / tex.width) * 100);
if (ui_text(scale_percent + "%") == ui_state_t.STARTED) {
ui_view2d_pan_scale = tex.width / (ui_view2d_ww * 0.95);
}
ui._x += ew * 0.5 + 3;
ui._y = 2 + start_y;
}
ui.enabled = false;
if ((ui_view2d_type == view_2d_type_t.ASSET || ui_view2d_type == view_2d_type_t.NODE) && tex != null) { // Texture resolution
ui._w = math_floor(ew * 0.7 + 3);
ui_text(tex.width + "x" + tex.height);
ui._x += ew * 0.7 + 3;
ui._y = 2 + start_y;
@@ -378,15 +390,11 @@ function ui_view2d_render() {
: ui_view2d_type == view_2d_type_t.NODE ? "Node"
: ui_view2d_type == view_2d_type_t.FONT ? "Font"
: "Layer";
ui._w = math_floor(ew * 0.5 + 3);
ui_text(view_type);
ui._x += ew * 0.5 + 3;
ui._y = 2 + start_y;
if (tex != null) {
let scale_percent: i32 = math_round((tw / tex.width) * 100);
ui_text(scale_percent + "%");
}
ui.enabled = true;
// Picked position