void context_brush_shape_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpBrush *brush; return_if_no_context (context, data); brush = gimp_context_get_brush (context); if (GIMP_IS_BRUSH_GENERATED (brush) && gimp_data_is_writable (GIMP_DATA (brush))) { GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush); GimpDisplay *display; const char *value_desc; gimp_brush_generated_set_shape (generated, (GimpBrushGeneratedShape) value); gimp_enum_get_value (GIMP_TYPE_BRUSH_GENERATED_SHAPE, value, NULL, NULL, &value_desc, NULL); display = action_data_get_display (data); if (value_desc && display) { action_message (display, G_OBJECT (brush), _("Brush Shape: %s"), value_desc); } } }
/* * gfig_read_gimp_style() reads the style settings from the Gimp core, * and applies them to the specified style, giving that style the * specified name. This is mainly useful as a way of initializing * a style. The function does not cause a repaint. */ void gfig_read_gimp_style (Style *style, const gchar *name) { gint dummy; if (!name) g_message ("Error: name is NULL in gfig_read_gimp_style."); if (gfig_context->debug_styles) g_printerr ("Reading Gimp settings as style %s\n", name); style->name = g_strdup (name); gimp_context_get_foreground (&style->foreground); gimp_context_get_background (&style->background); style->brush_name = gimp_context_get_brush (); gimp_brush_get_info (style->brush_name, &style->brush_width, &style->brush_height, &dummy, &dummy); gimp_brush_get_spacing (style->brush_name, &style->brush_spacing); style->gradient = gimp_context_get_gradient (); style->pattern = gimp_context_get_pattern (); style->fill_opacity = 100.; gfig_context->bdesc.name = style->brush_name; gfig_context->bdesc.width = style->brush_width; gfig_context->bdesc.height = style->brush_height; }
static GValueArray * brushes_get_spacing_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; gint32 spacing = 0; GimpBrush *brush = gimp_context_get_brush (context); if (brush) spacing = gimp_brush_get_spacing (brush); else success = FALSE; return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_set_int (&return_vals->values[1], spacing); return return_vals; }
void gimp_paint_options_set_default_brush_hardness (GimpPaintOptions *paint_options, GimpBrush *brush) { g_return_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options)); g_return_if_fail (brush == NULL || GIMP_IS_BRUSH (brush)); if (! brush) brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options)); if (GIMP_IS_BRUSH_GENERATED (brush)) { GimpBrushGenerated *generated_brush = GIMP_BRUSH_GENERATED (brush); g_object_set (paint_options, "brush-hardness", (gdouble) gimp_brush_generated_get_hardness (generated_brush), NULL); } else { g_object_set (paint_options, "brush-hardness", DEFAULT_BRUSH_HARDNESS, NULL); } }
void context_brush_radius_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpBrush *brush; return_if_no_context (context, data); brush = gimp_context_get_brush (context); if (GIMP_IS_BRUSH_GENERATED (brush) && gimp_data_is_writable (GIMP_DATA (brush))) { GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush); GimpDisplay *display; gdouble radius; gdouble min_radius; radius = gimp_brush_generated_get_radius (generated); /* If the user uses a high precision radius adjustment command * then we allow a minimum radius of 0.1 px, otherwise we set the * minimum radius to 1.0 px and adjust the radius to 1.0 px if it * is less than 1.0 px. This prevents irritating 0.1, 1.1, 2.1 etc * radius sequences when 1.0 px steps are used. */ switch ((GimpActionSelectType) value) { case GIMP_ACTION_SELECT_SMALL_PREVIOUS: case GIMP_ACTION_SELECT_SMALL_NEXT: case GIMP_ACTION_SELECT_PERCENT_PREVIOUS: case GIMP_ACTION_SELECT_PERCENT_NEXT: min_radius = 0.1; break; default: min_radius = 1.0; if (radius < 1.0) radius = 1.0; break; } radius = action_select_value ((GimpActionSelectType) value, radius, min_radius, 4000.0, min_radius, 0.1, 1.0, 10.0, 0.05, FALSE); gimp_brush_generated_set_radius (generated, radius); display = action_data_get_display (data); if (display) { action_message (action_data_get_display (data), G_OBJECT (brush), _("Brush Radius: %2.2f"), radius); } } }
static void gimp_paint_options_gui_reset_size (GtkWidget *button, GimpPaintOptions *paint_options) { GimpBrush *brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options)); if (brush) gimp_paint_options_set_default_brush_size (paint_options, brush); }
static void gimp_paint_options_gui_reset_size (GtkWidget *button, GimpPaintOptions *paint_options) { GimpBrush *brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options)); if (brush) { g_object_set (paint_options, "brush-size", (gdouble) MAX (brush->mask->width, brush->mask->height), NULL); } }
GtkWidget * gimp_brush_editor_new (GimpContext *context, GimpMenuFactory *menu_factory) { g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); return g_object_new (GIMP_TYPE_BRUSH_EDITOR, "menu-factory", menu_factory, "menu-identifier", "<BrushEditor>", "ui-path", "/brush-editor-popup", "data-factory", context->gimp->brush_factory, "context", context, "data", gimp_context_get_brush (context), NULL); }
void gimp_paint_options_set_default_brush_spacing (GimpPaintOptions *paint_options, GimpBrush *brush) { g_return_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options)); g_return_if_fail (brush == NULL || GIMP_IS_BRUSH (brush)); if (! brush) brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options)); if (brush) { g_object_set (paint_options, "brush-spacing", (gdouble) gimp_brush_get_spacing (brush) / 100.0, NULL); } }
static GValueArray * brushes_set_spacing_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; gint32 spacing; spacing = g_value_get_int (&args->values[0]); if (success) { gimp_brush_set_spacing (gimp_context_get_brush (context), spacing); } return gimp_procedure_get_return_values (procedure, success); }
void mygimp_brush_info (gint *width, gint *height) { gchar *name = gimp_context_get_brush (); gint dummy; if (name && gimp_brush_get_info (name, width, height, &dummy, &dummy)) { *width = MAX (*width, 32); *height = MAX (*height, 32); } else { g_message ("Failed to get brush info"); *width = *height = 48; } g_free (name); }
void context_brush_spacing_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpBrush *brush; return_if_no_context (context, data); brush = gimp_context_get_brush (context); if (GIMP_IS_BRUSH (brush) && gimp_data_is_writable (GIMP_DATA (brush))) { action_select_property ((GimpActionSelectType) value, action_data_get_display (data), G_OBJECT (brush), "spacing", 1.0, 5.0, 20.0, 0.1, FALSE); } }
void context_brush_angle_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpBrush *brush; return_if_no_context (context, data); brush = gimp_context_get_brush (context); if (GIMP_IS_BRUSH_GENERATED (brush) && gimp_data_is_writable (GIMP_DATA (brush))) { GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush); GimpDisplay *display; gdouble angle; angle = gimp_brush_generated_get_angle (generated); if (value == GIMP_ACTION_SELECT_FIRST) angle = 0.0; else if (value == GIMP_ACTION_SELECT_LAST) angle = 90.0; else angle = action_select_value ((GimpActionSelectType) value, angle, 0.0, 180.0, 0.0, 0.1, 1.0, 15.0, 0.1, TRUE); gimp_brush_generated_set_angle (generated, angle); display = action_data_get_display (data); if (display) { action_message (action_data_get_display (data), G_OBJECT (brush), _("Brush Angle: %2.2f"), angle); } } }
static void gimp_brush_tool_oper_update (GimpTool *tool, const GimpCoords *coords, GdkModifierType state, gboolean proximity, GimpDisplay *display) { GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool); GimpDrawable *drawable; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity, display); drawable = gimp_image_get_active_drawable (gimp_display_get_image (display)); if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)) && drawable && proximity) { GimpContext *context = GIMP_CONTEXT (paint_options); GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_tool->core); gimp_brush_core_set_brush (brush_core, gimp_context_get_brush (context)); gimp_brush_core_set_dynamics (brush_core, gimp_context_get_dynamics (context)); if (GIMP_BRUSH_CORE_GET_CLASS (brush_core)->handles_transforming_brush) { gimp_brush_core_eval_transform_dynamics (brush_core, drawable, paint_options, coords); } } gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); }
void gimp_paint_options_set_default_brush_size (GimpPaintOptions *paint_options, GimpBrush *brush) { g_return_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options)); g_return_if_fail (brush == NULL || GIMP_IS_BRUSH (brush)); if (! brush) brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options)); if (brush) { gint height; gint width; gimp_brush_transform_size (brush, 1.0, 0.0, 0.0, &height, &width); g_object_set (paint_options, "brush-size", (gdouble) MAX (height, width), NULL); } }
void brushes_actions_update (GimpActionGroup *group, gpointer user_data) { GimpContext *context = action_data_get_context (user_data); GimpBrush *brush = NULL; GimpData *data = NULL; GFile *file = NULL; if (context) { brush = gimp_context_get_brush (context); if (action_data_sel_count (user_data) > 1) { brush = NULL; } if (brush) { data = GIMP_DATA (brush); file = gimp_data_get_file (data); } } #define SET_SENSITIVE(action,condition) \ gimp_action_group_set_action_sensitive (group, action, (condition) != 0) SET_SENSITIVE ("brushes-edit", brush); SET_SENSITIVE ("brushes-open-as-image", file && ! GIMP_IS_BRUSH_GENERATED (brush)); SET_SENSITIVE ("brushes-duplicate", brush && GIMP_DATA_GET_CLASS (data)->duplicate); SET_SENSITIVE ("brushes-copy-location", file); SET_SENSITIVE ("brushes-show-in-file-manager", file); SET_SENSITIVE ("brushes-delete", brush && gimp_data_is_deletable (data)); #undef SET_SENSITIVE }
static GValueArray * brushes_get_brush_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; gchar *name = NULL; gint32 width = 0; gint32 height = 0; gint32 spacing = 0; GimpBrush *brush = gimp_context_get_brush (context); if (brush) { name = g_strdup (gimp_object_get_name (GIMP_OBJECT (brush))); width = brush->mask->width; height = brush->mask->height; spacing = gimp_brush_get_spacing (brush); } else success = FALSE; return_vals = gimp_procedure_get_return_values (procedure, success); if (success) { g_value_take_string (&return_vals->values[1], name); g_value_set_int (&return_vals->values[2], width); g_value_set_int (&return_vals->values[3], height); g_value_set_int (&return_vals->values[4], spacing); } return return_vals; }
GtkWidget * gimp_toolbox_indicator_area_create (GimpToolbox *toolbox) { GimpContext *context; GtkWidget *indicator_table; GtkWidget *brush_view; GtkWidget *pattern_view; GtkWidget *gradient_view; g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL); context = GIMP_DOCK (toolbox)->context; indicator_table = gtk_table_new (2, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (indicator_table), CELL_SPACING); gtk_table_set_col_spacings (GTK_TABLE (indicator_table), CELL_SPACING); /* brush view */ brush_view = gimp_view_new_full_by_types (context, GIMP_TYPE_VIEW, GIMP_TYPE_BRUSH, CELL_SIZE, CELL_SIZE, 1, FALSE, TRUE, TRUE); gimp_view_set_viewable (GIMP_VIEW (brush_view), GIMP_VIEWABLE (gimp_context_get_brush (context))); gtk_table_attach_defaults (GTK_TABLE (indicator_table), brush_view, 0, 1, 0, 1); gtk_widget_show (brush_view); gimp_help_set_help_data (brush_view, _("The active brush.\n" "Click to open the Brush Dialog."), NULL); g_signal_connect_object (context, "brush-changed", G_CALLBACK (gimp_view_set_viewable), brush_view, G_CONNECT_SWAPPED); g_signal_connect (brush_view, "clicked", G_CALLBACK (brush_preview_clicked), toolbox); gimp_dnd_viewable_dest_add (brush_view, GIMP_TYPE_BRUSH, brush_preview_drop_brush, context); /* pattern view */ pattern_view = gimp_view_new_full_by_types (context, GIMP_TYPE_VIEW, GIMP_TYPE_PATTERN, CELL_SIZE, CELL_SIZE, 1, FALSE, TRUE, TRUE); gimp_view_set_viewable (GIMP_VIEW (pattern_view), GIMP_VIEWABLE (gimp_context_get_pattern (context))); gtk_table_attach_defaults (GTK_TABLE (indicator_table), pattern_view, 1, 2, 0, 1); gtk_widget_show (pattern_view); gimp_help_set_help_data (pattern_view, _("The active pattern.\n" "Click to open the Pattern Dialog."), NULL); g_signal_connect_object (context, "pattern-changed", G_CALLBACK (gimp_view_set_viewable), pattern_view, G_CONNECT_SWAPPED); g_signal_connect (pattern_view, "clicked", G_CALLBACK (pattern_preview_clicked), toolbox); gimp_dnd_viewable_dest_add (pattern_view, GIMP_TYPE_PATTERN, pattern_preview_drop_pattern, context); /* gradient view */ gradient_view = gimp_view_new_full_by_types (context, GIMP_TYPE_VIEW, GIMP_TYPE_GRADIENT, GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, 1, FALSE, TRUE, TRUE); gimp_view_set_viewable (GIMP_VIEW (gradient_view), GIMP_VIEWABLE (gimp_context_get_gradient (context))); gtk_table_attach_defaults (GTK_TABLE (indicator_table), gradient_view, 0, 2, 1, 2); gtk_widget_show (gradient_view); gimp_help_set_help_data (gradient_view, _("The active gradient.\n" "Click to open the Gradient Dialog."), NULL); g_signal_connect_object (context, "gradient-changed", G_CALLBACK (gimp_view_set_viewable), gradient_view, G_CONNECT_SWAPPED); g_signal_connect (gradient_view, "clicked", G_CALLBACK (gradient_preview_clicked), toolbox); gimp_dnd_viewable_dest_add (gradient_view, GIMP_TYPE_GRADIENT, gradient_preview_drop_gradient, context); gtk_widget_show (indicator_table); return indicator_table; }
static GValueArray * brushes_get_brush_data_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; gchar *actual_name = NULL; gdouble opacity = 0.0; gint32 spacing = 0; gint32 paint_mode = 0; gint32 width = 0; gint32 height = 0; gint32 length = 0; guint8 *mask_data = NULL; name = g_value_get_string (&args->values[0]); if (success) { GimpBrush *brush; if (name && strlen (name)) { brush = (GimpBrush *) gimp_container_get_child_by_name (gimp->brush_factory->container, name); } else { brush = gimp_context_get_brush (context); } if (brush) { actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (brush))); opacity = 1.0; spacing = gimp_brush_get_spacing (brush); paint_mode = 0; width = brush->mask->width; height = brush->mask->height; length = brush->mask->height * brush->mask->width; mask_data = g_memdup (temp_buf_data (brush->mask), length); } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) { g_value_take_string (&return_vals->values[1], actual_name); g_value_set_double (&return_vals->values[2], opacity); g_value_set_int (&return_vals->values[3], spacing); g_value_set_enum (&return_vals->values[4], paint_mode); g_value_set_int (&return_vals->values[5], width); g_value_set_int (&return_vals->values[6], height); g_value_set_int (&return_vals->values[7], length); gimp_value_take_int8array (&return_vals->values[8], mask_data, length); } return return_vals; }