def perform_widget_quantity_setups(self):
        """Perform setups after changing number of widgets.

        Extra setups are needed after changing the number
        of existing widgets, so that the colors panel
        works properly. Such setups are performed here.
        """
        ### reference list of existing widgets locally for
        ### quicker and easier access
        widgets = self.widgets

        ### align the rects of the remaining color widgets
        ### one beside the other
        widgets.rect.snap_rects_ip("topright", "topleft")

        ### align the topleft of the color widgets
        ### collectively to the topleft of the scroll area
        widgets.rect.topleft = self.scroll_area.topleft

        ### retrieve the current index and clamp it to the
        ### available remaining indices

        current_index = self.colors_editor.current_color_index

        clamped_index = min(max(0, current_index), len(widgets) - 1)

        ### store the clamped index (which may or not be the
        ### same as the original) as the current index
        self.colors_editor.current_color_index = clamped_index

        ### store a reference to the widget in that
        ### position, which we call the current widget
        self.store_current_widget()

        ### finally, since we picked a widget and its
        ### color as the current ones, let's display that
        ### color in the controls so it can be seen/edited
        ###
        ### this also has the side-effect of moving the
        ### widgets so the current one is visible in the
        ### scroll area (though I'm not sure this side-effect
        ### is necessary here; it is ok, though)
        self.colors_editor.set_color_on_controls(self.current_widget.color)
Perform setups after changing number of widgets.

        Extra setups are needed after changing the number
        of existing widgets, so that the colors panel
        works properly. Such setups are performed here.
        
nodezator/colorsman/editor/panel/colorsop.py