diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index e5364f8..b242eb6 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -23,7 +23,6 @@ function Layout:init(node, mode, on_size_changed_callback) self._min_size = nil self._max_size = nil self._inited = false - self._is_stretch_position = nil self.gui_size = vmath.vector3(gui.get_width(), gui.get_height(), 0) self.mode = mode or const.LAYOUT_MODE.FIT @@ -84,12 +83,8 @@ function Layout:on_window_resized() end gui.set_size(self.node, new_size) - self.position.x = self.origin_position.x - self.position.y = self.origin_position.y - if self._is_stretch_position then - self.position.x = self.position.x + self.origin_position.x * (1 - x_koef) * (self.pivot.x * 2) - self.position.y = self.position.y + self.origin_position.y * (1 - y_koef) * (self.pivot.y * 2) - end + self.position.x = self.origin_position.x + self.origin_position.x * (x_koef - 1) + self.position.y = self.origin_position.y + self.origin_position.y * (y_koef - 1) gui.set_position(self.node, self.position) self.on_size_changed:trigger(self:get_context(), new_size) @@ -114,14 +109,6 @@ function Layout:set_origin_position(new_origin_position) end ---@tparam boolean state -function Layout:set_stretch_position(state) - self._is_stretch_position = state - self:on_window_resized() - return self -end - - function Layout:set_origin_size(new_origin_size) self.origin_size = new_origin_size or self.origin_size self:on_window_resized() diff --git a/example/examples/general/layout/layout.gui b/example/examples/general/layout/layout.gui index 9c1d020..f946c05 100644 --- a/example/examples/general/layout/layout.gui +++ b/example/examples/general/layout/layout.gui @@ -70,7 +70,7 @@ nodes { } nodes { position { - x: 0.0 + x: -100.0 y: 250.0 z: 0.0 w: 1.0 @@ -190,64 +190,8 @@ nodes { } nodes { position { - x: 0.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - size { - x: 1.0 - y: 1.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "kenney/empty" - id: "even_in_fit_node" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "root" - layer: "" - inherit_alpha: true - slice9 { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_AUTO - custom_type: 0 -} -nodes { - position { - x: 0.0 - y: 50.0 + x: -100.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -283,7 +227,7 @@ nodes { yanchor: YANCHOR_NONE pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH - parent: "even_in_fit_node" + parent: "root" layer: "" inherit_alpha: true slice9 { @@ -366,8 +310,8 @@ nodes { } nodes { position { - x: 0.0 - y: -100.0 + x: -100.0 + y: -50.0 z: 0.0 w: 1.0 } @@ -403,7 +347,7 @@ nodes { yanchor: YANCHOR_NONE pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH - parent: "even_in_fit_node" + parent: "root" layer: "" inherit_alpha: true slice9 { @@ -486,8 +430,8 @@ nodes { } nodes { position { - x: 0.0 - y: -250.0 + x: -100.0 + y: -200.0 z: 0.0 w: 1.0 } @@ -523,7 +467,7 @@ nodes { yanchor: YANCHOR_NONE pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH - parent: "even_in_fit_node" + parent: "root" layer: "" inherit_alpha: true slice9 { @@ -606,8 +550,8 @@ nodes { } nodes { position { - x: -150.0 - y: -400.0 + x: -250.0 + y: -350.0 z: 0.0 w: 1.0 } @@ -643,7 +587,7 @@ nodes { yanchor: YANCHOR_NONE pivot: PIVOT_W adjust_mode: ADJUST_MODE_STRETCH - parent: "even_in_fit_node" + parent: "root" layer: "" inherit_alpha: true slice9 {