mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-02 17:03:26 +00:00
tools: Don't run Foreground Selection without strokes
The Foreground Selection algorithm was being run when users switched to a different tool, even if no strokes had been painted. This caused an unnecessary delay, since no selection will be generated. This patch adds a check to verify we have at least one foreground stroke made by the user before trying to create the selection.
This commit is contained in:
parent
1f8f17cd9a
commit
0370aed02d
1 changed files with 28 additions and 5 deletions
|
@ -165,6 +165,8 @@ static void gimp_foreground_select_tool_preview_toggled(GtkToggleButton
|
|||
|
||||
static void gimp_foreground_select_tool_update_gui (GimpForegroundSelectTool *fg_select);
|
||||
|
||||
static gboolean gimp_foreground_select_tool_has_strokes (GimpForegroundSelectTool *fg_select);
|
||||
|
||||
static StrokeUndo * gimp_foreground_select_undo_new (GeglBuffer *trimap,
|
||||
GArray *stroke,
|
||||
GimpMattingDrawMode draw_mode,
|
||||
|
@ -964,13 +966,11 @@ gimp_foreground_select_tool_confirm (GimpPolygonSelectTool *poly_sel,
|
|||
static void
|
||||
gimp_foreground_select_tool_halt (GimpForegroundSelectTool *fg_select)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (fg_select);
|
||||
GimpTool *tool = GIMP_TOOL (fg_select);
|
||||
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (fg_select);
|
||||
|
||||
if (draw_tool->preview)
|
||||
{
|
||||
gimp_draw_tool_remove_preview (draw_tool, fg_select->grayscale_preview);
|
||||
}
|
||||
gimp_draw_tool_remove_preview (draw_tool, fg_select->grayscale_preview);
|
||||
|
||||
g_clear_object (&fg_select->grayscale_preview);
|
||||
g_clear_object (&fg_select->trimap);
|
||||
|
@ -1028,7 +1028,9 @@ gimp_foreground_select_tool_commit (GimpForegroundSelectTool *fg_select)
|
|||
GimpTool *tool = GIMP_TOOL (fg_select);
|
||||
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (fg_select);
|
||||
|
||||
if (tool->display && fg_select->state != MATTING_STATE_FREE_SELECT)
|
||||
if (tool->display &&
|
||||
fg_select->state != MATTING_STATE_FREE_SELECT &&
|
||||
gimp_foreground_select_tool_has_strokes (fg_select))
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (tool->display);
|
||||
|
||||
|
@ -1321,6 +1323,27 @@ gimp_foreground_select_tool_update_gui (GimpForegroundSelectTool *fg_select)
|
|||
gtk_widget_set_sensitive (fg_select->preview_toggle, TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_foreground_select_tool_has_strokes (GimpForegroundSelectTool *fg_select)
|
||||
{
|
||||
GList *iter;
|
||||
|
||||
if (fg_select->undo_stack == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* Check if undo_stack has any foreground strokes, as these are the
|
||||
only ones that can create a selection */
|
||||
for (iter = fg_select->undo_stack; iter; iter = iter->next)
|
||||
{
|
||||
StrokeUndo *undo = iter->data;
|
||||
|
||||
if (undo && undo->draw_mode == GIMP_MATTING_DRAW_MODE_FOREGROUND)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static StrokeUndo *
|
||||
gimp_foreground_select_undo_new (GeglBuffer *trimap,
|
||||
GArray *stroke,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue