Function Widgets
Defines the GUI components used with ceed.function.
- class ceed.function.func_widgets.FuncList(**kwargs)
Bases:
kivy_garden.drag_n_drop.DraggableLayoutBehavior,ceed.graphics.ShowMoreSelection,ceed.graphics.WidgetList,kivy.uix.boxlayout.BoxLayoutWidget that shows the list of available functions to the user and also allows for the creation of new functions to be added to the list.
The functions come from
ceed.function.FunctionFactoryBase.- function_factory: ceed.function.FunctionFactoryBase = None
The
ceed.function.FunctionFactoryBasethat is used for the list of functions available to the user and with whom new functions created in the GUI are registered.
- is_visible
Whether the list is currently visible.
It is used by the selection logic and it’s always True for this class.
- handle_drag_release(index, drag_widget)
This is called when a widget is dropped in the layout.
indexis the index in children where the widget should be added.drag_widgetis theDraggableObjectBehaviorthat was dropped there.This must be overwritten by the inherited class to actually do the
add_widgetor something else.
- add_func(name: str)
Adds a copy of the the function with the given
namefromfunction_factoryto the available functions infunction_factory(with a new name of course) or to a function group.
- show_child_func_in_func(parent_func: ceed.function.FuncGroup, child_func: Union[ceed.function.FuncBase, ceed.function.CeedFuncRef, ceed.function.FuncGroup])
Displays the child function in the GUI as the child of the parent.
- Parameters
parent_func – Function child is added to.
child_func – the child function.
- show_func_in_listing(func: ceed.function.FuncBase)
Shows the function, previously added to the
function_factoryin the GUI.- Parameters
func – The
ceed.function.FuncBaseto show.
- get_selectable_nodes()
(internal) Returns a list of the nodes that can be selected. It can be overwritten by the derived widget to return the correct list.
This list is used to determine which nodes to select with group selection. E.g. the last element in the list will be selected when home is pressed, pagedown will move (or add to, if shift is held) the selection from the current position by negative
page_countnodes starting from the position of the currently selected node in this list and so on. Still, nodes can be selected even if they are not in this list.Note
It is safe to dynamically change this list including removing, adding, or re-arranging its elements. Nodes can be selected even if they are not on this list. And selected nodes removed from the list will remain selected until
deselect_node()is called.Warning
Layouts display their children in the reverse order. That is, the contents of
childrenis displayed form right to left, bottom to top. Therefore, internally, the indices of the elements returned by this function are reversed to make it work by default for most layouts so that the final result is consistent e.g. home, although it will select the last element in this list visually, will select the first element when counting from top to bottom and left to right. If this behavior is not desired, a reversed list should be returned instead.Defaults to returning
children.
- clear_all()
Removes all the widgets associated with the registered functions in
function_factoryfrom the GUI.
- show_function(func: Union[ceed.function.FuncBase, ceed.function.CeedFuncRef, ceed.function.FuncGroup])
Displays the function (that is in the
function_factory) in the GUI.- Parameters
func – The
ceed.function.FuncBaseto display.
- class ceed.function.func_widgets.FuncWidget(**kwargs)
Bases:
ceed.graphics.ShowMoreBehavior,kivy.uix.boxlayout.BoxLayoutThe widget that represents a
ceed.function.CeedFuncinstance.It contains all the configuration options of the function.
The class is reused anywhere a function is shown in the GUI, including in
ceed.stageso it is abstracted.- func: Union[ceed.function.FuncBase, ceed.function.CeedFuncRef, ceed.function.FuncGroup] = None
The
ceed.function.BaseFuncorceed.function.CeedFuncRefinstance associated with this widget.
- ref_func = None
If
funcis aceed.function.CeedFuncRef, this is the actualceed.function.BaseFuncfuncis internally referencing. Otherwise, it’s None.
- selected
Whether the function is currently selected in the GUI.
- selection_controller = None
The container that gets called to select the widget when the user selects it with a touch. E.g.
FuncListin the function listing case orStageFuncChildrenListif it belongs to a stage.
- func_controller
The controller to which the function is added or removed from. This is e.g.
ceed.function.FunctionFactoryBasein the function list case or theceed.stage.CeedStageto which the function is attached.
- is_visible
Whether the function is currently visible in the GUI. I.e. when all of it’s parents all the way to the root is visible.
- theme_interpolation = 0
The fraction by which
base_kivy_app.utils.ColorTheme.interpolate()interpolates the two given colors (base_kivy_app.utils.ColorTheme.primary_lightandbase_kivy_app.utils.ColorTheme.primary).
- settings_root: ceed.function.func_widgets.FuncSettingsDropDown = None
The
FuncSettingsDropDownused by this function to show settings.
- expand_widget = None
The widget that when pressed will expand to show the
morewidget.
- property name
The
ceed.function.FuncBase.nameof the function.
- static get_display_cls(func: Union[ceed.function.FuncBase, ceed.function.FuncGroup]) Type[ceed.function.func_widgets.FuncWidgetType]
Gets the widget class to use to display the function.
- Parameters
func – The
ceed.function.FuncBaseinstance.- Returns
The widget class to use to display it in the GUI.
- add_func_noise_param(func: ceed.function.FuncBase, key: str, entry_widget)
Attaches a noise distribution to the function.
- display_properties()
Constructs the function’s configuration option widgets that is used by the user to customize the function in the GUI.
It uses e.g.
ceed.function.FuncBase.get_gui_elements()andceed.function.FuncBase.get_gui_props()to get the options to show.
- initialize_display(func: Union[ceed.function.FuncBase, ceed.function.CeedFuncRef, ceed.function.FuncGroup], func_controller, selection_controller)
Sets
selection_controllerandfunc_controller, and generates and applies the kv GUI rules for the widget.
- remove_func()
Removes the function from its parent and removes it from the GUI. This is used when deleting the function in the GUI.
- handle_expand_widget(expand)
Called from kv to hide the widget that exapnds the group view when the function being represented is not a group.
- replace_ref_func_with_source()
If this
funcis aceed.function.CeedFuncRef, this will replace the reference with the a copy of the original function being referenced and the GUI will also be updated to reflect that.
- apply_kv()
Applies the kv rules to the widget.
The rules are manually applied to the class because we want to have a chance to initialize some instance variables before the kv rules is applied so they can be referred to from kv without having to check if they are None.
- create_settings_dropdown()
Creates the dropdown widget that displays the function’s configuration options.
- class ceed.function.func_widgets.FuncWidgetGroup(**kwargs)
Bases:
ceed.function.func_widgets.FuncWidgetThe widget used to display a
ceed.function.FuncGroupinstance in the GUI.- children_container = None
The widget instance that displays all the widgets representing the children functions of this function.
- remove_func()
Removes the function from its parent and removes it from the GUI. This is used when deleting the function in the GUI.
- initialize_display(func, func_controller, selection_controller)
Sets
selection_controllerandfunc_controller, and generates and applies the kv GUI rules for the widget.
- apply_kv()
Applies the kv rules to the widget.
The rules are manually applied to the class because we want to have a chance to initialize some instance variables before the kv rules is applied so they can be referred to from kv without having to check if they are None.
- selected_child()
Returns the child or sub-child etc.
ceed.function.FuncBasethat is selected in the GUI or None.
- handle_expand_widget(expand)
Called from kv to hide the widget that exapnds the group view when the function being represented is not a group.
- class ceed.function.func_widgets.FuncPropTextWidget(**kwargs)
Bases:
base_kivy_app.graphics.FlatTextInputThe widget used to allow editing a text based configuration option of a
ceed.function.FuncBase.- func = None
The
ceed.function.FuncBaseinstance it’s associated with.
- apply_binding()
Starts tracking the
prop_nameof the associatedfuncand updates the GUI with changes.
- unbind_tracking()
Stops the tracking initialized with
apply_binding().
- class ceed.function.func_widgets.FuncNamePropTextWidget(**kwargs)
Bases:
ceed.function.func_widgets.FuncPropTextWidgetThe widget used to edit the
ceed.function.FuncBase.nameof aceed.function.FuncBase.
- class ceed.function.func_widgets.FuncSettingsDropDown(func_widget, **kwargs)
Bases:
kivy.factory.FlatDropDownA dropdown widget used to show settings when customizing functions.
- func_widget: ceed.function.func_widgets.FuncWidget
The
FuncWidgetthis dropdown is displaying settings for.
- class ceed.function.func_widgets.FuncNoiseDropDown(func, prop_name, **kwargs)
Bases:
kivy.factory.FlatDropDownWidget for displaying options to add randomness to the functions.
- param_container = None
The grid widget that displays all user configurable distribution parameters.
- func: ceed.function.FuncBase = None
The function to which this is attached.
- prop_name = ''
The property of the function for which this widget selects the (optional) distribution.
- noise_factory: ceed.function.param_noise.ParameterNoiseFactory
The
ceed.function.param_noise.ParameterNoiseFactoryto use to get the noise distribution from.
- noise_param: ceed.function.param_noise.NoiseBase
The optional
ceed.function.param_noise.NoiseBaseinstance to use for the parameter.
- noise_cls_update = None
Clock trigger to update the noise classes from the GUI.
- clear_noise_param()
Unbinds and clears the widgets that track the distributions parameters.
- set_noise_instance(*args)
Selects the distribution class to use, by name.
- show_noise_params(noise_param)
Displays the configurable parameters for the selected noise distribution.