Layout component update

This commit is contained in:
Insality 2022-07-17 18:23:07 +03:00
parent 43f75cd820
commit 45b4843887
2 changed files with 15 additions and 84 deletions

View File

@ -23,7 +23,6 @@ function Layout:init(node, mode, on_size_changed_callback)
self._min_size = nil self._min_size = nil
self._max_size = nil self._max_size = nil
self._inited = false self._inited = false
self._is_stretch_position = nil
self.gui_size = vmath.vector3(gui.get_width(), gui.get_height(), 0) self.gui_size = vmath.vector3(gui.get_width(), gui.get_height(), 0)
self.mode = mode or const.LAYOUT_MODE.FIT self.mode = mode or const.LAYOUT_MODE.FIT
@ -84,12 +83,8 @@ function Layout:on_window_resized()
end end
gui.set_size(self.node, new_size) gui.set_size(self.node, new_size)
self.position.x = self.origin_position.x self.position.x = self.origin_position.x + self.origin_position.x * (x_koef - 1)
self.position.y = self.origin_position.y self.position.y = self.origin_position.y + self.origin_position.y * (y_koef - 1)
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
gui.set_position(self.node, self.position) gui.set_position(self.node, self.position)
self.on_size_changed:trigger(self:get_context(), new_size) self.on_size_changed:trigger(self:get_context(), new_size)
@ -114,14 +109,6 @@ function Layout:set_origin_position(new_origin_position)
end 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) function Layout:set_origin_size(new_origin_size)
self.origin_size = new_origin_size or self.origin_size self.origin_size = new_origin_size or self.origin_size
self:on_window_resized() self:on_window_resized()

View File

@ -70,7 +70,7 @@ nodes {
} }
nodes { nodes {
position { position {
x: 0.0 x: -100.0
y: 250.0 y: 250.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0
@ -190,64 +190,8 @@ nodes {
} }
nodes { nodes {
position { position {
x: 0.0 x: -100.0
y: 50.0 y: 100.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
z: 0.0 z: 0.0
w: 1.0 w: 1.0
} }
@ -283,7 +227,7 @@ nodes {
yanchor: YANCHOR_NONE yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_STRETCH adjust_mode: ADJUST_MODE_STRETCH
parent: "even_in_fit_node" parent: "root"
layer: "" layer: ""
inherit_alpha: true inherit_alpha: true
slice9 { slice9 {
@ -366,8 +310,8 @@ nodes {
} }
nodes { nodes {
position { position {
x: 0.0 x: -100.0
y: -100.0 y: -50.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0
} }
@ -403,7 +347,7 @@ nodes {
yanchor: YANCHOR_NONE yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_STRETCH adjust_mode: ADJUST_MODE_STRETCH
parent: "even_in_fit_node" parent: "root"
layer: "" layer: ""
inherit_alpha: true inherit_alpha: true
slice9 { slice9 {
@ -486,8 +430,8 @@ nodes {
} }
nodes { nodes {
position { position {
x: 0.0 x: -100.0
y: -250.0 y: -200.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0
} }
@ -523,7 +467,7 @@ nodes {
yanchor: YANCHOR_NONE yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_STRETCH adjust_mode: ADJUST_MODE_STRETCH
parent: "even_in_fit_node" parent: "root"
layer: "" layer: ""
inherit_alpha: true inherit_alpha: true
slice9 { slice9 {
@ -606,8 +550,8 @@ nodes {
} }
nodes { nodes {
position { position {
x: -150.0 x: -250.0
y: -400.0 y: -350.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0
} }
@ -643,7 +587,7 @@ nodes {
yanchor: YANCHOR_NONE yanchor: YANCHOR_NONE
pivot: PIVOT_W pivot: PIVOT_W
adjust_mode: ADJUST_MODE_STRETCH adjust_mode: ADJUST_MODE_STRETCH
parent: "even_in_fit_node" parent: "root"
layer: "" layer: ""
inherit_alpha: true inherit_alpha: true
slice9 { slice9 {