mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Better scroll and slider API
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user