gint gimp_brush_generated_get_spikes (const GimpBrushGenerated *brush) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1); return brush->spikes; }
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); } }
gfloat gimp_brush_generated_get_angle (const GimpBrushGenerated *brush) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0); return brush->angle; }
gfloat gimp_brush_generated_get_hardness (GimpBrushGenerated *brush) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0); return brush->hardness; }
gfloat gimp_brush_generated_get_aspect_ratio (GimpBrushGenerated *brush) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0); return brush->aspect_ratio; }
GimpBrush * gimp_pdb_get_generated_brush (Gimp *gimp, const gchar *name, gboolean writable, GError **error) { GimpBrush *brush; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); brush = gimp_pdb_get_brush (gimp, name, writable, error); if (! brush) return NULL; if (! GIMP_IS_BRUSH_GENERATED (brush)) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Brush '%s' is not a generated brush"), name); return NULL; } return brush; }
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); } } }
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); } } }
GimpBrushGeneratedShape gimp_brush_generated_get_shape (const GimpBrushGenerated *brush) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), GIMP_BRUSH_GENERATED_CIRCLE); return brush->shape; }
static void gimp_brush_editor_set_data (GimpDataEditor *editor, GimpData *data) { GimpBrushEditor *brush_editor = GIMP_BRUSH_EDITOR (editor); GimpBrushGeneratedShape shape = GIMP_BRUSH_GENERATED_CIRCLE; gdouble radius = 0.0; gint spikes = 2; gdouble hardness = 0.0; gdouble ratio = 0.0; gdouble angle = 0.0; gdouble spacing = 0.0; if (editor->data) g_signal_handlers_disconnect_by_func (editor->data, gimp_brush_editor_notify_brush, editor); GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data); if (editor->data) g_signal_connect (editor->data, "notify", G_CALLBACK (gimp_brush_editor_notify_brush), editor); gimp_view_set_viewable (GIMP_VIEW (editor->view), GIMP_VIEWABLE (data)); if (editor->data) { spacing = gimp_brush_get_spacing (GIMP_BRUSH (editor->data)); if (GIMP_IS_BRUSH_GENERATED (editor->data)) { GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (editor->data); shape = gimp_brush_generated_get_shape (brush); radius = gimp_brush_generated_get_radius (brush); spikes = gimp_brush_generated_get_spikes (brush); hardness = gimp_brush_generated_get_hardness (brush); ratio = gimp_brush_generated_get_aspect_ratio (brush); angle = gimp_brush_generated_get_angle (brush); } } gtk_widget_set_sensitive (brush_editor->options_box, editor->data_editable); gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (brush_editor->shape_group), shape); gtk_adjustment_set_value (brush_editor->radius_data, radius); gtk_adjustment_set_value (brush_editor->spikes_data, spikes); gtk_adjustment_set_value (brush_editor->hardness_data, hardness); gtk_adjustment_set_value (brush_editor->aspect_ratio_data, ratio); gtk_adjustment_set_value (brush_editor->angle_data, angle); gtk_adjustment_set_value (brush_editor->spacing_data, spacing); }
static void gimp_brush_editor_update_brush (GtkAdjustment *adjustment, GimpBrushEditor *editor) { GimpBrushGenerated *brush; gdouble radius; gint spikes; gdouble hardness; gdouble ratio; gdouble angle; gdouble spacing; if (! GIMP_IS_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data)) return; brush = GIMP_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data); radius = gtk_adjustment_get_value (editor->radius_data); spikes = ROUND (gtk_adjustment_get_value (editor->spikes_data)); hardness = gtk_adjustment_get_value (editor->hardness_data); ratio = gtk_adjustment_get_value (editor->aspect_ratio_data); angle = gtk_adjustment_get_value (editor->angle_data); spacing = gtk_adjustment_get_value (editor->spacing_data); if (radius != gimp_brush_generated_get_radius (brush) || spikes != gimp_brush_generated_get_spikes (brush) || hardness != gimp_brush_generated_get_hardness (brush) || ratio != gimp_brush_generated_get_aspect_ratio (brush) || angle != gimp_brush_generated_get_angle (brush) || spacing != gimp_brush_get_spacing (GIMP_BRUSH (brush))) { g_signal_handlers_block_by_func (brush, gimp_brush_editor_notify_brush, editor); gimp_data_freeze (GIMP_DATA (brush)); g_object_freeze_notify (G_OBJECT (brush)); gimp_brush_generated_set_radius (brush, radius); gimp_brush_generated_set_spikes (brush, spikes); gimp_brush_generated_set_hardness (brush, hardness); gimp_brush_generated_set_aspect_ratio (brush, ratio); gimp_brush_generated_set_angle (brush, angle); gimp_brush_set_spacing (GIMP_BRUSH (brush), spacing); g_object_thaw_notify (G_OBJECT (brush)); gimp_data_thaw (GIMP_DATA (brush)); g_signal_handlers_unblock_by_func (brush, gimp_brush_editor_notify_brush, editor); } }
GimpBrushGeneratedShape gimp_brush_generated_set_shape (GimpBrushGenerated *brush, GimpBrushGeneratedShape shape) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), GIMP_BRUSH_GENERATED_CIRCLE); if (brush->shape != shape) { brush->shape = shape; g_object_notify (G_OBJECT (brush), "shape"); gimp_data_dirty (GIMP_DATA (brush)); } return brush->shape; }
gfloat gimp_brush_generated_set_radius (GimpBrushGenerated *brush, gfloat radius) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0); radius = CLAMP (radius, 0.0, 32767.0); if (brush->radius != radius) { brush->radius = radius; g_object_notify (G_OBJECT (brush), "radius"); gimp_data_dirty (GIMP_DATA (brush)); } return brush->radius; }
gfloat gimp_brush_generated_set_hardness (GimpBrushGenerated *brush, gfloat hardness) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0); hardness = CLAMP (hardness, 0.0, 1.0); if (brush->hardness != hardness) { brush->hardness = hardness; g_object_notify (G_OBJECT (brush), "hardness"); gimp_data_dirty (GIMP_DATA (brush)); } return brush->hardness; }
gfloat gimp_brush_generated_set_aspect_ratio (GimpBrushGenerated *brush, gfloat ratio) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0); ratio = CLAMP (ratio, 1.0, 1000.0); if (brush->aspect_ratio != ratio) { brush->aspect_ratio = ratio; g_object_notify (G_OBJECT (brush), "aspect-ratio"); gimp_data_dirty (GIMP_DATA (brush)); } return brush->aspect_ratio; }
gint gimp_brush_generated_set_spikes (GimpBrushGenerated *brush, gint spikes) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1); spikes = CLAMP (spikes, 2, 20); if (brush->spikes != spikes) { brush->spikes = spikes; g_object_notify (G_OBJECT (brush), "spikes"); gimp_data_dirty (GIMP_DATA (brush)); } return brush->spikes; }
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); } } }
void context_brush_aspect_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))) { action_select_property ((GimpActionSelectType) value, action_data_get_display (data), G_OBJECT (brush), "aspect-ratio", 0.1, 1.0, 4.0, 0.1, FALSE); } }
gfloat gimp_brush_generated_set_angle (GimpBrushGenerated *brush, gfloat angle) { g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0); if (angle < 0.0) angle = -1.0 * fmod (angle, 180.0); else if (angle > 180.0) angle = fmod (angle, 180.0); if (brush->angle != angle) { brush->angle = angle; g_object_notify (G_OBJECT (brush), "angle"); gimp_data_dirty (GIMP_DATA (brush)); } return brush->angle; }
static void gimp_brush_editor_update_shape (GtkWidget *widget, GimpBrushEditor *editor) { GimpBrushGenerated *brush; if (! GIMP_IS_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data)) return; brush = GIMP_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { GimpBrushGeneratedShape shape; shape = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "gimp-item-data")); if (gimp_brush_generated_get_shape (brush) != shape) gimp_brush_generated_set_shape (brush, shape); } }
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 }