Exemple #1
0
    def __init__(self):
        GObject.GObject.__init__(self)
        from gui.application import get_app
        app = get_app()
        self.app = app
        self.set_spacing(widgets.SPACING_CRAMPED)
        self.set_border_width(widgets.SPACING_TIGHT)
        # GtkTreeView init
        docmodel = app.doc.model
        view = layers.RootStackTreeView(docmodel)
        self._treemodel = view.get_model()
        self._treeview = view
        # RootStackTreeView events
        view.current_layer_rename_requested += self._layer_properties_cb
        view.current_layer_changed += self._blink_current_layer_cb
        view.current_layer_menu_requested += self._popup_menu_cb
        # Drag and drop
        view.drag_began += self._view_drag_began_cb
        view.drag_ended += self._view_drag_ended_cb
        statusbar_cid = app.statusbar.get_context_id(self.STATUSBAR_CONTEXT)
        self._drag_statusbar_context_id = statusbar_cid
        # View scrolls
        view_scroll = Gtk.ScrolledWindow()
        view_scroll.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        vscroll_pol = Gtk.PolicyType.ALWAYS
        hscroll_pol = Gtk.PolicyType.AUTOMATIC
        view_scroll.set_policy(hscroll_pol, vscroll_pol)
        view_scroll.add(view)
        view_scroll.set_size_request(-1, 200)
        view_scroll.set_hexpand(True)
        view_scroll.set_vexpand(True)
        # Context menu
        ui_dir = os.path.dirname(os.path.abspath(__file__))
        ui_path = os.path.join(ui_dir, "layerswindow.xml")
        self.app.ui_manager.add_ui_from_file(ui_path)
        menu = self.app.ui_manager.get_widget("/LayersWindowPopup")
        menu.set_title(_("Layer"))
        self.connect("popup-menu", self._popup_menu_cb)
        menu.attach_to_widget(self, None)
        self._menu = menu
        self._layer_specific_ui_mergeids = []
        self._layer_specific_ui_class = None

        # Main layout grid
        grid = Gtk.Grid()
        grid.set_row_spacing(widgets.SPACING_TIGHT)
        grid.set_column_spacing(widgets.SPACING)
        row = -1

        # Visibility set management
        row += 1
        layer_view_ui = gui.layervis.LayerViewUI(docmodel)
        grid.attach(layer_view_ui.widget, 0, row, 6, 1)
        self._layer_view_ui = layer_view_ui

        # Mode dropdown
        row += 1
        # ComboBox w/ list model (mode_num, label, sensitive, scale)
        modes = list(STACK_MODES + STANDARD_MODES)
        modes.remove(lib.mypaintlib.CombineSpectralWGM)
        modes.insert(0, lib.mypaintlib.CombineSpectralWGM)
        combo = layers.new_blend_mode_combo(modes, MODE_STRINGS)
        self._layer_mode_combo = combo
        grid.attach(combo, 0, row, 5, 1)

        # Opacity widgets
        adj = Gtk.Adjustment(lower=0,
                             upper=100,
                             step_increment=1,
                             page_increment=10)
        sbut = Gtk.ScaleButton()
        sbut.set_adjustment(adj)
        sbut.remove(sbut.get_child())
        sbut.set_hexpand(False)
        sbut.set_vexpand(False)
        label_text_widest = self.OPACITY_LABEL_TEXT_TEMPLATE % (100, )
        label = Gtk.Label(label_text_widest)
        label.set_width_chars(len(label_text_widest))
        # prog = Gtk.ProgressBar()
        # prog.set_show_text(False)
        sbut.add(label)
        self._opacity_scale_button = sbut
        # self._opacity_progress = prog
        self._opacity_label = label
        self._opacity_adj = adj
        grid.attach(sbut, 5, row, 1, 1)

        # Layer list and controls
        row += 1
        layersbox = Gtk.VBox()
        style = layersbox.get_style_context()
        style.add_class(Gtk.STYLE_CLASS_LINKED)
        style = view_scroll.get_style_context()
        style.set_junction_sides(Gtk.JunctionSides.BOTTOM)
        list_tools = inline_toolbar(self.app, [
            ("NewLayerGroupAbove", "mypaint-layer-group-new-symbolic"),
            ("NewPaintingLayerAbove", "mypaint-add-symbolic"),
            ("RemoveLayer", "mypaint-remove-symbolic"),
            ("RaiseLayerInStack", "mypaint-up-symbolic"),
            ("LowerLayerInStack", "mypaint-down-symbolic"),
            ("DuplicateLayer", None),
            ("MergeLayerDown", None),
        ])
        style = list_tools.get_style_context()
        style.set_junction_sides(Gtk.JunctionSides.TOP)
        layersbox.pack_start(view_scroll, True, True, 0)
        layersbox.pack_start(list_tools, False, False, 0)
        layersbox.set_hexpand(True)
        layersbox.set_vexpand(True)
        grid.attach(layersbox, 0, row, 6, 1)

        # Background layer controls
        row += 1
        show_bg_btn = Gtk.CheckButton()
        change_bg_act = self.app.find_action("BackgroundWindow")
        change_bg_btn = widgets.borderless_button(action=change_bg_act)
        show_bg_act = self.app.find_action("ShowBackgroundToggle")
        show_bg_btn.set_related_action(show_bg_act)
        grid.attach(show_bg_btn, 0, row, 5, 1)
        grid.attach(change_bg_btn, 5, row, 1, 1)

        # Pack
        self.pack_start(grid, False, True, 0)
        # Updates from the real layers tree (TODO: move to lib/layers.py)
        self._processing_model_updates = False
        self._opacity_adj.connect('value-changed',
                                  self._opacity_adj_changed_cb)
        self._layer_mode_combo.connect('changed',
                                       self._layer_mode_combo_changed_cb)
        rootstack = docmodel.layer_stack
        rootstack.layer_properties_changed += self._layer_propchange_cb
        rootstack.current_path_updated += self._current_path_updated_cb
        # Initial update
        self.connect("show", self._show_cb)
Exemple #2
0
    def __init__(self):
        Gtk.Grid.__init__(self)

        self.set_row_spacing(6)
        self.set_column_spacing(6)
        from gui.application import get_app
        self.app = get_app()
        prefs = self.app.preferences

        row = 0
        label = Gtk.Label()
        label.set_markup(_("Tolerance:"))
        label.set_tooltip_text(
            _("How much pixel colors are allowed to vary from the start\n"
              "before Flood Fill will refuse to fill them"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)
        value = prefs.get(self.TOLERANCE_PREF, self.DEFAULT_TOLERANCE)
        value = float(value)
        adj = Gtk.Adjustment(value=value, lower=0.0, upper=1.0,
                             step_increment=0.05, page_increment=0.05,
                             page_size=0)
        adj.connect("value-changed", self._tolerance_changed_cb)
        self._tolerance_adj = adj
        scale = Gtk.Scale()
        scale.set_hexpand(True)
        scale.set_adjustment(adj)
        scale.set_draw_value(False)
        self.attach(scale, 1, row, 1, 1)

        row += 1
        label = Gtk.Label()
        label.set_markup(_("Source:"))
        label.set_tooltip_text(_("Which visible layers should be filled"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)

        # Selection independent fill-basis

        root = self.app.doc.model.layer_stack
        src_list = FlatLayerList(root)
        self.src_list = src_list
        combo = Gtk.ComboBox.new_with_model(src_list)
        cell = Gtk.CellRendererText()
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        combo.pack_start(cell, True)

        def layer_name_render(_, name_cell, model, it):
            """
            Display layer groups in italics and child layers
            indented with two spaces per level
            """
            name, path, layer = model[it][:3]
            if name is None:
                name = "Layer"
            if layer is None:
                name_cell.set_property(
                    "markup", "( <i>{text}</i> )".format(text=name)
                )
                return
            indented = "  " * (len(path) - 1) + name
            if isinstance(layer, lib.layer.LayerStack):
                name_cell.set_property(
                    "markup", "<i>{text}</i>".format(text=indented)
                )
            else:
                name_cell.set_property("text", indented)

        def sep_func(model, it):
            return model[it][0] is None

        combo.set_row_separator_func(sep_func)
        combo.set_cell_data_func(cell, layer_name_render)
        combo.set_tooltip_text(
            C_(
                "fill option (not saved): Specific fill source choice",
                "Select a specific layer you want the fill to be based on"
            )
        )
        combo.set_active(0)
        self._prev_src_layer = None
        root.layer_inserted += self._layer_inserted_cb
        self._src_combo_cb_id = combo.connect(
            "changed", self._src_combo_changed_cb
        )
        self._src_combo = combo
        self.attach(combo, 1, row, 2, 1)

        row += 1

        text = _("Sample Merged")
        checkbut = Gtk.CheckButton.new_with_label(text)
        checkbut.set_tooltip_text(
            _("When considering which area to fill, use a\n"
              "temporary merge of all the visible layers\n"
              "underneath the current layer"))
        self.attach(checkbut, 1, row, 1, 1)
        active = bool(prefs.get(self.SAMPLE_MERGED_PREF,
                                self.DEFAULT_SAMPLE_MERGED))
        checkbut.set_active(active)
        checkbut.connect("toggled", self._sample_merged_toggled_cb)
        self._sample_merged_toggle = checkbut
        self._src_combo.set_sensitive(not active)

        row += 1

        text = _("Limit to view")
        checkbut = Gtk.CheckButton.new_with_label(text)
        checkbut.set_tooltip_text(
            C_("fill option: fill does not reach beyond view when active",
               "Constrain the area that may be filled to the view area"))
        self.attach(checkbut, 1, row, 1, 1)
        active = bool(prefs.get(self.LIM_TO_VIEW_PREF,
                                self.DEFAULT_LIM_TO_VIEW))
        checkbut.set_active(active)
        checkbut.connect("toggled", self._limit_to_view_toggled_cb)
        self._limit_to_view_toggle = checkbut

        row += 1
        label = Gtk.Label()
        label.set_markup(_("Target:"))
        label.set_tooltip_text(_("Where the output should go"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)

        text = _("New Layer (once)")
        checkbut = Gtk.CheckButton.new_with_label(text)
        checkbut.set_tooltip_text(
            _("Create a new layer with the results of the fill.\n"
              "This is turned off automatically after use."))
        self.attach(checkbut, 1, row, 1, 1)
        active = self.DEFAULT_MAKE_NEW_LAYER
        checkbut.set_active(active)
        self._make_new_layer_toggle = checkbut

        row += 1
        label = Gtk.Label()
        label.set_markup(u"<b>\u26a0</b>")  # unicode warning sign
        label.set_tooltip_text(C_(
            "floodfill options warning text",
            "This mode does nothing when alpha locking is enabled!")
        )
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self._warning_shown = False
        # Not attached here, warning label is only shown for no-op combinations
        self._bm_warning_label = (label, 0, row, 1, 1)

        modes = list(lib.modes.STANDARD_MODES)
        modes.remove(lib.modes.DEFAULT_MODE)
        modes.insert(0, lib.modes.DEFAULT_MODE)
        combo = gui.layers.new_blend_mode_combo(modes, lib.modes.MODE_STRINGS)
        combo.set_tooltip_text(C_(
            "floodfill option tooltip text - blend modes",
            "Blend mode used when filling"))
        active = prefs.get(self.BLEND_MODE_PREF, self.DEFAULT_BLEND_MODE)
        active = int(active)
        combo.set_active(active)
        combo.connect(
            "changed", self._bm_combo_changed_cb
        )
        self._blend_mode_combo = combo
        self.attach(combo, 1, row, 2, 1)

        row += 1
        label = Gtk.Label()
        label.set_markup(_("Opacity:"))
        label.set_tooltip_text(
            _("Opacity of the fill"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)
        value = prefs.get(self.OPACITY_PREF, self.DEFAULT_OPACITY)
        adj = Gtk.Adjustment(value=value, lower=0.0, upper=1.0,
                             step_increment=0.05, page_increment=0.05,
                             page_size=0)
        adj.connect("value-changed", self._opacity_changed_cb)
        self._opacity_adj = adj
        scale = Gtk.Scale()
        scale.set_hexpand(True)
        scale.set_adjustment(adj)
        scale.set_draw_value(False)
        self.attach(scale, 1, row, 1, 1)

        row += 1
        self.attach(Gtk.Separator(), 0, row, 2, 1)

        row += 1
        label = Gtk.Label()
        label.set_markup(C_(
            "fill options: offset (grow/shrink) label",
            u"Offset:"
        ))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)

        TILE_SIZE = lib.floodfill.TILE_SIZE
        value = prefs.get(self.OFFSET_PREF, self.DEFAULT_OFFSET)
        adj = Gtk.Adjustment(value=value,
                             lower=-TILE_SIZE, upper=TILE_SIZE,
                             step_increment=1, page_increment=4)
        adj.connect("value-changed", self._offset_changed_cb)
        self._offset_adj = adj
        spinbut = Gtk.SpinButton()
        spinbut.set_tooltip_text(C_(
            "fill options: offset (grow/shrink) description",
            u"The distance in pixels to grow or shrink the fill"
        ))
        spinbut.set_hexpand(True)
        spinbut.set_adjustment(adj)
        spinbut.set_numeric(True)
        self.attach(spinbut, 1, row, 1, 1)

        row += 1
        label = Gtk.Label()
        label.set_markup(C_(
            "fill options: feather (blur) label",
            u"Feather:"
        ))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)

        value = prefs.get(self.FEATHER_PREF, self.DEFAULT_FEATHER)
        adj = Gtk.Adjustment(value=value,
                             lower=0, upper=TILE_SIZE,
                             step_increment=1, page_increment=4)
        adj.connect("value-changed", self._feather_changed_cb)
        self._feather_adj = adj
        spinbut = Gtk.SpinButton()
        spinbut.set_tooltip_text(C_(
            "fill options: feather (blur) description",
            u"The amount of blur to apply to the fill"
        ))
        spinbut.set_hexpand(True)
        spinbut.set_adjustment(adj)
        spinbut.set_numeric(True)
        self.attach(spinbut, 1, row, 1, 1)

        row += 1
        self.attach(Gtk.Separator(), 0, row, 2, 1)

        row += 1
        gap_closing_params = Gtk.Grid()
        self._gap_closing_grid = gap_closing_params

        text = C_(
            "fill options: gap detection on/off label",
            u'Use gap detection'
        )
        checkbut = Gtk.CheckButton.new_with_label(text)
        checkbut.set_tooltip_text(C_(
            "fill options: gap closing on/off description",
            u"Try to detect gaps and not fill past them.\n"
            u"Note: This can be a lot slower than the regular fill, "
            u"only enable when you really need it."
        ))
        self._gap_closing_toggle = checkbut
        checkbut.connect("toggled", self._gap_closing_toggled_cb)
        active = prefs.get(self.GAP_CLOSING_PREF, self.DEFAULT_GAP_CLOSING)
        checkbut.set_active(active)
        gap_closing_params.set_sensitive(active)
        self.attach(checkbut, 0, row, 2, 1)

        row += 1
        self.attach(gap_closing_params, 0, row, 2, 1)

        gcp_row = 0
        label = Gtk.Label()
        label.set_markup(C_(
            "fill options: maximum size of gaps label",
            u"Max gap size:"
        ))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        gap_closing_params.attach(label, 0, gcp_row, 1, 1)

        value = prefs.get(self.GAP_SIZE_PREF, self.DEFAULT_GAP_SIZE)
        adj = Gtk.Adjustment(value=value,
                             lower=1, upper=int(TILE_SIZE/2),
                             step_increment=1, page_increment=4)
        adj.connect("value-changed", self._max_gap_size_changed_cb)
        self._max_gap_adj = adj
        spinbut = Gtk.SpinButton()
        spinbut.set_tooltip_text(C_(
            "fill options: max gap size description",
            u"The size of the largest gaps that can be detected"
        ))
        spinbut.set_hexpand(True)
        spinbut.set_adjustment(adj)
        spinbut.set_numeric(True)
        gap_closing_params.attach(spinbut, 1, gcp_row, 1, 1)

        gcp_row += 1
        text = C_(
            "fill options: on/off sub-option to gap closing fill; "
            "When enabled, the fill will stay outside of detected "
            "gaps, when disabled, they will seep into them",
            u"Prevent seeping"
        )
        checkbut = Gtk.CheckButton.new_with_label(text)
        active = prefs.get(self.RETRACT_SEEPS_PREF, self.DEFAULT_RETRACT_SEEPS)
        checkbut.set_active(active)
        checkbut.set_tooltip_text(C_(
            "gui/fill.py - description of (Retract seeps) option",
            u"Try to prevent the fill from seeping into the gaps"
        ))
        checkbut.connect("toggled", self._retract_seeps_toggled_cb)
        self._retract_seeps_toggle = checkbut
        gap_closing_params.attach(checkbut, 1, gcp_row, 1, 1)

        row += 1
        align = Gtk.Alignment.new(0.5, 1.0, 1.0, 0.0)
        align.set_vexpand(True)
        button = Gtk.Button(label=_("Reset"))
        button.connect("clicked", self._reset_clicked_cb)
        button.set_tooltip_text(_("Reset options to their defaults"))
        align.add(button)
        self.attach(align, 0, row, 2, 1)

        # Set up blend modifier callbacks
        self.bm = self.get_blend_modes()
        self.bm.mode_changed += self.update_blend_mode
Exemple #3
0
    def __init__(self):
        Gtk.Grid.__init__(self)

        self.set_row_spacing(6)
        self.set_column_spacing(6)
        from gui.application import get_app
        self.app = get_app()
        prefs = self.app.preferences

        row = 0
        label = Gtk.Label()
        label.set_markup(
            C_(
                "fill options: numeric value that determines whether tested pixels"
                " will be included in the fill, based on color difference",
                u"Tolerance:"))
        label.set_tooltip_text(
            C_(
                "fill options: Tolerance (tooltip) "
                "Note: 'the start' refers to the color of "
                "the starting point (pixel) of the fill",
                u"How much pixel colors are allowed to vary from the start\n"
                u"before Flood Fill will refuse to fill them"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)
        value = prefs.get(self.TOLERANCE_PREF, self.DEFAULT_TOLERANCE)
        value = float(value)
        adj = Gtk.Adjustment(value=value,
                             lower=0.0,
                             upper=1.0,
                             step_increment=0.05,
                             page_increment=0.05,
                             page_size=0)
        adj.connect("value-changed", self._tolerance_changed_cb)
        self._tolerance_adj = adj
        scale = Gtk.Scale()
        scale.set_hexpand(True)
        scale.set_adjustment(adj)
        scale.set_draw_value(False)
        self.attach(scale, 1, row, 1, 1)

        row += 1
        label = Gtk.Label()
        label.set_markup(
            C_(
                "fill options: option category (label) "
                "Options under this category relate to what the fill is"
                "based on, not where the actual fill ends up.", u"Source:"))
        label.set_tooltip_text(
            C_("fill options: 'Source:' category (tooltip)",
               u"The input that the fill will be based on"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)

        # Selection independent fill-basis

        root = self.app.doc.model.layer_stack
        src_list = FlatLayerList(root)
        self.src_list = src_list
        combo = Gtk.ComboBox.new_with_model(src_list)
        cell = Gtk.CellRendererText()
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        combo.pack_start(cell, True)

        def layer_name_render(_, name_cell, model, it):
            """
            Display layer groups in italics and child layers
            indented with two spaces per level
            """
            name, path, layer = model[it][:3]
            if name is None:
                name = "Layer"
            if layer is None:
                name_cell.set_property("markup",
                                       "( <i>{text}</i> )".format(text=name))
                return
            indented = "  " * (len(path) - 1) + name
            if isinstance(layer, lib.layer.LayerStack):
                name_cell.set_property("markup",
                                       "<i>{text}</i>".format(text=indented))
            else:
                name_cell.set_property("text", indented)

        def sep_func(model, it):
            return model[it][0] is None

        combo.set_row_separator_func(sep_func)
        combo.set_cell_data_func(cell, layer_name_render)
        combo.set_tooltip_text(
            C_("fill options: 'Source' category: Layer dropdown (tooltip)",
               u"Select a specific layer you want the fill to be based on"))
        combo.set_active(0)
        self._prev_src_layer = None
        root.layer_inserted += self._layer_inserted_cb
        self._src_combo_cb_id = combo.connect("changed",
                                              self._src_combo_changed_cb)
        self._src_combo = combo
        self.attach(combo, 1, row, 2, 1)

        row += 1

        text = C_(
            "fill options: 'Source:' category: toggle (label)\n"
            "When this option is enabled, the fill is based\n"
            "on the combination of all visible layers", u"Sample Merged")
        checkbut = Gtk.CheckButton.new_with_label(text)
        checkbut.set_tooltip_text(
            C_(
                "fill options: Sample Merged (tooltip)",
                u"When considering which area to fill, use a\n"
                u"temporary merge of all the visible layers\n"
                u"underneath the current layer"))
        self.attach(checkbut, 1, row, 1, 1)
        active = bool(
            prefs.get(self.SAMPLE_MERGED_PREF, self.DEFAULT_SAMPLE_MERGED))
        checkbut.set_active(active)
        checkbut.connect("toggled", self._sample_merged_toggled_cb)
        self._sample_merged_toggle = checkbut
        self._src_combo.set_sensitive(not active)

        row += 1

        text = C_(
            "fill options: toggle whether the fill will be limited "
            "by the viewport", u"Limit to View")
        checkbut = Gtk.CheckButton.new_with_label(text)
        checkbut.set_tooltip_text(
            C_(
                "fill options: Limit to View (tooltip)\n"
                "Note: 'that can fit the view' is equivalent to: "
                "'in which the entire visible part of the canvas can fit",
                u"Limit the area that can be filled, based on the viewport.\n"
                u"If the view is rotated, the fill will be limited to the\n"
                u"smallest canvas-aligned rectangle that can fit the view."))
        self.attach(checkbut, 1, row, 1, 1)
        active = bool(
            prefs.get(self.LIM_TO_VIEW_PREF, self.DEFAULT_LIM_TO_VIEW))
        checkbut.set_active(active)
        checkbut.connect("toggled", self._limit_to_view_toggled_cb)
        self._limit_to_view_toggle = checkbut

        row += 1
        label = Gtk.Label()
        label.set_markup(
            C_(
                "fill options: option category (label)\n"
                "Options under this category relate to where the fill "
                "will end up (default: the active layer) and how it "
                "will be combined with that layer.", u"Target:"))
        label.set_tooltip_text(
            C_("fill options: 'Target:' category (tooltip)",
               u"Where the output should go"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)

        text = C_(
            "fill options: Target | toggle (label)\n"
            "When this option is enabled, the fill will be placed on a new\n"
            "layer above the active layer. Option resets after each fill.",
            u"New Layer (once)")
        checkbut = Gtk.CheckButton.new_with_label(text)
        checkbut.set_tooltip_text(
            C_(
                "fill options: Target | New Layer (tooltip)",
                u"Create a new layer with the results of the fill.\n"
                u"This is turned off automatically after use."))
        self.attach(checkbut, 1, row, 1, 1)
        active = self.DEFAULT_MAKE_NEW_LAYER
        checkbut.set_active(active)
        self._make_new_layer_toggle = checkbut

        row += 1
        label = Gtk.Label()
        label.set_markup(u"<b>\u26a0</b>")  # unicode warning sign
        label.set_tooltip_text(
            C_("fill options: Target | Blend Mode dropdown - warning text",
               u"This mode does nothing when alpha locking is enabled!"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self._warning_shown = False
        # Not attached here, warning label is only shown for no-op combinations
        self._bm_warning_label = (label, 0, row, 1, 1)

        modes = list(lib.modes.STANDARD_MODES)
        modes.remove(lib.mypaintlib.CombineSpectralWGM)
        modes.insert(0, lib.mypaintlib.CombineSpectralWGM)
        combo = gui.layers.new_blend_mode_combo(modes, lib.modes.MODE_STRINGS)
        combo.set_tooltip_text(
            C_("fill options: Target | Blend Mode dropdown (tooltip)",
               u"Blend mode used when filling"))
        # Reinstate the last _mode id_ independent of mode-list order
        mode_type = prefs.get(self.BLEND_MODE_PREF, self.DEFAULT_BLEND_MODE)
        mode_dict = {mode: index for index, mode, in enumerate(modes)}
        # Fallback is only necessary for compat. if a mode is ever removed
        active = mode_dict.get(int(mode_type), self.DEFAULT_BLEND_MODE)
        combo.set_active(active)
        combo.connect("changed", self._bm_combo_changed_cb)
        self._blend_mode_combo = combo
        self.attach(combo, 1, row, 2, 1)

        row += 1
        label = Gtk.Label()
        label.set_markup(_(u"Opacity:"))
        label.set_tooltip_text(
            C_("fill options: Opacity slider (tooltip)",
               u"Opacity of the fill"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)
        value = prefs.get(self.OPACITY_PREF, self.DEFAULT_OPACITY)
        adj = Gtk.Adjustment(value=value,
                             lower=0.0,
                             upper=1.0,
                             step_increment=0.05,
                             page_increment=0.05,
                             page_size=0)
        adj.connect("value-changed", self._opacity_changed_cb)
        self._opacity_adj = adj
        scale = Gtk.Scale()
        scale.set_hexpand(True)
        scale.set_adjustment(adj)
        scale.set_draw_value(False)
        self.attach(scale, 1, row, 1, 1)

        row += 1
        self.attach(Gtk.Separator(), 0, row, 2, 1)

        row += 1
        label = Gtk.Label()
        label.set_markup(
            C_("fill options: numeric option - grow/shrink fill (label)",
               u"Offset:"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)

        TILE_SIZE = lib.floodfill.TILE_SIZE
        value = prefs.get(self.OFFSET_PREF, self.DEFAULT_OFFSET)
        adj = Gtk.Adjustment(value=value,
                             lower=-TILE_SIZE,
                             upper=TILE_SIZE,
                             step_increment=1,
                             page_increment=4)
        adj.connect("value-changed", self._offset_changed_cb)
        self._offset_adj = adj
        spinbut = Gtk.SpinButton()
        spinbut.set_tooltip_text(
            C_("fill options: Offset (tooltip)",
               u"The distance in pixels to grow or shrink the fill"))
        spinbut.set_hexpand(True)
        spinbut.set_adjustment(adj)
        spinbut.set_numeric(True)
        self.attach(spinbut, 1, row, 1, 1)

        row += 1
        label = Gtk.Label()
        label.set_markup(
            C_("fill options: numeric option for blurring fill (label)",
               u"Feather:"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        self.attach(label, 0, row, 1, 1)

        value = prefs.get(self.FEATHER_PREF, self.DEFAULT_FEATHER)
        adj = Gtk.Adjustment(value=value,
                             lower=0,
                             upper=TILE_SIZE,
                             step_increment=1,
                             page_increment=4)
        adj.connect("value-changed", self._feather_changed_cb)
        self._feather_adj = adj
        spinbut = Gtk.SpinButton()
        spinbut.set_tooltip_text(
            C_("fill options: Feather (tooltip)",
               u"The amount of blur to apply to the fill"))
        spinbut.set_hexpand(True)
        spinbut.set_adjustment(adj)
        spinbut.set_numeric(True)
        self.attach(spinbut, 1, row, 1, 1)

        row += 1
        self.attach(Gtk.Separator(), 0, row, 2, 1)

        row += 1
        gap_closing_params = Gtk.Grid()
        self._gap_closing_grid = gap_closing_params

        text = C_("fill options: gap detection toggle (label)",
                  u'Use Gap Detection')
        checkbut = Gtk.CheckButton.new_with_label(text)
        checkbut.set_tooltip_text(
            C_(
                "fill options: Use Gap Detection (tooltip)",
                u"Try to detect gaps and not fill past them.\n"
                u"Note: This can be a lot slower than the regular fill, "
                u"only enable when you need it."))
        self._gap_closing_toggle = checkbut
        checkbut.connect("toggled", self._gap_closing_toggled_cb)
        active = prefs.get(self.GAP_CLOSING_PREF, self.DEFAULT_GAP_CLOSING)
        checkbut.set_active(active)
        gap_closing_params.set_sensitive(active)
        self.attach(checkbut, 0, row, 2, 1)

        row += 1
        self.attach(gap_closing_params, 0, row, 2, 1)

        gcp_row = 0
        label = Gtk.Label()
        label.set_markup(
            C_(
                "fill options: gap-detection sub-option, numeric setting (label)",
                u"Max Gap Size:"))
        label.set_alignment(1.0, 0.5)
        label.set_hexpand(False)
        gap_closing_params.attach(label, 0, gcp_row, 1, 1)

        value = prefs.get(self.GAP_SIZE_PREF, self.DEFAULT_GAP_SIZE)
        adj = Gtk.Adjustment(value=value,
                             lower=1,
                             upper=int(TILE_SIZE / 2),
                             step_increment=1,
                             page_increment=4)
        adj.connect("value-changed", self._max_gap_size_changed_cb)
        self._max_gap_adj = adj
        spinbut = Gtk.SpinButton()
        spinbut.set_tooltip_text(
            C_(
                "fill options: Max Gap Size (tooltip)",
                u"The size of the largest gaps that can be detected.\n"
                u"Using large values can make the fill run a lot slower."))
        spinbut.set_hexpand(True)
        spinbut.set_adjustment(adj)
        spinbut.set_numeric(True)
        gap_closing_params.attach(spinbut, 1, gcp_row, 1, 1)

        gcp_row += 1
        text = C_(
            "fill options: on/off sub-option, numeric (label)\n"
            "When enabled, if the fill stops after going past a detected gap, "
            "it 'pulls' the fill back out of the gap to the other side of it.",
            u"Prevent seeping")
        checkbut = Gtk.CheckButton.new_with_label(text)
        active = prefs.get(self.RETRACT_SEEPS_PREF, self.DEFAULT_RETRACT_SEEPS)
        checkbut.set_active(active)
        checkbut.set_tooltip_text(
            C_(
                "fill options: Prevent seeping (tooltip)",
                u"Try to prevent the fill from seeping into the gaps.\n"
                u"If a fill starts in a detected gap, this option will do nothing."
            ))
        checkbut.connect("toggled", self._retract_seeps_toggled_cb)
        self._retract_seeps_toggle = checkbut
        gap_closing_params.attach(checkbut, 1, gcp_row, 1, 1)

        row += 1
        align = Gtk.Alignment.new(0.5, 1.0, 1.0, 0.0)
        align.set_vexpand(True)
        button = Gtk.Button(label=_("Reset"))
        button.connect("clicked", self._reset_clicked_cb)
        button.set_tooltip_text(
            C_("fill options: Reset button (tooltip)",
               "Reset options to their defaults"))
        align.add(button)
        self.attach(align, 0, row, 2, 1)

        # Set up blend modifier callbacks
        self.bm = self.get_blend_modes()
        self.bm.mode_changed += self.update_blend_mode