Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollcontainer: Add automatic scrollbar calculation #14623

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SmallJoker
Copy link
Member

@SmallJoker SmallJoker commented May 8, 2024

When specifying 'scroll factor'='auto', it will be calculated automatically based
on the associated scrollbar maximal value. Previously, calculating the exact value was mostly guesswork and try & error.

EDIT: This could also be implemented in reverse by adjusting the maximum value of the scrollbar, which would however be more annoying to read out from mods.

Part fix for #12482

To do

This PR is Ready for Review.

How to test

/c 0 (factor 0.005) vs /c 1 (automatic)

minetest.register_chatcommand("c", {
	func = function(name, param)
		local player = minetest.get_player_by_name(name)
		local value = minetest.is_yes(param) and "auto" or (5 / 1000)
		minetest.show_formspec(name, "lab:scrollcontainer",
			"formspec_version[7]"..
			"size[12,8]"..
			"scroll_container[0,0;10,4;scrbar2;vertical;" .. value .. "]"..
				"label[0.5,0.5;nest]"..
				"list[current_player;main;0,1;8,4;]"..
			"scroll_container_end[]"..
			"scrollbar[10.1,0;0.5,4;vertical;scrbar2;0]"..
			-- Scale
			"button[11,0;1,1;;0]"..
			"button[11,1;1,1;;1]"..
			"button[11,2;1,1;;2]"..
			"button[11,3;1,1;;3]"..
			"button[11,4;1,1;;4]"..
			""
		)
	end
})

When specifying 'scroll factor'='auto', it will be calculated automatically based
on the associated scrollbar maximal value.
@SmallJoker SmallJoker added Feature ✨ PRs that add or enhance a feature Formspec labels May 8, 2024
@Desour
Copy link
Member

Desour commented May 8, 2024

Doesn't fix #12482 entirely, because that issue wants to set other scrollbaroptions as well, like thumb size.

@rubenwardy
Copy link
Member

Aw that's what I thought this did...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature ✨ PRs that add or enhance a feature Formspec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants