Druid question for scrolling gui node

I am aiming to get @Insality’s attention, but maybe someone else can help me out?

In the video, you can see that the scrolling seems broken as I am allowed to go higher than the top most content entry. The content is entered via templates and I modify the data at run time.

I doubt druid is broken as I have used standard controls in my game in production. I am just trying to figure out what could cause it to go beyond the boundary.

I added some code, minus my module, to show what is happening

-- Create the grid for the colors
	self.color_grid = createGrid(self, colors, "colors/content", "tile_prefab" )
	-- Tasks
	self.task_grid = createGrid(self, tasks, "tasks/content", "tile_prefab" )
	-- Specials
	self.special_grid = createGrid(self, specials, "specials/content", "tile_prefab" )
	-- Blockers
	self.blocker_grid = createGrid(self, blockers, "blockers/content", "tile_prefab" )
	-- Locks
	self.lock_grid = createGrid(self, locks, "locks/content", "tile_prefab" )

	-------------------------------------------
	-- Draw the dropdown items consecutively
	-- Going downward
	-------------------------------------------
	local parent_top = 0

	-- local roots = {
	-- 	[1] = { root = "colors", anchor_bottom = "tasks", header_color = vmath.vector4(0xF9 / 255, 0xDD / 255, 0x12 / 255, 1) },
	-- 	[2] = { root = "tasks", anchor_bottom = "specials", header_color = vmath.vector4(0xFD / 255, 0x51 / 255, 0x39 / 255, 1) }, 
	-- 	[3] = { root = "specials", anchor_bottom = "blockers" }, 
	-- 	[4] = { root = "blockers", anchor_bottom = "locks", header_color = vmath.vector4(0x10 / 255, 0xDC / 255, 0x67 / 255, 1) }, 
	-- 	[5] = { root = "locks", header_color = vmath.vector4(0xFF / 255, 0xA6 / 255, 0x0A / 255, 1) },
	-- }

	-- -- 
	for i, node in ipairs(roots) do
		local root = gui.get_node(node.root .. "/root")
		local content = gui.get_node(node.root .. "/content")
		local header = gui.get_node(node.root .. "/header")
		local size = gui.get_size(content)

		-- Create an instance of a dropdown menu
		self[node.root] = dd:new_dropdown(node.root)

		-- Initialize the data: Druid, content_size, menu_position
		self[node.root]:init(self.druid, size, vmath.vector3(0, parent_top, 1))
		-- Header size defaults to 64 pixels high
		parent_top = parent_top - 64  

		--
		if node.header_color then
			gui.set_color(header, node.header_color)
		end
	end

	-- Set anchors
	for i, node in ipairs(roots) do
		local anchor_bottom = node.anchor_bottom

		if anchor_bottom then
			self[node.root]:setAnchor(self[anchor_bottom])
		end
	end

	-- Drop down list scroll box
	self.left_scroll = self.druid:new_scroll("list_container", "list_content")

Hello!

The scroll usually contains from a view node and a content node (your container and content nodes). View node act like a camera and defines “visible” area. Content node size defines size of the content to check, that is actual borders of the scroll.

For most simple cases, size of content node managing by grid module via scroll:bind_grid() function. But in case where you want to define size manually, you want to set scroll size with scroll:set_size() function.

So in your case the “view” node size should be equal to window height, and “content” size should be re-calculated and set after each changes I suppose.

Hard to say that’s going on and is everything corrent, since I don’t see how you manage this “content” size exactly.

1 Like

Thank you for answering. I will delete on github issue. For the content size, once the editor is loaded, I use the expanded size of my custom dropdown items calculated as once loaded, it does not change. I do not use scroll:set_size(). I will give that a try. Thanks.

Hmm, not making a difference. I did notice that content range = 0 - 0 ( scroll.avalabile_pos)

I assume you can debug your scroll by making these nodes (view and content) visible to check their actual borders visually

About content range data all seems correct. There is no available scroll for X axis (horizontal) and some available space for the Y axis (vertical)

Also the content node should be a child of view node.

As I remember by default scroll is not allow to scroll, if the content size less than view. You can turn this option if required by styles or directly with
self.scroll.style.SMALL_CONTENT_SCROLL = true

2 Likes

Thank you. I really appreciate your help. I think the issue might be be manually adjusting position on init. I will figure it out. Thanks.

1 Like