Skip to content
New issue

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

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

Already on GitHub? # to your account

Add Options and Fallback arguments to Properties #40

Closed
wants to merge 1 commit into from

Conversation

idbrii
Copy link
Contributor

@idbrii idbrii commented Jul 26, 2020

Add optional Options and Fallback arguments that lets you customize each
property or use default options for multiple properties.

Instead of defining options for every parameter, it's often convenient
to define it once. Alternative implementation is a fallback key in
Options but that risks that the user picks that key.

This gives you access to slider widgets, limits, etc:

Slab.Properties(trails, {
    -- integers
    history       = {MinNumber = trails.display, MaxNumber = 1000},
    display       = {MinNumber = 0,              MaxNumber = trails.history},
    -- floats
    initial_scale = {MinNumber = 0.001,          MaxNumber = 5},
    scale_down    = {MinNumber = 0.001,          MaxNumber = 1},
    alpha         = {MinNumber = 0.001,          MaxNumber = 1},
},
                    {MinNumber = -200.1,         MaxNumber = 200})

Or alternatively:

Slab.Properties(trails, nil,
                    {MinNumber = -200.1,         MaxNumber = 200})

Test:
paste the above Properties uses in SlabTest and add to the top of the file:

local trails = {
	history = 30,
	display = 21,
	initial_scale = 2.1,
	scale_down = 0.96,
	alpha = 0.5,
	beta = 0.5,
	kappa = 5,
}

Add optional Options and Fallback arguments that lets you customize each
property or use default options for multiple properties.

Instead of defining options for every parameter, it's often convenient
to define it once. Alternative implementation is a fallback key in
Options but that risks that the user picks that key.

This gives you access to slider widgets, limits, etc:

    Slab.Properties(trails, {
        -- integers
        history       = {MinNumber = trails.display, MaxNumber = 1000},
        display       = {MinNumber = 0,              MaxNumber = trails.history},
        -- floats
        initial_scale = {MinNumber = 0.001,          MaxNumber = 5},
        scale_down    = {MinNumber = 0.001,          MaxNumber = 1},
        alpha         = {MinNumber = 0.001,          MaxNumber = 1},
    },
                        {MinNumber = -200.1,         MaxNumber = 200})
@idbrii idbrii deleted the properties-options branch March 11, 2021 08:08
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant