Skip to content

paint, tools: threshold brush pick

This merge adds an extra option to paintbrush tools. This option is called 'Threshold foreground pick'. When it is checked, the foreground color that is picked using 'ctrl' click, is set to white or black. To add the extra option to the brush tool, several files needed to be touched;

  • gimppaintoptions-gui.c
  • gimppaintoptions.h
  • gimppaintoptions.c

And to add the extra functionality of processing the picked color;

  • gimpcolortool.c

This merge is set to 'Draft' because I couldn't work out how to avoid a warning given by GIMP. The warning comes when using the color picking tool, rather than ctrl picking with the paint tool. I've tried many things to fix it, but it's beyond me.

(gimp-2.99:169786): GLib-GObject-WARNING **: 15:49:39.664: invalid cast from 'GimpColorPickerOptions' to 'GimpPaintOptions'

If anyone can see a way to do a test, for if the picking is coming from the brush tool, or from the color picker tool, I'd appreciate the help.

  /* needs a test. if this is coming from the painting tool, then change the color */
  if (TRUE)
    {
      GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS(color_tool); 
      if (paint_options->brush_threshold_fg)
        gimp_threshold_color (&threshold_color, 128);
    }

This is a wonderful new feature for mask painters! It makes it possible to paint a mask without having to think much about black or white, and the current foreground color. Just ctrl dab an area that's colored to carry on coloring with pure white, or dab an area less colored to erase color.

Hopefully the attached video illustrates this concept.

threshold-brush-foreground-pick

Merge request reports