Better scroll and slider API

This commit is contained in:
Insality
2020-03-21 19:40:50 +03:00
parent c41957c751
commit b33efd692f
4 changed files with 59 additions and 8 deletions

View File

@@ -6153,7 +6153,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Tap me!"
text: "<<<"
font: "game"
id: "button_left/text"
xanchor: XANCHOR_NONE
@@ -6179,6 +6179,7 @@ nodes {
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.78
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
@@ -6311,7 +6312,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Tap me!"
text: ">>>"
font: "game"
id: "button_right/text"
xanchor: XANCHOR_NONE
@@ -6337,6 +6338,7 @@ nodes {
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.78
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0

View File

@@ -17,17 +17,16 @@ local function init_grid(self)
end
gui.set_enabled(prefab, false)
local grid_scroll = self.druid:new_scroll("grid_content", "scroll_with_grid_size")
local size = grid:get_size()
grid_scroll:set_border(grid:get_size())
local scroll_slider = self.druid:new_slider("grid_scroll_pin", vmath.vector3(300, 0, 0), function(_, value)
grid_scroll:scroll_to(vmath.vector3(-size.x * value, size.y, size.z), true)
grid_scroll:scroll_to_percent(vmath.vector3(value, 0, 0), true)
end)
grid_scroll.on_scroll:subscribe(function(_, point)
local value = -point.x / size.x
scroll_slider:set(value)
scroll_slider:set(grid_scroll:get_scroll_percent().x, true)
end)
end