1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* Gradient editor module copyight (C) 1996-1997 Federico Mena Quintero
|
|
|
|
* federico@nuclecu.unam.mx
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURIGHTE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Special thanks to:
|
|
|
|
*
|
|
|
|
* Luis Albarran (luis4@mindspring.com) - Nice UI suggestions
|
|
|
|
*
|
|
|
|
* Miguel de Icaza (miguel@nuclecu.unam.mx) - Pop-up menu suggestion
|
|
|
|
*
|
|
|
|
* Marcelo Malheiros (malheiro@dca.fee.unicamp.br) - many, many
|
|
|
|
* suggestions, nice gradient files
|
|
|
|
*
|
|
|
|
* Adam Moss (adam@uunet.pipex.com) - idea for the hint bar
|
|
|
|
*
|
|
|
|
* Everyone on #gimp - many suggestions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* TODO:
|
|
|
|
*
|
|
|
|
* - Fix memory leaks: grad_free_gradient_editor() and any others
|
|
|
|
* which I may have missed.
|
|
|
|
*
|
|
|
|
* - Add all of Marcelo's neat suggestions:
|
|
|
|
* - Hue rotate, saturation, brightness, contrast.
|
|
|
|
*
|
|
|
|
* - Better handling of bogus gradient files and inconsistent
|
|
|
|
* segments. Do not loop indefinitely in seg_get_segment_at() if
|
|
|
|
* there is a missing segment between two others.
|
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1999-02-21 07:20:54 +08:00
|
|
|
#include "config.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "libgimp/gimpenv.h"
|
|
|
|
#include "libgimp/gimplimits.h"
|
2001-01-24 02:49:44 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "apptypes.h"
|
|
|
|
|
2001-05-09 03:29:15 +08:00
|
|
|
#include "widgets/gimpdnd.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "color-notebook.h"
|
|
|
|
#include "gradient-editor.h"
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
#include "context_manager.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "cursorutil.h"
|
|
|
|
#include "errors.h"
|
2001-02-11 03:35:29 +08:00
|
|
|
#include "gimpcontainer.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "gimpcontext.h"
|
2001-02-14 03:53:07 +08:00
|
|
|
#include "gimpdatafactory.h"
|
2001-02-11 03:35:29 +08:00
|
|
|
#include "gimpgradient.h"
|
|
|
|
#include "gimplist.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gimprc.h"
|
1998-11-23 22:47:09 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
#include "pixmaps/zoom_in.xpm"
|
|
|
|
#include "pixmaps/zoom_out.xpm"
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#define EPSILON 1e-10
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
#define GRAD_SCROLLBAR_STEP_SIZE 0.05
|
|
|
|
#define GRAD_SCROLLBAR_PAGE_SIZE 0.75
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
#define GRAD_PREVIEW_WIDTH 600
|
|
|
|
#define GRAD_PREVIEW_HEIGHT 64
|
|
|
|
#define GRAD_CONTROL_HEIGHT 10
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
#define GRAD_COLOR_BOX_WIDTH 24
|
|
|
|
#define GRAD_COLOR_BOX_HEIGHT 16
|
|
|
|
|
|
|
|
#define GRAD_NUM_COLORS 10
|
|
|
|
|
|
|
|
#define GRAD_MOVE_TIME 150 /* ms between mouse click and detection of movement in gradient control */
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
|
|
|
|
#define GRAD_PREVIEW_EVENT_MASK (GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_LEAVE_NOTIFY_MASK | \
|
|
|
|
GDK_POINTER_MOTION_MASK | \
|
1999-11-14 18:50:19 +08:00
|
|
|
GDK_POINTER_MOTION_HINT_MASK | \
|
2001-02-13 08:12:15 +08:00
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
1999-11-14 18:50:19 +08:00
|
|
|
GDK_BUTTON_RELEASE_MASK)
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
#define GRAD_CONTROL_EVENT_MASK (GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_LEAVE_NOTIFY_MASK | \
|
|
|
|
GDK_POINTER_MOTION_MASK | \
|
1999-11-14 18:50:19 +08:00
|
|
|
GDK_POINTER_MOTION_HINT_MASK | \
|
2001-02-13 08:12:15 +08:00
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
1999-10-28 23:05:49 +08:00
|
|
|
GDK_BUTTON1_MOTION_MASK)
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2000-02-24 09:52:31 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GRAD_UPDATE_GRADIENT = 1 << 0,
|
|
|
|
GRAD_UPDATE_PREVIEW = 1 << 1,
|
|
|
|
GRAD_UPDATE_CONTROL = 1 << 2,
|
|
|
|
GRAD_RESET_CONTROL = 1 << 3
|
|
|
|
};
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Gradient editor type */
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GRAD_DRAG_NONE = 0,
|
|
|
|
GRAD_DRAG_LEFT,
|
|
|
|
GRAD_DRAG_MIDDLE,
|
|
|
|
GRAD_DRAG_ALL
|
|
|
|
} control_drag_mode_t;
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
struct _GradientEditor
|
1999-10-28 23:05:49 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *shell;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
GtkWidget *name;
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *hint_label;
|
|
|
|
GtkWidget *scrollbar;
|
|
|
|
GtkWidget *preview;
|
|
|
|
GtkWidget *control;
|
|
|
|
|
|
|
|
GimpContext *context;
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Zoom and scrollbar */
|
2001-02-13 08:12:15 +08:00
|
|
|
guint zoom_factor;
|
|
|
|
GtkObject *scroll_data;
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Instant update */
|
2001-02-13 08:12:15 +08:00
|
|
|
gboolean instant_update;
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Gradient preview */
|
2001-02-13 08:12:15 +08:00
|
|
|
guchar *preview_rows[2]; /* For caching redraw info */
|
|
|
|
gint preview_last_x;
|
|
|
|
gboolean preview_button_down;
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Gradient control */
|
|
|
|
GdkPixmap *control_pixmap;
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradientSegment *control_drag_segment; /* Segment which is being dragged */
|
|
|
|
GimpGradientSegment *control_sel_l; /* Left segment of selection */
|
|
|
|
GimpGradientSegment *control_sel_r; /* Right segment of selection */
|
1999-10-28 23:05:49 +08:00
|
|
|
control_drag_mode_t control_drag_mode; /* What is being dragged? */
|
|
|
|
guint32 control_click_time; /* Time when mouse was pressed */
|
|
|
|
gboolean control_compress; /* Compressing/expanding handles */
|
|
|
|
gint control_last_x; /* Last mouse position when dragging */
|
|
|
|
gdouble control_last_gx; /* Last position (wrt gradient) when dragging */
|
|
|
|
gdouble control_orig_pos; /* Original click position when dragging */
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *control_main_popup; /* Popup menu */
|
|
|
|
GtkWidget *control_blending_label; /* Blending function label */
|
|
|
|
GtkWidget *control_coloring_label; /* Coloring type label */
|
|
|
|
GtkWidget *control_split_m_label; /* Split at midpoint label */
|
|
|
|
GtkWidget *control_split_u_label; /* Split uniformly label */
|
|
|
|
GtkWidget *control_delete_menu_item; /* Delete menu item */
|
|
|
|
GtkWidget *control_delete_label; /* Delete label */
|
|
|
|
GtkWidget *control_recenter_label; /* Re-center label */
|
|
|
|
GtkWidget *control_redistribute_label; /* Re-distribute label */
|
|
|
|
GtkWidget *control_flip_label; /* Flip label */
|
|
|
|
GtkWidget *control_replicate_label; /* Replicate label */
|
|
|
|
GtkWidget *control_blend_colors_menu_item; /* Blend colors menu item */
|
|
|
|
GtkWidget *control_blend_opacity_menu_item; /* Blend opacity menu item */
|
|
|
|
GtkWidget *control_left_load_popup; /* Left endpoint load menu */
|
|
|
|
GtkWidget *control_left_save_popup; /* Left endpoint save menu */
|
|
|
|
GtkWidget *control_right_load_popup; /* Right endpoint load menu */
|
|
|
|
GtkWidget *control_right_save_popup; /* Right endpoint save menu */
|
|
|
|
GtkWidget *control_blending_popup; /* Blending function menu */
|
|
|
|
GtkWidget *control_coloring_popup; /* Coloring type menu */
|
|
|
|
GtkWidget *control_sel_ops_popup; /* Selection ops menu */
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
GtkAccelGroup *accel_group;
|
|
|
|
|
|
|
|
/* Blending and coloring menus */
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *control_blending_items[5 + 1]; /* Add 1 for the "Varies" item */
|
|
|
|
GtkWidget *control_coloring_items[3 + 1];
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Split uniformly dialog */
|
2001-02-13 08:12:15 +08:00
|
|
|
gint split_parts;
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Replicate dialog */
|
2001-02-13 08:12:15 +08:00
|
|
|
gint replicate_times;
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Saved colors */
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpRGB saved_colors[GRAD_NUM_COLORS];
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *left_load_color_boxes[GRAD_NUM_COLORS + 3];
|
|
|
|
GtkWidget *left_load_labels[GRAD_NUM_COLORS + 3];
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *left_save_color_boxes[GRAD_NUM_COLORS];
|
|
|
|
GtkWidget *left_save_labels[GRAD_NUM_COLORS];
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *right_load_color_boxes[GRAD_NUM_COLORS + 3];
|
|
|
|
GtkWidget *right_load_labels[GRAD_NUM_COLORS + 3];
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *right_save_color_boxes[GRAD_NUM_COLORS];
|
|
|
|
GtkWidget *right_save_labels[GRAD_NUM_COLORS];
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* Color dialogs */
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *left_color_preview;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *left_saved_segments;
|
2001-02-13 08:12:15 +08:00
|
|
|
gboolean left_saved_dirty;
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
GtkWidget *right_color_preview;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *right_saved_segments;
|
2001-02-13 08:12:15 +08:00
|
|
|
gboolean right_saved_dirty;
|
2001-02-18 05:20:10 +08:00
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
/***** Local functions *****/
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void gradient_editor_name_activate (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor);
|
|
|
|
static void gradient_editor_name_focus_out (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GradientEditor *gradient_editor);
|
|
|
|
static void gradient_editor_drop_gradient (GtkWidget *widget,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
|
|
|
static void gradient_editor_gradient_changed (GimpContext *context,
|
|
|
|
GimpGradient *gradient,
|
|
|
|
GradientEditor *gradient_editor);
|
1999-10-28 23:05:49 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Gradient editor functions */
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void ed_update_editor (GradientEditor *gradient_editor,
|
|
|
|
gint flags);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void ed_set_hint (GradientEditor *gradient_editor,
|
|
|
|
gchar *str);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void ed_initialize_saved_colors (GradientEditor *gradient_editor);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Main dialog button callbacks & functions */
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static void ed_save_pov_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void ed_do_save_pov_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void ed_cancel_save_pov_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static gint ed_delete_save_pov_callback (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
|
|
|
static void ed_close_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Zoom, scrollbar & instant update callbacks */
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static void ed_scrollbar_update (GtkAdjustment *adjustment,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void ed_zoom_all_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void ed_zoom_out_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void ed_zoom_in_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void ed_instant_update_update (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Gradient preview functions */
|
|
|
|
|
2000-12-21 19:56:58 +08:00
|
|
|
static gint preview_events (GtkWidget *widget,
|
2000-12-20 05:49:46 +08:00
|
|
|
GdkEvent *event,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
|
|
|
static void preview_set_hint (GradientEditor *gradient_editor,
|
|
|
|
gint x);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void preview_set_foreground (GradientEditor *gradient_editor,
|
|
|
|
gint x);
|
|
|
|
static void preview_set_background (GradientEditor *gradient_editor,
|
|
|
|
gint x);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void preview_update (GradientEditor *gradient_editor,
|
|
|
|
gboolean recalculate);
|
|
|
|
static void preview_fill_image (GradientEditor *gradient_editor,
|
|
|
|
gint width,
|
2000-12-20 05:49:46 +08:00
|
|
|
gint height,
|
|
|
|
gdouble left,
|
|
|
|
gdouble right);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Gradient control functions */
|
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static gint control_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
|
|
|
static void control_do_hint (GradientEditor *gradient_editor,
|
|
|
|
gint x,
|
2000-12-20 05:49:46 +08:00
|
|
|
gint y);
|
2001-02-18 05:20:10 +08:00
|
|
|
static void control_button_press (GradientEditor *gradient_editor,
|
|
|
|
gint x,
|
2000-12-20 05:49:46 +08:00
|
|
|
gint y,
|
|
|
|
guint button,
|
|
|
|
guint state);
|
2001-02-18 05:20:10 +08:00
|
|
|
static gboolean control_point_in_handle (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient,
|
2001-02-13 08:12:15 +08:00
|
|
|
gint x,
|
2000-12-20 05:49:46 +08:00
|
|
|
gint y,
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg,
|
2000-12-20 05:49:46 +08:00
|
|
|
control_drag_mode_t handle);
|
2001-02-18 05:20:10 +08:00
|
|
|
static void control_select_single_segment (GradientEditor *gradient_editor,
|
|
|
|
GimpGradientSegment *seg);
|
|
|
|
static void control_extend_selection (GradientEditor *gradient_editor,
|
|
|
|
GimpGradientSegment *seg,
|
|
|
|
gdouble pos);
|
|
|
|
static void control_motion (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient,
|
2001-02-13 08:12:15 +08:00
|
|
|
gint x);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void control_compress_left (GimpGradientSegment *range_l,
|
|
|
|
GimpGradientSegment *range_r,
|
|
|
|
GimpGradientSegment *drag_seg,
|
|
|
|
gdouble pos);
|
|
|
|
static void control_compress_range (GimpGradientSegment *range_l,
|
|
|
|
GimpGradientSegment *range_r,
|
|
|
|
gdouble new_l,
|
|
|
|
gdouble new_r);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static double control_move (GradientEditor *gradient_editor,
|
|
|
|
GimpGradientSegment *range_l,
|
|
|
|
GimpGradientSegment *range_r,
|
|
|
|
gdouble delta);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Control update/redraw functions */
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void control_update (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient,
|
2001-02-13 08:12:15 +08:00
|
|
|
gboolean recalculate);
|
2001-02-18 05:20:10 +08:00
|
|
|
static void control_draw (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient,
|
2001-02-13 08:12:15 +08:00
|
|
|
GdkPixmap *pixmap,
|
2000-12-20 05:49:46 +08:00
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gdouble left,
|
|
|
|
gdouble right);
|
2001-02-18 05:20:10 +08:00
|
|
|
static void control_draw_normal_handle (GradientEditor *gradient_editor,
|
|
|
|
GdkPixmap *pixmap,
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble pos,
|
|
|
|
gint height);
|
2001-02-18 05:20:10 +08:00
|
|
|
static void control_draw_middle_handle (GradientEditor *gradient_editor,
|
|
|
|
GdkPixmap *pixmap,
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble pos,
|
|
|
|
gint height);
|
|
|
|
static void control_draw_handle (GdkPixmap *pixmap,
|
|
|
|
GdkGC *border_gc,
|
|
|
|
GdkGC *fill_gc,
|
|
|
|
gint xpos,
|
|
|
|
gint height);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static gint control_calc_p_pos (GradientEditor *gradient_editor,
|
|
|
|
gdouble pos);
|
|
|
|
static gdouble control_calc_g_pos (GradientEditor *gradient_editor,
|
|
|
|
gint pos);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Control popup functions */
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void cpopup_create_main_menu (GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_do_popup (GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static GtkWidget * cpopup_create_color_item (GtkWidget **color_box,
|
|
|
|
GtkWidget **label);
|
|
|
|
static GtkWidget * cpopup_create_menu_item_with_label (gchar *str,
|
|
|
|
GtkWidget **label);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void cpopup_adjust_menus (GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_adjust_blending_menu (GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_adjust_coloring_menu (GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_check_selection_params (GradientEditor *gradient_editor,
|
|
|
|
gint *equal_blending,
|
2000-12-20 05:49:46 +08:00
|
|
|
gint *equal_coloring);
|
|
|
|
|
|
|
|
static void cpopup_render_color_box (GtkPreview *preview,
|
2001-01-20 23:37:26 +08:00
|
|
|
GimpRGB *color);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static GtkWidget * cpopup_create_load_menu (GradientEditor *gradient_editor,
|
|
|
|
GtkWidget **color_boxes,
|
2000-12-20 05:49:46 +08:00
|
|
|
GtkWidget **labels,
|
|
|
|
gchar *label1,
|
|
|
|
gchar *label2,
|
|
|
|
GtkSignalFunc callback,
|
|
|
|
gchar accel_key_0,
|
|
|
|
guint8 accel_mods_0,
|
|
|
|
gchar accel_key_1,
|
|
|
|
guint8 accel_mods_1,
|
|
|
|
gchar accel_key_2,
|
|
|
|
guint8 accel_mods_2);
|
2001-02-18 05:20:10 +08:00
|
|
|
static GtkWidget * cpopup_create_save_menu (GradientEditor *gradient_editor,
|
|
|
|
GtkWidget **color_boxes,
|
2000-12-20 05:49:46 +08:00
|
|
|
GtkWidget **labels,
|
|
|
|
GtkSignalFunc callback);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void cpopup_update_saved_color (GradientEditor *gradient_editor,
|
|
|
|
gint n,
|
2001-01-20 23:37:26 +08:00
|
|
|
GimpRGB *color);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
|
|
|
static void cpopup_load_left_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_save_left_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_load_right_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_save_right_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static GimpGradientSegment * cpopup_save_selection(GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_replace_selection (GradientEditor *gradient_editor,
|
|
|
|
GimpGradientSegment *replace_seg);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* ----- */
|
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
static void cpopup_set_left_color_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2001-01-21 21:41:07 +08:00
|
|
|
static void cpopup_set_right_color_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
static void cpopup_left_color_changed (ColorNotebook *cnb,
|
|
|
|
const GimpRGB *color,
|
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data);
|
|
|
|
static void cpopup_right_color_changed (ColorNotebook *cnb,
|
|
|
|
const GimpRGB *color,
|
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* ----- */
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static GtkWidget * cpopup_create_blending_menu (GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_blending_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor);
|
|
|
|
static GtkWidget * cpopup_create_coloring_menu (GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_coloring_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* ----- */
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void cpopup_split_midpoint_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_split_midpoint (GimpGradient *gradient,
|
|
|
|
GimpGradientSegment *lseg,
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment **newl,
|
|
|
|
GimpGradientSegment **newr);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
|
|
|
static void cpopup_split_uniform_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_split_uniform_scale_update (GtkAdjustment *adjustment,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_split_uniform_split_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_split_uniform_cancel_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
|
|
|
static void cpopup_split_uniform (GimpGradient *gradient,
|
|
|
|
GimpGradientSegment *lseg,
|
|
|
|
gint parts,
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment **newl,
|
|
|
|
GimpGradientSegment **newr);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
|
|
|
static void cpopup_delete_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_recenter_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_redistribute_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Control popup -> Selection operations functions */
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static GtkWidget * cpopup_create_sel_ops_menu (GradientEditor *gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_flip_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_replicate_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_replicate_scale_update (GtkAdjustment *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_do_replicate_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_replicate_cancel_callback (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_blend_colors (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
2000-12-20 05:49:46 +08:00
|
|
|
static void cpopup_blend_opacity (GtkWidget *widget,
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Blend function */
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void cpopup_blend_endpoints (GradientEditor *gradient_editor,
|
|
|
|
GimpRGB *left,
|
2001-01-20 23:37:26 +08:00
|
|
|
GimpRGB *right,
|
2000-12-20 05:49:46 +08:00
|
|
|
gint blend_colors,
|
|
|
|
gint blend_opacity);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Segment functions */
|
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
static void seg_get_closest_handle (GimpGradient *grad,
|
|
|
|
gdouble pos,
|
|
|
|
GimpGradientSegment **seg,
|
|
|
|
control_drag_mode_t *handle);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-21 19:56:58 +08:00
|
|
|
|
2001-02-14 09:42:12 +08:00
|
|
|
/***** Public gradient editor functions *****/
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *
|
|
|
|
gradient_editor_new (void)
|
2001-02-14 09:42:12 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
2001-02-19 08:05:03 +08:00
|
|
|
GtkWidget *vbox2;
|
2001-02-18 05:20:10 +08:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *frame;
|
|
|
|
gint i;
|
2001-02-14 09:42:12 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor = g_new (GradientEditor, 1);
|
2001-02-14 09:42:12 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->context = gimp_context_new (NULL, NULL);
|
2001-02-14 09:42:12 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gradient_editor->context), "gradient_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gradient_editor_gradient_changed),
|
|
|
|
gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
/* Shell and main vbox */
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->shell =
|
1999-10-04 16:40:33 +08:00
|
|
|
gimp_dialog_new (_("Gradient Editor"), "gradient_editor",
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/gradient_editor/gradient_editor.html",
|
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
"_delete_event_", ed_close_callback,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor, NULL, NULL, FALSE, TRUE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1999-10-04 16:40:33 +08:00
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (gradient_editor->shell)->vbox),
|
|
|
|
main_vbox);
|
|
|
|
gtk_widget_show (main_vbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-19 08:05:03 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
/* Gradient's name */
|
|
|
|
gradient_editor->name = gtk_entry_new ();
|
2001-03-30 19:16:05 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), gradient_editor->name, FALSE, FALSE, 0);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_show (gradient_editor->name);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gradient_editor->name), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (gradient_editor_name_activate),
|
|
|
|
gradient_editor);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (gradient_editor->name), "focus_out_event",
|
|
|
|
GTK_SIGNAL_FUNC (gradient_editor_name_focus_out),
|
|
|
|
gradient_editor);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
/* Frame for gradient preview and gradient control */
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2001-02-19 08:05:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2001-02-19 08:05:03 +08:00
|
|
|
vbox2 = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox2);
|
|
|
|
gtk_widget_show (vbox2);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
|
|
|
/* Gradient preview */
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->preview_rows[0] = NULL;
|
|
|
|
gradient_editor->preview_rows[1] = NULL;
|
|
|
|
gradient_editor->preview_last_x = 0;
|
|
|
|
gradient_editor->preview_button_down = FALSE;
|
|
|
|
|
|
|
|
gradient_editor->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_set_dither (GTK_PREVIEW (gradient_editor->preview), GDK_RGB_DITHER_MAX);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (gradient_editor->preview),
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
GRAD_PREVIEW_WIDTH, GRAD_PREVIEW_HEIGHT);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Enable auto-resizing of the preview but ensure a minimal size */
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_usize (gradient_editor->preview,
|
1999-07-24 23:37:03 +08:00
|
|
|
GRAD_PREVIEW_WIDTH, GRAD_PREVIEW_HEIGHT);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_preview_set_expand (GTK_PREVIEW (gradient_editor->preview), TRUE);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_events (gradient_editor->preview, GRAD_PREVIEW_EVENT_MASK);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (gradient_editor->preview), "event",
|
2000-12-21 19:56:58 +08:00
|
|
|
GTK_SIGNAL_FUNC (preview_events),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor);
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_gtk_drag_dest_set_by_type (gradient_editor->preview,
|
2001-02-13 08:12:15 +08:00
|
|
|
GTK_DEST_DEFAULT_ALL,
|
|
|
|
GIMP_TYPE_GRADIENT,
|
|
|
|
GDK_ACTION_COPY);
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_dnd_viewable_dest_set (GTK_WIDGET (gradient_editor->preview),
|
2001-02-13 08:12:15 +08:00
|
|
|
GIMP_TYPE_GRADIENT,
|
|
|
|
gradient_editor_drop_gradient,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor);
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2001-02-19 08:05:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), gradient_editor->preview, TRUE, TRUE, 0);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_show (gradient_editor->preview);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
|
|
|
/* Gradient control */
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_pixmap = NULL;
|
|
|
|
gradient_editor->control_drag_segment = NULL;
|
|
|
|
gradient_editor->control_sel_l = NULL;
|
|
|
|
gradient_editor->control_sel_r = NULL;
|
|
|
|
gradient_editor->control_drag_mode = GRAD_DRAG_NONE;
|
|
|
|
gradient_editor->control_click_time = 0;
|
|
|
|
gradient_editor->control_compress = FALSE;
|
|
|
|
gradient_editor->control_last_x = 0;
|
|
|
|
gradient_editor->control_last_gx = 0.0;
|
|
|
|
gradient_editor->control_orig_pos = 0.0;
|
|
|
|
gradient_editor->control_main_popup = NULL;
|
|
|
|
gradient_editor->control_blending_label = NULL;
|
|
|
|
gradient_editor->control_coloring_label = NULL;
|
|
|
|
gradient_editor->control_split_m_label = NULL;
|
|
|
|
gradient_editor->control_split_u_label = NULL;
|
|
|
|
gradient_editor->control_delete_menu_item = NULL;
|
|
|
|
gradient_editor->control_delete_label = NULL;
|
|
|
|
gradient_editor->control_recenter_label = NULL;
|
|
|
|
gradient_editor->control_redistribute_label = NULL;
|
|
|
|
gradient_editor->control_flip_label = NULL;
|
|
|
|
gradient_editor->control_replicate_label = NULL;
|
|
|
|
gradient_editor->control_blend_colors_menu_item = NULL;
|
|
|
|
gradient_editor->control_blend_opacity_menu_item = NULL;
|
|
|
|
gradient_editor->control_left_load_popup = NULL;
|
|
|
|
gradient_editor->control_left_save_popup = NULL;
|
|
|
|
gradient_editor->control_right_load_popup = NULL;
|
|
|
|
gradient_editor->control_right_save_popup = NULL;
|
|
|
|
gradient_editor->control_blending_popup = NULL;
|
|
|
|
gradient_editor->control_coloring_popup = NULL;
|
|
|
|
gradient_editor->control_sel_ops_popup = NULL;
|
|
|
|
|
|
|
|
gradient_editor->accel_group = NULL;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
|
|
|
for (i = 0;
|
2001-02-18 05:20:10 +08:00
|
|
|
i < (sizeof (gradient_editor->control_blending_items) /
|
|
|
|
sizeof (gradient_editor->control_blending_items[0]));
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
i++)
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_blending_items[i] = NULL;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
|
|
|
for (i = 0;
|
2001-02-18 05:20:10 +08:00
|
|
|
i < (sizeof (gradient_editor->control_coloring_items) /
|
|
|
|
sizeof (gradient_editor->control_coloring_items[0]));
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
i++)
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_coloring_items[i] = NULL;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control = gtk_drawing_area_new ();
|
|
|
|
gtk_drawing_area_size (GTK_DRAWING_AREA (gradient_editor->control),
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
GRAD_PREVIEW_WIDTH, GRAD_CONTROL_HEIGHT);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_events (gradient_editor->control, GRAD_CONTROL_EVENT_MASK);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (gradient_editor->control), "event",
|
|
|
|
GTK_SIGNAL_FUNC (control_events),
|
|
|
|
gradient_editor);
|
2001-02-19 08:05:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), gradient_editor->control,
|
|
|
|
FALSE, FALSE, 0);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_show (gradient_editor->control);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-19 08:05:03 +08:00
|
|
|
/* Scrollbar */
|
|
|
|
gradient_editor->zoom_factor = 1;
|
|
|
|
|
|
|
|
gradient_editor->scroll_data =
|
|
|
|
gtk_adjustment_new (0.0, 0.0, 1.0,
|
|
|
|
1.0 * GRAD_SCROLLBAR_STEP_SIZE,
|
|
|
|
1.0 * GRAD_SCROLLBAR_PAGE_SIZE,
|
|
|
|
1.0);
|
|
|
|
|
|
|
|
gtk_signal_connect (gradient_editor->scroll_data, "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (ed_scrollbar_update),
|
|
|
|
gradient_editor);
|
|
|
|
gtk_signal_connect (gradient_editor->scroll_data, "changed",
|
|
|
|
GTK_SIGNAL_FUNC (ed_scrollbar_update),
|
|
|
|
gradient_editor);
|
|
|
|
|
|
|
|
gradient_editor->scrollbar =
|
|
|
|
gtk_hscrollbar_new (GTK_ADJUSTMENT (gradient_editor->scroll_data));
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (gradient_editor->scrollbar),
|
|
|
|
GTK_UPDATE_CONTINUOUS);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), gradient_editor->scrollbar,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (gradient_editor->scrollbar);
|
|
|
|
|
|
|
|
/* Horizontal box for name, zoom controls and instant update toggle */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* Save as POV-Ray button */
|
|
|
|
button = gtk_button_new_with_label (_("Save as POV-Ray"));
|
|
|
|
gimp_help_set_help_data (button, NULL,
|
|
|
|
"dialogs/gradient_editor/save_as_povray.html");
|
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (ed_save_pov_callback),
|
|
|
|
gradient_editor);
|
|
|
|
|
|
|
|
/* + and - buttons */
|
|
|
|
gtk_widget_realize (gradient_editor->shell);
|
|
|
|
|
|
|
|
button = gimp_pixmap_button_new (zoom_out_xpm, NULL);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (ed_zoom_out_callback),
|
|
|
|
gradient_editor);
|
|
|
|
|
|
|
|
button = gimp_pixmap_button_new (zoom_in_xpm, NULL);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (ed_zoom_in_callback),
|
|
|
|
gradient_editor);
|
|
|
|
|
|
|
|
/* Zoom all button */
|
|
|
|
button = gtk_button_new_with_label (_("Zoom all"));
|
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (ed_zoom_all_callback),
|
|
|
|
gradient_editor);
|
|
|
|
|
|
|
|
/* Instant update toggle */
|
|
|
|
gradient_editor->instant_update = TRUE;
|
|
|
|
|
|
|
|
button = gtk_check_button_new_with_label (_("Instant update"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
|
|
|
GTK_SIGNAL_FUNC (ed_instant_update_update),
|
|
|
|
gradient_editor);
|
|
|
|
|
|
|
|
/* Hint bar */
|
|
|
|
hbox = GTK_DIALOG (gradient_editor->shell)->action_area;
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->hint_label = gtk_label_new ("");
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (gradient_editor->hint_label), 0.0, 0.5);
|
2001-02-19 08:05:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gradient_editor->hint_label,
|
2001-02-18 05:20:10 +08:00
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (gradient_editor->hint_label);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
|
|
|
/* Initialize other data */
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->left_color_preview = NULL;
|
|
|
|
gradient_editor->left_saved_segments = NULL;
|
|
|
|
gradient_editor->left_saved_dirty = FALSE;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->right_color_preview = NULL;
|
|
|
|
gradient_editor->right_saved_segments = NULL;
|
|
|
|
gradient_editor->right_saved_dirty = FALSE;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_initialize_saved_colors (gradient_editor);
|
|
|
|
cpopup_create_main_menu (gradient_editor);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-14 03:53:07 +08:00
|
|
|
if (gimp_container_num_children (global_gradient_factory->container))
|
1999-11-14 18:50:19 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_context_set_gradient (gradient_editor->context,
|
2001-02-14 03:53:07 +08:00
|
|
|
GIMP_GRADIENT (gimp_container_get_child_by_index (global_gradient_factory->container, 0)));
|
1999-11-14 18:50:19 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
gradient = GIMP_GRADIENT (gimp_gradient_new (_("Default")));
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2001-02-14 03:53:07 +08:00
|
|
|
gimp_container_add (global_gradient_factory->container,
|
|
|
|
GIMP_OBJECT (gradient));
|
1999-11-14 18:50:19 +08:00
|
|
|
}
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_show (gradient_editor->shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
return gradient_editor;
|
1999-10-28 23:05:49 +08:00
|
|
|
}
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
void
|
|
|
|
gradient_editor_set_gradient (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
g_return_if_fail (gradient_editor != NULL);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gimp_container_have (global_gradient_factory->container,
|
|
|
|
GIMP_OBJECT (gradient)))
|
1999-11-14 18:50:19 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_context_set_gradient (gradient_editor->context, gradient);
|
1999-11-14 18:50:19 +08:00
|
|
|
}
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! GTK_WIDGET_VISIBLE (gradient_editor->shell))
|
|
|
|
gtk_widget_show (gradient_editor->shell);
|
|
|
|
else
|
|
|
|
gdk_window_raise (gradient_editor->shell->window);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
void
|
|
|
|
gradient_editor_free (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
g_return_if_fail (gradient_editor != NULL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
/* private functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor_name_activate (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-09-30 18:50:36 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
gchar *entry_text;
|
1999-09-30 18:50:36 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1999-09-30 18:50:36 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
entry_text = gtk_entry_get_text (GTK_ENTRY (widget));
|
1999-09-30 18:50:36 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_object_set_name (GIMP_OBJECT (gradient), entry_text);
|
1999-09-30 18:50:36 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor_name_focus_out (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor_name_activate (widget, gradient_editor);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor_drop_gradient (GtkWidget *widget,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor = (GradientEditor *) data;
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor_set_gradient (gradient_editor,
|
|
|
|
GIMP_GRADIENT (viewable));
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-10-13 07:31:08 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor_gradient_changed (GimpContext *context,
|
|
|
|
GimpGradient *gradient,
|
|
|
|
GradientEditor *gradient_editor)
|
1998-10-13 07:31:08 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (gradient_editor->name),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (gradient)));
|
1998-10-13 07:31:08 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1998-10-13 07:31:08 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
/*****/
|
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (GradientEditor *gradient_editor,
|
|
|
|
gint flags)
|
1999-07-23 04:42:59 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1998-10-13 07:31:08 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (flags & GRAD_UPDATE_GRADIENT)
|
1999-07-23 04:42:59 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_update (gradient_editor, TRUE);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (flags & GRAD_UPDATE_PREVIEW)
|
|
|
|
preview_update (gradient_editor, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (flags & GRAD_UPDATE_CONTROL)
|
|
|
|
control_update (gradient_editor, gradient, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (flags & GRAD_RESET_CONTROL)
|
|
|
|
control_update (gradient_editor, gradient, TRUE);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (GradientEditor *gradient_editor,
|
|
|
|
gchar *str)
|
1999-07-23 04:42:59 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->hint_label), str);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_initialize_saved_colors (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gint i;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
for (i = 0; i < (GRAD_NUM_COLORS + 3); i++)
|
|
|
|
{
|
|
|
|
gradient_editor->left_load_color_boxes[i] = NULL;
|
|
|
|
gradient_editor->left_load_labels[i] = NULL;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->right_load_color_boxes[i] = NULL;
|
|
|
|
gradient_editor->right_load_labels[i] = NULL;
|
|
|
|
}
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
for (i = 0; i < GRAD_NUM_COLORS; i++)
|
|
|
|
{
|
|
|
|
gradient_editor->left_save_color_boxes[i] = NULL;
|
|
|
|
gradient_editor->left_save_labels[i] = NULL;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->right_save_color_boxes[i] = NULL;
|
|
|
|
gradient_editor->right_save_labels[i] = NULL;
|
|
|
|
}
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->saved_colors[0].r = 0.0; /* Black */
|
|
|
|
gradient_editor->saved_colors[0].g = 0.0;
|
|
|
|
gradient_editor->saved_colors[0].b = 0.0;
|
|
|
|
gradient_editor->saved_colors[0].a = 1.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[1].r = 0.5; /* 50% Gray */
|
|
|
|
gradient_editor->saved_colors[1].g = 0.5;
|
|
|
|
gradient_editor->saved_colors[1].b = 0.5;
|
|
|
|
gradient_editor->saved_colors[1].a = 1.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[2].r = 1.0; /* White */
|
|
|
|
gradient_editor->saved_colors[2].g = 1.0;
|
|
|
|
gradient_editor->saved_colors[2].b = 1.0;
|
|
|
|
gradient_editor->saved_colors[2].a = 1.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[3].r = 0.0; /* Clear */
|
|
|
|
gradient_editor->saved_colors[3].g = 0.0;
|
|
|
|
gradient_editor->saved_colors[3].b = 0.0;
|
|
|
|
gradient_editor->saved_colors[3].a = 0.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[4].r = 1.0; /* Red */
|
|
|
|
gradient_editor->saved_colors[4].g = 0.0;
|
|
|
|
gradient_editor->saved_colors[4].b = 0.0;
|
|
|
|
gradient_editor->saved_colors[4].a = 1.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[5].r = 1.0; /* Yellow */
|
|
|
|
gradient_editor->saved_colors[5].g = 1.0;
|
|
|
|
gradient_editor->saved_colors[5].b = 0.0;
|
|
|
|
gradient_editor->saved_colors[5].a = 1.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[6].r = 0.0; /* Green */
|
|
|
|
gradient_editor->saved_colors[6].g = 1.0;
|
|
|
|
gradient_editor->saved_colors[6].b = 0.0;
|
|
|
|
gradient_editor->saved_colors[6].a = 1.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[7].r = 0.0; /* Cyan */
|
|
|
|
gradient_editor->saved_colors[7].g = 1.0;
|
|
|
|
gradient_editor->saved_colors[7].b = 1.0;
|
|
|
|
gradient_editor->saved_colors[7].a = 1.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[8].r = 0.0; /* Blue */
|
|
|
|
gradient_editor->saved_colors[8].g = 0.0;
|
|
|
|
gradient_editor->saved_colors[8].b = 1.0;
|
|
|
|
gradient_editor->saved_colors[8].a = 1.0;
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[9].r = 1.0; /* Magenta */
|
|
|
|
gradient_editor->saved_colors[9].g = 0.0;
|
|
|
|
gradient_editor->saved_colors[9].b = 1.0;
|
|
|
|
gradient_editor->saved_colors[9].a = 1.0;
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
/***** Main gradient editor dialog callbacks *****/
|
2001-02-11 03:35:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** The "save as pov" dialog functions *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_save_pov_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
GtkWidget *window;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
if (! gradient)
|
1999-07-23 04:42:59 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
window = gtk_file_selection_new (_("Save as POV-Ray"));
|
1999-12-31 04:16:58 +08:00
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (window), "save_gradient", "Gimp");
|
1999-09-28 01:58:10 +08:00
|
|
|
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-12-31 04:16:58 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (window)->button_area), 2);
|
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->ok_button),
|
2000-12-20 05:49:46 +08:00
|
|
|
"clicked",
|
|
|
|
GTK_SIGNAL_FUNC (ed_do_save_pov_callback),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->cancel_button),
|
2000-12-20 05:49:46 +08:00
|
|
|
"clicked",
|
|
|
|
GTK_SIGNAL_FUNC (ed_cancel_save_pov_callback),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
2000-12-20 05:49:46 +08:00
|
|
|
GTK_SIGNAL_FUNC (ed_delete_save_pov_callback),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Connect the "F1" help key */
|
|
|
|
gimp_help_connect_help_accel (window, gimp_standard_help_func,
|
configure.in Updated Gimp-Help. See help/ChangeLog for details.
2000-12-15 Michael Natterer <mitch@gimp.org>
* configure.in
* help/*: Updated Gimp-Help. See help/ChangeLog for details.
* app/channels_dialog.c
* app/gdisplay.c
* app/gradient.c
* app/layers_dialog.c
* app/menus.c
* app/paths_dialog.c
* app/preferences_dialog.c
* app/resize.c: fixed menu paths.
* plug-ins/helpbrowser/helpbrowser.c: load a special
"undocumented_filter.html" page if a filter was not found.
Adapted to the new help structure.
2000-12-15 Michael Natterer <mitch@gimp.org>
* makedummyhelpfile.sh
* makeindex.sh: removed.
* images/*: added some images.
* help/*: Updated to the latest version of the gimp-help CVS module.
This Version instoduces a bunch of new toplevel HTML files for
general topics, an autogenerated index, TOC, glossary,
an "image" directory on the "C" level, peace, love, and stuff...
Thanks to all help writers: Prof, Bex, Piers, ...
2000-12-15 11:47:24 +08:00
|
|
|
"dialogs/gradient_editor/save_as_povray.html");
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
gtk_widget_show (window);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, FALSE);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_do_save_pov_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
gchar *filename;
|
|
|
|
FILE *file;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
|
|
|
if (! gradient)
|
2000-12-21 19:56:58 +08:00
|
|
|
return;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (gtk_widget_get_toplevel (widget)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
file = fopen (filename, "wb");
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
if (!file)
|
2000-12-20 05:49:46 +08:00
|
|
|
{
|
|
|
|
g_message ("Could not open \"%s\"", filename);
|
|
|
|
}
|
1999-07-23 04:42:59 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf (file, "/* color_map file created by the GIMP */\n");
|
|
|
|
fprintf (file, "/* http://www.gimp.org/ */\n");
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
fprintf (file, "color_map {\n");
|
1998-10-13 07:31:08 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
for (seg = gradient->segments; seg; seg = seg->next)
|
1999-07-23 04:42:59 +08:00
|
|
|
{
|
|
|
|
/* Left */
|
|
|
|
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
|
|
|
seg->left,
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->left_color.r,
|
|
|
|
seg->left_color.g,
|
|
|
|
seg->left_color.b,
|
|
|
|
1.0 - seg->left_color.a);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
|
|
|
/* Middle */
|
|
|
|
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
|
|
|
seg->middle,
|
2001-01-20 23:37:26 +08:00
|
|
|
(seg->left_color.r + seg->right_color.r) / 2.0,
|
|
|
|
(seg->left_color.g + seg->right_color.g) / 2.0,
|
|
|
|
(seg->left_color.b + seg->right_color.b) / 2.0,
|
|
|
|
1.0 - (seg->left_color.a + seg->right_color.a) / 2.0);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
|
|
|
/* Right */
|
|
|
|
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
|
|
|
seg->right,
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->right_color.r,
|
|
|
|
seg->right_color.g,
|
|
|
|
seg->right_color.b,
|
|
|
|
1.0 - seg->right_color.a);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1998-11-01 00:22:37 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
fprintf (file, "} /* color_map */\n");
|
|
|
|
fclose (file);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_cancel_save_pov_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static gint
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_delete_save_pov_callback (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_cancel_save_pov_callback (widget, gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** The main dialog action area button callbacks *****/
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_close_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (gradient_editor->shell))
|
|
|
|
gtk_widget_hide (gradient_editor->shell);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** Zoom, scrollbar & instant update callbacks *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_scrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-10 05:31:01 +08:00
|
|
|
gchar *str;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
str = g_strdup_printf (_("Zoom factor: %d:1 Displaying [%0.6f, %0.6f]"),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->zoom_factor, adjustment->value,
|
2000-01-10 05:31:01 +08:00
|
|
|
adjustment->value + adjustment->page_size);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, str);
|
2000-01-10 05:31:01 +08:00
|
|
|
g_free (str);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_zoom_all_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
|
|
|
GtkAdjustment *adjustment;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
adjustment = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->zoom_factor = 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
adjustment->value = 0.0;
|
|
|
|
adjustment->page_size = 1.0;
|
|
|
|
adjustment->step_increment = 1.0 * GRAD_SCROLLBAR_STEP_SIZE;
|
|
|
|
adjustment->page_increment = 1.0 * GRAD_SCROLLBAR_PAGE_SIZE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_adjustment_changed (GTK_ADJUSTMENT (gradient_editor->scroll_data));
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_zoom_out_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
|
|
|
GtkAdjustment *adjustment;
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble old_value;
|
|
|
|
gdouble value;
|
|
|
|
gdouble old_page_size;
|
|
|
|
gdouble page_size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->zoom_factor <= 1)
|
1999-07-24 23:37:03 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
adjustment = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
old_value = adjustment->value;
|
|
|
|
old_page_size = adjustment->page_size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->zoom_factor--;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
page_size = 1.0 / gradient_editor->zoom_factor;
|
1999-07-24 23:37:03 +08:00
|
|
|
value = old_value - (page_size - old_page_size) / 2.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (value < 0.0)
|
|
|
|
value = 0.0;
|
|
|
|
else if ((value + page_size) > 1.0)
|
|
|
|
value = 1.0 - page_size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-30 18:50:36 +08:00
|
|
|
adjustment->value = value;
|
|
|
|
adjustment->page_size = page_size;
|
1999-07-24 23:37:03 +08:00
|
|
|
adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE;
|
|
|
|
adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_adjustment_changed (GTK_ADJUSTMENT (gradient_editor->scroll_data));
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_zoom_in_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkAdjustment *adjustment;
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble old_value;
|
|
|
|
gdouble old_page_size;
|
|
|
|
gdouble page_size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
adjustment = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
old_value = adjustment->value;
|
|
|
|
old_page_size = adjustment->page_size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->zoom_factor++;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
page_size = 1.0 / gradient_editor->zoom_factor;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
adjustment->value = old_value + (old_page_size - page_size) / 2.0;
|
|
|
|
adjustment->page_size = page_size;
|
|
|
|
adjustment->step_increment = page_size * GRAD_SCROLLBAR_STEP_SIZE;
|
|
|
|
adjustment->page_increment = page_size * GRAD_SCROLLBAR_PAGE_SIZE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_adjustment_changed (GTK_ADJUSTMENT (gradient_editor->scroll_data));
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_instant_update_update (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->instant_update = TRUE;
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (gradient_editor->scrollbar),
|
1999-07-24 23:37:03 +08:00
|
|
|
GTK_UPDATE_CONTINUOUS);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->instant_update = FALSE;
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (gradient_editor->scrollbar),
|
1999-07-24 23:37:03 +08:00
|
|
|
GTK_UPDATE_DELAYED);
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/***** Gradient preview functions *****/
|
|
|
|
|
|
|
|
static gint
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gint x, y;
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GdkEventMotion *mevent;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_update (gradient_editor, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GDK_LEAVE_NOTIFY:
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, "");
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GDK_MOTION_NOTIFY:
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_get_pointer (gradient_editor->preview, &x, &y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
mevent = (GdkEventMotion *) event;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (x != gradient_editor->preview_last_x)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->preview_last_x = x;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->preview_button_down)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
|
|
|
if (mevent->state & GDK_CONTROL_MASK)
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_background (gradient_editor, x);
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_foreground (gradient_editor, x);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
else
|
2000-12-20 05:49:46 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_hint (gradient_editor, x);
|
2000-12-20 05:49:46 +08:00
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
break;
|
1999-07-23 04:42:59 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_get_pointer (gradient_editor->preview, &x, &y);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
bevent = (GdkEventButton *) event;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
switch (bevent->button)
|
|
|
|
{
|
|
|
|
case 1:
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->preview_last_x = x;
|
|
|
|
gradient_editor->preview_button_down = TRUE;
|
1999-07-24 23:37:03 +08:00
|
|
|
if (bevent->state & GDK_CONTROL_MASK)
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_background (gradient_editor, x);
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_foreground (gradient_editor, x);
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_do_popup (gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
/* wheelmouse support */
|
|
|
|
case 4:
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GtkAdjustment *adj = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
1999-07-25 00:27:47 +08:00
|
|
|
gfloat new_value = adj->value - adj->page_increment / 2;
|
|
|
|
new_value =
|
|
|
|
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
gtk_adjustment_set_value (adj, new_value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GtkAdjustment *adj = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
1999-07-25 00:27:47 +08:00
|
|
|
gfloat new_value = adj->value + adj->page_increment / 2;
|
|
|
|
new_value =
|
|
|
|
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
gtk_adjustment_set_value (adj, new_value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
1999-07-23 04:42:59 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GDK_BUTTON_RELEASE:
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->preview_button_down)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_get_pointer (gradient_editor->preview, &x, &y);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
bevent = (GdkEventButton *) event;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->preview_last_x = x;
|
|
|
|
gradient_editor->preview_button_down = FALSE;
|
1999-07-24 23:37:03 +08:00
|
|
|
if (bevent->state & GDK_CONTROL_MASK)
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_background (gradient_editor, x);
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_foreground (gradient_editor, x);
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_hint (GradientEditor *gradient_editor,
|
|
|
|
gint x)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble xpos;
|
2001-01-21 00:28:05 +08:00
|
|
|
GimpRGB rgb;
|
|
|
|
GimpHSV hsv;
|
2000-01-10 05:31:01 +08:00
|
|
|
gchar *str;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
xpos = control_calc_g_pos (gradient_editor, x);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_gradient_get_color_at
|
|
|
|
(gimp_context_get_gradient (gradient_editor->context),
|
|
|
|
xpos, &rgb);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 00:28:05 +08:00
|
|
|
gimp_rgb_to_hsv (&rgb, &hsv);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
str = g_strdup_printf (_("Position: %0.6f "
|
|
|
|
"RGB (%0.3f, %0.3f, %0.3f) "
|
|
|
|
"HSV (%0.3f, %0.3f, %0.3f) "
|
|
|
|
"Opacity: %0.3f"),
|
2001-01-21 00:28:05 +08:00
|
|
|
xpos,
|
|
|
|
rgb.r,
|
|
|
|
rgb.g,
|
|
|
|
rgb.b,
|
|
|
|
hsv.h * 360.0,
|
|
|
|
hsv.s,
|
|
|
|
hsv.v,
|
|
|
|
rgb.a);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, str);
|
2000-01-10 05:31:01 +08:00
|
|
|
g_free (str);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_foreground (GradientEditor *gradient_editor,
|
|
|
|
gint x)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
GimpRGB color;
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble xpos;
|
2000-01-10 05:31:01 +08:00
|
|
|
gchar *str;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
xpos = control_calc_g_pos (gradient_editor, x);
|
|
|
|
gimp_gradient_get_color_at
|
|
|
|
(gimp_context_get_gradient (gradient_editor->context),
|
|
|
|
xpos, &color);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_context_set_foreground (gimp_context_get_user (), &color);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
str = g_strdup_printf (_("Foreground color set to RGB (%d, %d, %d) <-> "
|
|
|
|
"(%0.3f, %0.3f, %0.3f)"),
|
2001-01-15 09:48:53 +08:00
|
|
|
(gint) (color.r * 255.0),
|
|
|
|
(gint) (color.g * 255.0),
|
|
|
|
(gint) (color.b * 255.0),
|
|
|
|
color.r, color.g, color.b);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, str);
|
2000-01-10 05:31:01 +08:00
|
|
|
g_free (str);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-23 04:42:59 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_set_background (GradientEditor *gradient_editor,
|
|
|
|
gint x)
|
1999-07-23 04:42:59 +08:00
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
GimpRGB color;
|
|
|
|
gdouble xpos;
|
2000-01-10 05:31:01 +08:00
|
|
|
gchar *str;
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
xpos = control_calc_g_pos (gradient_editor, x);
|
|
|
|
gimp_gradient_get_color_at
|
|
|
|
(gimp_context_get_gradient (gradient_editor->context),
|
|
|
|
xpos, &color);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_context_set_background (gimp_context_get_user (), &color);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
str = g_strdup_printf (_("Background color to RGB (%d, %d, %d) <-> "
|
|
|
|
"(%0.3f, %0.3f, %0.3f)"),
|
2001-01-15 09:48:53 +08:00
|
|
|
(gint) (color.r * 255.0),
|
|
|
|
(gint) (color.g * 255.0),
|
|
|
|
(gint) (color.b * 255.0),
|
|
|
|
color.r, color.g, color.b);
|
1999-07-23 04:42:59 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, str);
|
2000-01-10 05:31:01 +08:00
|
|
|
g_free (str);
|
1999-07-23 04:42:59 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_update (GradientEditor *gradient_editor,
|
|
|
|
gboolean recalculate)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-20 05:49:46 +08:00
|
|
|
glong rowsiz;
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkAdjustment *adjustment;
|
2000-12-21 19:56:58 +08:00
|
|
|
guint16 width;
|
|
|
|
guint16 height;
|
1998-01-31 09:49:25 +08:00
|
|
|
|
2000-12-21 19:56:58 +08:00
|
|
|
static guint16 last_width = 0;
|
|
|
|
static guint16 last_height = 0;
|
1998-01-31 09:49:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! GTK_WIDGET_DRAWABLE (gradient_editor->preview))
|
1999-07-24 23:37:03 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* See whether we have to re-create the preview widget
|
|
|
|
* (note that the preview automatically follows the size of it's container)
|
|
|
|
*/
|
2001-02-18 05:20:10 +08:00
|
|
|
width = gradient_editor->preview->allocation.width;
|
|
|
|
height = gradient_editor->preview->allocation.height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! gradient_editor->preview_rows[0] ||
|
|
|
|
! gradient_editor->preview_rows[1] ||
|
2000-12-20 05:49:46 +08:00
|
|
|
(width != last_width) ||
|
1999-07-24 23:37:03 +08:00
|
|
|
(height != last_height))
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->preview_rows[0])
|
|
|
|
g_free (gradient_editor->preview_rows[0]);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->preview_rows[1])
|
|
|
|
g_free (gradient_editor->preview_rows[1]);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
rowsiz = width * 3 * sizeof (guchar);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->preview_rows[0] = g_malloc (rowsiz);
|
|
|
|
gradient_editor->preview_rows[1] = g_malloc (rowsiz);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
recalculate = TRUE; /* Force recalculation */
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
last_width = width;
|
|
|
|
last_height = height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Have to redraw? */
|
|
|
|
if (recalculate)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
adjustment = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_fill_image (gradient_editor,
|
|
|
|
width, height,
|
2000-12-21 19:56:58 +08:00
|
|
|
adjustment->value,
|
|
|
|
adjustment->value + adjustment->page_size);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_draw (gradient_editor->preview, NULL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
preview_fill_image (GradientEditor *gradient_editor,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gdouble left,
|
|
|
|
gdouble right)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
guchar *p0, *p1;
|
|
|
|
gint x, y;
|
|
|
|
gdouble dx, cur_x;
|
|
|
|
GimpRGB color;
|
|
|
|
gdouble c0, c1;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
dx = (right - left) / (width - 1);
|
|
|
|
cur_x = left;
|
2001-02-18 05:20:10 +08:00
|
|
|
p0 = gradient_editor->preview_rows[0];
|
|
|
|
p1 = gradient_editor->preview_rows[1];
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
/* Create lines to fill the image */
|
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_gradient_get_color_at (gradient, cur_x, &color);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if ((x / GIMP_CHECK_SIZE) & 1)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
c0 = GIMP_CHECK_LIGHT;
|
|
|
|
c1 = GIMP_CHECK_DARK;
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
c0 = GIMP_CHECK_DARK;
|
|
|
|
c1 = GIMP_CHECK_LIGHT;
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 00:28:05 +08:00
|
|
|
*p0++ = (c0 + (color.r - c0) * color.a) * 255.0;
|
|
|
|
*p0++ = (c0 + (color.g - c0) * color.a) * 255.0;
|
|
|
|
*p0++ = (c0 + (color.b - c0) * color.a) * 255.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 00:28:05 +08:00
|
|
|
*p1++ = (c1 + (color.r - c1) * color.a) * 255.0;
|
|
|
|
*p1++ = (c1 + (color.g - c1) * color.a) * 255.0;
|
|
|
|
*p1++ = (c1 + (color.b - c1) * color.a) * 255.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
cur_x += dx;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Fill image */
|
|
|
|
for (y = 0; y < height; y++)
|
2000-12-20 05:49:46 +08:00
|
|
|
{
|
|
|
|
if ((y / GIMP_CHECK_SIZE) & 1)
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (gradient_editor->preview),
|
|
|
|
gradient_editor->preview_rows[1], 0, y, width);
|
2000-12-20 05:49:46 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (gradient_editor->preview),
|
|
|
|
gradient_editor->preview_rows[0], 0, y, width);
|
2000-12-20 05:49:46 +08:00
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/***** Gradient control functions *****/
|
|
|
|
|
|
|
|
/* *** WARNING *** WARNING *** WARNING ***
|
|
|
|
*
|
|
|
|
* All the event-handling code for the gradient control widget is
|
|
|
|
* extremely hairy. You are not expected to understand it. If you
|
|
|
|
* find bugs, mail me unless you are very brave and you want to fix
|
|
|
|
* them yourself ;-)
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gint
|
2001-02-18 05:20:10 +08:00
|
|
|
control_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
GdkEventButton *bevent;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg;
|
2001-02-13 08:12:15 +08:00
|
|
|
gint x, y;
|
|
|
|
guint32 time;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
2001-02-18 05:20:10 +08:00
|
|
|
control_update (gradient_editor, gradient, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GDK_LEAVE_NOTIFY:
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, "");
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_drag_mode == GRAD_DRAG_NONE)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_get_pointer (gradient_editor->control, &x, &y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
bevent = (GdkEventButton *) event;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_last_x = x;
|
|
|
|
gradient_editor->control_click_time = bevent->time;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
control_button_press (gradient_editor,
|
|
|
|
x, y, bevent->button, bevent->state);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_drag_mode != GRAD_DRAG_NONE)
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_grab_add (widget);
|
|
|
|
}
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GDK_BUTTON_RELEASE:
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, "");
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_drag_mode != GRAD_DRAG_NONE)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
|
|
|
gtk_grab_remove (widget);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_get_pointer (gradient_editor->control, &x, &y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
time = ((GdkEventButton *) event)->time;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if ((time - gradient_editor->control_click_time) >= GRAD_MOVE_TIME)
|
2000-12-20 05:49:46 +08:00
|
|
|
{
|
2001-02-19 08:05:03 +08:00
|
|
|
if (! gradient_editor->instant_update)
|
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor,
|
|
|
|
GRAD_UPDATE_GRADIENT); /* Possible move */
|
2000-12-20 05:49:46 +08:00
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
else if ((gradient_editor->control_drag_mode == GRAD_DRAG_MIDDLE) ||
|
|
|
|
(gradient_editor->control_drag_mode == GRAD_DRAG_ALL))
|
2000-12-20 05:49:46 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_drag_segment;
|
2000-12-20 05:49:46 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if ((gradient_editor->control_drag_mode == GRAD_DRAG_ALL) &&
|
|
|
|
gradient_editor->control_compress)
|
|
|
|
control_extend_selection (gradient_editor, seg,
|
|
|
|
control_calc_g_pos (gradient_editor,
|
|
|
|
x));
|
2000-12-20 05:49:46 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
control_select_single_segment (gradient_editor, seg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_CONTROL);
|
2000-12-20 05:49:46 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_drag_mode = GRAD_DRAG_NONE;
|
|
|
|
gradient_editor->control_compress = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
control_do_hint (gradient_editor, x, y);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GDK_MOTION_NOTIFY:
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_get_pointer (gradient_editor->control, &x, &y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (x != gradient_editor->control_last_x)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_last_x = x;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_drag_mode != GRAD_DRAG_NONE)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
|
|
|
time = ((GdkEventButton *) event)->time;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if ((time - gradient_editor->control_click_time) >= GRAD_MOVE_TIME)
|
|
|
|
control_motion (gradient_editor, gradient, x);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_CONTROL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
control_do_hint (gradient_editor, x, y);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_do_hint (GradientEditor *gradient_editor,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
GimpGradientSegment *seg;
|
1999-09-28 01:58:10 +08:00
|
|
|
control_drag_mode_t handle;
|
|
|
|
gboolean in_handle;
|
|
|
|
double pos;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
pos = control_calc_g_pos (gradient_editor, x);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if ((pos < 0.0) || (pos > 1.0))
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
seg_get_closest_handle (gradient, pos, &seg, &handle);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
in_handle = control_point_in_handle (gradient_editor, gradient,
|
|
|
|
x, y, seg, handle);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (in_handle)
|
|
|
|
{
|
|
|
|
switch (handle)
|
|
|
|
{
|
|
|
|
case GRAD_DRAG_LEFT:
|
|
|
|
if (seg != NULL)
|
|
|
|
{
|
|
|
|
if (seg->prev != NULL)
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor,
|
|
|
|
_("Drag: move Shift+drag: move & compress"));
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor,
|
|
|
|
_("Click: select Shift+click: extend selection"));
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
|
|
|
else
|
2000-12-20 05:49:46 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor,
|
|
|
|
_("Click: select Shift+click: extend selection"));
|
2000-12-20 05:49:46 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case GRAD_DRAG_MIDDLE:
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor,
|
|
|
|
_("Click: select Shift+click: extend selection "
|
1999-09-28 01:58:10 +08:00
|
|
|
"Drag: move"));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
default:
|
1999-11-25 19:35:48 +08:00
|
|
|
g_warning ("in_handle is true yet we got handle type %d",
|
|
|
|
(int) handle);
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor,
|
|
|
|
_("Click: select Shift+click: extend selection "
|
1999-09-28 01:58:10 +08:00
|
|
|
"Drag: move Shift+drag: move & compress"));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_button_press (GradientEditor *gradient_editor,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint button,
|
|
|
|
guint state)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
GimpGradientSegment *seg;
|
1999-07-25 00:27:47 +08:00
|
|
|
control_drag_mode_t handle;
|
|
|
|
double xpos;
|
1999-09-28 01:58:10 +08:00
|
|
|
gboolean in_handle;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
switch (button)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
case 3:
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_do_popup (gradient_editor);
|
1999-07-25 00:27:47 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
/* wheelmouse support */
|
|
|
|
case 4:
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GtkAdjustment *adj = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
2000-12-21 19:56:58 +08:00
|
|
|
gfloat new_value = adj->value - adj->page_increment / 2;
|
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
gtk_adjustment_set_value (adj, new_value);
|
|
|
|
}
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
case 5:
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GtkAdjustment *adj = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
2000-12-21 19:56:58 +08:00
|
|
|
gfloat new_value = adj->value + adj->page_increment / 2;
|
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
gtk_adjustment_set_value (adj, new_value);
|
|
|
|
}
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
/* Find the closest handle */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
xpos = control_calc_g_pos (gradient_editor, x);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
seg_get_closest_handle (gradient, xpos, &seg, &handle);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
in_handle = control_point_in_handle (gradient_editor, gradient,
|
|
|
|
x, y, seg, handle);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
/* Now see what we have */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
if (in_handle)
|
|
|
|
{
|
|
|
|
switch (handle)
|
|
|
|
{
|
|
|
|
case GRAD_DRAG_LEFT:
|
|
|
|
if (seg != NULL)
|
|
|
|
{
|
|
|
|
/* Left handle of some segment */
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
if (seg->prev != NULL)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_drag_mode = GRAD_DRAG_LEFT;
|
|
|
|
gradient_editor->control_drag_segment = seg;
|
|
|
|
gradient_editor->control_compress = TRUE;
|
1999-07-25 00:27:47 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
control_extend_selection (gradient_editor, seg, xpos);
|
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_CONTROL);
|
1999-07-25 00:27:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (seg->prev != NULL)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_drag_mode = GRAD_DRAG_LEFT;
|
|
|
|
gradient_editor->control_drag_segment = seg;
|
1999-07-25 00:27:47 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
control_select_single_segment (gradient_editor, seg);
|
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_CONTROL);
|
1999-07-25 00:27:47 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else /* seg == NULL */
|
|
|
|
{
|
|
|
|
/* Right handle of last segment */
|
2001-02-13 08:12:15 +08:00
|
|
|
seg = gimp_gradient_segment_get_last (gradient->segments);
|
1999-07-25 00:27:47 +08:00
|
|
|
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
control_extend_selection (gradient_editor, seg, xpos);
|
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_CONTROL);
|
1999-07-25 00:27:47 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
control_select_single_segment (gradient_editor, seg);
|
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_CONTROL);
|
1999-07-25 00:27:47 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
case GRAD_DRAG_MIDDLE:
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
control_extend_selection (gradient_editor, seg, xpos);
|
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_CONTROL);
|
1999-07-25 00:27:47 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_drag_mode = GRAD_DRAG_MIDDLE;
|
|
|
|
gradient_editor->control_drag_segment = seg;
|
1999-07-25 00:27:47 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
default:
|
1999-11-25 19:35:48 +08:00
|
|
|
g_warning ("in_handle is true yet we got handle type %d",
|
|
|
|
(int) handle);
|
1999-07-25 00:27:47 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* !in_handle */
|
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
seg = gimp_gradient_get_segment_at (gradient, xpos);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_drag_mode = GRAD_DRAG_ALL;
|
|
|
|
gradient_editor->control_drag_segment = seg;
|
|
|
|
gradient_editor->control_last_gx = xpos;
|
|
|
|
gradient_editor->control_orig_pos = xpos;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
if (state & GDK_SHIFT_MASK)
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_compress = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-25 00:27:47 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
static gboolean
|
2001-02-18 05:20:10 +08:00
|
|
|
control_point_in_handle (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient,
|
2001-02-13 08:12:15 +08:00
|
|
|
gint x,
|
1999-09-28 01:58:10 +08:00
|
|
|
gint y,
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradientSegment *seg,
|
1999-09-28 01:58:10 +08:00
|
|
|
control_drag_mode_t handle)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
gint handle_pos;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
switch (handle)
|
|
|
|
{
|
|
|
|
case GRAD_DRAG_LEFT:
|
|
|
|
if (seg)
|
2000-12-20 05:49:46 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
handle_pos = control_calc_p_pos (gradient_editor, seg->left);
|
2000-12-20 05:49:46 +08:00
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
seg = gimp_gradient_segment_get_last (gradient->segments);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
handle_pos = control_calc_p_pos (gradient_editor, seg->right);
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case GRAD_DRAG_MIDDLE:
|
2001-02-18 05:20:10 +08:00
|
|
|
handle_pos = control_calc_p_pos (gradient_editor, seg->middle);
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
default:
|
2000-12-20 05:49:46 +08:00
|
|
|
g_warning ("can not handle drag mode %d", (gint) handle);
|
1999-09-28 01:58:10 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
y /= 2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if ((x >= (handle_pos - y)) && (x <= (handle_pos + y)))
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_select_single_segment (GradientEditor *gradient_editor,
|
|
|
|
GimpGradientSegment *seg)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_l = seg;
|
|
|
|
gradient_editor->control_sel_r = seg;
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_extend_selection (GradientEditor *gradient_editor,
|
|
|
|
GimpGradientSegment *seg,
|
|
|
|
gdouble pos)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
if (fabs (pos - gradient_editor->control_sel_l->left) <
|
|
|
|
fabs (pos - gradient_editor->control_sel_r->right))
|
|
|
|
gradient_editor->control_sel_l = seg;
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_r = seg;
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_motion (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient,
|
|
|
|
gint x)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg;
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble pos;
|
|
|
|
gdouble delta;
|
|
|
|
gchar *str = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_drag_segment;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
switch (gradient_editor->control_drag_mode)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
|
|
|
case GRAD_DRAG_LEFT:
|
2001-02-18 05:20:10 +08:00
|
|
|
pos = control_calc_g_pos (gradient_editor, x);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! gradient_editor->control_compress)
|
2000-01-26 07:06:12 +08:00
|
|
|
seg->prev->right = seg->left = CLAMP (pos,
|
|
|
|
seg->prev->middle + EPSILON,
|
|
|
|
seg->middle - EPSILON);
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
control_compress_left (gradient_editor->control_sel_l,
|
|
|
|
gradient_editor->control_sel_r,
|
1999-09-28 01:58:10 +08:00
|
|
|
seg, pos);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
str = g_strdup_printf (_("Handle position: %0.6f"), seg->left);
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, str);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case GRAD_DRAG_MIDDLE:
|
2001-02-18 05:20:10 +08:00
|
|
|
pos = control_calc_g_pos (gradient_editor, x);
|
2000-01-26 07:06:12 +08:00
|
|
|
seg->middle = CLAMP (pos, seg->left + EPSILON, seg->right - EPSILON);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
str = g_strdup_printf (_("Handle position: %0.6f"), seg->middle);
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_set_hint (gradient_editor, str);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case GRAD_DRAG_ALL:
|
2001-02-18 05:20:10 +08:00
|
|
|
pos = control_calc_g_pos (gradient_editor, x);
|
|
|
|
delta = pos - gradient_editor->control_last_gx;
|
|
|
|
|
|
|
|
if ((seg->left >= gradient_editor->control_sel_l->left) &&
|
|
|
|
(seg->right <= gradient_editor->control_sel_r->right))
|
|
|
|
delta = control_move (gradient_editor,
|
|
|
|
gradient_editor->control_sel_l,
|
|
|
|
gradient_editor->control_sel_r, delta);
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
delta = control_move (gradient_editor, seg, seg, delta);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_last_gx += delta;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
str = g_strdup_printf (_("Distance: %0.6f"),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_last_gx -
|
|
|
|
gradient_editor->control_orig_pos);
|
|
|
|
ed_set_hint (gradient_editor, str);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
default:
|
1999-11-25 19:35:48 +08:00
|
|
|
gimp_fatal_error ("Attempt to move bogus handle %d",
|
2001-02-18 05:20:10 +08:00
|
|
|
(gint) gradient_editor->control_drag_mode);
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
if (str)
|
|
|
|
g_free (str);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->instant_update)
|
2001-02-19 08:05:03 +08:00
|
|
|
{
|
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
|
|
|
|
|
|
|
ed_update_editor (gradient_editor,
|
|
|
|
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
2001-02-19 08:05:03 +08:00
|
|
|
{
|
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_CONTROL);
|
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-11 03:35:29 +08:00
|
|
|
control_compress_left (GimpGradientSegment *range_l,
|
|
|
|
GimpGradientSegment *range_r,
|
|
|
|
GimpGradientSegment *drag_seg,
|
2001-02-18 05:20:10 +08:00
|
|
|
gdouble pos)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg;
|
2001-02-13 08:12:15 +08:00
|
|
|
gdouble lbound, rbound;
|
|
|
|
gint k;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Check what we have to compress */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (!((drag_seg->left >= range_l->left) &&
|
|
|
|
((drag_seg->right <= range_r->right) || (drag_seg == range_r->next))))
|
|
|
|
{
|
|
|
|
/* We are compressing a segment outside the selection */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
range_l = range_r = drag_seg;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Calculate left bound for dragged hadle */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (drag_seg == range_l)
|
|
|
|
lbound = range_l->prev->left + 2.0 * EPSILON;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Count number of segments to the left of the dragged handle */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
seg = drag_seg;
|
|
|
|
k = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
while (seg != range_l)
|
|
|
|
{
|
|
|
|
k++;
|
|
|
|
seg = seg->prev;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* 2*k handles have to fit */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
lbound = range_l->left + 2.0 * k * EPSILON;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Calculate right bound for dragged handle */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (drag_seg == range_r->next)
|
|
|
|
rbound = range_r->next->right - 2.0 * EPSILON;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Count number of segments to the right of the dragged handle */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
seg = drag_seg;
|
|
|
|
k = 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
while (seg != range_r)
|
|
|
|
{
|
|
|
|
k++;
|
|
|
|
seg = seg->next;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* 2*k handles have to fit */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
rbound = range_r->right - 2.0 * k * EPSILON;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Calculate position */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
pos = CLAMP (pos, lbound, rbound);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Compress segments to the left of the handle */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (drag_seg == range_l)
|
|
|
|
control_compress_range (range_l->prev, range_l->prev,
|
|
|
|
range_l->prev->left, pos);
|
|
|
|
else
|
|
|
|
control_compress_range (range_l, drag_seg->prev, range_l->left, pos);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Compress segments to the right of the handle */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (drag_seg != range_r->next)
|
|
|
|
control_compress_range (drag_seg, range_r, pos, range_r->right);
|
|
|
|
else
|
|
|
|
control_compress_range (drag_seg, drag_seg, pos, drag_seg->right);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-11 03:35:29 +08:00
|
|
|
control_compress_range (GimpGradientSegment *range_l,
|
|
|
|
GimpGradientSegment *range_r,
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble new_l,
|
|
|
|
gdouble new_r)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-20 05:49:46 +08:00
|
|
|
gdouble orig_l, orig_r;
|
|
|
|
gdouble scale;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg, *aseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
orig_l = range_l->left;
|
|
|
|
orig_r = range_r->right;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
scale = (new_r - new_l) / (orig_r - orig_l);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
seg = range_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
seg->left = new_l + (seg->left - orig_l) * scale;
|
|
|
|
seg->middle = new_l + (seg->middle - orig_l) * scale;
|
|
|
|
seg->right = new_l + (seg->right - orig_l) * scale;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Next */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
aseg = seg;
|
|
|
|
seg = seg->next;
|
2000-12-20 05:49:46 +08:00
|
|
|
}
|
|
|
|
while (aseg != range_r);
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static gdouble
|
2001-02-18 05:20:10 +08:00
|
|
|
control_move (GradientEditor *gradient_editor,
|
|
|
|
GimpGradientSegment *range_l,
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *range_r,
|
2001-02-18 05:20:10 +08:00
|
|
|
gdouble delta)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gdouble lbound, rbound;
|
|
|
|
gint is_first, is_last;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg, *aseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* First or last segments in gradient? */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
is_first = (range_l->prev == NULL);
|
|
|
|
is_last = (range_r->next == NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Calculate drag bounds */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! gradient_editor->control_compress)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
|
|
|
if (!is_first)
|
|
|
|
lbound = range_l->prev->middle + EPSILON;
|
|
|
|
else
|
|
|
|
lbound = range_l->left + EPSILON;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (!is_last)
|
|
|
|
rbound = range_r->next->middle - EPSILON;
|
|
|
|
else
|
|
|
|
rbound = range_r->right - EPSILON;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!is_first)
|
|
|
|
lbound = range_l->prev->left + 2.0 * EPSILON;
|
|
|
|
else
|
|
|
|
lbound = range_l->left + EPSILON;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (!is_last)
|
|
|
|
rbound = range_r->next->right - 2.0 * EPSILON;
|
|
|
|
else
|
|
|
|
rbound = range_r->right - EPSILON;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Fix the delta if necessary */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (delta < 0.0)
|
|
|
|
{
|
|
|
|
if (!is_first)
|
|
|
|
{
|
|
|
|
if (range_l->left + delta < lbound)
|
|
|
|
delta = lbound - range_l->left;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (range_l->middle + delta < lbound)
|
|
|
|
delta = lbound - range_l->middle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!is_last)
|
|
|
|
{
|
|
|
|
if (range_r->right + delta > rbound)
|
|
|
|
delta = rbound - range_r->right;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (range_r->middle + delta > rbound)
|
|
|
|
delta = rbound - range_r->middle;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Move all the segments inside the range */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
seg = range_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!((seg == range_l) && is_first))
|
|
|
|
seg->left += delta;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
seg->middle += delta;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (!((seg == range_r) && is_last))
|
|
|
|
seg->right += delta;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Next */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
aseg = seg;
|
|
|
|
seg = seg->next;
|
|
|
|
}
|
|
|
|
while (aseg != range_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Fix the segments that surround the range */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (!is_first)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! gradient_editor->control_compress)
|
1999-09-28 01:58:10 +08:00
|
|
|
range_l->prev->right = range_l->left;
|
|
|
|
else
|
|
|
|
control_compress_range (range_l->prev, range_l->prev,
|
|
|
|
range_l->prev->left, range_l->left);
|
|
|
|
}
|
2000-12-20 05:49:46 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (!is_last)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! gradient_editor->control_compress)
|
1999-09-28 01:58:10 +08:00
|
|
|
range_r->next->left = range_r->right;
|
|
|
|
else
|
|
|
|
control_compress_range (range_r->next, range_r->next,
|
|
|
|
range_r->right, range_r->next->right);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
return delta;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_update (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient,
|
|
|
|
gboolean recalculate)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkAdjustment *adjustment;
|
2000-12-20 05:49:46 +08:00
|
|
|
gint cwidth, cheight;
|
|
|
|
gint pwidth, pheight;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! GTK_WIDGET_DRAWABLE (gradient_editor->control))
|
1999-07-24 23:37:03 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* See whether we have to re-create the control pixmap
|
|
|
|
* depending on the preview's width
|
|
|
|
*/
|
2001-02-18 05:20:10 +08:00
|
|
|
cwidth = gradient_editor->preview->allocation.width;
|
1999-07-24 23:37:03 +08:00
|
|
|
cheight = GRAD_CONTROL_HEIGHT;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_pixmap)
|
|
|
|
gdk_window_get_size (gradient_editor->control_pixmap, &pwidth, &pheight);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (! gradient_editor->control_pixmap ||
|
1999-07-24 23:37:03 +08:00
|
|
|
(cwidth != pwidth) ||
|
|
|
|
(cheight != pheight))
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_pixmap)
|
|
|
|
gdk_pixmap_unref (gradient_editor->control_pixmap);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_pixmap =
|
|
|
|
gdk_pixmap_new (gradient_editor->control->window, cwidth, cheight, -1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
recalculate = TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Avaoid segfault on first invocation */
|
|
|
|
if (cwidth < GRAD_PREVIEW_WIDTH)
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Have to reset the selection? */
|
|
|
|
if (recalculate)
|
2001-02-18 05:20:10 +08:00
|
|
|
control_select_single_segment (gradient_editor, gradient->segments);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Redraw pixmap */
|
2001-02-18 05:20:10 +08:00
|
|
|
adjustment = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw (gradient_editor,
|
|
|
|
gradient,
|
|
|
|
gradient_editor->control_pixmap,
|
1999-07-24 23:37:03 +08:00
|
|
|
cwidth, cheight,
|
|
|
|
adjustment->value,
|
|
|
|
adjustment->value + adjustment->page_size);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gdk_draw_pixmap (gradient_editor->control->window,
|
|
|
|
gradient_editor->control->style->black_gc,
|
|
|
|
gradient_editor->control_pixmap,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
cwidth, cheight);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw (GradientEditor *gradient_editor,
|
|
|
|
GimpGradient *gradient,
|
|
|
|
GdkPixmap *pixmap,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gdouble left,
|
|
|
|
gdouble right)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
2000-12-20 05:49:46 +08:00
|
|
|
gint sel_l, sel_r;
|
|
|
|
gdouble g_pos;
|
2001-02-18 05:20:10 +08:00
|
|
|
GimpGradientSegment *seg;
|
1999-09-28 01:58:10 +08:00
|
|
|
control_drag_mode_t handle;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Clear the pixmap */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gdk_draw_rectangle (pixmap, gradient_editor->control->style->bg_gc[GTK_STATE_NORMAL],
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, 0, 0, width, height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Draw selection */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
sel_l = control_calc_p_pos (gradient_editor,
|
|
|
|
gradient_editor->control_sel_l->left);
|
|
|
|
sel_r = control_calc_p_pos (gradient_editor,
|
|
|
|
gradient_editor->control_sel_r->right);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
gdk_draw_rectangle (pixmap,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control->style->dark_gc[GTK_STATE_NORMAL],
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, sel_l, 0, sel_r - sel_l + 1, height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Draw handles */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
seg = gradient->segments;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
while (seg)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw_normal_handle (gradient_editor, pixmap, seg->left, height);
|
|
|
|
control_draw_middle_handle (gradient_editor, pixmap, seg->middle, height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Draw right handle only if this is the last segment */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (seg->next == NULL)
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw_normal_handle (gradient_editor, pixmap, seg->right, height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Next! */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
seg = seg->next;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Draw the handle which is closest to the mouse position */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
g_pos = control_calc_g_pos (gradient_editor, gradient_editor->control_last_x);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
seg_get_closest_handle (gradient, CLAMP (g_pos, 0.0, 1.0), &seg, &handle);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
switch (handle)
|
|
|
|
{
|
|
|
|
case GRAD_DRAG_LEFT:
|
|
|
|
if (seg)
|
2000-12-20 05:49:46 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw_normal_handle (gradient_editor, pixmap,
|
|
|
|
seg->left, height);
|
2000-12-20 05:49:46 +08:00
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
seg = gimp_gradient_segment_get_last (gradient->segments);
|
2000-12-20 05:49:46 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw_normal_handle (gradient_editor, pixmap,
|
|
|
|
seg->right, height);
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case GRAD_DRAG_MIDDLE:
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw_middle_handle (gradient_editor, pixmap, seg->middle, height);
|
1999-09-28 01:58:10 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw_normal_handle (GradientEditor *gradient_editor,
|
|
|
|
GdkPixmap *pixmap,
|
|
|
|
gdouble pos,
|
|
|
|
gint height)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
|
|
|
control_draw_handle (pixmap,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control->style->black_gc,
|
|
|
|
gradient_editor->control->style->black_gc,
|
|
|
|
control_calc_p_pos (gradient_editor, pos), height);
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
control_draw_middle_handle (GradientEditor *gradient_editor,
|
|
|
|
GdkPixmap *pixmap,
|
|
|
|
gdouble pos,
|
|
|
|
gint height)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
|
|
|
control_draw_handle (pixmap,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control->style->black_gc,
|
|
|
|
gradient_editor->control->style->bg_gc[GTK_STATE_PRELIGHT],
|
|
|
|
control_calc_p_pos (gradient_editor, pos), height);
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
1999-09-28 01:58:10 +08:00
|
|
|
control_draw_handle (GdkPixmap *pixmap,
|
|
|
|
GdkGC *border_gc,
|
|
|
|
GdkGC *fill_gc,
|
2000-12-20 05:49:46 +08:00
|
|
|
gint xpos,
|
|
|
|
gint height)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-20 05:49:46 +08:00
|
|
|
gint y;
|
|
|
|
gint left, right, bottom;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
for (y = 0; y < height; y++)
|
|
|
|
gdk_draw_line (pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
bottom = height - 1;
|
|
|
|
left = xpos - bottom / 2;
|
|
|
|
right = xpos + bottom / 2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
gdk_draw_line (pixmap, border_gc, xpos, 0, left, bottom);
|
|
|
|
gdk_draw_line (pixmap, border_gc, xpos, 0, right, bottom);
|
|
|
|
gdk_draw_line (pixmap, border_gc, left, bottom, right, bottom);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static gint
|
2001-02-18 05:20:10 +08:00
|
|
|
control_calc_p_pos (GradientEditor *gradient_editor,
|
|
|
|
gdouble pos)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
gint pwidth, pheight;
|
|
|
|
GtkAdjustment *adjustment;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Calculate the position (in widget's coordinates) of the
|
|
|
|
* requested point from the gradient. Rounding is done to
|
|
|
|
* minimize mismatches between the rendered gradient preview
|
|
|
|
* and the gradient control's handles.
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
adjustment = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
|
|
|
gdk_window_get_size (gradient_editor->control_pixmap, &pwidth, &pheight);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
return RINT ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size);
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-20 05:49:46 +08:00
|
|
|
static gdouble
|
2001-02-18 05:20:10 +08:00
|
|
|
control_calc_g_pos (GradientEditor *gradient_editor,
|
|
|
|
gint pos)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-20 05:49:46 +08:00
|
|
|
gint pwidth, pheight;
|
1999-09-28 01:58:10 +08:00
|
|
|
GtkAdjustment *adjustment;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Calculate the gradient position that corresponds to widget's coordinates */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
adjustment = GTK_ADJUSTMENT (gradient_editor->scroll_data);
|
|
|
|
gdk_window_get_size (gradient_editor->control_pixmap, &pwidth, &pheight);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
return adjustment->page_size * pos / (pwidth - 1) + adjustment->value;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/***** Control popup functions *****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_create_main_menu (GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkAccelGroup *accel_group;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menu = gtk_menu_new ();
|
|
|
|
accel_group = gtk_accel_group_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->accel_group = accel_group;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (gradient_editor->shell), accel_group);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Left endpoint */
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_color_item (&gradient_editor->left_color_preview,
|
|
|
|
&label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (label), _("Left endpoint's color"));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
|
|
|
(GtkSignalFunc) cpopup_set_left_color_callback,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'L', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Load from"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_left_load_popup =
|
|
|
|
cpopup_create_load_menu (gradient_editor,
|
|
|
|
gradient_editor->left_load_color_boxes,
|
|
|
|
gradient_editor->left_load_labels,
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Left neighbor's right endpoint"),
|
|
|
|
_("Right endpoint"),
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_load_left_callback),
|
1999-07-24 23:37:03 +08:00
|
|
|
'L', GDK_CONTROL_MASK,
|
|
|
|
'L', GDK_MOD1_MASK,
|
|
|
|
'F', GDK_CONTROL_MASK);
|
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_left_load_popup);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Save to"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_left_save_popup =
|
|
|
|
cpopup_create_save_menu (gradient_editor,
|
|
|
|
gradient_editor->left_save_color_boxes,
|
|
|
|
gradient_editor->left_save_labels,
|
|
|
|
GTK_SIGNAL_FUNC (cpopup_save_left_callback));
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM(menuitem),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_left_save_popup);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
/* Right endpoint */
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_color_item (&gradient_editor->right_color_preview,
|
|
|
|
&label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (label), _("Right endpoint's color"));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
|
|
|
(GtkSignalFunc) cpopup_set_right_color_callback,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'R', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Load from"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_right_load_popup =
|
|
|
|
cpopup_create_load_menu (gradient_editor,
|
|
|
|
gradient_editor->right_load_color_boxes,
|
|
|
|
gradient_editor->right_load_labels,
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Right neighbor's left endpoint"),
|
|
|
|
_("Left endpoint"),
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_load_right_callback),
|
1999-07-24 23:37:03 +08:00
|
|
|
'R', GDK_CONTROL_MASK,
|
|
|
|
'R', GDK_MOD1_MASK,
|
|
|
|
'F', GDK_MOD1_MASK);
|
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM(menuitem),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_right_load_popup);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Save to"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_right_save_popup =
|
|
|
|
cpopup_create_save_menu (gradient_editor,
|
|
|
|
gradient_editor->right_save_color_boxes,
|
|
|
|
gradient_editor->right_save_labels,
|
|
|
|
GTK_SIGNAL_FUNC (cpopup_save_right_callback));
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM(menuitem),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_right_save_popup);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
/* Blending function */
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_menu_item_with_label ("", &gradient_editor->control_blending_label);
|
|
|
|
gradient_editor->control_blending_popup =
|
|
|
|
cpopup_create_blending_menu (gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM(menuitem),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_blending_popup);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU(menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
/* Coloring type */
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_menu_item_with_label ("", &gradient_editor->control_coloring_label);
|
|
|
|
gradient_editor->control_coloring_popup =
|
|
|
|
cpopup_create_coloring_menu (gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM(menuitem),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_coloring_popup);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
/* Operations */
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
/* Split at midpoint */
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_menu_item_with_label ("", &gradient_editor->control_split_m_label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_split_midpoint_callback),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator(menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'S', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
/* Split uniformly */
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_menu_item_with_label ("", &gradient_editor->control_split_u_label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT(menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_split_uniform_callback),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'U', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
/* Delete */
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_menu_item_with_label ("", &gradient_editor->control_delete_label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_delete_callback),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_delete_menu_item = menuitem;
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'D', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
/* Recenter */
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_menu_item_with_label ("", &gradient_editor->control_recenter_label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_recenter_callback),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'C', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
/* Redistribute */
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = cpopup_create_menu_item_with_label ("", &gradient_editor->control_redistribute_label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_redistribute_callback),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'C', GDK_CONTROL_MASK,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
/* Selection ops */
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Selection operations"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_ops_popup =
|
|
|
|
cpopup_create_sel_ops_menu (gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_ops_popup);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
/* Done */
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_main_popup = menu;
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_do_popup (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_adjust_menus (gradient_editor);
|
|
|
|
|
|
|
|
gtk_menu_popup (GTK_MENU (gradient_editor->control_main_popup),
|
1999-07-24 23:37:03 +08:00
|
|
|
NULL, NULL, NULL, NULL, 3, 0);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** Create a single menu item *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static GtkWidget *
|
1999-07-24 23:37:03 +08:00
|
|
|
cpopup_create_color_item (GtkWidget **color_box,
|
|
|
|
GtkWidget **label)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *menuitem;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *wcolor_box;
|
|
|
|
GtkWidget *wlabel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menuitem = gtk_menu_item_new();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (menuitem), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
wcolor_box = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_set_dither (GTK_PREVIEW (wcolor_box), GDK_RGB_DITHER_MAX);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (wcolor_box),
|
|
|
|
GRAD_COLOR_BOX_WIDTH, GRAD_COLOR_BOX_HEIGHT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), wcolor_box, FALSE, FALSE, 2);
|
|
|
|
gtk_widget_show (wcolor_box);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (color_box)
|
|
|
|
*color_box = wcolor_box;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
wlabel = gtk_label_new ("");
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (wlabel), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), wlabel, FALSE, FALSE, 4);
|
|
|
|
gtk_widget_show (wlabel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (label)
|
|
|
|
*label = wlabel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return menuitem;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static GtkWidget *
|
|
|
|
cpopup_create_menu_item_with_label (gchar *str,
|
|
|
|
GtkWidget **label)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *menuitem;
|
|
|
|
GtkWidget *accel_label;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menuitem = gtk_menu_item_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
accel_label = gtk_accel_label_new (str);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
|
|
|
|
gtk_container_add (GTK_CONTAINER (menuitem), accel_label);
|
|
|
|
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menuitem);
|
|
|
|
gtk_widget_show (accel_label);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (label)
|
|
|
|
*label = accel_label;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return menuitem;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** Update all menus *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_adjust_menus (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg;
|
2001-02-13 08:12:15 +08:00
|
|
|
gint i;
|
|
|
|
GimpRGB fg;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Render main menu color boxes */
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->left_color_preview),
|
|
|
|
&gradient_editor->control_sel_l->left_color);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->right_color_preview),
|
|
|
|
&gradient_editor->control_sel_r->right_color);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Render load color from endpoint color boxes */
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_sel_l->prev != NULL)
|
|
|
|
seg = gradient_editor->control_sel_l->prev;
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gimp_gradient_segment_get_last (gradient_editor->control_sel_l);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->left_load_color_boxes[0]),
|
2001-01-20 23:37:26 +08:00
|
|
|
&seg->right_color);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->left_load_color_boxes[1]),
|
|
|
|
&gradient_editor->control_sel_r->right_color);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_sel_r->next != NULL)
|
|
|
|
seg = gradient_editor->control_sel_r->next;
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
2001-02-13 08:12:15 +08:00
|
|
|
seg = gradient->segments;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->right_load_color_boxes[0]),
|
2001-01-20 23:37:26 +08:00
|
|
|
&seg->left_color);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->right_load_color_boxes[1]),
|
|
|
|
&gradient_editor->control_sel_l->left_color);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Render Foreground color boxes */
|
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
gimp_context_get_foreground (gimp_context_get_user (), &fg);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->left_load_color_boxes[2]),
|
2001-01-20 23:37:26 +08:00
|
|
|
&fg);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->right_load_color_boxes[2]),
|
2001-01-20 23:37:26 +08:00
|
|
|
&fg);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Render saved color boxes */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (i = 0; i < GRAD_NUM_COLORS; i++)
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_update_saved_color (gradient_editor,
|
|
|
|
i, &gradient_editor->saved_colors[i]);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Adjust labels */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_sel_l == gradient_editor->control_sel_r)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_blending_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Blending function for segment"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_coloring_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Coloring type for segment"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_split_m_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Split segment at midpoint"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_split_u_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Split segment uniformly"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_delete_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Delete segment"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_recenter_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Re-center segment's midpoint"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_redistribute_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Re-distribute handles in segment"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_flip_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Flip segment"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_replicate_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Replicate segment"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_blending_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Blending function for selection"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_coloring_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Coloring type for selection"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_split_m_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Split segments at midpoints"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_split_u_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Split segments uniformly"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_delete_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Delete selection"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_recenter_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Re-center midpoints in selection"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_redistribute_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Re-distribute handles in selection"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_flip_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Flip selection"));
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->control_replicate_label),
|
1999-07-24 23:37:03 +08:00
|
|
|
_("Replicate selection"));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Adjust blending and coloring menus */
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_adjust_blending_menu (gradient_editor);
|
|
|
|
cpopup_adjust_coloring_menu (gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Can invoke delete? */
|
2001-02-18 05:20:10 +08:00
|
|
|
if ((gradient_editor->control_sel_l->prev == NULL) &&
|
|
|
|
(gradient_editor->control_sel_r->next == NULL))
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->control_delete_menu_item, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->control_delete_menu_item, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Can invoke blend colors / opacity? */
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_sel_l == gradient_editor->control_sel_r)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->control_blend_colors_menu_item,
|
|
|
|
FALSE);
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->control_blend_opacity_menu_item,
|
|
|
|
FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->control_blend_colors_menu_item,
|
|
|
|
TRUE);
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->control_blend_opacity_menu_item,
|
|
|
|
TRUE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_adjust_blending_menu (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gint equal;
|
|
|
|
glong i, num_items;
|
|
|
|
gint type;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_check_selection_params (gradient_editor, &equal, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Block activate signals */
|
2001-02-18 05:20:10 +08:00
|
|
|
num_items = (sizeof (gradient_editor->control_blending_items) /
|
|
|
|
sizeof (gradient_editor->control_blending_items[0]));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
type = (int) gradient_editor->control_sel_l->type;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (i = 0; i < num_items; i++)
|
|
|
|
gtk_signal_handler_block_by_data
|
2001-02-19 03:44:28 +08:00
|
|
|
(GTK_OBJECT (gradient_editor->control_blending_items[i]),
|
|
|
|
gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Set state */
|
|
|
|
if (equal)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gradient_editor->control_blending_items[type]), TRUE);
|
|
|
|
gtk_widget_hide (gradient_editor->control_blending_items[num_items - 1]);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_show (gradient_editor->control_blending_items[num_items - 1]);
|
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gradient_editor->control_blending_items[num_items - 1]), TRUE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Unblock signals */
|
|
|
|
for (i = 0; i < num_items; i++)
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_blending_items[i]),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_adjust_coloring_menu (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gint equal;
|
|
|
|
glong i, num_items;
|
|
|
|
gint coloring;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_check_selection_params (gradient_editor, NULL, &equal);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Block activate signals */
|
2001-02-18 05:20:10 +08:00
|
|
|
num_items = (sizeof (gradient_editor->control_coloring_items) /
|
|
|
|
sizeof (gradient_editor->control_coloring_items[0]));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
coloring = (int) gradient_editor->control_sel_l->color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (i = 0; i < num_items; i++)
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]),
|
|
|
|
gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Set state */
|
|
|
|
if (equal)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gradient_editor->control_coloring_items[coloring]), TRUE);
|
|
|
|
gtk_widget_hide (gradient_editor->control_coloring_items[num_items - 1]);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_show (gradient_editor->control_coloring_items[num_items - 1]);
|
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gradient_editor->control_coloring_items[num_items - 1]), TRUE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Unblock signals */
|
|
|
|
for (i = 0; i < num_items; i++)
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gradient_editor->control_coloring_items[i]),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_check_selection_params (GradientEditor *gradient_editor,
|
|
|
|
gint *equal_blending,
|
|
|
|
gint *equal_coloring)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GimpGradientSegmentType type;
|
|
|
|
GimpGradientSegmentColor color;
|
|
|
|
gint etype, ecolor;
|
|
|
|
GimpGradientSegment *seg, *aseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
type = gradient_editor->control_sel_l->type;
|
|
|
|
color = gradient_editor->control_sel_l->color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
etype = 1;
|
|
|
|
ecolor = 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
etype = etype && (seg->type == type);
|
|
|
|
ecolor = ecolor && (seg->color == color);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
aseg = seg;
|
|
|
|
seg = seg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (aseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (equal_blending)
|
|
|
|
*equal_blending = etype;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (equal_coloring)
|
|
|
|
*equal_coloring = ecolor;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
1999-09-28 01:58:10 +08:00
|
|
|
cpopup_render_color_box (GtkPreview *preview,
|
2001-01-20 23:37:26 +08:00
|
|
|
GimpRGB *color)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3];
|
2001-01-20 23:37:26 +08:00
|
|
|
gint x, y;
|
|
|
|
gint r0, g0, b0;
|
|
|
|
gint r1, g1, b1;
|
1999-09-28 01:58:10 +08:00
|
|
|
guchar *p0, *p1, *p2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Fill rows */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
r0 = (GIMP_CHECK_DARK + (color->r - GIMP_CHECK_DARK) * color->a) * 255.0;
|
|
|
|
r1 = (GIMP_CHECK_LIGHT + (color->r - GIMP_CHECK_LIGHT) * color->a) * 255.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
g0 = (GIMP_CHECK_DARK + (color->g - GIMP_CHECK_DARK) * color->a) * 255.0;
|
|
|
|
g1 = (GIMP_CHECK_LIGHT + (color->g - GIMP_CHECK_LIGHT) * color->a) * 255.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
b0 = (GIMP_CHECK_DARK + (color->b - GIMP_CHECK_DARK) * color->a) * 255.0;
|
|
|
|
b1 = (GIMP_CHECK_LIGHT + (color->b - GIMP_CHECK_LIGHT) * color->a) * 255.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
p0 = rows[0];
|
|
|
|
p1 = rows[1];
|
|
|
|
p2 = rows[2];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++)
|
|
|
|
{
|
|
|
|
if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1)))
|
|
|
|
{
|
|
|
|
*p0++ = 0;
|
|
|
|
*p0++ = 0;
|
|
|
|
*p0++ = 0;
|
|
|
|
|
|
|
|
*p1++ = 0;
|
|
|
|
*p1++ = 0;
|
|
|
|
*p1++ = 0;
|
|
|
|
}
|
|
|
|
else
|
1999-10-28 23:05:49 +08:00
|
|
|
if ((x / GIMP_CHECK_SIZE) & 1)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
|
|
|
*p0++ = r1;
|
|
|
|
*p0++ = g1;
|
|
|
|
*p0++ = b1;
|
|
|
|
|
|
|
|
*p1++ = r0;
|
|
|
|
*p1++ = g0;
|
|
|
|
*p1++ = b0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*p0++ = r0;
|
|
|
|
*p0++ = g0;
|
|
|
|
*p0++ = b0;
|
|
|
|
|
|
|
|
*p1++ = r1;
|
|
|
|
*p1++ = g1;
|
|
|
|
*p1++ = b1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p2++ = 0;
|
|
|
|
*p2++ = 0;
|
|
|
|
*p2++ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill preview */
|
|
|
|
|
|
|
|
gtk_preview_draw_row (preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH);
|
|
|
|
|
|
|
|
for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++)
|
1999-10-28 23:05:49 +08:00
|
|
|
if ((y / GIMP_CHECK_SIZE) & 1)
|
1999-09-28 01:58:10 +08:00
|
|
|
gtk_preview_draw_row (preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH);
|
|
|
|
else
|
|
|
|
gtk_preview_draw_row (preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH);
|
|
|
|
|
|
|
|
gtk_preview_draw_row (preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** Creale load & save menus *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static GtkWidget *
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_create_load_menu (GradientEditor *gradient_editor,
|
|
|
|
GtkWidget **color_boxes,
|
|
|
|
GtkWidget **labels,
|
|
|
|
gchar *label1,
|
|
|
|
gchar *label2,
|
|
|
|
GtkSignalFunc callback,
|
1999-07-24 23:37:03 +08:00
|
|
|
gchar accel_key_0, guint8 accel_mods_0,
|
|
|
|
gchar accel_key_1, guint8 accel_mods_1,
|
|
|
|
gchar accel_key_2, guint8 accel_mods_2)
|
|
|
|
{
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
|
|
|
GtkAccelGroup *accel_group;
|
2001-02-18 05:20:10 +08:00
|
|
|
gint i;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
menu = gtk_menu_new ();
|
2001-02-18 05:20:10 +08:00
|
|
|
accel_group = gradient_editor->accel_group;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Create items */
|
|
|
|
for (i = 0; i < (GRAD_NUM_COLORS + 3); i++)
|
|
|
|
{
|
|
|
|
if (i == 3)
|
|
|
|
{
|
|
|
|
/* Insert separator between "to fetch" and "saved" colors */
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menuitem = cpopup_create_color_item (&color_boxes[i], &labels[i]);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menuitem),
|
|
|
|
GINT_TO_POINTER (i));
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
callback,
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
accel_key_0, accel_mods_0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
break;
|
1998-06-07 21:55:36 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case 1:
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
accel_key_1, accel_mods_1,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
break;
|
1998-06-07 21:55:36 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case 2:
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
accel_key_2, accel_mods_2,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
break;
|
1998-06-07 21:55:36 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Set labels */
|
|
|
|
gtk_label_set_text (GTK_LABEL (labels[0]), label1);
|
|
|
|
gtk_label_set_text (GTK_LABEL (labels[1]), label2);
|
|
|
|
gtk_label_set_text (GTK_LABEL (labels[2]), _("FG color"));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return menu;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static GtkWidget *
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_create_save_menu (GradientEditor *gradient_editor,
|
|
|
|
GtkWidget **color_boxes,
|
|
|
|
GtkWidget **labels,
|
|
|
|
GtkSignalFunc callback)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
2001-01-20 23:37:26 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menu = gtk_menu_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (i = 0; i < GRAD_NUM_COLORS; i++)
|
|
|
|
{
|
|
|
|
menuitem = cpopup_create_color_item (&color_boxes[i], &labels[i]);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menuitem),
|
|
|
|
GINT_TO_POINTER (i));
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
callback,
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return menu;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_update_saved_color (GradientEditor *gradient_editor,
|
|
|
|
gint n,
|
|
|
|
GimpRGB *color)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
2000-01-10 05:31:01 +08:00
|
|
|
gchar *str;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->left_load_color_boxes[n + 3]),
|
2001-01-20 23:37:26 +08:00
|
|
|
color);
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->left_save_color_boxes[n]),
|
2001-01-20 23:37:26 +08:00
|
|
|
color);
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->right_load_color_boxes[n + 3]),
|
2001-01-20 23:37:26 +08:00
|
|
|
color);
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_render_color_box (GTK_PREVIEW (gradient_editor->right_save_color_boxes[n]),
|
2001-01-20 23:37:26 +08:00
|
|
|
color);
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
str = g_strdup_printf (_("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"),
|
|
|
|
color->r,
|
|
|
|
color->g,
|
|
|
|
color->b,
|
|
|
|
color->a);
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->left_load_labels[n + 3]), str);
|
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->left_save_labels[n]), str);
|
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->right_load_labels[n + 3]), str);
|
|
|
|
gtk_label_set_text (GTK_LABEL (gradient_editor->right_save_labels[n]), str);
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2000-01-10 05:31:01 +08:00
|
|
|
g_free (str);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->saved_colors[n] = *color;
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_load_left_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg;
|
2001-02-18 05:20:10 +08:00
|
|
|
GimpRGB fg;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
i = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
|
|
|
|
|
|
|
|
switch (i)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
|
|
|
case 0: /* Fetch from left neighbor's right endpoint */
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_sel_l->prev != NULL)
|
|
|
|
seg = gradient_editor->control_sel_l->prev;
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gimp_gradient_segment_get_last (gradient_editor->control_sel_l);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&seg->right_color,
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, TRUE);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case 1: /* Fetch from right endpoint */
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, TRUE);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case 2: /* Fetch from FG color */
|
2001-01-20 23:37:26 +08:00
|
|
|
gimp_context_get_foreground (gimp_context_get_user (), &fg);
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&fg,
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, TRUE);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
default: /* Load a color */
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->saved_colors[i - 3],
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, TRUE);
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gimp_context_get_gradient (gradient_editor->context)));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_save_left_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
i = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[i] = gradient_editor->control_sel_l->left_color;
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_load_right_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg;
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpRGB fg;
|
2001-02-18 05:20:10 +08:00
|
|
|
gint i;
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
i = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
|
|
|
|
|
|
|
switch (i)
|
1999-09-28 01:58:10 +08:00
|
|
|
{
|
|
|
|
case 0: /* Fetch from right neighbor's left endpoint */
|
2001-02-18 05:20:10 +08:00
|
|
|
if (gradient_editor->control_sel_r->next != NULL)
|
|
|
|
seg = gradient_editor->control_sel_r->next;
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
2001-02-13 08:12:15 +08:00
|
|
|
seg = gradient->segments;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_r->left_color,
|
2001-01-20 23:37:26 +08:00
|
|
|
&seg->left_color,
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, TRUE);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case 1: /* Fetch from left endpoint */
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_l->left_color,
|
|
|
|
&gradient_editor->control_sel_l->left_color,
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, TRUE);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
case 2: /* Fetch from FG color */
|
2001-01-20 23:37:26 +08:00
|
|
|
gimp_context_get_foreground (gimp_context_get_user (), &fg);
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_l->left_color,
|
2001-01-20 23:37:26 +08:00
|
|
|
&fg,
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, TRUE);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
default: /* Load a color */
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_l->left_color,
|
|
|
|
&gradient_editor->saved_colors[i - 3],
|
1999-09-28 01:58:10 +08:00
|
|
|
TRUE, TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_save_right_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
i = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
|
|
|
|
|
|
|
|
gradient_editor->saved_colors[i] = gradient_editor->control_sel_r->right_color;
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
static GimpGradientSegment *
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_save_selection (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg, *prev, *tmp;
|
|
|
|
GimpGradientSegment *oseg, *oaseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
prev = NULL;
|
2001-02-18 05:20:10 +08:00
|
|
|
oseg = gradient_editor->control_sel_l;
|
1999-09-28 01:58:10 +08:00
|
|
|
tmp = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
do
|
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
seg = gimp_gradient_segment_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
*seg = *oseg; /* Copy everything */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (prev == NULL)
|
|
|
|
tmp = seg; /* Remember first segment */
|
|
|
|
else
|
|
|
|
prev->next = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
seg->prev = prev;
|
|
|
|
seg->next = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
prev = seg;
|
|
|
|
oaseg = oseg;
|
|
|
|
oseg = oseg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (oaseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
return tmp;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_replace_selection (GradientEditor *gradient_editor,
|
|
|
|
GimpGradientSegment *replace_seg)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *lseg, *rseg;
|
|
|
|
GimpGradientSegment *replace_last;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Remember left and right segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
lseg = gradient_editor->control_sel_l->prev;
|
|
|
|
rseg = gradient_editor->control_sel_r->next;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
replace_last = gimp_gradient_segment_get_last (replace_seg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Free old selection */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_r->next = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_gradient_segments_free (gradient_editor->control_sel_l);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Link in new segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (lseg)
|
|
|
|
lseg->next = replace_seg;
|
|
|
|
else
|
2001-02-13 08:12:15 +08:00
|
|
|
gradient->segments = replace_seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
replace_seg->prev = lseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (rseg)
|
|
|
|
rseg->prev = replace_last;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
replace_last->next = rseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_l = replace_seg;
|
|
|
|
gradient_editor->control_sel_r = replace_last;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gradient->last_visited = NULL; /* Force re-search */
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** Color dialogs for left and right endpoint *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_set_left_color_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->left_saved_dirty = GIMP_DATA (gradient)->dirty;
|
|
|
|
gradient_editor->left_saved_segments = cpopup_save_selection (gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
color_notebook_new (_("Left Endpoint Color"),
|
2001-02-18 05:20:10 +08:00
|
|
|
&gradient_editor->control_sel_l->left_color,
|
2001-01-21 21:41:07 +08:00
|
|
|
(GtkSignalFunc) cpopup_left_color_changed,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor,
|
|
|
|
gradient_editor->instant_update,
|
2001-01-21 21:41:07 +08:00
|
|
|
TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_set_right_color_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->right_saved_dirty = GIMP_DATA (gradient)->dirty;
|
|
|
|
gradient_editor->right_saved_segments = cpopup_save_selection (gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
color_notebook_new (_("Right Endpoint Color"),
|
2001-02-18 05:20:10 +08:00
|
|
|
&gradient_editor->control_sel_l->right_color,
|
2001-01-21 21:41:07 +08:00
|
|
|
(GtkSignalFunc) cpopup_right_color_changed,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor,
|
|
|
|
gradient_editor->instant_update,
|
2001-01-21 21:41:07 +08:00
|
|
|
TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-01-21 21:41:07 +08:00
|
|
|
cpopup_left_color_changed (ColorNotebook *cnb,
|
|
|
|
const GimpRGB *color,
|
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor;
|
|
|
|
GimpGradient *gradient;
|
|
|
|
|
|
|
|
gradient_editor = (GradientEditor *) data;
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case COLOR_NOTEBOOK_OK:
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
(GimpRGB *) color,
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
2001-01-21 21:41:07 +08:00
|
|
|
TRUE, TRUE);
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_gradient_segments_free (gradient_editor->left_saved_segments);
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-01-21 21:41:07 +08:00
|
|
|
color_notebook_free (cnb);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
2001-01-21 21:41:07 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
case COLOR_NOTEBOOK_UPDATE:
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
(GimpRGB *) color,
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
2001-01-21 21:41:07 +08:00
|
|
|
TRUE, TRUE);
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-01-21 21:41:07 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
case COLOR_NOTEBOOK_CANCEL:
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_replace_selection (gradient_editor,
|
|
|
|
gradient_editor->left_saved_segments);
|
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
|
|
|
GIMP_DATA (gradient)->dirty = gradient_editor->left_saved_dirty;
|
2001-01-21 21:41:07 +08:00
|
|
|
color_notebook_free (cnb);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
2001-01-21 21:41:07 +08:00
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-01-21 21:41:07 +08:00
|
|
|
cpopup_right_color_changed (ColorNotebook *cnb,
|
|
|
|
const GimpRGB *color,
|
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GradientEditor *gradient_editor;
|
|
|
|
GimpGradient *gradient;
|
|
|
|
|
|
|
|
gradient_editor = (GradientEditor *) data;
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case COLOR_NOTEBOOK_UPDATE:
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_r->left_color,
|
2001-01-21 21:41:07 +08:00
|
|
|
(GimpRGB *) color,
|
|
|
|
TRUE, TRUE);
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-01-21 21:41:07 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
case COLOR_NOTEBOOK_OK:
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_r->left_color,
|
2001-01-21 21:41:07 +08:00
|
|
|
(GimpRGB *) color,
|
|
|
|
TRUE, TRUE);
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_gradient_segments_free (gradient_editor->right_saved_segments);
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-01-21 21:41:07 +08:00
|
|
|
color_notebook_free (cnb);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
2001-01-21 21:41:07 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
case COLOR_NOTEBOOK_CANCEL:
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_replace_selection (gradient_editor,
|
|
|
|
gradient_editor->right_saved_segments);
|
|
|
|
GIMP_DATA (gradient)->dirty = gradient_editor->right_saved_dirty;
|
2001-01-21 21:41:07 +08:00
|
|
|
color_notebook_free (cnb);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
2001-01-21 21:41:07 +08:00
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** Blending menu *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static GtkWidget *
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_create_blending_menu (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
|
|
|
GSList *group;
|
|
|
|
gint i;
|
|
|
|
gint num_items;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
static const gchar *blending_types[] =
|
|
|
|
{
|
|
|
|
N_("Linear"),
|
|
|
|
N_("Curved"),
|
|
|
|
N_("Sinusoidal"),
|
|
|
|
N_("Spherical (increasing)"),
|
|
|
|
N_("Spherical (decreasing)")
|
|
|
|
};
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menu = gtk_menu_new ();
|
|
|
|
group = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
num_items = (sizeof (gradient_editor->control_blending_items) /
|
|
|
|
sizeof (gradient_editor->control_blending_items[0]));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (i = 0; i < num_items; i++)
|
|
|
|
{
|
|
|
|
if (i == (num_items - 1))
|
2001-02-18 05:20:10 +08:00
|
|
|
menuitem = gtk_radio_menu_item_new_with_label (group, _("(Varies)"));
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
|
|
|
menuitem =
|
|
|
|
gtk_radio_menu_item_new_with_label (group,
|
|
|
|
gettext (blending_types[i]));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menuitem),
|
|
|
|
GINT_TO_POINTER (i));
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_blending_callback),
|
|
|
|
gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_blending_items[i] = menuitem;
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* "Varies" is always disabled */
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->control_blending_items[num_items - 1], FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return menu;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blending_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
GimpGradientSegmentType type;
|
|
|
|
GimpGradientSegment *seg, *aseg;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!GTK_CHECK_MENU_ITEM (widget)->active)
|
|
|
|
return; /* Do nothing if the menu item is being deactivated */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
type = (GimpGradientSegmentType)
|
|
|
|
GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
|
|
|
|
|
|
|
|
seg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
seg->type = type;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
aseg = seg;
|
|
|
|
seg = seg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (aseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** Coloring menu *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static GtkWidget *
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_create_coloring_menu (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
|
|
|
GSList *group;
|
2001-02-13 08:12:15 +08:00
|
|
|
gint i;
|
|
|
|
gint num_items;
|
|
|
|
|
|
|
|
static const gchar *coloring_types[] =
|
|
|
|
{
|
|
|
|
N_("Plain RGB"),
|
|
|
|
N_("HSV (counter-clockwise hue)"),
|
|
|
|
N_("HSV (clockwise hue)")
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menu = gtk_menu_new ();
|
|
|
|
group = NULL;
|
1998-04-15 04:45:53 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
num_items = (sizeof (gradient_editor->control_coloring_items) /
|
|
|
|
sizeof (gradient_editor->control_coloring_items[0]));
|
1998-04-15 04:45:53 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (i = 0; i < num_items; i++)
|
|
|
|
{
|
|
|
|
if (i == (num_items - 1))
|
|
|
|
menuitem = gtk_radio_menu_item_new_with_label(group, _("(Varies)"));
|
|
|
|
else
|
|
|
|
menuitem = gtk_radio_menu_item_new_with_label (group, gettext (coloring_types[i]));
|
1998-04-15 04:45:53 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menuitem),
|
|
|
|
GINT_TO_POINTER (i));
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_coloring_callback),
|
|
|
|
gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_coloring_items[i] = menuitem;
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* "Varies" is always disabled */
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->control_coloring_items[num_items - 1], FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return menu;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_coloring_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
GimpGradientSegmentColor color;
|
|
|
|
GimpGradientSegment *seg, *aseg;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (! GTK_CHECK_MENU_ITEM (widget)->active)
|
|
|
|
return; /* Do nothing if the menu item is being deactivated */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
color = (GimpGradientSegmentColor)
|
|
|
|
GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
|
|
|
|
|
|
|
|
seg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
seg->color = color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
aseg = seg;
|
|
|
|
seg = seg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (aseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_midpoint_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg, *lseg, *rseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_midpoint (gradient, seg, &lseg, &rseg);
|
1999-07-24 23:37:03 +08:00
|
|
|
seg = rseg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (lseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_r = rseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_midpoint (GimpGradient *gradient,
|
|
|
|
GimpGradientSegment *lseg,
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment **newl,
|
|
|
|
GimpGradientSegment **newr)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-01-21 00:28:05 +08:00
|
|
|
GimpRGB color;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *newseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Get color at original segment's midpoint */
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_gradient_get_color_at (gradient, lseg->middle, &color);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Create a new segment and insert it in the list */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
newseg = gimp_gradient_segment_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
newseg->prev = lseg;
|
|
|
|
newseg->next = lseg->next;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
lseg->next = newseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (newseg->next)
|
|
|
|
newseg->next->prev = newseg;
|
1998-04-15 04:45:53 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Set coordinates of new segment */
|
1998-04-15 04:45:53 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
newseg->left = lseg->middle;
|
|
|
|
newseg->right = lseg->right;
|
|
|
|
newseg->middle = (newseg->left + newseg->right) / 2.0;
|
1998-04-15 04:45:53 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Set coordinates of original segment */
|
1998-04-15 04:45:53 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
lseg->right = newseg->left;
|
|
|
|
lseg->middle = (lseg->left + lseg->right) / 2.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Set colors of both segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
newseg->right_color = lseg->right_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 00:28:05 +08:00
|
|
|
lseg->right_color.r = newseg->left_color.r = color.r;
|
|
|
|
lseg->right_color.g = newseg->left_color.g = color.g;
|
|
|
|
lseg->right_color.b = newseg->left_color.b = color.b;
|
|
|
|
lseg->right_color.a = newseg->left_color.a = color.a;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Set parameters of new segment */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
newseg->type = lseg->type;
|
|
|
|
newseg->color = lseg->color;
|
|
|
|
|
|
|
|
/* Done */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
*newl = lseg;
|
|
|
|
*newr = newseg;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_uniform_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scale;
|
|
|
|
GtkObject *scale_data;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Create dialog window */
|
1999-09-28 01:58:10 +08:00
|
|
|
dialog =
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_dialog_new ((gradient_editor->control_sel_l ==
|
|
|
|
gradient_editor->control_sel_r) ?
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Split segment uniformly") :
|
|
|
|
_("Split segments uniformly"),
|
|
|
|
"gradient_segment_split_uniformly",
|
|
|
|
gimp_standard_help_func,
|
1999-10-04 16:40:33 +08:00
|
|
|
"dialogs/gradient_editor/split_segments_uniformly.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
GTK_WIN_POS_MOUSE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("Split"), cpopup_split_uniform_split_callback,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor, NULL, NULL, TRUE, FALSE,
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Cancel"), cpopup_split_uniform_cancel_callback,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor, NULL, NULL, FALSE, TRUE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
NULL);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* The main vbox */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Instructions */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
label = gtk_label_new (_("Please select the number of uniform parts"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
label =
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_label_new ((gradient_editor->control_sel_l ==
|
|
|
|
gradient_editor->control_sel_r) ?
|
1999-07-24 23:37:03 +08:00
|
|
|
_("in which you want to split the selected segment") :
|
|
|
|
_("in which you want to split the segments in the selection"));
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Scale */
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->split_parts = 2;
|
|
|
|
scale_data = gtk_adjustment_new (2.0, 2.0, 21.0, 1.0, 1.0, 1.0);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
|
|
|
scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data));
|
|
|
|
gtk_scale_set_digits (GTK_SCALE (scale), 0);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 4);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gtk_widget_show (scale);
|
|
|
|
|
|
|
|
gtk_signal_connect (scale_data, "value_changed",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_split_uniform_scale_update),
|
|
|
|
gradient_editor);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Show! */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gtk_widget_show (dialog);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_uniform_scale_update (GtkAdjustment *adjustment,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->split_parts = ROUND (adjustment->value + 0.5);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_uniform_split_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg, *aseg, *lseg, *rseg, *lsel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_sel_l;
|
1999-07-24 23:37:03 +08:00
|
|
|
lsel = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
aseg = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_uniform (gradient, seg,
|
|
|
|
gradient_editor->split_parts, &lseg, &rseg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
if (seg == gradient_editor->control_sel_l)
|
1999-07-24 23:37:03 +08:00
|
|
|
lsel = lseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg = rseg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (aseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_l = lsel;
|
|
|
|
gradient_editor->control_sel_r = rseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_uniform_cancel_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_split_uniform (GimpGradient *gradient,
|
|
|
|
GimpGradientSegment *lseg,
|
2001-02-11 09:39:24 +08:00
|
|
|
gint parts,
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment **newl,
|
|
|
|
GimpGradientSegment **newr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg, *prev, *tmp;
|
2001-02-13 08:12:15 +08:00
|
|
|
gdouble seg_len;
|
|
|
|
gint i;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg_len = (lseg->right - lseg->left) / parts; /* Length of divisions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg = NULL;
|
|
|
|
prev = NULL;
|
|
|
|
tmp = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (i = 0; i < parts; i++)
|
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
seg = gimp_gradient_segment_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (i == 0)
|
|
|
|
tmp = seg; /* Remember first segment */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->left = lseg->left + i * seg_len;
|
|
|
|
seg->right = lseg->left + (i + 1) * seg_len;
|
|
|
|
seg->middle = (seg->left + seg->right) / 2.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_gradient_get_color_at (gradient, seg->left, &seg->left_color);
|
|
|
|
gimp_gradient_get_color_at (gradient, seg->right, &seg->right_color);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->type = lseg->type;
|
|
|
|
seg->color = lseg->color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->prev = prev;
|
|
|
|
seg->next = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (prev)
|
|
|
|
prev->next = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
prev = seg;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Fix edges */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
tmp->left_color = lseg->left_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->right_color = lseg->right_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
tmp->left = lseg->left;
|
|
|
|
seg->right = lseg->right; /* To squish accumulative error */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Link in list */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
tmp->prev = lseg->prev;
|
|
|
|
seg->next = lseg->next;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (lseg->prev)
|
|
|
|
lseg->prev->next = tmp;
|
|
|
|
else
|
2001-02-13 08:12:15 +08:00
|
|
|
gradient->segments = tmp; /* We are on leftmost segment */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (lseg->next)
|
|
|
|
lseg->next->prev = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gradient->last_visited = NULL; /* Force re-search */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Done */
|
|
|
|
|
|
|
|
*newl = tmp;
|
|
|
|
*newr = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Delete old segment */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_gradient_segment_free (lseg);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_delete_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *lseg, *rseg, *seg, *aseg, *next;
|
2001-02-13 08:12:15 +08:00
|
|
|
double join;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Remember segments to the left and to the right of the selection */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
lseg = gradient_editor->control_sel_l->prev;
|
|
|
|
rseg = gradient_editor->control_sel_r->next;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Cannot delete all the segments in the gradient */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if ((lseg == NULL) && (rseg == NULL))
|
|
|
|
return;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Calculate join point */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
join = (gradient_editor->control_sel_l->left +
|
|
|
|
gradient_editor->control_sel_r->right) / 2.0;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (lseg == NULL)
|
|
|
|
join = 0.0;
|
|
|
|
else if (rseg == NULL)
|
|
|
|
join = 1.0;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Move segments */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (lseg != NULL)
|
|
|
|
control_compress_range (lseg, lseg, lseg->left, join);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (rseg != NULL)
|
|
|
|
control_compress_range (rseg, rseg, join, rseg->right);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Link */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (lseg)
|
|
|
|
lseg->next = rseg;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (rseg)
|
|
|
|
rseg->prev = lseg;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Delete old segments */
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_sel_l;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
next = seg->next;
|
|
|
|
aseg = seg;
|
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_gradient_segment_free (seg);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
seg = next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (aseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Change selection */
|
|
|
|
|
|
|
|
if (rseg)
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_l = rseg;
|
|
|
|
gradient_editor->control_sel_r = rseg;
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_l = lseg;
|
|
|
|
gradient_editor->control_sel_r = lseg;
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lseg == NULL)
|
2001-02-13 08:12:15 +08:00
|
|
|
gradient->segments = rseg;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Done */
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_recenter_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg, *aseg;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_sel_l;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
seg->middle = (seg->left + seg->right) / 2.0;
|
|
|
|
|
|
|
|
aseg = seg;
|
|
|
|
seg = seg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (aseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_redistribute_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg, *aseg;
|
2001-02-13 08:12:15 +08:00
|
|
|
gdouble left, right, seg_len;
|
|
|
|
gint num_segs;
|
|
|
|
gint i;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Count number of segments in selection */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
num_segs = 0;
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
num_segs++;
|
|
|
|
aseg = seg;
|
|
|
|
seg = seg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (aseg != gradient_editor->control_sel_r);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Calculate new segment length */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
left = gradient_editor->control_sel_l->left;
|
|
|
|
right = gradient_editor->control_sel_r->right;
|
1999-07-24 23:37:03 +08:00
|
|
|
seg_len = (right - left) / num_segs;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Redistribute */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (i = 0; i < num_segs; i++)
|
|
|
|
{
|
|
|
|
seg->left = left + i * seg_len;
|
|
|
|
seg->right = left + (i + 1) * seg_len;
|
|
|
|
seg->middle = (seg->left + seg->right) / 2.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg = seg->next;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Fix endpoints to squish accumulative error */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_l->left = left;
|
|
|
|
gradient_editor->control_sel_r->right = right;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* Done */
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** Control popup -> selection options functions *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static GtkWidget *
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_create_sel_ops_menu (GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
|
|
|
GtkAccelGroup *accel_group;
|
|
|
|
|
|
|
|
menu = gtk_menu_new ();
|
2001-02-18 05:20:10 +08:00
|
|
|
accel_group = gradient_editor->accel_group;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Flip */
|
|
|
|
menuitem =
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_create_menu_item_with_label ("", &gradient_editor->control_flip_label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_flip_callback),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'F', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
/* Replicate */
|
|
|
|
menuitem =
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_create_menu_item_with_label ("", &gradient_editor->control_replicate_label);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_replicate_callback),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'M', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
/* Blend colors / opacity */
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Blend endpoints' colors"));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_blend_colors),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_blend_colors_menu_item = menuitem;
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'B', 0,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Blend endpoints' opacity"));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_blend_opacity),
|
|
|
|
gradient_editor);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_widget_add_accelerator (menuitem, "activate",
|
|
|
|
accel_group,
|
|
|
|
'B', GDK_CONTROL_MASK,
|
|
|
|
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_blend_opacity_menu_item = menuitem;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_flip_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *oseg, *oaseg;
|
|
|
|
GimpGradientSegment *seg, *prev, *tmp;
|
|
|
|
GimpGradientSegment *lseg, *rseg;
|
2001-02-13 08:12:15 +08:00
|
|
|
gdouble left, right;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
left = gradient_editor->control_sel_l->left;
|
|
|
|
right = gradient_editor->control_sel_r->right;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Build flipped segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
prev = NULL;
|
2001-02-18 05:20:10 +08:00
|
|
|
oseg = gradient_editor->control_sel_r;
|
1999-07-24 23:37:03 +08:00
|
|
|
tmp = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
seg = gimp_gradient_segment_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (prev == NULL)
|
|
|
|
{
|
|
|
|
seg->left = left;
|
|
|
|
tmp = seg; /* Remember first segment */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
seg->left = left + right - oseg->right;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->middle = left + right - oseg->middle;
|
|
|
|
seg->right = left + right - oseg->left;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->left_color = oseg->right_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->right_color = oseg->left_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
switch (oseg->type)
|
|
|
|
{
|
|
|
|
case GRAD_SPHERE_INCREASING:
|
|
|
|
seg->type = GRAD_SPHERE_DECREASING;
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GRAD_SPHERE_DECREASING:
|
|
|
|
seg->type = GRAD_SPHERE_INCREASING;
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
default:
|
|
|
|
seg->type = oseg->type;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
switch (oseg->color)
|
|
|
|
{
|
|
|
|
case GRAD_HSV_CCW:
|
|
|
|
seg->color = GRAD_HSV_CW;
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
case GRAD_HSV_CW:
|
|
|
|
seg->color = GRAD_HSV_CCW;
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
default:
|
|
|
|
seg->color = oseg->color;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->prev = prev;
|
|
|
|
seg->next = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (prev)
|
|
|
|
prev->next = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
prev = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
oaseg = oseg;
|
|
|
|
oseg = oseg->prev; /* Move backwards! */
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (oaseg != gradient_editor->control_sel_l);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->right = right; /* Squish accumulative error */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Free old segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
lseg = gradient_editor->control_sel_l->prev;
|
|
|
|
rseg = gradient_editor->control_sel_r->next;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
oseg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
oaseg = oseg->next;
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_gradient_segment_free (oseg);
|
1999-07-24 23:37:03 +08:00
|
|
|
oseg = oaseg;
|
|
|
|
}
|
|
|
|
while (oaseg != rseg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Link in new segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (lseg)
|
|
|
|
lseg->next = tmp;
|
|
|
|
else
|
2001-02-13 08:12:15 +08:00
|
|
|
gradient->segments = tmp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
tmp->prev = lseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->next = rseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (rseg)
|
|
|
|
rseg->prev = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Reset selection */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_l = tmp;
|
|
|
|
gradient_editor->control_sel_r = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Done */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_replicate_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scale;
|
|
|
|
GtkObject *scale_data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Create dialog window */
|
1999-09-28 01:58:10 +08:00
|
|
|
dialog =
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_dialog_new ((gradient_editor->control_sel_l ==
|
|
|
|
gradient_editor->control_sel_r) ?
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Replicate segment") :
|
|
|
|
_("Replicate selection"),
|
|
|
|
"gradient_segment_replicate",
|
|
|
|
gimp_standard_help_func,
|
1999-10-04 16:40:33 +08:00
|
|
|
"dialogs/gradient_editor/replicate_segment.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
GTK_WIN_POS_MOUSE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("Replicate"), cpopup_do_replicate_callback,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor, NULL, NULL, FALSE, FALSE,
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Cancel"), cpopup_replicate_cancel_callback,
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor, NULL, NULL, TRUE, TRUE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Instructions */
|
|
|
|
label = gtk_label_new (_("Please select the number of times"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
label = gtk_label_new ((gradient_editor->control_sel_l ==
|
|
|
|
gradient_editor->control_sel_r) ?
|
1999-07-24 23:37:03 +08:00
|
|
|
_("you want to replicate the selected segment") :
|
|
|
|
_("you want to replicate the selection"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Scale */
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->replicate_times = 2;
|
1999-07-24 23:37:03 +08:00
|
|
|
scale_data = gtk_adjustment_new (2.0, 2.0, 21.0, 1.0, 1.0, 1.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data));
|
|
|
|
gtk_scale_set_digits (GTK_SCALE (scale), 0);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, TRUE, 4);
|
|
|
|
gtk_widget_show (scale);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (scale_data, "value_changed",
|
2001-02-18 05:20:10 +08:00
|
|
|
GTK_SIGNAL_FUNC (cpopup_replicate_scale_update),
|
|
|
|
gradient_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Show! */
|
|
|
|
gtk_widget_show (dialog);
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_replicate_scale_update (GtkAdjustment *adjustment,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->replicate_times = (int) (adjustment->value + 0.5);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_do_replicate_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpGradient *gradient;
|
|
|
|
gdouble sel_left, sel_right, sel_len;
|
|
|
|
gdouble new_left;
|
|
|
|
gdouble factor;
|
|
|
|
GimpGradientSegment *prev, *seg, *tmp;
|
|
|
|
GimpGradientSegment *oseg, *oaseg;
|
|
|
|
GimpGradientSegment *lseg, *rseg;
|
|
|
|
gint i;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient = gimp_context_get_gradient (gradient_editor->context);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Remember original parameters */
|
2001-02-18 05:20:10 +08:00
|
|
|
sel_left = gradient_editor->control_sel_l->left;
|
|
|
|
sel_right = gradient_editor->control_sel_r->right;
|
1999-07-24 23:37:03 +08:00
|
|
|
sel_len = sel_right - sel_left;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
factor = 1.0 / gradient_editor->replicate_times;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Build replicated segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
prev = NULL;
|
|
|
|
seg = NULL;
|
|
|
|
tmp = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
for (i = 0; i < gradient_editor->replicate_times; i++)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
|
|
|
/* Build one cycle */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
new_left = sel_left + i * factor * sel_len;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
oseg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
seg = gimp_gradient_segment_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (prev == NULL)
|
|
|
|
{
|
|
|
|
seg->left = sel_left;
|
|
|
|
tmp = seg; /* Remember first segment */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
seg->left = new_left + factor * (oseg->left - sel_left);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->middle = new_left + factor * (oseg->middle - sel_left);
|
|
|
|
seg->right = new_left + factor * (oseg->right - sel_left);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->left_color = oseg->right_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->right_color = oseg->right_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->type = oseg->type;
|
|
|
|
seg->color = oseg->color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->prev = prev;
|
|
|
|
seg->next = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (prev)
|
|
|
|
prev->next = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
prev = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
oaseg = oseg;
|
|
|
|
oseg = oseg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (oaseg != gradient_editor->control_sel_r);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->right = sel_right; /* Squish accumulative error */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Free old segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
lseg = gradient_editor->control_sel_l->prev;
|
|
|
|
rseg = gradient_editor->control_sel_r->next;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
oseg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
oaseg = oseg->next;
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_gradient_segment_free (oseg);
|
1999-07-24 23:37:03 +08:00
|
|
|
oseg = oaseg;
|
|
|
|
}
|
|
|
|
while (oaseg != rseg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Link in new segments */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (lseg)
|
|
|
|
lseg->next = tmp;
|
|
|
|
else
|
2001-02-13 08:12:15 +08:00
|
|
|
gradient->segments = tmp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
tmp->prev = lseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
seg->next = rseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (rseg)
|
|
|
|
rseg->prev = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Reset selection */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gradient_editor->control_sel_l = tmp;
|
|
|
|
gradient_editor->control_sel_r = seg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Done */
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gradient));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_replicate_cancel_callback (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
|
|
|
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_colors (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_l->left_color,
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
1999-07-24 23:37:03 +08:00
|
|
|
TRUE, FALSE);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gimp_context_get_gradient (gradient_editor->context)));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_opacity (GtkWidget *widget,
|
|
|
|
GradientEditor *gradient_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (gradient_editor,
|
|
|
|
&gradient_editor->control_sel_l->left_color,
|
|
|
|
&gradient_editor->control_sel_r->right_color,
|
1999-07-24 23:37:03 +08:00
|
|
|
FALSE, TRUE);
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gimp_context_get_gradient (gradient_editor->context)));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
ed_update_editor (gradient_editor, GRAD_UPDATE_GRADIENT);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/***** Main blend function *****/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
2001-02-18 05:20:10 +08:00
|
|
|
cpopup_blend_endpoints (GradientEditor *gradient_editor,
|
|
|
|
GimpRGB *rgb1,
|
|
|
|
GimpRGB *rgb2,
|
|
|
|
gboolean blend_colors,
|
|
|
|
gboolean blend_opacity)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpRGB d;
|
|
|
|
gdouble left, len;
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradientSegment *seg;
|
|
|
|
GimpGradientSegment *aseg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
d.r = rgb2->r - rgb1->r;
|
|
|
|
d.g = rgb2->g - rgb1->g;
|
|
|
|
d.b = rgb2->b - rgb1->b;
|
|
|
|
d.a = rgb2->a - rgb1->a;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
left = gradient_editor->control_sel_l->left;
|
|
|
|
len = gradient_editor->control_sel_r->right - left;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
seg = gradient_editor->control_sel_l;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (blend_colors)
|
|
|
|
{
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->left_color.r = rgb1->r + (seg->left - left) / len * d.r;
|
|
|
|
seg->left_color.g = rgb1->g + (seg->left - left) / len * d.g;
|
|
|
|
seg->left_color.b = rgb1->b + (seg->left - left) / len * d.b;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->right_color.r = rgb1->r + (seg->right - left) / len * d.r;
|
|
|
|
seg->right_color.g = rgb1->g + (seg->right - left) / len * d.g;
|
|
|
|
seg->right_color.b = rgb1->b + (seg->right - left) / len * d.b;
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (blend_opacity)
|
|
|
|
{
|
2001-01-20 23:37:26 +08:00
|
|
|
seg->left_color.a = rgb1->a + (seg->left - left) / len * d.a;
|
|
|
|
seg->right_color.a = rgb1->a + (seg->right - left) / len * d.a;
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
aseg = seg;
|
|
|
|
seg = seg->next;
|
|
|
|
}
|
2001-02-18 05:20:10 +08:00
|
|
|
while (aseg != gradient_editor->control_sel_r);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/***** Segment functions *****/
|
|
|
|
|
|
|
|
static void
|
2001-02-13 08:12:15 +08:00
|
|
|
seg_get_closest_handle (GimpGradient *grad,
|
|
|
|
gdouble pos,
|
|
|
|
GimpGradientSegment **seg,
|
1999-09-28 01:58:10 +08:00
|
|
|
control_drag_mode_t *handle)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
gdouble l_delta, m_delta, r_delta;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
*seg = gimp_gradient_get_segment_at (grad, pos);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
m_delta = fabs (pos - (*seg)->middle);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (pos < (*seg)->middle)
|
|
|
|
{
|
|
|
|
l_delta = fabs (pos - (*seg)->left);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (l_delta < m_delta)
|
|
|
|
*handle = GRAD_DRAG_LEFT;
|
|
|
|
else
|
|
|
|
*handle = GRAD_DRAG_MIDDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r_delta = fabs (pos - (*seg)->right);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (m_delta < r_delta)
|
|
|
|
{
|
|
|
|
*handle = GRAD_DRAG_MIDDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*seg = (*seg)->next;
|
|
|
|
*handle = GRAD_DRAG_LEFT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|