static gboolean gimp_brightness_contrast_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool); GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { return FALSE; } if (gimp_drawable_get_precision (drawable) == GIMP_PRECISION_U8) { gimp_prop_widget_set_factor (bc_tool->brightness_scale, 127.0, 0); gimp_prop_widget_set_factor (bc_tool->contrast_scale, 127.0, 0); } else { gimp_prop_widget_set_factor (bc_tool->brightness_scale, 0.5, 3); gimp_prop_widget_set_factor (bc_tool->contrast_scale, 0.5, 3); } return TRUE; }
static gboolean gimp_levels_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpLevelsTool *l_tool = GIMP_LEVELS_TOOL (tool); GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); gdouble scale_factor; gdouble step_increment; gdouble page_increment; gint digits; if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { return FALSE; } gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (l_tool->channel_menu), levels_menu_sensitivity, drawable, NULL); gimp_drawable_calculate_histogram (drawable, l_tool->histogram); gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (l_tool->histogram_view), l_tool->histogram); if (gimp_drawable_get_component_type (drawable) == GIMP_COMPONENT_TYPE_U8) { scale_factor = 255.0; step_increment = 1.0; page_increment = 8.0; digits = 0; } else { scale_factor = 100; step_increment = 0.01; page_increment = 1.0; digits = 2; } gimp_prop_widget_set_factor (l_tool->low_input_spinbutton, scale_factor, step_increment, page_increment, digits); gimp_prop_widget_set_factor (l_tool->high_input_spinbutton, scale_factor, step_increment, page_increment, digits); gimp_prop_widget_set_factor (l_tool->low_output_spinbutton, scale_factor, step_increment, page_increment, digits); gimp_prop_widget_set_factor (l_tool->high_output_spinbutton, scale_factor, step_increment, page_increment, digits); gtk_adjustment_configure (l_tool->gamma_linear, scale_factor / 2.0, 0, scale_factor, 0.1, 1.0, 0); return TRUE; }
static void create_levels_scale (GObject *config, const gchar *property_name, const gchar *left, const gchar *right, GtkWidget *table, gint col) { GtkWidget *label; GtkWidget *scale; label = gtk_label_new (left); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, col, col + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (label); scale = gimp_prop_spin_scale_new (config, property_name, NULL, 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1); gtk_table_attach_defaults (GTK_TABLE (table), scale, 1, 2, col, col + 1); gtk_widget_show (scale); label = gtk_label_new (right); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 2, 3, col, col + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (label); }
/** * gimp_transform_options_gui: * @tool_options: a #GimpToolOptions * * Build the Transform Tool Options. * * Return value: a container holding the transform tool options **/ GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_tool_options_gui (tool_options); GtkWidget *hbox; GtkWidget *box; GtkWidget *label; GtkWidget *frame; GtkWidget *combo; GtkWidget *scale; GtkWidget *grid_box; const gchar *constrain_name = NULL; const gchar *constrain_label = NULL; const gchar *constrain_tip = NULL; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Transform:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); box = gimp_prop_enum_icon_box_new (config, "type", "gimp", 0, 0); gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0); gtk_widget_show (box); frame = gimp_prop_enum_radio_frame_new (config, "direction", _("Direction"), 0, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the interpolation menu */ combo = gimp_prop_enum_combo_box_new (config, "interpolation", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Interpolation")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); /* the clipping menu */ combo = gimp_prop_enum_combo_box_new (config, "clip", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Clipping")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); /* the preview frame */ scale = gimp_prop_spin_scale_new (config, "preview-opacity", _("Image opacity"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1); frame = gimp_prop_expanding_frame_new (config, "show-preview", _("Show image preview"), scale, NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the guides frame */ frame = gimp_frame_new (NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the guides type menu */ combo = gimp_prop_enum_combo_box_new (config, "grid-type", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Guides")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_frame_set_label_widget (GTK_FRAME (frame), combo); gtk_widget_show (combo); /* the grid density scale */ scale = gimp_prop_spin_scale_new (config, "grid-size", NULL, 1.8, 8.0, 0); gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), NULL); gtk_container_add (GTK_CONTAINER (frame), scale); g_object_bind_property_full (config, "grid-type", scale, "visible", G_BINDING_SYNC_CREATE, gimp_transform_options_sync_grid, NULL, NULL, NULL); if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL) { constrain_name = "constrain-rotate"; constrain_label = _("15 degrees (%s)"); constrain_tip = _("Limit rotation steps to 15 degrees"); } else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL) { constrain_name = "constrain-scale"; constrain_label = _("Keep aspect (%s)"); constrain_tip = _("Keep the original aspect ratio"); } //TODO: check that the selection tools use the gimp_get_*_mask() functions for constrain/etc or change to what they use else if (tool_options->tool_info->tool_type == GIMP_TYPE_UNIFIED_TRANSFORM_TOOL) { GdkModifierType shift = gimp_get_extend_selection_mask (); GdkModifierType ctrl = gimp_get_constrain_behavior_mask (); struct { GdkModifierType mod; gchar *name; gchar *desc; gchar *tip; } opt_list[] = { { shift, NULL, "Constrain (%s)" }, { shift, "constrain-move", "Move", "Constrain movement to 45 degree angles from center (%s)" }, { shift, "constrain-scale", "Scale", "Maintain aspect ratio when scaling (%s)" }, { shift, "constrain-rotate", "Rotate", "Constrain rotation to 15 degree increments (%s)" }, { shift, "constrain-shear", "Shear", "Shear along edge direction only (%s)" }, { shift, "constrain-perspective", "Perspective", "Constrain perspective handles to move along edges and diagonal (%s)" }, { ctrl, NULL, "From pivot (%s)" }, { ctrl, "frompivot-scale", "Scale", "Scale from pivot point (%s)" }, { ctrl, "frompivot-shear", "Shear", "Shear opposite edge by same amount (%s)" }, { ctrl, "frompivot-perspective", "Perspective", "Maintain position of pivot while changing perspective (%s)" }, { 0, NULL, "Pivot" }, { shift, "cornersnap", "Snap (%s)", "Snap pivot to corners and center (%s)" }, { 0, "fixedpivot", "Lock", "Lock pivot position to canvas" }, }; GtkWidget *button; gchar *label; gint i; frame = NULL; for (i = 0; i < G_N_ELEMENTS (opt_list); i++) { if (!opt_list[i].name && !opt_list[i].desc) { frame = NULL; continue; } label = g_strdup_printf (opt_list[i].desc, gimp_get_mod_string (opt_list[i].mod)); if (opt_list[i].name) { button = gimp_prop_check_button_new (config, opt_list[i].name, label); gtk_box_pack_start (GTK_BOX (frame ? grid_box : vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_free (label); label = g_strdup_printf (opt_list[i].tip, gimp_get_mod_string (opt_list[i].mod)); gimp_help_set_help_data (button, label, NULL); } else { frame = gimp_frame_new (label); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); grid_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (frame), grid_box); gtk_widget_show (grid_box); } g_free (label); } } if (constrain_label) { GtkWidget *button; gchar *label; GdkModifierType constrain_mask; constrain_mask = gimp_get_extend_selection_mask (); label = g_strdup_printf (constrain_label, gimp_get_mod_string (constrain_mask)); button = gimp_prop_check_button_new (config, constrain_name, label); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); gimp_help_set_help_data (button, constrain_tip, NULL); g_free (label); } return vbox; }
GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GimpPaintOptions *options = GIMP_PAINT_OPTIONS (tool_options); GtkWidget *vbox = gimp_tool_options_gui (tool_options); GtkWidget *menu; GtkWidget *scale; GType tool_type; tool_type = tool_options->tool_info->tool_type; /* the paint mode menu */ menu = gimp_prop_paint_mode_menu_new (config, "paint-mode", TRUE, FALSE); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (menu), _("Mode")); g_object_set (menu, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), menu, FALSE, FALSE, 0); gtk_widget_show (menu); if (tool_type == GIMP_TYPE_ERASER_TOOL || tool_type == GIMP_TYPE_CONVOLVE_TOOL || tool_type == GIMP_TYPE_DODGE_BURN_TOOL || tool_type == GIMP_TYPE_HEAL_TOOL || tool_type == GIMP_TYPE_SMUDGE_TOOL) { gtk_widget_set_sensitive (menu, FALSE); } /* the opacity scale */ scale = gimp_prop_spin_scale_new (config, "opacity", _("Opacity"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* temp debug foo */ if (g_type_is_a (tool_type, GIMP_TYPE_PAINT_TOOL)) { GtkWidget *button; button = gimp_prop_check_button_new (config, "use-applicator", "Use GimpApplicator"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); } /* the brush */ if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL)) { GtkWidget *button; GtkWidget *hbox; GtkWidget *frame; button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), _("Brush"), 2, "brush-view-type", "brush-view-size", "gimp-brush-editor"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); scale = gimp_prop_spin_scale_new (config, "brush-size", _("Size"), 1.0, 10.0, 2); gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0); gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), 1.7); gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); gtk_widget_show (scale); button = gimp_icon_button_new (GIMP_STOCK_RESET, NULL); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_image_set_from_icon_name (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))), GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (gimp_paint_options_gui_reset_size), options); gimp_help_set_help_data (button, _("Reset size to brush's native size"), NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); scale = gimp_prop_spin_scale_new (config, "brush-aspect-ratio", _("Aspect Ratio"), 0.1, 1.0, 2); gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); gtk_widget_show (scale); button = gimp_icon_button_new (GIMP_STOCK_RESET, NULL); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_image_set_from_icon_name (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))), GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (gimp_paint_options_gui_reset_aspect_ratio), options); gimp_help_set_help_data (button, _("Reset aspect ratio to brush's native"), NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); scale = gimp_prop_spin_scale_new (config, "brush-angle", _("Angle"), 1.0, 5.0, 2); gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); gtk_widget_show (scale); button = gimp_icon_button_new (GIMP_STOCK_RESET, NULL); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_image_set_from_icon_name (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))), GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (gimp_paint_options_gui_reset_angle), options); gimp_help_set_help_data (button, _("Reset angle to zero"), NULL); button = gimp_prop_dynamics_box_new (NULL, GIMP_CONTEXT (tool_options), _("Dynamics"), 2, "dynamics-view-type", "dynamics-view-size", "gimp-dynamics-editor"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); frame = dynamics_options_gui (options, tool_type); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); frame = jitter_options_gui (options, tool_type); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); } /* the "smooth stroke" options */ if (g_type_is_a (tool_type, GIMP_TYPE_PAINT_TOOL)) { GtkWidget *frame; frame = smoothing_options_gui (options, tool_type); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); } /* the "incremental" toggle */ if (tool_type == GIMP_TYPE_PENCIL_TOOL || tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || tool_type == GIMP_TYPE_ERASER_TOOL) { GtkWidget *button; button = gimp_prop_enum_check_button_new (config, "application-mode", _("Incremental"), GIMP_PAINT_CONSTANT, GIMP_PAINT_INCREMENTAL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); } /* the "hard edge" toggle */ if (tool_type == GIMP_TYPE_ERASER_TOOL || tool_type == GIMP_TYPE_CLONE_TOOL || tool_type == GIMP_TYPE_HEAL_TOOL || tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL || tool_type == GIMP_TYPE_CONVOLVE_TOOL || tool_type == GIMP_TYPE_DODGE_BURN_TOOL || tool_type == GIMP_TYPE_SMUDGE_TOOL) { GtkWidget *button; button = gimp_prop_check_button_new (config, "hard", _("Hard edge")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); } return vbox; }
static void gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool) { GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool); GtkWidget *main_vbox; GtkWidget *frame; GtkWidget *vbox; GtkWidget *scale; GtkWidget *hbox; GtkWidget *button; main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool); frame = gimp_frame_new (_("Select Color")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); /* Create the hue scale widget */ scale = gimp_prop_spin_scale_new (image_map_tool->config, "hue", _("_Hue"), 1.0 / 230.0, 15.0 / 360.0, 0); gimp_prop_widget_set_factor (scale, 360.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* Create the saturation scale widget */ scale = gimp_prop_spin_scale_new (image_map_tool->config, "saturation", _("_Saturation"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* Create the lightness scale widget */ scale = gimp_prop_spin_scale_new (image_map_tool->config, "lightness", _("_Lightness"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* Create the color button */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); button = gimp_prop_color_button_new (image_map_tool->config, "color", _("Colorize Color"), 128, 24, GIMP_COLOR_AREA_FLAT); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (col_tool))); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); gtk_widget_show (button); button = gimp_image_map_tool_add_color_picker (image_map_tool, "colorize", GIMP_STOCK_COLOR_PICKER_GRAY, _("Pick color from image")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); }