added "gboolean data_editable" which gets set in
2003-03-10 Michael Natterer <mitch@gimp.org> * app/widgets/gimpdataeditor.[ch]: added "gboolean data_editable" which gets set in gimp_data_editor_real_set_data(). Set the name entry insensitive if the data is not editable. * app/widgets/gimpbrusheditor.c * app/widgets/gimppaletteeditor.c * app/widgets/gimpgradienteditor.c: look at editor->data_editable instead of duplicating the logic in all subclasses. * app/widgets/gimppreview.[ch]: added "gboolean expand" and gimp_preview_set_expand() like in GtkPreview bacause smooth auto resizing can only be done by the widget itself, not via external callbacks. * app/display/gimpnavigationview.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpgradienteditor.c * app/widgets/gimpselectioneditor.c: set expand == TRUE. Removed "size_allocate" callbacks. They resize *much* smoother now. Various cleanups. * app/widgets/gimpnavigationpreview.c: recalculate the preview coordinates when the size changes. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimppreviewrenderer-utils.c * app/widgets/gimppreviewrenderergradient.[ch]: new renderer which is much faster because it projects the gradient without creating intermediate buffers. Rendering can be restricted to an interval from [left...right]. * app/widgets/gimpgradienteditor.[ch]: undeprecated by using GimpPreview instead of GtkPreview. Cleanup. * app/gui/gradient-editor-commands.c: changed accordingly.
This commit is contained in:

committed by
Michael Natterer

parent
3f588521ff
commit
1522b841fa
39
ChangeLog
39
ChangeLog
@ -1,3 +1,42 @@
|
|||||||
|
2003-03-10 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/widgets/gimpdataeditor.[ch]: added "gboolean data_editable"
|
||||||
|
which gets set in gimp_data_editor_real_set_data(). Set the name
|
||||||
|
entry insensitive if the data is not editable.
|
||||||
|
|
||||||
|
* app/widgets/gimpbrusheditor.c
|
||||||
|
* app/widgets/gimppaletteeditor.c
|
||||||
|
* app/widgets/gimpgradienteditor.c: look at editor->data_editable
|
||||||
|
instead of duplicating the logic in all subclasses.
|
||||||
|
|
||||||
|
* app/widgets/gimppreview.[ch]: added "gboolean expand" and
|
||||||
|
gimp_preview_set_expand() like in GtkPreview bacause smooth auto
|
||||||
|
resizing can only be done by the widget itself, not via external
|
||||||
|
callbacks.
|
||||||
|
|
||||||
|
* app/display/gimpnavigationview.c
|
||||||
|
* app/widgets/gimpbrusheditor.c
|
||||||
|
* app/widgets/gimpgradienteditor.c
|
||||||
|
* app/widgets/gimpselectioneditor.c: set expand == TRUE. Removed
|
||||||
|
"size_allocate" callbacks. They resize *much* smoother now.
|
||||||
|
Various cleanups.
|
||||||
|
|
||||||
|
* app/widgets/gimpnavigationpreview.c: recalculate the preview
|
||||||
|
coordinates when the size changes.
|
||||||
|
|
||||||
|
* app/widgets/Makefile.am
|
||||||
|
* app/widgets/widgets-types.h
|
||||||
|
* app/widgets/gimppreviewrenderer-utils.c
|
||||||
|
* app/widgets/gimppreviewrenderergradient.[ch]: new renderer which
|
||||||
|
is much faster because it projects the gradient without creating
|
||||||
|
intermediate buffers. Rendering can be restricted to an interval
|
||||||
|
from [left...right].
|
||||||
|
|
||||||
|
* app/widgets/gimpgradienteditor.[ch]: undeprecated by using
|
||||||
|
GimpPreview instead of GtkPreview. Cleanup.
|
||||||
|
|
||||||
|
* app/gui/gradient-editor-commands.c: changed accordingly.
|
||||||
|
|
||||||
2003-03-10 Sven Neumann <sven@gimp.org>
|
2003-03-10 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/tools/gimpbycolorselecttool.c
|
* app/tools/gimpbycolorselecttool.c
|
||||||
|
@ -165,8 +165,6 @@ gradient_editor_load_left_cmd_callback (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -283,8 +281,6 @@ gradient_editor_load_right_cmd_callback (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -330,8 +326,6 @@ gradient_editor_blending_func_cmd_callback (GtkWidget *widget,
|
|||||||
while (aseg != editor->control_sel_r);
|
while (aseg != editor->control_sel_r);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -365,8 +359,6 @@ gradient_editor_coloring_type_cmd_callback (GtkWidget *widget,
|
|||||||
while (aseg != editor->control_sel_r);
|
while (aseg != editor->control_sel_r);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -493,9 +485,7 @@ gradient_editor_flip_cmd_callback (GtkWidget *widget,
|
|||||||
/* Done */
|
/* Done */
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -601,9 +591,7 @@ gradient_editor_split_midpoint_cmd_callback (GtkWidget *widget,
|
|||||||
editor->control_sel_r = rseg;
|
editor->control_sel_r = rseg;
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -771,9 +759,7 @@ gradient_editor_delete_cmd_callback (GtkWidget *widget,
|
|||||||
/* Done */
|
/* Done */
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -801,9 +787,7 @@ gradient_editor_recenter_cmd_callback (GtkWidget *widget,
|
|||||||
while (aseg != editor->control_sel_r);
|
while (aseg != editor->control_sel_r);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -862,9 +846,7 @@ gradient_editor_redistribute_cmd_callback (GtkWidget *widget,
|
|||||||
/* Done */
|
/* Done */
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -883,8 +865,6 @@ gradient_editor_blend_color_cmd_callback (GtkWidget *widget,
|
|||||||
TRUE, FALSE);
|
TRUE, FALSE);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
|
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -903,8 +883,6 @@ gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
|
|||||||
FALSE, TRUE);
|
FALSE, TRUE);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
|
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -950,14 +928,12 @@ gradient_editor_left_color_changed (ColorNotebook *cnb,
|
|||||||
case COLOR_NOTEBOOK_CANCEL:
|
case COLOR_NOTEBOOK_CANCEL:
|
||||||
gradient_editor_replace_selection (editor, editor->left_saved_segments);
|
gradient_editor_replace_selection (editor, editor->left_saved_segments);
|
||||||
GIMP_DATA (gradient)->dirty = editor->left_saved_dirty;
|
GIMP_DATA (gradient)->dirty = editor->left_saved_dirty;
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient));
|
||||||
color_notebook_free (cnb);
|
color_notebook_free (cnb);
|
||||||
editor->color_notebook = NULL;
|
editor->color_notebook = NULL;
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1000,13 +976,12 @@ gradient_editor_right_color_changed (ColorNotebook *cnb,
|
|||||||
case COLOR_NOTEBOOK_CANCEL:
|
case COLOR_NOTEBOOK_CANCEL:
|
||||||
gradient_editor_replace_selection (editor, editor->right_saved_segments);
|
gradient_editor_replace_selection (editor, editor->right_saved_segments);
|
||||||
GIMP_DATA (gradient)->dirty = editor->right_saved_dirty;
|
GIMP_DATA (gradient)->dirty = editor->right_saved_dirty;
|
||||||
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient));
|
||||||
color_notebook_free (cnb);
|
color_notebook_free (cnb);
|
||||||
editor->color_notebook = NULL;
|
editor->color_notebook = NULL;
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GimpGradientSegment *
|
static GimpGradientSegment *
|
||||||
@ -1126,9 +1101,7 @@ gradient_editor_split_uniform_callback (GtkWidget *widget,
|
|||||||
editor->control_sel_r = rseg;
|
editor->control_sel_r = rseg;
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1245,7 +1218,5 @@ gradient_editor_replicate_callback (GtkWidget *widget,
|
|||||||
/* Done */
|
/* Done */
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,6 @@ static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
|
|||||||
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
|
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
|
||||||
GdkEventButton *bevent,
|
GdkEventButton *bevent,
|
||||||
GimpDisplayShell *shell);
|
GimpDisplayShell *shell);
|
||||||
static void gimp_navigation_view_abox_resized (GtkWidget *widget,
|
|
||||||
GtkAllocation *allocation,
|
|
||||||
GimpNavigationView *view);
|
|
||||||
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
@ -147,7 +144,6 @@ gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
|
|||||||
static void
|
static void
|
||||||
gimp_navigation_view_init (GimpNavigationView *view)
|
gimp_navigation_view_init (GimpNavigationView *view)
|
||||||
{
|
{
|
||||||
GtkWidget *abox;
|
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
|
|
||||||
view->shell = NULL;
|
view->shell = NULL;
|
||||||
@ -157,16 +153,13 @@ gimp_navigation_view_init (GimpNavigationView *view)
|
|||||||
gtk_box_pack_start (GTK_BOX (view), frame, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (view), frame, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
view->preview = gimp_preview_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
|
||||||
gtk_container_add (GTK_CONTAINER (frame), abox);
|
GIMP_TYPE_IMAGE,
|
||||||
gtk_widget_show (abox);
|
GIMP_PREVIEW_SIZE_MEDIUM, 0, TRUE);
|
||||||
|
gtk_widget_set_size_request (view->preview,
|
||||||
g_signal_connect (abox, "size_allocate",
|
GIMP_PREVIEW_SIZE_HUGE, GIMP_PREVIEW_SIZE_HUGE);
|
||||||
G_CALLBACK (gimp_navigation_view_abox_resized),
|
gimp_preview_set_expand (GIMP_PREVIEW (view->preview), TRUE);
|
||||||
view);
|
gtk_container_add (GTK_CONTAINER (frame), view->preview);
|
||||||
|
|
||||||
view->preview = gimp_navigation_preview_new (NULL, GIMP_PREVIEW_SIZE_MEDIUM);
|
|
||||||
gtk_container_add (GTK_CONTAINER (abox), view->preview);
|
|
||||||
gtk_widget_show (view->preview);
|
gtk_widget_show (view->preview);
|
||||||
|
|
||||||
g_signal_connect (view->preview, "marker_changed",
|
g_signal_connect (view->preview, "marker_changed",
|
||||||
@ -467,71 +460,6 @@ gimp_navigation_view_button_release (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_navigation_view_abox_resized (GtkWidget *widget,
|
|
||||||
GtkAllocation *allocation,
|
|
||||||
GimpNavigationView *view)
|
|
||||||
{
|
|
||||||
GimpPreview *preview;
|
|
||||||
|
|
||||||
preview = GIMP_PREVIEW (view->preview);
|
|
||||||
|
|
||||||
if (! preview->viewable)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (preview->renderer->width > allocation->width ||
|
|
||||||
preview->renderer->height > allocation->height ||
|
|
||||||
(preview->renderer->width != allocation->width &&
|
|
||||||
preview->renderer->height != allocation->height))
|
|
||||||
{
|
|
||||||
GimpNavigationPreview *nav_preview;
|
|
||||||
GimpImage *gimage;
|
|
||||||
gint width;
|
|
||||||
gint height;
|
|
||||||
gboolean dummy;
|
|
||||||
|
|
||||||
gimage = GIMP_IMAGE (preview->viewable);
|
|
||||||
|
|
||||||
gimp_viewable_calc_preview_size (preview->viewable,
|
|
||||||
gimage->width,
|
|
||||||
gimage->height,
|
|
||||||
MIN (allocation->width,
|
|
||||||
GIMP_PREVIEW_MAX_SIZE),
|
|
||||||
MIN (allocation->height,
|
|
||||||
GIMP_PREVIEW_MAX_SIZE),
|
|
||||||
preview->renderer->dot_for_dot,
|
|
||||||
gimage->xresolution,
|
|
||||||
gimage->yresolution,
|
|
||||||
&width,
|
|
||||||
&height,
|
|
||||||
&dummy);
|
|
||||||
|
|
||||||
if (width > allocation->width)
|
|
||||||
{
|
|
||||||
height = height * allocation->width / width;
|
|
||||||
width = width * allocation->width / width;
|
|
||||||
}
|
|
||||||
else if (height > allocation->height)
|
|
||||||
{
|
|
||||||
width = width * allocation->height / height;
|
|
||||||
height = height * allocation->height / height;
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_preview_set_size_full (preview, width, height,
|
|
||||||
preview->renderer->border_width);
|
|
||||||
|
|
||||||
/* FIXME: the GimpNavigationPreview should handle this stuff itself */
|
|
||||||
|
|
||||||
nav_preview = GIMP_NAVIGATION_PREVIEW (preview);
|
|
||||||
|
|
||||||
gimp_navigation_preview_set_marker (nav_preview,
|
|
||||||
nav_preview->x,
|
|
||||||
nav_preview->y,
|
|
||||||
nav_preview->width,
|
|
||||||
nav_preview->height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
||||||
gint x,
|
gint x,
|
||||||
|
@ -62,9 +62,6 @@ static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
|
|||||||
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
|
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
|
||||||
GdkEventButton *bevent,
|
GdkEventButton *bevent,
|
||||||
GimpDisplayShell *shell);
|
GimpDisplayShell *shell);
|
||||||
static void gimp_navigation_view_abox_resized (GtkWidget *widget,
|
|
||||||
GtkAllocation *allocation,
|
|
||||||
GimpNavigationView *view);
|
|
||||||
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
@ -147,7 +144,6 @@ gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
|
|||||||
static void
|
static void
|
||||||
gimp_navigation_view_init (GimpNavigationView *view)
|
gimp_navigation_view_init (GimpNavigationView *view)
|
||||||
{
|
{
|
||||||
GtkWidget *abox;
|
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
|
|
||||||
view->shell = NULL;
|
view->shell = NULL;
|
||||||
@ -157,16 +153,13 @@ gimp_navigation_view_init (GimpNavigationView *view)
|
|||||||
gtk_box_pack_start (GTK_BOX (view), frame, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (view), frame, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
view->preview = gimp_preview_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
|
||||||
gtk_container_add (GTK_CONTAINER (frame), abox);
|
GIMP_TYPE_IMAGE,
|
||||||
gtk_widget_show (abox);
|
GIMP_PREVIEW_SIZE_MEDIUM, 0, TRUE);
|
||||||
|
gtk_widget_set_size_request (view->preview,
|
||||||
g_signal_connect (abox, "size_allocate",
|
GIMP_PREVIEW_SIZE_HUGE, GIMP_PREVIEW_SIZE_HUGE);
|
||||||
G_CALLBACK (gimp_navigation_view_abox_resized),
|
gimp_preview_set_expand (GIMP_PREVIEW (view->preview), TRUE);
|
||||||
view);
|
gtk_container_add (GTK_CONTAINER (frame), view->preview);
|
||||||
|
|
||||||
view->preview = gimp_navigation_preview_new (NULL, GIMP_PREVIEW_SIZE_MEDIUM);
|
|
||||||
gtk_container_add (GTK_CONTAINER (abox), view->preview);
|
|
||||||
gtk_widget_show (view->preview);
|
gtk_widget_show (view->preview);
|
||||||
|
|
||||||
g_signal_connect (view->preview, "marker_changed",
|
g_signal_connect (view->preview, "marker_changed",
|
||||||
@ -467,71 +460,6 @@ gimp_navigation_view_button_release (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_navigation_view_abox_resized (GtkWidget *widget,
|
|
||||||
GtkAllocation *allocation,
|
|
||||||
GimpNavigationView *view)
|
|
||||||
{
|
|
||||||
GimpPreview *preview;
|
|
||||||
|
|
||||||
preview = GIMP_PREVIEW (view->preview);
|
|
||||||
|
|
||||||
if (! preview->viewable)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (preview->renderer->width > allocation->width ||
|
|
||||||
preview->renderer->height > allocation->height ||
|
|
||||||
(preview->renderer->width != allocation->width &&
|
|
||||||
preview->renderer->height != allocation->height))
|
|
||||||
{
|
|
||||||
GimpNavigationPreview *nav_preview;
|
|
||||||
GimpImage *gimage;
|
|
||||||
gint width;
|
|
||||||
gint height;
|
|
||||||
gboolean dummy;
|
|
||||||
|
|
||||||
gimage = GIMP_IMAGE (preview->viewable);
|
|
||||||
|
|
||||||
gimp_viewable_calc_preview_size (preview->viewable,
|
|
||||||
gimage->width,
|
|
||||||
gimage->height,
|
|
||||||
MIN (allocation->width,
|
|
||||||
GIMP_PREVIEW_MAX_SIZE),
|
|
||||||
MIN (allocation->height,
|
|
||||||
GIMP_PREVIEW_MAX_SIZE),
|
|
||||||
preview->renderer->dot_for_dot,
|
|
||||||
gimage->xresolution,
|
|
||||||
gimage->yresolution,
|
|
||||||
&width,
|
|
||||||
&height,
|
|
||||||
&dummy);
|
|
||||||
|
|
||||||
if (width > allocation->width)
|
|
||||||
{
|
|
||||||
height = height * allocation->width / width;
|
|
||||||
width = width * allocation->width / width;
|
|
||||||
}
|
|
||||||
else if (height > allocation->height)
|
|
||||||
{
|
|
||||||
width = width * allocation->height / height;
|
|
||||||
height = height * allocation->height / height;
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_preview_set_size_full (preview, width, height,
|
|
||||||
preview->renderer->border_width);
|
|
||||||
|
|
||||||
/* FIXME: the GimpNavigationPreview should handle this stuff itself */
|
|
||||||
|
|
||||||
nav_preview = GIMP_NAVIGATION_PREVIEW (preview);
|
|
||||||
|
|
||||||
gimp_navigation_preview_set_marker (nav_preview,
|
|
||||||
nav_preview->x,
|
|
||||||
nav_preview->y,
|
|
||||||
nav_preview->width,
|
|
||||||
nav_preview->height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
||||||
gint x,
|
gint x,
|
||||||
|
@ -165,8 +165,6 @@ gradient_editor_load_left_cmd_callback (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -283,8 +281,6 @@ gradient_editor_load_right_cmd_callback (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -330,8 +326,6 @@ gradient_editor_blending_func_cmd_callback (GtkWidget *widget,
|
|||||||
while (aseg != editor->control_sel_r);
|
while (aseg != editor->control_sel_r);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -365,8 +359,6 @@ gradient_editor_coloring_type_cmd_callback (GtkWidget *widget,
|
|||||||
while (aseg != editor->control_sel_r);
|
while (aseg != editor->control_sel_r);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -493,9 +485,7 @@ gradient_editor_flip_cmd_callback (GtkWidget *widget,
|
|||||||
/* Done */
|
/* Done */
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -601,9 +591,7 @@ gradient_editor_split_midpoint_cmd_callback (GtkWidget *widget,
|
|||||||
editor->control_sel_r = rseg;
|
editor->control_sel_r = rseg;
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -771,9 +759,7 @@ gradient_editor_delete_cmd_callback (GtkWidget *widget,
|
|||||||
/* Done */
|
/* Done */
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -801,9 +787,7 @@ gradient_editor_recenter_cmd_callback (GtkWidget *widget,
|
|||||||
while (aseg != editor->control_sel_r);
|
while (aseg != editor->control_sel_r);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -862,9 +846,7 @@ gradient_editor_redistribute_cmd_callback (GtkWidget *widget,
|
|||||||
/* Done */
|
/* Done */
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -883,8 +865,6 @@ gradient_editor_blend_color_cmd_callback (GtkWidget *widget,
|
|||||||
TRUE, FALSE);
|
TRUE, FALSE);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
|
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -903,8 +883,6 @@ gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
|
|||||||
FALSE, TRUE);
|
FALSE, TRUE);
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
|
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -950,14 +928,12 @@ gradient_editor_left_color_changed (ColorNotebook *cnb,
|
|||||||
case COLOR_NOTEBOOK_CANCEL:
|
case COLOR_NOTEBOOK_CANCEL:
|
||||||
gradient_editor_replace_selection (editor, editor->left_saved_segments);
|
gradient_editor_replace_selection (editor, editor->left_saved_segments);
|
||||||
GIMP_DATA (gradient)->dirty = editor->left_saved_dirty;
|
GIMP_DATA (gradient)->dirty = editor->left_saved_dirty;
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient));
|
||||||
color_notebook_free (cnb);
|
color_notebook_free (cnb);
|
||||||
editor->color_notebook = NULL;
|
editor->color_notebook = NULL;
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1000,13 +976,12 @@ gradient_editor_right_color_changed (ColorNotebook *cnb,
|
|||||||
case COLOR_NOTEBOOK_CANCEL:
|
case COLOR_NOTEBOOK_CANCEL:
|
||||||
gradient_editor_replace_selection (editor, editor->right_saved_segments);
|
gradient_editor_replace_selection (editor, editor->right_saved_segments);
|
||||||
GIMP_DATA (gradient)->dirty = editor->right_saved_dirty;
|
GIMP_DATA (gradient)->dirty = editor->right_saved_dirty;
|
||||||
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient));
|
||||||
color_notebook_free (cnb);
|
color_notebook_free (cnb);
|
||||||
editor->color_notebook = NULL;
|
editor->color_notebook = NULL;
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GimpGradientSegment *
|
static GimpGradientSegment *
|
||||||
@ -1126,9 +1101,7 @@ gradient_editor_split_uniform_callback (GtkWidget *widget,
|
|||||||
editor->control_sel_r = rseg;
|
editor->control_sel_r = rseg;
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1245,7 +1218,5 @@ gradient_editor_replicate_callback (GtkWidget *widget,
|
|||||||
/* Done */
|
/* Done */
|
||||||
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
gimp_gradient_editor_update (editor,
|
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,8 @@ libappwidgets_a_sources = \
|
|||||||
gimppreviewrendererbrush.h \
|
gimppreviewrendererbrush.h \
|
||||||
gimppreviewrendererdrawable.c \
|
gimppreviewrendererdrawable.c \
|
||||||
gimppreviewrendererdrawable.h \
|
gimppreviewrendererdrawable.h \
|
||||||
|
gimppreviewrenderergradient.c \
|
||||||
|
gimppreviewrenderergradient.h \
|
||||||
gimppreviewrendererimage.c \
|
gimppreviewrendererimage.c \
|
||||||
gimppreviewrendererimage.h \
|
gimppreviewrendererimage.h \
|
||||||
gimppreviewrenderertextlayer.c \
|
gimppreviewrenderertextlayer.c \
|
||||||
|
@ -36,6 +36,10 @@
|
|||||||
#include "libgimp/gimpintl.h"
|
#include "libgimp/gimpintl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define BRUSH_PREVIEW_WIDTH 128
|
||||||
|
#define BRUSH_PREVIEW_HEIGHT 96
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void gimp_brush_editor_class_init (GimpBrushEditorClass *klass);
|
static void gimp_brush_editor_class_init (GimpBrushEditorClass *klass);
|
||||||
@ -46,9 +50,6 @@ static void gimp_brush_editor_set_data (GimpDataEditor *editor,
|
|||||||
|
|
||||||
static void gimp_brush_editor_update_brush (GtkAdjustment *adjustment,
|
static void gimp_brush_editor_update_brush (GtkAdjustment *adjustment,
|
||||||
GimpBrushEditor *editor);
|
GimpBrushEditor *editor);
|
||||||
static void gimp_brush_editor_preview_resize (GtkWidget *widget,
|
|
||||||
GtkAllocation *allocation,
|
|
||||||
GimpBrushEditor *editor);
|
|
||||||
|
|
||||||
|
|
||||||
static GimpDataEditorClass *parent_class = NULL;
|
static GimpDataEditorClass *parent_class = NULL;
|
||||||
@ -104,17 +105,14 @@ gimp_brush_editor_init (GimpBrushEditor *editor)
|
|||||||
gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
g_signal_connect_after (frame, "size_allocate",
|
|
||||||
G_CALLBACK (gimp_brush_editor_preview_resize),
|
|
||||||
editor);
|
|
||||||
|
|
||||||
editor->preview = gimp_preview_new_full_by_types (GIMP_TYPE_PREVIEW,
|
editor->preview = gimp_preview_new_full_by_types (GIMP_TYPE_PREVIEW,
|
||||||
GIMP_TYPE_BRUSH,
|
GIMP_TYPE_BRUSH,
|
||||||
125, 100, 0,
|
BRUSH_PREVIEW_WIDTH,
|
||||||
|
BRUSH_PREVIEW_HEIGHT, 0,
|
||||||
FALSE, FALSE, TRUE);
|
FALSE, FALSE, TRUE);
|
||||||
|
gtk_widget_set_size_request (editor->preview,
|
||||||
/* ensure a minimal size */
|
BRUSH_PREVIEW_WIDTH, BRUSH_PREVIEW_HEIGHT);
|
||||||
gtk_widget_set_size_request (editor->preview, 125, 100);
|
gimp_preview_set_expand (GIMP_PREVIEW (editor->preview), TRUE);
|
||||||
gtk_container_add (GTK_CONTAINER (frame), editor->preview);
|
gtk_container_add (GTK_CONTAINER (frame), editor->preview);
|
||||||
gtk_widget_show (editor->preview);
|
gtk_widget_show (editor->preview);
|
||||||
|
|
||||||
@ -185,8 +183,8 @@ gimp_brush_editor_set_data (GimpDataEditor *editor,
|
|||||||
GimpBrushEditor *brush_editor;
|
GimpBrushEditor *brush_editor;
|
||||||
gdouble radius = 0.0;
|
gdouble radius = 0.0;
|
||||||
gdouble hardness = 0.0;
|
gdouble hardness = 0.0;
|
||||||
gdouble angle = 0.0;
|
|
||||||
gdouble ratio = 0.0;
|
gdouble ratio = 0.0;
|
||||||
|
gdouble angle = 0.0;
|
||||||
|
|
||||||
brush_editor = GIMP_BRUSH_EDITOR (editor);
|
brush_editor = GIMP_BRUSH_EDITOR (editor);
|
||||||
|
|
||||||
@ -195,9 +193,7 @@ gimp_brush_editor_set_data (GimpDataEditor *editor,
|
|||||||
gimp_preview_set_viewable (GIMP_PREVIEW (brush_editor->preview),
|
gimp_preview_set_viewable (GIMP_PREVIEW (brush_editor->preview),
|
||||||
(GimpViewable *) data);
|
(GimpViewable *) data);
|
||||||
|
|
||||||
if (editor->data)
|
if (editor->data && GIMP_IS_BRUSH_GENERATED (editor->data))
|
||||||
{
|
|
||||||
if (GIMP_IS_BRUSH_GENERATED (editor->data))
|
|
||||||
{
|
{
|
||||||
GimpBrushGenerated *brush;
|
GimpBrushGenerated *brush;
|
||||||
|
|
||||||
@ -205,15 +201,11 @@ gimp_brush_editor_set_data (GimpDataEditor *editor,
|
|||||||
|
|
||||||
radius = gimp_brush_generated_get_radius (brush);
|
radius = gimp_brush_generated_get_radius (brush);
|
||||||
hardness = gimp_brush_generated_get_hardness (brush);
|
hardness = gimp_brush_generated_get_hardness (brush);
|
||||||
angle = gimp_brush_generated_get_angle (brush);
|
|
||||||
ratio = gimp_brush_generated_get_aspect_ratio (brush);
|
ratio = gimp_brush_generated_get_aspect_ratio (brush);
|
||||||
|
angle = gimp_brush_generated_get_angle (brush);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (brush_editor->options_table, TRUE);
|
gtk_widget_set_sensitive (brush_editor->options_table,
|
||||||
}
|
editor->data_editable);
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (brush_editor->options_table, FALSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -222,8 +214,8 @@ gimp_brush_editor_set_data (GimpDataEditor *editor,
|
|||||||
|
|
||||||
gtk_adjustment_set_value (brush_editor->radius_data, radius);
|
gtk_adjustment_set_value (brush_editor->radius_data, radius);
|
||||||
gtk_adjustment_set_value (brush_editor->hardness_data, hardness);
|
gtk_adjustment_set_value (brush_editor->hardness_data, hardness);
|
||||||
gtk_adjustment_set_value (brush_editor->angle_data, angle);
|
|
||||||
gtk_adjustment_set_value (brush_editor->aspect_ratio_data, ratio);
|
gtk_adjustment_set_value (brush_editor->aspect_ratio_data, ratio);
|
||||||
|
gtk_adjustment_set_value (brush_editor->angle_data, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -256,43 +248,33 @@ gimp_brush_editor_update_brush (GtkAdjustment *adjustment,
|
|||||||
GimpBrushEditor *editor)
|
GimpBrushEditor *editor)
|
||||||
{
|
{
|
||||||
GimpBrushGenerated *brush;
|
GimpBrushGenerated *brush;
|
||||||
|
gdouble radius;
|
||||||
|
gdouble hardness;
|
||||||
|
gdouble ratio;
|
||||||
|
gdouble angle;
|
||||||
|
|
||||||
if (! GIMP_IS_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data))
|
if (! GIMP_IS_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
brush = GIMP_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data);
|
brush = GIMP_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
if (((editor->radius_data->value
|
radius = editor->radius_data->value;
|
||||||
!= gimp_brush_generated_get_radius (brush))
|
hardness = editor->hardness_data->value;
|
||||||
|| (editor->hardness_data->value
|
ratio = editor->aspect_ratio_data->value;
|
||||||
!= gimp_brush_generated_get_hardness (brush))
|
angle = editor->angle_data->value;
|
||||||
|| (editor->aspect_ratio_data->value
|
|
||||||
!= gimp_brush_generated_get_aspect_ratio (brush))
|
if (angle != gimp_brush_generated_get_radius (brush) ||
|
||||||
|| (editor->angle_data->value
|
hardness != gimp_brush_generated_get_hardness (brush) ||
|
||||||
!= gimp_brush_generated_get_angle (brush))))
|
ratio != gimp_brush_generated_get_aspect_ratio (brush) ||
|
||||||
|
angle != gimp_brush_generated_get_angle (brush))
|
||||||
{
|
{
|
||||||
gimp_brush_generated_freeze (brush);
|
gimp_brush_generated_freeze (brush);
|
||||||
|
|
||||||
gimp_brush_generated_set_radius (brush,
|
gimp_brush_generated_set_radius (brush, radius);
|
||||||
editor->radius_data->value);
|
gimp_brush_generated_set_hardness (brush, hardness);
|
||||||
gimp_brush_generated_set_hardness (brush,
|
gimp_brush_generated_set_aspect_ratio (brush, ratio);
|
||||||
editor->hardness_data->value);
|
gimp_brush_generated_set_angle (brush, angle);
|
||||||
gimp_brush_generated_set_aspect_ratio (brush,
|
|
||||||
editor->aspect_ratio_data->value);
|
|
||||||
gimp_brush_generated_set_angle (brush,
|
|
||||||
editor->angle_data->value);
|
|
||||||
|
|
||||||
gimp_brush_generated_thaw (brush);
|
gimp_brush_generated_thaw (brush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_brush_editor_preview_resize (GtkWidget *widget,
|
|
||||||
GtkAllocation *allocation,
|
|
||||||
GimpBrushEditor *editor)
|
|
||||||
{
|
|
||||||
gimp_preview_set_size_full (GIMP_PREVIEW (editor->preview),
|
|
||||||
allocation->width - 2 * widget->style->xthickness,
|
|
||||||
allocation->height - 2 * widget->style->ythickness,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
@ -111,6 +111,7 @@ gimp_data_editor_init (GimpDataEditor *editor)
|
|||||||
{
|
{
|
||||||
editor->data_type = G_TYPE_NONE;
|
editor->data_type = G_TYPE_NONE;
|
||||||
editor->data = NULL;
|
editor->data = NULL;
|
||||||
|
editor->data_editable = FALSE;
|
||||||
editor->item_factory = NULL;
|
editor->item_factory = NULL;
|
||||||
|
|
||||||
editor->name_entry = gtk_entry_new ();
|
editor->name_entry = gtk_entry_new ();
|
||||||
@ -192,10 +193,11 @@ gimp_data_editor_real_set_data (GimpDataEditor *editor,
|
|||||||
gtk_entry_set_text (GTK_ENTRY (editor->name_entry), "");
|
gtk_entry_set_text (GTK_ENTRY (editor->name_entry), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editor->data && ! editor->data->internal)
|
editor->data_editable = (editor->data &&
|
||||||
gtk_widget_set_sensitive (editor->name_entry, TRUE);
|
editor->data->writeable &&
|
||||||
else
|
! editor->data->internal);
|
||||||
gtk_widget_set_sensitive (editor->name_entry, FALSE);
|
|
||||||
|
gtk_widget_set_sensitive (editor->name_entry, editor->data_editable);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -44,6 +44,7 @@ struct _GimpDataEditor
|
|||||||
|
|
||||||
GType data_type;
|
GType data_type;
|
||||||
GimpData *data;
|
GimpData *data;
|
||||||
|
gboolean data_editable;
|
||||||
|
|
||||||
GimpItemFactory *item_factory;
|
GimpItemFactory *item_factory;
|
||||||
|
|
||||||
|
@ -51,11 +51,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#warning GTK_DISABLE_DEPRECATED
|
|
||||||
#endif
|
|
||||||
#undef GTK_DISABLE_DEPRECATED
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "libgimpcolor/gimpcolor.h"
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
@ -74,6 +69,8 @@
|
|||||||
#include "gimpdnd.h"
|
#include "gimpdnd.h"
|
||||||
#include "gimpgradienteditor.h"
|
#include "gimpgradienteditor.h"
|
||||||
#include "gimpitemfactory.h"
|
#include "gimpitemfactory.h"
|
||||||
|
#include "gimppreview.h"
|
||||||
|
#include "gimppreviewrenderergradient.h"
|
||||||
#include "gimpwidgets-utils.h"
|
#include "gimpwidgets-utils.h"
|
||||||
|
|
||||||
#include "gui/color-notebook.h"
|
#include "gui/color-notebook.h"
|
||||||
@ -86,8 +83,8 @@
|
|||||||
#define GRAD_SCROLLBAR_STEP_SIZE 0.05
|
#define GRAD_SCROLLBAR_STEP_SIZE 0.05
|
||||||
#define GRAD_SCROLLBAR_PAGE_SIZE 0.75
|
#define GRAD_SCROLLBAR_PAGE_SIZE 0.75
|
||||||
|
|
||||||
#define GRAD_PREVIEW_WIDTH 600
|
#define GRAD_PREVIEW_WIDTH 128
|
||||||
#define GRAD_PREVIEW_HEIGHT 64
|
#define GRAD_PREVIEW_HEIGHT 96
|
||||||
#define GRAD_CONTROL_HEIGHT 10
|
#define GRAD_CONTROL_HEIGHT 10
|
||||||
|
|
||||||
#define GRAD_MOVE_TIME 150 /* ms between mouse click and detection of movement in gradient control */
|
#define GRAD_MOVE_TIME 150 /* ms between mouse click and detection of movement in gradient control */
|
||||||
@ -150,14 +147,6 @@ static void preview_set_foreground (GimpGradientEditor *editor,
|
|||||||
static void preview_set_background (GimpGradientEditor *editor,
|
static void preview_set_background (GimpGradientEditor *editor,
|
||||||
gint x);
|
gint x);
|
||||||
|
|
||||||
static void preview_update (GimpGradientEditor *editor,
|
|
||||||
gboolean recalculate);
|
|
||||||
static void preview_fill_image (GimpGradientEditor *editor,
|
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
gdouble left,
|
|
||||||
gdouble right);
|
|
||||||
|
|
||||||
/* Gradient control functions */
|
/* Gradient control functions */
|
||||||
|
|
||||||
static gint control_events (GtkWidget *widget,
|
static gint control_events (GtkWidget *widget,
|
||||||
@ -301,22 +290,20 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
|
|||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
/* Gradient preview */
|
/* Gradient preview */
|
||||||
editor->preview_rows[0] = NULL;
|
|
||||||
editor->preview_rows[1] = NULL;
|
|
||||||
editor->preview_last_x = 0;
|
editor->preview_last_x = 0;
|
||||||
editor->preview_button_down = FALSE;
|
editor->preview_button_down = FALSE;
|
||||||
|
|
||||||
editor->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
editor->preview = gimp_preview_new_full_by_types (GIMP_TYPE_PREVIEW,
|
||||||
gtk_preview_set_dither (GTK_PREVIEW (editor->preview), GDK_RGB_DITHER_MAX);
|
GIMP_TYPE_GRADIENT,
|
||||||
gtk_preview_size (GTK_PREVIEW (editor->preview),
|
GRAD_PREVIEW_WIDTH,
|
||||||
GRAD_PREVIEW_WIDTH, GRAD_PREVIEW_HEIGHT);
|
GRAD_PREVIEW_HEIGHT, 0,
|
||||||
|
FALSE, FALSE, FALSE);
|
||||||
/* Enable auto-resizing of the preview but ensure a minimal size */
|
|
||||||
gtk_widget_set_size_request (editor->preview,
|
gtk_widget_set_size_request (editor->preview,
|
||||||
GRAD_PREVIEW_WIDTH, GRAD_PREVIEW_HEIGHT);
|
GRAD_PREVIEW_WIDTH, GRAD_PREVIEW_HEIGHT);
|
||||||
gtk_preview_set_expand (GTK_PREVIEW (editor->preview), TRUE);
|
|
||||||
|
|
||||||
gtk_widget_set_events (editor->preview, GRAD_PREVIEW_EVENT_MASK);
|
gtk_widget_set_events (editor->preview, GRAD_PREVIEW_EVENT_MASK);
|
||||||
|
gimp_preview_set_expand (GIMP_PREVIEW (editor->preview), TRUE);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), editor->preview, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show (editor->preview);
|
||||||
|
|
||||||
g_signal_connect (editor->preview, "event",
|
g_signal_connect (editor->preview, "event",
|
||||||
G_CALLBACK (preview_events),
|
G_CALLBACK (preview_events),
|
||||||
@ -327,9 +314,6 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
|
|||||||
gradient_editor_drop_gradient,
|
gradient_editor_drop_gradient,
|
||||||
editor);
|
editor);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), editor->preview, TRUE, TRUE, 0);
|
|
||||||
gtk_widget_show (editor->preview);
|
|
||||||
|
|
||||||
/* Gradient control */
|
/* Gradient control */
|
||||||
editor->control_pixmap = NULL;
|
editor->control_pixmap = NULL;
|
||||||
editor->control_drag_segment = NULL;
|
editor->control_drag_segment = NULL;
|
||||||
@ -405,7 +389,8 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
|
|||||||
editor->instant_update = TRUE;
|
editor->instant_update = TRUE;
|
||||||
|
|
||||||
button = gtk_check_button_new_with_label (_("Instant update"));
|
button = gtk_check_button_new_with_label (_("Instant update"));
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
||||||
|
editor->instant_update);
|
||||||
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (button);
|
gtk_widget_show (button);
|
||||||
|
|
||||||
@ -436,55 +421,19 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
|
|||||||
editor->right_saved_segments = NULL;
|
editor->right_saved_segments = NULL;
|
||||||
editor->right_saved_dirty = FALSE;
|
editor->right_saved_dirty = FALSE;
|
||||||
|
|
||||||
editor->saved_colors[0].r = 0.0; /* Black */
|
/* Black, 50% Gray, White, Clear */
|
||||||
editor->saved_colors[0].g = 0.0;
|
gimp_rgba_set (&editor->saved_colors[0], 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||||
editor->saved_colors[0].b = 0.0;
|
gimp_rgba_set (&editor->saved_colors[1], 0.5, 0.5, 0.5, GIMP_OPACITY_OPAQUE);
|
||||||
editor->saved_colors[0].a = GIMP_OPACITY_OPAQUE;
|
gimp_rgba_set (&editor->saved_colors[2], 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
|
||||||
|
gimp_rgba_set (&editor->saved_colors[3], 0.0, 0.0, 0.0, GIMP_OPACITY_TRANSPARENT);
|
||||||
|
|
||||||
editor->saved_colors[1].r = 0.5; /* 50% Gray */
|
/* Red, Yellow, Green, Cyan, Blue, Magenta */
|
||||||
editor->saved_colors[1].g = 0.5;
|
gimp_rgba_set (&editor->saved_colors[4], 1.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||||
editor->saved_colors[1].b = 0.5;
|
gimp_rgba_set (&editor->saved_colors[5], 1.0, 1.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||||
editor->saved_colors[1].a = GIMP_OPACITY_OPAQUE;
|
gimp_rgba_set (&editor->saved_colors[6], 0.0, 1.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||||
|
gimp_rgba_set (&editor->saved_colors[7], 0.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
|
||||||
editor->saved_colors[2].r = 1.0; /* White */
|
gimp_rgba_set (&editor->saved_colors[8], 0.0, 0.0, 1.0, GIMP_OPACITY_OPAQUE);
|
||||||
editor->saved_colors[2].g = 1.0;
|
gimp_rgba_set (&editor->saved_colors[9], 1.0, 0.0, 1.0, GIMP_OPACITY_OPAQUE);
|
||||||
editor->saved_colors[2].b = 1.0;
|
|
||||||
editor->saved_colors[2].a = GIMP_OPACITY_OPAQUE;
|
|
||||||
|
|
||||||
editor->saved_colors[3].r = 0.0; /* Clear */
|
|
||||||
editor->saved_colors[3].g = 0.0;
|
|
||||||
editor->saved_colors[3].b = 0.0;
|
|
||||||
editor->saved_colors[3].a = GIMP_OPACITY_TRANSPARENT;
|
|
||||||
|
|
||||||
editor->saved_colors[4].r = 1.0; /* Red */
|
|
||||||
editor->saved_colors[4].g = 0.0;
|
|
||||||
editor->saved_colors[4].b = 0.0;
|
|
||||||
editor->saved_colors[4].a = GIMP_OPACITY_OPAQUE;
|
|
||||||
|
|
||||||
editor->saved_colors[5].r = 1.0; /* Yellow */
|
|
||||||
editor->saved_colors[5].g = 1.0;
|
|
||||||
editor->saved_colors[5].b = 0.0;
|
|
||||||
editor->saved_colors[5].a = GIMP_OPACITY_OPAQUE;
|
|
||||||
|
|
||||||
editor->saved_colors[6].r = 0.0; /* Green */
|
|
||||||
editor->saved_colors[6].g = 1.0;
|
|
||||||
editor->saved_colors[6].b = 0.0;
|
|
||||||
editor->saved_colors[6].a = GIMP_OPACITY_OPAQUE;
|
|
||||||
|
|
||||||
editor->saved_colors[7].r = 0.0; /* Cyan */
|
|
||||||
editor->saved_colors[7].g = 1.0;
|
|
||||||
editor->saved_colors[7].b = 1.0;
|
|
||||||
editor->saved_colors[7].a = GIMP_OPACITY_OPAQUE;
|
|
||||||
|
|
||||||
editor->saved_colors[8].r = 0.0; /* Blue */
|
|
||||||
editor->saved_colors[8].g = 0.0;
|
|
||||||
editor->saved_colors[8].b = 1.0;
|
|
||||||
editor->saved_colors[8].a = GIMP_OPACITY_OPAQUE;
|
|
||||||
|
|
||||||
editor->saved_colors[9].r = 1.0; /* Magenta */
|
|
||||||
editor->saved_colors[9].g = 0.0;
|
|
||||||
editor->saved_colors[9].b = 1.0;
|
|
||||||
editor->saved_colors[9].a = GIMP_OPACITY_OPAQUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -497,23 +446,19 @@ gimp_gradient_editor_set_data (GimpDataEditor *editor,
|
|||||||
|
|
||||||
GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data);
|
GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data);
|
||||||
|
|
||||||
if (editor->data)
|
gimp_preview_set_viewable (GIMP_PREVIEW (gradient_editor->preview),
|
||||||
{
|
(GimpViewable *) data);
|
||||||
|
|
||||||
if (gradient_editor->color_notebook)
|
if (gradient_editor->color_notebook)
|
||||||
{
|
{
|
||||||
color_notebook_free (gradient_editor->color_notebook);
|
color_notebook_free (gradient_editor->color_notebook);
|
||||||
gradient_editor->color_notebook = NULL;
|
gradient_editor->color_notebook = NULL;
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (data && data->writeable && !data->internal)
|
gtk_widget_set_sensitive (gradient_editor->control, editor->data_editable);
|
||||||
gtk_widget_set_sensitive (gradient_editor->control, TRUE);
|
|
||||||
else
|
|
||||||
gtk_widget_set_sensitive (gradient_editor->control, FALSE);
|
|
||||||
|
|
||||||
gimp_gradient_editor_update (gradient_editor,
|
control_update (gradient_editor, (GimpGradient *) data, TRUE);
|
||||||
GRAD_UPDATE_PREVIEW | GRAD_RESET_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -540,27 +485,16 @@ gimp_gradient_editor_new (Gimp *gimp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_gradient_editor_update (GimpGradientEditor *editor,
|
gimp_gradient_editor_update (GimpGradientEditor *editor)
|
||||||
GradientEditorUpdateMask flags)
|
|
||||||
{
|
{
|
||||||
if (GIMP_DATA_EDITOR (editor)->data)
|
GimpGradient *gradient = NULL;
|
||||||
{
|
|
||||||
GimpGradient *gradient;
|
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_GRADIENT_EDITOR (editor));
|
||||||
|
|
||||||
|
if (GIMP_DATA_EDITOR (editor)->data)
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
if (flags & GRAD_UPDATE_GRADIENT)
|
|
||||||
preview_update (editor, TRUE);
|
|
||||||
|
|
||||||
if (flags & GRAD_UPDATE_PREVIEW)
|
|
||||||
preview_update (editor, TRUE);
|
|
||||||
|
|
||||||
if (flags & GRAD_UPDATE_CONTROL)
|
|
||||||
control_update (editor, gradient, FALSE);
|
control_update (editor, gradient, FALSE);
|
||||||
|
|
||||||
if (flags & GRAD_RESET_CONTROL)
|
|
||||||
control_update (editor, gradient, TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -578,6 +512,7 @@ static void
|
|||||||
gradient_editor_scrollbar_update (GtkAdjustment *adjustment,
|
gradient_editor_scrollbar_update (GtkAdjustment *adjustment,
|
||||||
GimpGradientEditor *editor)
|
GimpGradientEditor *editor)
|
||||||
{
|
{
|
||||||
|
GimpPreviewRendererGradient *renderer;
|
||||||
gchar *str1;
|
gchar *str1;
|
||||||
gchar *str2;
|
gchar *str2;
|
||||||
|
|
||||||
@ -593,8 +528,14 @@ gradient_editor_scrollbar_update (GtkAdjustment *adjustment,
|
|||||||
g_free (str1);
|
g_free (str1);
|
||||||
g_free (str2);
|
g_free (str2);
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor,
|
renderer = GIMP_PREVIEW_RENDERER_GRADIENT (GIMP_PREVIEW (editor->preview)->renderer);
|
||||||
GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL);
|
|
||||||
|
gimp_preview_renderer_gradient_set_offsets (renderer,
|
||||||
|
adjustment->value,
|
||||||
|
adjustment->value +
|
||||||
|
adjustment->page_size,
|
||||||
|
editor->instant_update);
|
||||||
|
gimp_gradient_editor_update (editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -724,10 +665,6 @@ preview_events (GtkWidget *widget,
|
|||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case GDK_EXPOSE:
|
|
||||||
preview_update (editor, FALSE);
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
case GDK_LEAVE_NOTIFY:
|
case GDK_LEAVE_NOTIFY:
|
||||||
gradient_editor_set_hint (editor, "", "", "");
|
gradient_editor_set_hint (editor, "", "", "");
|
||||||
break;
|
break;
|
||||||
@ -772,11 +709,9 @@ preview_events (GtkWidget *widget,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (! GIMP_DATA_EDITOR (editor)->data->internal)
|
if (GIMP_DATA_EDITOR (editor)->data_editable)
|
||||||
{
|
|
||||||
gimp_item_factory_popup_with_data (GIMP_DATA_EDITOR (editor)->item_factory,
|
gimp_item_factory_popup_with_data (GIMP_DATA_EDITOR (editor)->item_factory,
|
||||||
editor, NULL);
|
editor, NULL);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -826,7 +761,7 @@ preview_events (GtkWidget *widget,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -937,125 +872,6 @@ preview_set_background (GimpGradientEditor *editor,
|
|||||||
g_free (str3);
|
g_free (str3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****/
|
|
||||||
|
|
||||||
static void
|
|
||||||
preview_update (GimpGradientEditor *editor,
|
|
||||||
gboolean recalculate)
|
|
||||||
{
|
|
||||||
glong rowsiz;
|
|
||||||
GtkAdjustment *adjustment;
|
|
||||||
guint16 width;
|
|
||||||
guint16 height;
|
|
||||||
|
|
||||||
static guint16 last_width = 0;
|
|
||||||
static guint16 last_height = 0;
|
|
||||||
|
|
||||||
if (! GTK_WIDGET_DRAWABLE (editor->preview))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* See whether we have to re-create the preview widget
|
|
||||||
* (note that the preview automatically follows the size of it's container)
|
|
||||||
*/
|
|
||||||
width = editor->preview->allocation.width;
|
|
||||||
height = editor->preview->allocation.height;
|
|
||||||
|
|
||||||
if (! editor->preview_rows[0] ||
|
|
||||||
! editor->preview_rows[1] ||
|
|
||||||
(width != last_width) ||
|
|
||||||
(height != last_height))
|
|
||||||
{
|
|
||||||
if (editor->preview_rows[0])
|
|
||||||
g_free (editor->preview_rows[0]);
|
|
||||||
|
|
||||||
if (editor->preview_rows[1])
|
|
||||||
g_free (editor->preview_rows[1]);
|
|
||||||
|
|
||||||
rowsiz = width * 3 * sizeof (guchar);
|
|
||||||
|
|
||||||
editor->preview_rows[0] = g_malloc (rowsiz);
|
|
||||||
editor->preview_rows[1] = g_malloc (rowsiz);
|
|
||||||
|
|
||||||
recalculate = TRUE; /* Force recalculation */
|
|
||||||
}
|
|
||||||
|
|
||||||
last_width = width;
|
|
||||||
last_height = height;
|
|
||||||
|
|
||||||
/* Have to redraw? */
|
|
||||||
if (recalculate)
|
|
||||||
{
|
|
||||||
adjustment = GTK_ADJUSTMENT (editor->scroll_data);
|
|
||||||
|
|
||||||
preview_fill_image (editor,
|
|
||||||
width, height,
|
|
||||||
adjustment->value,
|
|
||||||
adjustment->value + adjustment->page_size);
|
|
||||||
|
|
||||||
gtk_widget_queue_draw (editor->preview);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
preview_fill_image (GimpGradientEditor *editor,
|
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
gdouble left,
|
|
||||||
gdouble right)
|
|
||||||
{
|
|
||||||
GimpGradient *gradient;
|
|
||||||
guchar *p0, *p1;
|
|
||||||
gint x, y;
|
|
||||||
gdouble dx, cur_x;
|
|
||||||
GimpRGB color;
|
|
||||||
gdouble c0, c1;
|
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
|
||||||
|
|
||||||
dx = (right - left) / (width - 1);
|
|
||||||
cur_x = left;
|
|
||||||
p0 = editor->preview_rows[0];
|
|
||||||
p1 = editor->preview_rows[1];
|
|
||||||
|
|
||||||
/* Create lines to fill the image */
|
|
||||||
for (x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
gimp_gradient_get_color_at (gradient, cur_x, &color);
|
|
||||||
|
|
||||||
if ((x / GIMP_CHECK_SIZE) & 1)
|
|
||||||
{
|
|
||||||
c0 = GIMP_CHECK_LIGHT;
|
|
||||||
c1 = GIMP_CHECK_DARK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c0 = GIMP_CHECK_DARK;
|
|
||||||
c1 = GIMP_CHECK_LIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
*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;
|
|
||||||
|
|
||||||
*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;
|
|
||||||
|
|
||||||
cur_x += dx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill image */
|
|
||||||
for (y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
if ((y / GIMP_CHECK_SIZE) & 1)
|
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (editor->preview),
|
|
||||||
editor->preview_rows[1], 0, y, width);
|
|
||||||
else
|
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (editor->preview),
|
|
||||||
editor->preview_rows[0], 0, y, width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Gradient control functions *****/
|
/***** Gradient control functions *****/
|
||||||
|
|
||||||
/* *** WARNING *** WARNING *** WARNING ***
|
/* *** WARNING *** WARNING *** WARNING ***
|
||||||
@ -1073,6 +889,7 @@ control_events (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
GdkEventButton *bevent;
|
GdkEventButton *bevent;
|
||||||
|
GdkEventScroll *sevent;
|
||||||
GimpGradientSegment *seg;
|
GimpGradientSegment *seg;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
guint32 time;
|
guint32 time;
|
||||||
@ -1110,6 +927,30 @@ control_events (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GDK_SCROLL:
|
||||||
|
sevent = (GdkEventScroll *) event;
|
||||||
|
|
||||||
|
if (sevent->state & GDK_SHIFT_MASK)
|
||||||
|
{
|
||||||
|
if (sevent->direction == GDK_SCROLL_UP)
|
||||||
|
gradient_editor_zoom_in_callback (NULL, editor);
|
||||||
|
else
|
||||||
|
gradient_editor_zoom_out_callback (NULL, editor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj = GTK_ADJUSTMENT (editor->scroll_data);
|
||||||
|
|
||||||
|
gfloat new_value = adj->value + ((sevent->direction == GDK_SCROLL_UP) ?
|
||||||
|
-adj->page_increment / 2 :
|
||||||
|
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 GDK_BUTTON_RELEASE:
|
case GDK_BUTTON_RELEASE:
|
||||||
gradient_editor_set_hint (editor, "", "", "");
|
gradient_editor_set_hint (editor, "", "", "");
|
||||||
|
|
||||||
@ -1125,9 +966,6 @@ control_events (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
if (! editor->instant_update)
|
if (! editor->instant_update)
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
/* Possible move */
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
|
|
||||||
}
|
}
|
||||||
else if ((editor->control_drag_mode == GRAD_DRAG_MIDDLE) ||
|
else if ((editor->control_drag_mode == GRAD_DRAG_MIDDLE) ||
|
||||||
(editor->control_drag_mode == GRAD_DRAG_ALL))
|
(editor->control_drag_mode == GRAD_DRAG_ALL))
|
||||||
@ -1142,7 +980,7 @@ control_events (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
control_select_single_segment (editor, seg);
|
control_select_single_segment (editor, seg);
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_CONTROL);
|
gimp_gradient_editor_update (editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
editor->control_drag_mode = GRAD_DRAG_NONE;
|
editor->control_drag_mode = GRAD_DRAG_NONE;
|
||||||
@ -1168,7 +1006,7 @@ control_events (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_CONTROL);
|
gimp_gradient_editor_update (editor);
|
||||||
|
|
||||||
control_do_hint (editor, x, y);
|
control_do_hint (editor, x, y);
|
||||||
}
|
}
|
||||||
@ -1305,43 +1143,14 @@ control_button_press (GimpGradientEditor *editor,
|
|||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
switch (button)
|
if (button == 3)
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
{
|
{
|
||||||
GimpItemFactory *factory;
|
GimpItemFactory *factory;
|
||||||
|
|
||||||
factory = GIMP_DATA_EDITOR (editor)->item_factory;
|
factory = GIMP_DATA_EDITOR (editor)->item_factory;
|
||||||
|
|
||||||
gimp_item_factory_popup_with_data (factory, editor, NULL);
|
gimp_item_factory_popup_with_data (factory, editor, NULL);
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* wheelmouse support */
|
|
||||||
case 4:
|
|
||||||
{
|
|
||||||
GtkAdjustment *adj = GTK_ADJUSTMENT (editor->scroll_data);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
{
|
|
||||||
GtkAdjustment *adj = GTK_ADJUSTMENT (editor->scroll_data);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1351,8 +1160,7 @@ control_button_press (GimpGradientEditor *editor,
|
|||||||
|
|
||||||
seg_get_closest_handle (gradient, xpos, &seg, &handle);
|
seg_get_closest_handle (gradient, xpos, &seg, &handle);
|
||||||
|
|
||||||
in_handle = control_point_in_handle (editor, gradient,
|
in_handle = control_point_in_handle (editor, gradient, x, y, seg, handle);
|
||||||
x, y, seg, handle);
|
|
||||||
|
|
||||||
/* Now see what we have */
|
/* Now see what we have */
|
||||||
|
|
||||||
@ -1375,7 +1183,7 @@ control_button_press (GimpGradientEditor *editor,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
control_extend_selection (editor, seg, xpos);
|
control_extend_selection (editor, seg, xpos);
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_CONTROL);
|
gimp_gradient_editor_update (editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (seg->prev != NULL)
|
else if (seg->prev != NULL)
|
||||||
@ -1386,7 +1194,7 @@ control_button_press (GimpGradientEditor *editor,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
control_select_single_segment (editor, seg);
|
control_select_single_segment (editor, seg);
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_CONTROL);
|
gimp_gradient_editor_update (editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1399,12 +1207,12 @@ control_button_press (GimpGradientEditor *editor,
|
|||||||
if (state & GDK_SHIFT_MASK)
|
if (state & GDK_SHIFT_MASK)
|
||||||
{
|
{
|
||||||
control_extend_selection (editor, seg, xpos);
|
control_extend_selection (editor, seg, xpos);
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_CONTROL);
|
gimp_gradient_editor_update (editor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
control_select_single_segment (editor, seg);
|
control_select_single_segment (editor, seg);
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_CONTROL);
|
gimp_gradient_editor_update (editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1416,7 +1224,7 @@ control_button_press (GimpGradientEditor *editor,
|
|||||||
if (state & GDK_SHIFT_MASK)
|
if (state & GDK_SHIFT_MASK)
|
||||||
{
|
{
|
||||||
control_extend_selection (editor, seg, xpos);
|
control_extend_selection (editor, seg, xpos);
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_CONTROL);
|
gimp_gradient_editor_update (editor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1586,16 +1394,9 @@ control_motion (GimpGradientEditor *editor,
|
|||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
if (editor->instant_update)
|
if (editor->instant_update)
|
||||||
{
|
|
||||||
gimp_data_dirty (GIMP_DATA (gradient));
|
gimp_data_dirty (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_editor_update (editor,
|
gimp_gradient_editor_update (editor);
|
||||||
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gimp_gradient_editor_update (editor, GRAD_UPDATE_CONTROL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1831,7 +1632,7 @@ control_move (GimpGradientEditor *editor,
|
|||||||
static void
|
static void
|
||||||
control_update (GimpGradientEditor *editor,
|
control_update (GimpGradientEditor *editor,
|
||||||
GimpGradient *gradient,
|
GimpGradient *gradient,
|
||||||
gboolean recalculate)
|
gboolean reset_selection)
|
||||||
{
|
{
|
||||||
GtkAdjustment *adjustment;
|
GtkAdjustment *adjustment;
|
||||||
gint cwidth, cheight;
|
gint cwidth, cheight;
|
||||||
@ -1858,11 +1659,10 @@ control_update (GimpGradientEditor *editor,
|
|||||||
editor->control_pixmap =
|
editor->control_pixmap =
|
||||||
gdk_pixmap_new (editor->control->window, cwidth, cheight, -1);
|
gdk_pixmap_new (editor->control->window, cwidth, cheight, -1);
|
||||||
|
|
||||||
recalculate = TRUE;
|
reset_selection = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Have to reset the selection? */
|
if (reset_selection && gradient)
|
||||||
if (recalculate)
|
|
||||||
control_select_single_segment (editor, gradient->segments);
|
control_select_single_segment (editor, gradient->segments);
|
||||||
|
|
||||||
/* Redraw pixmap */
|
/* Redraw pixmap */
|
||||||
@ -1901,6 +1701,9 @@ control_draw (GimpGradientEditor *editor,
|
|||||||
gdk_draw_rectangle (pixmap, editor->control->style->bg_gc[GTK_STATE_NORMAL],
|
gdk_draw_rectangle (pixmap, editor->control->style->bg_gc[GTK_STATE_NORMAL],
|
||||||
TRUE, 0, 0, width, height);
|
TRUE, 0, 0, width, height);
|
||||||
|
|
||||||
|
if (! gradient)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Draw selection */
|
/* Draw selection */
|
||||||
|
|
||||||
sel_l = control_calc_p_pos (editor,
|
sel_l = control_calc_p_pos (editor,
|
||||||
|
@ -39,14 +39,6 @@ typedef enum
|
|||||||
GRAD_DRAG_ALL
|
GRAD_DRAG_ALL
|
||||||
} GradientEditorDragMode;
|
} GradientEditorDragMode;
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GRAD_UPDATE_GRADIENT = 1 << 0,
|
|
||||||
GRAD_UPDATE_PREVIEW = 1 << 1,
|
|
||||||
GRAD_UPDATE_CONTROL = 1 << 2,
|
|
||||||
GRAD_RESET_CONTROL = 1 << 3
|
|
||||||
} GradientEditorUpdateMask;
|
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_GRADIENT_EDITOR (gimp_gradient_editor_get_type ())
|
#define GIMP_TYPE_GRADIENT_EDITOR (gimp_gradient_editor_get_type ())
|
||||||
#define GIMP_GRADIENT_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_GRADIENT_EDITOR, GimpGradientEditor))
|
#define GIMP_GRADIENT_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_GRADIENT_EDITOR, GimpGradientEditor))
|
||||||
@ -80,7 +72,6 @@ struct _GimpGradientEditor
|
|||||||
ColorNotebook *color_notebook;
|
ColorNotebook *color_notebook;
|
||||||
|
|
||||||
/* Gradient preview */
|
/* Gradient preview */
|
||||||
guchar *preview_rows[2]; /* For caching redraw info */
|
|
||||||
gint preview_last_x;
|
gint preview_last_x;
|
||||||
gboolean preview_button_down;
|
gboolean preview_button_down;
|
||||||
|
|
||||||
@ -124,8 +115,7 @@ GType gimp_gradient_editor_get_type (void) G_GNUC_CONST;
|
|||||||
GimpDataEditor * gimp_gradient_editor_new (Gimp *gimp,
|
GimpDataEditor * gimp_gradient_editor_new (Gimp *gimp,
|
||||||
GimpMenuFactory *menu_factory);
|
GimpMenuFactory *menu_factory);
|
||||||
|
|
||||||
void gimp_gradient_editor_update (GimpGradientEditor *editor,
|
void gimp_gradient_editor_update (GimpGradientEditor *editor);
|
||||||
GradientEditorUpdateMask flags);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_GRADIENT_EDITOR_H__ */
|
#endif /* __GIMP_GRADIENT_EDITOR_H__ */
|
||||||
|
@ -55,6 +55,8 @@ static void gimp_navigation_preview_init (GimpNavigationPreview *pr
|
|||||||
|
|
||||||
static void gimp_navigation_preview_destroy (GtkObject *object);
|
static void gimp_navigation_preview_destroy (GtkObject *object);
|
||||||
static void gimp_navigation_preview_realize (GtkWidget *widget);
|
static void gimp_navigation_preview_realize (GtkWidget *widget);
|
||||||
|
static void gimp_navigation_preview_size_allocate (GtkWidget *widget,
|
||||||
|
GtkAllocation *allocation);
|
||||||
static gboolean gimp_navigation_preview_expose (GtkWidget *widget,
|
static gboolean gimp_navigation_preview_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *eevent);
|
GdkEventExpose *eevent);
|
||||||
static gboolean gimp_navigation_preview_button_press (GtkWidget *widget,
|
static gboolean gimp_navigation_preview_button_press (GtkWidget *widget,
|
||||||
@ -67,6 +69,8 @@ static gboolean gimp_navigation_preview_motion_notify (GtkWidget *wi
|
|||||||
GdkEventMotion *mevent);
|
GdkEventMotion *mevent);
|
||||||
static gboolean gimp_navigation_preview_key_press (GtkWidget *widget,
|
static gboolean gimp_navigation_preview_key_press (GtkWidget *widget,
|
||||||
GdkEventKey *kevent);
|
GdkEventKey *kevent);
|
||||||
|
|
||||||
|
static void gimp_navigation_preview_transform (GimpNavigationPreview *nav_preview);
|
||||||
static void gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
static void gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||||
GdkRectangle *area);
|
GdkRectangle *area);
|
||||||
|
|
||||||
@ -149,6 +153,7 @@ gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass)
|
|||||||
object_class->destroy = gimp_navigation_preview_destroy;
|
object_class->destroy = gimp_navigation_preview_destroy;
|
||||||
|
|
||||||
widget_class->realize = gimp_navigation_preview_realize;
|
widget_class->realize = gimp_navigation_preview_realize;
|
||||||
|
widget_class->size_allocate = gimp_navigation_preview_size_allocate;
|
||||||
widget_class->expose_event = gimp_navigation_preview_expose;
|
widget_class->expose_event = gimp_navigation_preview_expose;
|
||||||
widget_class->button_press_event = gimp_navigation_preview_button_press;
|
widget_class->button_press_event = gimp_navigation_preview_button_press;
|
||||||
widget_class->button_release_event = gimp_navigation_preview_button_release;
|
widget_class->button_release_event = gimp_navigation_preview_button_release;
|
||||||
@ -216,6 +221,17 @@ gimp_navigation_preview_realize (GtkWidget *widget)
|
|||||||
GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_ROUND);
|
GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_navigation_preview_size_allocate (GtkWidget *widget,
|
||||||
|
GtkAllocation *allocation)
|
||||||
|
{
|
||||||
|
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
|
||||||
|
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
||||||
|
|
||||||
|
if (GIMP_PREVIEW (widget)->renderer->viewable)
|
||||||
|
gimp_navigation_preview_transform (GIMP_NAVIGATION_PREVIEW (widget));
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gimp_navigation_preview_expose (GtkWidget *widget,
|
gimp_navigation_preview_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *eevent)
|
GdkEventExpose *eevent)
|
||||||
@ -507,6 +523,27 @@ gimp_navigation_preview_key_press (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_navigation_preview_transform (GimpNavigationPreview *nav_preview)
|
||||||
|
{
|
||||||
|
GimpPreview *preview;
|
||||||
|
GimpImage *gimage;
|
||||||
|
gdouble ratiox, ratioy;
|
||||||
|
|
||||||
|
preview = GIMP_PREVIEW (nav_preview);
|
||||||
|
|
||||||
|
gimage = GIMP_IMAGE (preview->viewable);
|
||||||
|
|
||||||
|
ratiox = ((gdouble) preview->renderer->width / (gdouble) gimage->width);
|
||||||
|
ratioy = ((gdouble) preview->renderer->height / (gdouble) gimage->height);
|
||||||
|
|
||||||
|
nav_preview->p_x = RINT (nav_preview->x * ratiox);
|
||||||
|
nav_preview->p_y = RINT (nav_preview->y * ratioy);
|
||||||
|
|
||||||
|
nav_preview->p_width = RINT (nav_preview->width * ratiox);
|
||||||
|
nav_preview->p_height = RINT (nav_preview->height * ratioy);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||||
GdkRectangle *area)
|
GdkRectangle *area)
|
||||||
@ -544,25 +581,6 @@ gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gimp_navigation_preview_new (GimpImage *gimage,
|
|
||||||
gint size)
|
|
||||||
{
|
|
||||||
GtkWidget *preview;
|
|
||||||
|
|
||||||
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
|
|
||||||
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
|
|
||||||
|
|
||||||
preview = gimp_preview_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
|
|
||||||
GIMP_TYPE_IMAGE,
|
|
||||||
size, 0, TRUE);
|
|
||||||
|
|
||||||
if (gimage)
|
|
||||||
gimp_preview_set_viewable (GIMP_PREVIEW (preview), GIMP_VIEWABLE (gimage));
|
|
||||||
|
|
||||||
return preview;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
||||||
gint x,
|
gint x,
|
||||||
@ -572,7 +590,6 @@ gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
|||||||
{
|
{
|
||||||
GimpPreview *preview;
|
GimpPreview *preview;
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
gdouble ratiox, ratioy;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_NAVIGATION_PREVIEW (nav_preview));
|
g_return_if_fail (GIMP_IS_NAVIGATION_PREVIEW (nav_preview));
|
||||||
|
|
||||||
@ -598,15 +615,7 @@ gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
|||||||
nav_preview->width = CLAMP (width, 1, gimage->width - nav_preview->x);
|
nav_preview->width = CLAMP (width, 1, gimage->width - nav_preview->x);
|
||||||
nav_preview->height = CLAMP (height, 1, gimage->height - nav_preview->y);
|
nav_preview->height = CLAMP (height, 1, gimage->height - nav_preview->y);
|
||||||
|
|
||||||
/* transform to preview coordinates */
|
gimp_navigation_preview_transform (nav_preview);
|
||||||
ratiox = ((gdouble) preview->renderer->width / (gdouble) gimage->width);
|
|
||||||
ratioy = ((gdouble) preview->renderer->height / (gdouble) gimage->height);
|
|
||||||
|
|
||||||
nav_preview->p_x = RINT (nav_preview->x * ratiox);
|
|
||||||
nav_preview->p_y = RINT (nav_preview->y * ratioy);
|
|
||||||
|
|
||||||
nav_preview->p_width = RINT (nav_preview->width * ratiox);
|
|
||||||
nav_preview->p_height = RINT (nav_preview->height * ratioy);
|
|
||||||
|
|
||||||
/* draw new marker */
|
/* draw new marker */
|
||||||
if (GTK_WIDGET_DRAWABLE (preview))
|
if (GTK_WIDGET_DRAWABLE (preview))
|
||||||
|
@ -77,8 +77,6 @@ struct _GimpNavigationPreviewClass
|
|||||||
|
|
||||||
GType gimp_navigation_preview_get_type (void) G_GNUC_CONST;
|
GType gimp_navigation_preview_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget * gimp_navigation_preview_new (GimpImage *gimage,
|
|
||||||
gint size);
|
|
||||||
void gimp_navigation_preview_set_marker (GimpNavigationPreview *preview,
|
void gimp_navigation_preview_set_marker (GimpNavigationPreview *preview,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
|
@ -55,6 +55,8 @@ static void gimp_navigation_preview_init (GimpNavigationPreview *pr
|
|||||||
|
|
||||||
static void gimp_navigation_preview_destroy (GtkObject *object);
|
static void gimp_navigation_preview_destroy (GtkObject *object);
|
||||||
static void gimp_navigation_preview_realize (GtkWidget *widget);
|
static void gimp_navigation_preview_realize (GtkWidget *widget);
|
||||||
|
static void gimp_navigation_preview_size_allocate (GtkWidget *widget,
|
||||||
|
GtkAllocation *allocation);
|
||||||
static gboolean gimp_navigation_preview_expose (GtkWidget *widget,
|
static gboolean gimp_navigation_preview_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *eevent);
|
GdkEventExpose *eevent);
|
||||||
static gboolean gimp_navigation_preview_button_press (GtkWidget *widget,
|
static gboolean gimp_navigation_preview_button_press (GtkWidget *widget,
|
||||||
@ -67,6 +69,8 @@ static gboolean gimp_navigation_preview_motion_notify (GtkWidget *wi
|
|||||||
GdkEventMotion *mevent);
|
GdkEventMotion *mevent);
|
||||||
static gboolean gimp_navigation_preview_key_press (GtkWidget *widget,
|
static gboolean gimp_navigation_preview_key_press (GtkWidget *widget,
|
||||||
GdkEventKey *kevent);
|
GdkEventKey *kevent);
|
||||||
|
|
||||||
|
static void gimp_navigation_preview_transform (GimpNavigationPreview *nav_preview);
|
||||||
static void gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
static void gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||||
GdkRectangle *area);
|
GdkRectangle *area);
|
||||||
|
|
||||||
@ -149,6 +153,7 @@ gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass)
|
|||||||
object_class->destroy = gimp_navigation_preview_destroy;
|
object_class->destroy = gimp_navigation_preview_destroy;
|
||||||
|
|
||||||
widget_class->realize = gimp_navigation_preview_realize;
|
widget_class->realize = gimp_navigation_preview_realize;
|
||||||
|
widget_class->size_allocate = gimp_navigation_preview_size_allocate;
|
||||||
widget_class->expose_event = gimp_navigation_preview_expose;
|
widget_class->expose_event = gimp_navigation_preview_expose;
|
||||||
widget_class->button_press_event = gimp_navigation_preview_button_press;
|
widget_class->button_press_event = gimp_navigation_preview_button_press;
|
||||||
widget_class->button_release_event = gimp_navigation_preview_button_release;
|
widget_class->button_release_event = gimp_navigation_preview_button_release;
|
||||||
@ -216,6 +221,17 @@ gimp_navigation_preview_realize (GtkWidget *widget)
|
|||||||
GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_ROUND);
|
GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_navigation_preview_size_allocate (GtkWidget *widget,
|
||||||
|
GtkAllocation *allocation)
|
||||||
|
{
|
||||||
|
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
|
||||||
|
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
||||||
|
|
||||||
|
if (GIMP_PREVIEW (widget)->renderer->viewable)
|
||||||
|
gimp_navigation_preview_transform (GIMP_NAVIGATION_PREVIEW (widget));
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gimp_navigation_preview_expose (GtkWidget *widget,
|
gimp_navigation_preview_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *eevent)
|
GdkEventExpose *eevent)
|
||||||
@ -507,6 +523,27 @@ gimp_navigation_preview_key_press (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_navigation_preview_transform (GimpNavigationPreview *nav_preview)
|
||||||
|
{
|
||||||
|
GimpPreview *preview;
|
||||||
|
GimpImage *gimage;
|
||||||
|
gdouble ratiox, ratioy;
|
||||||
|
|
||||||
|
preview = GIMP_PREVIEW (nav_preview);
|
||||||
|
|
||||||
|
gimage = GIMP_IMAGE (preview->viewable);
|
||||||
|
|
||||||
|
ratiox = ((gdouble) preview->renderer->width / (gdouble) gimage->width);
|
||||||
|
ratioy = ((gdouble) preview->renderer->height / (gdouble) gimage->height);
|
||||||
|
|
||||||
|
nav_preview->p_x = RINT (nav_preview->x * ratiox);
|
||||||
|
nav_preview->p_y = RINT (nav_preview->y * ratioy);
|
||||||
|
|
||||||
|
nav_preview->p_width = RINT (nav_preview->width * ratiox);
|
||||||
|
nav_preview->p_height = RINT (nav_preview->height * ratioy);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||||
GdkRectangle *area)
|
GdkRectangle *area)
|
||||||
@ -544,25 +581,6 @@ gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gimp_navigation_preview_new (GimpImage *gimage,
|
|
||||||
gint size)
|
|
||||||
{
|
|
||||||
GtkWidget *preview;
|
|
||||||
|
|
||||||
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
|
|
||||||
g_return_val_if_fail (size > 0 && size <= GIMP_PREVIEW_MAX_SIZE, NULL);
|
|
||||||
|
|
||||||
preview = gimp_preview_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
|
|
||||||
GIMP_TYPE_IMAGE,
|
|
||||||
size, 0, TRUE);
|
|
||||||
|
|
||||||
if (gimage)
|
|
||||||
gimp_preview_set_viewable (GIMP_PREVIEW (preview), GIMP_VIEWABLE (gimage));
|
|
||||||
|
|
||||||
return preview;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
||||||
gint x,
|
gint x,
|
||||||
@ -572,7 +590,6 @@ gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
|||||||
{
|
{
|
||||||
GimpPreview *preview;
|
GimpPreview *preview;
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
gdouble ratiox, ratioy;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_NAVIGATION_PREVIEW (nav_preview));
|
g_return_if_fail (GIMP_IS_NAVIGATION_PREVIEW (nav_preview));
|
||||||
|
|
||||||
@ -598,15 +615,7 @@ gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
|||||||
nav_preview->width = CLAMP (width, 1, gimage->width - nav_preview->x);
|
nav_preview->width = CLAMP (width, 1, gimage->width - nav_preview->x);
|
||||||
nav_preview->height = CLAMP (height, 1, gimage->height - nav_preview->y);
|
nav_preview->height = CLAMP (height, 1, gimage->height - nav_preview->y);
|
||||||
|
|
||||||
/* transform to preview coordinates */
|
gimp_navigation_preview_transform (nav_preview);
|
||||||
ratiox = ((gdouble) preview->renderer->width / (gdouble) gimage->width);
|
|
||||||
ratioy = ((gdouble) preview->renderer->height / (gdouble) gimage->height);
|
|
||||||
|
|
||||||
nav_preview->p_x = RINT (nav_preview->x * ratiox);
|
|
||||||
nav_preview->p_y = RINT (nav_preview->y * ratioy);
|
|
||||||
|
|
||||||
nav_preview->p_width = RINT (nav_preview->width * ratiox);
|
|
||||||
nav_preview->p_height = RINT (nav_preview->height * ratioy);
|
|
||||||
|
|
||||||
/* draw new marker */
|
/* draw new marker */
|
||||||
if (GTK_WIDGET_DRAWABLE (preview))
|
if (GTK_WIDGET_DRAWABLE (preview))
|
||||||
|
@ -77,8 +77,6 @@ struct _GimpNavigationPreviewClass
|
|||||||
|
|
||||||
GType gimp_navigation_preview_get_type (void) G_GNUC_CONST;
|
GType gimp_navigation_preview_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget * gimp_navigation_preview_new (GimpImage *gimage,
|
|
||||||
gint size);
|
|
||||||
void gimp_navigation_preview_set_marker (GimpNavigationPreview *preview,
|
void gimp_navigation_preview_set_marker (GimpNavigationPreview *preview,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
|
@ -456,7 +456,7 @@ palette_editor_eventbox_button_press (GtkWidget *widget,
|
|||||||
GdkEventButton *bevent,
|
GdkEventButton *bevent,
|
||||||
GimpPaletteEditor *editor)
|
GimpPaletteEditor *editor)
|
||||||
{
|
{
|
||||||
if (bevent->button == 3)
|
if (bevent->button == 3 && GIMP_DATA_EDITOR (editor)->data_editable)
|
||||||
{
|
{
|
||||||
gimp_item_factory_popup_with_data (GIMP_DATA_EDITOR (editor)->item_factory,
|
gimp_item_factory_popup_with_data (GIMP_DATA_EDITOR (editor)->item_factory,
|
||||||
editor, NULL);
|
editor, NULL);
|
||||||
@ -542,7 +542,8 @@ palette_editor_color_area_button_press (GtkWidget *widget,
|
|||||||
g_signal_handler_unblock (editor->color_name,
|
g_signal_handler_unblock (editor->color_name,
|
||||||
editor->entry_sig_id);
|
editor->entry_sig_id);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (editor->color_name, TRUE);
|
gtk_widget_set_sensitive (editor->color_name,
|
||||||
|
GIMP_DATA_EDITOR (editor)->data_editable);
|
||||||
/* palette_update_current_entry (editor); */
|
/* palette_update_current_entry (editor); */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -574,9 +575,6 @@ palette_editor_draw_color_row (guchar *colors,
|
|||||||
gint i, j;
|
gint i, j;
|
||||||
GtkWidget *preview;
|
GtkWidget *preview;
|
||||||
|
|
||||||
if (! palette_editor)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
preview = palette_editor->color_area;
|
preview = palette_editor->color_area;
|
||||||
|
|
||||||
bcolor = 0;
|
bcolor = 0;
|
||||||
@ -817,7 +815,7 @@ palette_editor_scroll_top_left (GimpPaletteEditor *palette_editor)
|
|||||||
GtkAdjustment *hadj;
|
GtkAdjustment *hadj;
|
||||||
GtkAdjustment *vadj;
|
GtkAdjustment *vadj;
|
||||||
|
|
||||||
if (! (palette_editor && palette_editor->scrolled_window))
|
if (! palette_editor->scrolled_window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (palette_editor->scrolled_window));
|
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (palette_editor->scrolled_window));
|
||||||
@ -846,7 +844,7 @@ palette_editor_redraw (GimpPaletteEditor *editor)
|
|||||||
|
|
||||||
width = editor->color_area->parent->parent->parent->allocation.width;
|
width = editor->color_area->parent->parent->parent->allocation.width;
|
||||||
|
|
||||||
if ((editor->columns_valid) && editor->last_width == width)
|
if (editor->columns_valid && editor->last_width == width)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
editor->last_width = width;
|
editor->last_width = width;
|
||||||
@ -1011,7 +1009,7 @@ palette_editor_drag_color (GtkWidget *widget,
|
|||||||
|
|
||||||
editor = GIMP_PALETTE_EDITOR (data);
|
editor = GIMP_PALETTE_EDITOR (data);
|
||||||
|
|
||||||
if (editor && GIMP_DATA_EDITOR (editor)->data && editor->dnd_color)
|
if (GIMP_DATA_EDITOR (editor)->data && editor->dnd_color)
|
||||||
{
|
{
|
||||||
*color = editor->dnd_color->color;
|
*color = editor->dnd_color->color;
|
||||||
}
|
}
|
||||||
@ -1030,7 +1028,7 @@ palette_editor_drop_color (GtkWidget *widget,
|
|||||||
|
|
||||||
editor = GIMP_PALETTE_EDITOR (data);
|
editor = GIMP_PALETTE_EDITOR (data);
|
||||||
|
|
||||||
if (editor && GIMP_DATA_EDITOR (editor)->data)
|
if (editor && GIMP_DATA_EDITOR (editor)->data_editable)
|
||||||
{
|
{
|
||||||
editor->color =
|
editor->color =
|
||||||
gimp_palette_add_entry (GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data),
|
gimp_palette_add_entry (GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data),
|
||||||
@ -1057,6 +1055,5 @@ palette_editor_invalidate_preview (GimpPalette *palette,
|
|||||||
editor->columns = COLUMNS;
|
editor->columns = COLUMNS;
|
||||||
|
|
||||||
editor->columns_valid = FALSE;
|
editor->columns_valid = FALSE;
|
||||||
|
|
||||||
palette_editor_redraw (editor);
|
palette_editor_redraw (editor);
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||||||
preview->clickable = FALSE;
|
preview->clickable = FALSE;
|
||||||
preview->eat_button_events = TRUE;
|
preview->eat_button_events = TRUE;
|
||||||
preview->show_popup = FALSE;
|
preview->show_popup = FALSE;
|
||||||
|
preview->expand = FALSE;
|
||||||
|
|
||||||
preview->in_button = FALSE;
|
preview->in_button = FALSE;
|
||||||
|
|
||||||
@ -223,10 +224,18 @@ gimp_preview_size_request (GtkWidget *widget,
|
|||||||
|
|
||||||
preview = GIMP_PREVIEW (widget);
|
preview = GIMP_PREVIEW (widget);
|
||||||
|
|
||||||
|
if (preview->expand)
|
||||||
|
{
|
||||||
|
requisition->width = 2 * preview->renderer->border_width + 1;
|
||||||
|
requisition->height = 2 * preview->renderer->border_width + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
requisition->width = (preview->renderer->width +
|
requisition->width = (preview->renderer->width +
|
||||||
2 * preview->renderer->border_width);
|
2 * preview->renderer->border_width);
|
||||||
requisition->height = (preview->renderer->height +
|
requisition->height = (preview->renderer->height +
|
||||||
2 * preview->renderer->border_width);
|
2 * preview->renderer->border_width);
|
||||||
|
}
|
||||||
|
|
||||||
if (GTK_WIDGET_CLASS (parent_class)->size_request)
|
if (GTK_WIDGET_CLASS (parent_class)->size_request)
|
||||||
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
|
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
|
||||||
@ -242,6 +251,66 @@ gimp_preview_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
preview = GIMP_PREVIEW (widget);
|
preview = GIMP_PREVIEW (widget);
|
||||||
|
|
||||||
|
if (preview->expand)
|
||||||
|
{
|
||||||
|
width = MIN (GIMP_PREVIEW_MAX_SIZE,
|
||||||
|
allocation->width - 2 * preview->renderer->border_width);
|
||||||
|
height = MIN (GIMP_PREVIEW_MAX_SIZE,
|
||||||
|
allocation->height - 2 * preview->renderer->border_width);
|
||||||
|
|
||||||
|
if (preview->renderer->width != width ||
|
||||||
|
preview->renderer->height != height)
|
||||||
|
{
|
||||||
|
gint border_width = preview->renderer->border_width;
|
||||||
|
|
||||||
|
if (preview->renderer->size != -1 && preview->renderer->viewable)
|
||||||
|
{
|
||||||
|
gint preview_width;
|
||||||
|
gint preview_height;
|
||||||
|
gint scaled_width;
|
||||||
|
gint scaled_height;
|
||||||
|
|
||||||
|
gimp_viewable_get_preview_size (preview->renderer->viewable,
|
||||||
|
GIMP_PREVIEW_MAX_SIZE,
|
||||||
|
preview->renderer->is_popup,
|
||||||
|
preview->renderer->dot_for_dot,
|
||||||
|
&preview_width,
|
||||||
|
&preview_height);
|
||||||
|
|
||||||
|
gimp_viewable_calc_preview_size (preview->renderer->viewable,
|
||||||
|
preview_width,
|
||||||
|
preview_height,
|
||||||
|
width, height,
|
||||||
|
TRUE, 1.0, 1.0,
|
||||||
|
&scaled_width, &scaled_height,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (scaled_width > width)
|
||||||
|
{
|
||||||
|
scaled_height = scaled_height * width / scaled_width;
|
||||||
|
scaled_width = scaled_width * width / scaled_width;
|
||||||
|
}
|
||||||
|
else if (scaled_height > height)
|
||||||
|
{
|
||||||
|
scaled_width = scaled_width * height / scaled_height;
|
||||||
|
scaled_height = scaled_height * height / scaled_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_preview_renderer_set_size (preview->renderer,
|
||||||
|
MAX (scaled_width, scaled_height),
|
||||||
|
border_width);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_preview_renderer_set_size_full (preview->renderer,
|
||||||
|
width, height,
|
||||||
|
border_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_preview_renderer_remove_idle (preview->renderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
width = (preview->renderer->width +
|
width = (preview->renderer->width +
|
||||||
2 * preview->renderer->border_width);
|
2 * preview->renderer->border_width);
|
||||||
height = (preview->renderer->height +
|
height = (preview->renderer->height +
|
||||||
@ -642,6 +711,19 @@ gimp_preview_set_size_full (GimpPreview *preview,
|
|||||||
border_width);
|
border_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_preview_set_expand (GimpPreview *preview,
|
||||||
|
gboolean expand)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
||||||
|
|
||||||
|
if (preview->expand != expand)
|
||||||
|
{
|
||||||
|
preview->expand = expand ? TRUE : FALSE;
|
||||||
|
gtk_widget_queue_resize (GTK_WIDGET (preview));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||||
gboolean dot_for_dot)
|
gboolean dot_for_dot)
|
||||||
|
@ -50,6 +50,7 @@ struct _GimpPreview
|
|||||||
gboolean clickable;
|
gboolean clickable;
|
||||||
gboolean eat_button_events;
|
gboolean eat_button_events;
|
||||||
gboolean show_popup;
|
gboolean show_popup;
|
||||||
|
gboolean expand;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
gboolean in_button;
|
gboolean in_button;
|
||||||
@ -105,6 +106,8 @@ void gimp_preview_set_size_full (GimpPreview *preview,
|
|||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
gint border_width);
|
gint border_width);
|
||||||
|
void gimp_preview_set_expand (GimpPreview *preview,
|
||||||
|
gboolean expand);
|
||||||
void gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
void gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||||
gboolean dot_for_dot);
|
gboolean dot_for_dot);
|
||||||
void gimp_preview_set_border_color (GimpPreview *preview,
|
void gimp_preview_set_border_color (GimpPreview *preview,
|
||||||
|
@ -27,12 +27,14 @@
|
|||||||
|
|
||||||
#include "core/gimpbrush.h"
|
#include "core/gimpbrush.h"
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
|
#include "core/gimpgradient.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
#include "text/gimptextlayer.h"
|
#include "text/gimptextlayer.h"
|
||||||
|
|
||||||
#include "gimppreviewrendererbrush.h"
|
#include "gimppreviewrendererbrush.h"
|
||||||
#include "gimppreviewrendererdrawable.h"
|
#include "gimppreviewrendererdrawable.h"
|
||||||
#include "gimppreviewrenderertextlayer.h"
|
#include "gimppreviewrenderertextlayer.h"
|
||||||
|
#include "gimppreviewrenderergradient.h"
|
||||||
#include "gimppreviewrendererimage.h"
|
#include "gimppreviewrendererimage.h"
|
||||||
|
|
||||||
|
|
||||||
@ -60,6 +62,10 @@ gimp_preview_renderer_type_from_viewable_type (GType viewable_type)
|
|||||||
{
|
{
|
||||||
type = GIMP_TYPE_PREVIEW_RENDERER_DRAWABLE;
|
type = GIMP_TYPE_PREVIEW_RENDERER_DRAWABLE;
|
||||||
}
|
}
|
||||||
|
else if (g_type_is_a (viewable_type, GIMP_TYPE_GRADIENT))
|
||||||
|
{
|
||||||
|
type = GIMP_TYPE_PREVIEW_RENDERER_GRADIENT;
|
||||||
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
244
app/widgets/gimppreviewrenderergradient.c
Normal file
244
app/widgets/gimppreviewrenderergradient.c
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimppreviewrenderergradient.c
|
||||||
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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 PURPOSE. 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
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
|
#include "libgimpmath/gimpmath.h"
|
||||||
|
|
||||||
|
#include "widgets-types.h"
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#warning FIXME #include "display/display-types.h"
|
||||||
|
#endif
|
||||||
|
#include "display/display-types.h"
|
||||||
|
|
||||||
|
#include "core/gimpgradient.h"
|
||||||
|
|
||||||
|
#include "display/gimpdisplayshell-render.h"
|
||||||
|
|
||||||
|
#include "gimppreviewrenderergradient.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void gimp_preview_renderer_gradient_class_init (GimpPreviewRendererGradientClass *klass);
|
||||||
|
static void gimp_preview_renderer_gradient_init (GimpPreviewRendererGradient *renderer);
|
||||||
|
|
||||||
|
static void gimp_preview_renderer_gradient_finalize (GObject *object);
|
||||||
|
|
||||||
|
static void gimp_preview_renderer_gradient_render (GimpPreviewRenderer *renderer,
|
||||||
|
GtkWidget *widget);
|
||||||
|
|
||||||
|
|
||||||
|
static GimpPreviewRendererClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
GType
|
||||||
|
gimp_preview_renderer_gradient_get_type (void)
|
||||||
|
{
|
||||||
|
static GType renderer_type = 0;
|
||||||
|
|
||||||
|
if (! renderer_type)
|
||||||
|
{
|
||||||
|
static const GTypeInfo renderer_info =
|
||||||
|
{
|
||||||
|
sizeof (GimpPreviewRendererGradientClass),
|
||||||
|
NULL, /* base_init */
|
||||||
|
NULL, /* base_finalize */
|
||||||
|
(GClassInitFunc) gimp_preview_renderer_gradient_class_init,
|
||||||
|
NULL, /* class_finalize */
|
||||||
|
NULL, /* class_data */
|
||||||
|
sizeof (GimpPreviewRendererGradient),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) gimp_preview_renderer_gradient_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
renderer_type = g_type_register_static (GIMP_TYPE_PREVIEW_RENDERER,
|
||||||
|
"GimpPreviewRendererGradient",
|
||||||
|
&renderer_info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return renderer_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_preview_renderer_gradient_class_init (GimpPreviewRendererGradientClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
|
GimpPreviewRendererClass *renderer_class;
|
||||||
|
|
||||||
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
|
renderer_class = GIMP_PREVIEW_RENDERER_CLASS (klass);
|
||||||
|
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
|
object_class->finalize = gimp_preview_renderer_gradient_finalize;
|
||||||
|
|
||||||
|
renderer_class->render = gimp_preview_renderer_gradient_render;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_preview_renderer_gradient_init (GimpPreviewRendererGradient *renderer)
|
||||||
|
{
|
||||||
|
renderer->even = NULL;
|
||||||
|
renderer->odd = NULL;
|
||||||
|
renderer->width = -1;
|
||||||
|
renderer->left = 0.0;
|
||||||
|
renderer->right = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_preview_renderer_gradient_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GimpPreviewRendererGradient *renderer;
|
||||||
|
|
||||||
|
renderer = GIMP_PREVIEW_RENDERER_GRADIENT (object);
|
||||||
|
|
||||||
|
if (renderer->even)
|
||||||
|
{
|
||||||
|
g_free (renderer->even);
|
||||||
|
renderer->even = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderer->odd)
|
||||||
|
{
|
||||||
|
g_free (renderer->odd);
|
||||||
|
renderer->odd = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_preview_renderer_gradient_render (GimpPreviewRenderer *renderer,
|
||||||
|
GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GimpPreviewRendererGradient *rendergrad;
|
||||||
|
GimpGradient *gradient;
|
||||||
|
guchar *even;
|
||||||
|
guchar *odd;
|
||||||
|
guchar *buf;
|
||||||
|
gint x;
|
||||||
|
gint y;
|
||||||
|
gint a;
|
||||||
|
gdouble dx, cur_x;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
rendergrad = GIMP_PREVIEW_RENDERER_GRADIENT (renderer);
|
||||||
|
|
||||||
|
gradient = GIMP_GRADIENT (renderer->viewable);
|
||||||
|
|
||||||
|
if (renderer->width != rendergrad->width)
|
||||||
|
{
|
||||||
|
if (rendergrad->even)
|
||||||
|
g_free (rendergrad->even);
|
||||||
|
|
||||||
|
if (rendergrad->odd)
|
||||||
|
g_free (rendergrad->odd);
|
||||||
|
|
||||||
|
rendergrad->even = g_new (guchar, renderer->rowstride);
|
||||||
|
rendergrad->odd = g_new (guchar, renderer->rowstride);
|
||||||
|
|
||||||
|
rendergrad->width = renderer->width;
|
||||||
|
}
|
||||||
|
|
||||||
|
even = rendergrad->even;
|
||||||
|
odd = rendergrad->odd;
|
||||||
|
|
||||||
|
dx = (rendergrad->right - rendergrad->left) / (renderer->width - 1);
|
||||||
|
cur_x = rendergrad->left;
|
||||||
|
|
||||||
|
for (x = 0; x < renderer->width; x++)
|
||||||
|
{
|
||||||
|
guchar r, g, b;
|
||||||
|
|
||||||
|
gimp_gradient_get_color_at (gradient, cur_x, &color);
|
||||||
|
cur_x += dx;
|
||||||
|
|
||||||
|
a = ((gint) (color.a * 255.0)) << 8;
|
||||||
|
|
||||||
|
gimp_rgb_get_uchar (&color, &r, &g, &b);
|
||||||
|
|
||||||
|
if (x & 0x4)
|
||||||
|
{
|
||||||
|
*even++ = render_blend_dark_check[a | r];
|
||||||
|
*even++ = render_blend_dark_check[a | g];
|
||||||
|
*even++ = render_blend_dark_check[a | b];
|
||||||
|
|
||||||
|
*odd++ = render_blend_light_check[a | r];
|
||||||
|
*odd++ = render_blend_light_check[a | g];
|
||||||
|
*odd++ = render_blend_light_check[a | b];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*even++ = render_blend_light_check[a | r];
|
||||||
|
*even++ = render_blend_light_check[a | g];
|
||||||
|
*even++ = render_blend_light_check[a | b];
|
||||||
|
|
||||||
|
*odd++ = render_blend_dark_check[a | r];
|
||||||
|
*odd++ = render_blend_dark_check[a | g];
|
||||||
|
*odd++ = render_blend_dark_check[a | b];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! renderer->buffer)
|
||||||
|
renderer->buffer = g_new (guchar, renderer->height * renderer->rowstride);
|
||||||
|
|
||||||
|
buf = renderer->buffer;
|
||||||
|
|
||||||
|
for (y = 0; y < renderer->height; y++)
|
||||||
|
{
|
||||||
|
if (y & 0x4)
|
||||||
|
memcpy (buf, rendergrad->even, renderer->rowstride);
|
||||||
|
else
|
||||||
|
memcpy (buf, rendergrad->odd, renderer->rowstride);
|
||||||
|
|
||||||
|
buf += renderer->rowstride;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer->needs_render = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_preview_renderer_gradient_set_offsets (GimpPreviewRendererGradient *renderer,
|
||||||
|
gdouble left,
|
||||||
|
gdouble right,
|
||||||
|
gboolean instant_update)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER_GRADIENT (renderer));
|
||||||
|
|
||||||
|
left = CLAMP (left, 0.0, 1.0);
|
||||||
|
right = CLAMP (right, left, 1.0);
|
||||||
|
|
||||||
|
if (left != renderer->left || right != renderer->right)
|
||||||
|
{
|
||||||
|
renderer->left = left;
|
||||||
|
renderer->right = right;
|
||||||
|
|
||||||
|
gimp_preview_renderer_invalidate (GIMP_PREVIEW_RENDERER (renderer));
|
||||||
|
|
||||||
|
if (instant_update)
|
||||||
|
gimp_preview_renderer_update (GIMP_PREVIEW_RENDERER (renderer));
|
||||||
|
}
|
||||||
|
}
|
62
app/widgets/gimppreviewrenderergradient.h
Normal file
62
app/widgets/gimppreviewrenderergradient.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimppreviewrenderergradient.h
|
||||||
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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 PURPOSE. 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
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_PREVIEW_RENDERER_GRADIENT_H__
|
||||||
|
#define __GIMP_PREVIEW_RENDERER_GRADIENT_H__
|
||||||
|
|
||||||
|
#include "gimppreviewrenderer.h"
|
||||||
|
|
||||||
|
#define GIMP_TYPE_PREVIEW_RENDERER_GRADIENT (gimp_preview_renderer_gradient_get_type ())
|
||||||
|
#define GIMP_PREVIEW_RENDERER_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PREVIEW_RENDERER_GRADIENT, GimpPreviewRendererGradient))
|
||||||
|
#define GIMP_PREVIEW_RENDERER_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PREVIEW_RENDERER_GRADIENT, GimpPreviewRendererGradientClass))
|
||||||
|
#define GIMP_IS_PREVIEW_RENDERER_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_PREVIEW_RENDERER_GRADIENT))
|
||||||
|
#define GIMP_IS_PREVIEW_RENDERER_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PREVIEW_RENDERER_GRADIENT))
|
||||||
|
#define GIMP_PREVIEW_RENDERER_GRADIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PREVIEW_RENDERER_GRADIENT, GimpPreviewRendererGradientClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpPreviewRendererGradientClass GimpPreviewRendererGradientClass;
|
||||||
|
|
||||||
|
struct _GimpPreviewRendererGradient
|
||||||
|
{
|
||||||
|
GimpPreviewRenderer parent_instance;
|
||||||
|
|
||||||
|
guchar *even;
|
||||||
|
guchar *odd;
|
||||||
|
gint width;
|
||||||
|
gdouble left;
|
||||||
|
gdouble right;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpPreviewRendererGradientClass
|
||||||
|
{
|
||||||
|
GimpPreviewRendererClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_preview_renderer_gradient_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
void gimp_preview_renderer_gradient_set_offsets (GimpPreviewRendererGradient *renderer,
|
||||||
|
gdouble left,
|
||||||
|
gdouble right,
|
||||||
|
gboolean instant_update);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_PREVIEW_RENDERER_GRADIENT_H__ */
|
@ -59,9 +59,6 @@ static void gimp_selection_editor_init (GimpSelectionEditor *select
|
|||||||
static void gimp_selection_editor_set_image (GimpImageEditor *editor,
|
static void gimp_selection_editor_set_image (GimpImageEditor *editor,
|
||||||
GimpImage *gimage);
|
GimpImage *gimage);
|
||||||
|
|
||||||
static void gimp_selection_editor_abox_resized (GtkWidget *widget,
|
|
||||||
GtkAllocation *allocation,
|
|
||||||
GimpSelectionEditor *editor);
|
|
||||||
static void gimp_selection_editor_invert_clicked (GtkWidget *widget,
|
static void gimp_selection_editor_invert_clicked (GtkWidget *widget,
|
||||||
GimpImageEditor *editor);
|
GimpImageEditor *editor);
|
||||||
static void gimp_selection_editor_all_clicked (GtkWidget *widget,
|
static void gimp_selection_editor_all_clicked (GtkWidget *widget,
|
||||||
@ -129,30 +126,20 @@ static void
|
|||||||
gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
|
gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
|
||||||
{
|
{
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
GtkWidget *abox;
|
|
||||||
/* FIXME: take value from GimpGuiConfig */
|
|
||||||
GimpPreviewSize nav_preview_size = GIMP_PREVIEW_SIZE_HUGE;
|
|
||||||
|
|
||||||
frame = gtk_frame_new (NULL);
|
frame = gtk_frame_new (NULL);
|
||||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||||
gtk_box_pack_start (GTK_BOX (selection_editor), frame, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (selection_editor), frame, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
|
||||||
gtk_container_add (GTK_CONTAINER (frame), abox);
|
|
||||||
gtk_widget_show (abox);
|
|
||||||
|
|
||||||
gtk_widget_set_size_request (abox, nav_preview_size, nav_preview_size);
|
|
||||||
|
|
||||||
g_signal_connect (abox, "size_allocate",
|
|
||||||
G_CALLBACK (gimp_selection_editor_abox_resized),
|
|
||||||
selection_editor);
|
|
||||||
|
|
||||||
selection_editor->preview = gimp_preview_new_by_types (GIMP_TYPE_PREVIEW,
|
selection_editor->preview = gimp_preview_new_by_types (GIMP_TYPE_PREVIEW,
|
||||||
GIMP_TYPE_DRAWABLE,
|
GIMP_TYPE_DRAWABLE,
|
||||||
nav_preview_size,
|
GIMP_PREVIEW_SIZE_HUGE,
|
||||||
0, FALSE);
|
0, FALSE);
|
||||||
gtk_container_add (GTK_CONTAINER (abox), selection_editor->preview);
|
gtk_widget_set_size_request (selection_editor->preview,
|
||||||
|
GIMP_PREVIEW_SIZE_HUGE, GIMP_PREVIEW_SIZE_HUGE);
|
||||||
|
gimp_preview_set_expand (GIMP_PREVIEW (selection_editor->preview), TRUE);
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), selection_editor->preview);
|
||||||
gtk_widget_show (selection_editor->preview);
|
gtk_widget_show (selection_editor->preview);
|
||||||
|
|
||||||
g_signal_connect (selection_editor->preview, "button_press_event",
|
g_signal_connect (selection_editor->preview, "button_press_event",
|
||||||
@ -251,59 +238,6 @@ gimp_selection_editor_new (GimpImage *gimage)
|
|||||||
return GTK_WIDGET (editor);
|
return GTK_WIDGET (editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_selection_editor_abox_resized (GtkWidget *widget,
|
|
||||||
GtkAllocation *allocation,
|
|
||||||
GimpSelectionEditor *editor)
|
|
||||||
{
|
|
||||||
GimpImageEditor *image_editor;
|
|
||||||
GimpPreview *preview;
|
|
||||||
|
|
||||||
image_editor = GIMP_IMAGE_EDITOR (editor);
|
|
||||||
preview = GIMP_PREVIEW (editor->preview);
|
|
||||||
|
|
||||||
if (! preview->viewable)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (preview->renderer->width > allocation->width ||
|
|
||||||
preview->renderer->height > allocation->height ||
|
|
||||||
(preview->renderer->width != allocation->width &&
|
|
||||||
preview->renderer->height != allocation->height))
|
|
||||||
{
|
|
||||||
gint width;
|
|
||||||
gint height;
|
|
||||||
gboolean dummy;
|
|
||||||
|
|
||||||
gimp_viewable_calc_preview_size (preview->viewable,
|
|
||||||
image_editor->gimage->width,
|
|
||||||
image_editor->gimage->height,
|
|
||||||
MIN (allocation->width,
|
|
||||||
GIMP_PREVIEW_MAX_SIZE),
|
|
||||||
MIN (allocation->height,
|
|
||||||
GIMP_PREVIEW_MAX_SIZE),
|
|
||||||
preview->renderer->dot_for_dot,
|
|
||||||
image_editor->gimage->xresolution,
|
|
||||||
image_editor->gimage->yresolution,
|
|
||||||
&width,
|
|
||||||
&height,
|
|
||||||
&dummy);
|
|
||||||
|
|
||||||
if (width > allocation->width)
|
|
||||||
{
|
|
||||||
height = height * allocation->width / width;
|
|
||||||
width = width * allocation->width / width;
|
|
||||||
}
|
|
||||||
else if (height > allocation->height)
|
|
||||||
{
|
|
||||||
width = width * allocation->height / height;
|
|
||||||
height = height * allocation->height / height;
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_preview_set_size_full (preview, width, height,
|
|
||||||
preview->renderer->border_width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_selection_editor_invert_clicked (GtkWidget *widget,
|
gimp_selection_editor_invert_clicked (GtkWidget *widget,
|
||||||
GimpImageEditor *editor)
|
GimpImageEditor *editor)
|
||||||
@ -353,6 +287,7 @@ gimp_selection_preview_button_press (GtkWidget *widget,
|
|||||||
GimpSelectionEditor *editor)
|
GimpSelectionEditor *editor)
|
||||||
{
|
{
|
||||||
GimpImageEditor *image_editor;
|
GimpImageEditor *image_editor;
|
||||||
|
GimpPreviewRenderer *renderer;
|
||||||
GimpToolInfo *tool_info;
|
GimpToolInfo *tool_info;
|
||||||
GimpSelectionOptions *options;
|
GimpSelectionOptions *options;
|
||||||
GimpDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
@ -366,6 +301,8 @@ gimp_selection_preview_button_press (GtkWidget *widget,
|
|||||||
if (! image_editor->gimage)
|
if (! image_editor->gimage)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
renderer = GIMP_PREVIEW (editor->preview)->renderer;
|
||||||
|
|
||||||
tool_info = (GimpToolInfo *)
|
tool_info = (GimpToolInfo *)
|
||||||
gimp_container_get_child_by_name (image_editor->gimage->gimp->tool_info_list,
|
gimp_container_get_child_by_name (image_editor->gimage->gimp->tool_info_list,
|
||||||
"gimp-by-color-select-tool");
|
"gimp-by-color-select-tool");
|
||||||
@ -396,13 +333,11 @@ gimp_selection_preview_button_press (GtkWidget *widget,
|
|||||||
operation = SELECTION_SUBTRACT;
|
operation = SELECTION_SUBTRACT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x = image_editor->gimage->width * bevent->x / renderer->width;
|
||||||
|
y = image_editor->gimage->height * bevent->y / renderer->height;
|
||||||
|
|
||||||
if (options->sample_merged)
|
if (options->sample_merged)
|
||||||
{
|
{
|
||||||
x = (image_editor->gimage->width * bevent->x /
|
|
||||||
editor->preview->allocation.width);
|
|
||||||
y = (image_editor->gimage->height * bevent->y /
|
|
||||||
editor->preview->allocation.height);
|
|
||||||
|
|
||||||
if (x < 0 || y < 0 ||
|
if (x < 0 || y < 0 ||
|
||||||
x >= image_editor->gimage->width ||
|
x >= image_editor->gimage->width ||
|
||||||
y >= image_editor->gimage->height)
|
y >= image_editor->gimage->height)
|
||||||
@ -412,14 +347,12 @@ gimp_selection_preview_button_press (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gint offx, offy;
|
gint off_x, off_y;
|
||||||
|
|
||||||
gimp_drawable_offsets (drawable, &offx, &offy);
|
gimp_drawable_offsets (drawable, &off_x, &off_y);
|
||||||
|
|
||||||
x = (gimp_drawable_width (drawable) * bevent->x /
|
x -= off_x;
|
||||||
editor->preview->requisition.width - offx);
|
y -= off_y;
|
||||||
y = (gimp_drawable_height (drawable) * bevent->y /
|
|
||||||
editor->preview->requisition.height - offy);
|
|
||||||
|
|
||||||
if (x < 0 || y < 0 ||
|
if (x < 0 || y < 0 ||
|
||||||
x >= gimp_drawable_width (drawable) ||
|
x >= gimp_drawable_width (drawable) ||
|
||||||
|
@ -190,6 +190,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||||||
preview->clickable = FALSE;
|
preview->clickable = FALSE;
|
||||||
preview->eat_button_events = TRUE;
|
preview->eat_button_events = TRUE;
|
||||||
preview->show_popup = FALSE;
|
preview->show_popup = FALSE;
|
||||||
|
preview->expand = FALSE;
|
||||||
|
|
||||||
preview->in_button = FALSE;
|
preview->in_button = FALSE;
|
||||||
|
|
||||||
@ -223,10 +224,18 @@ gimp_preview_size_request (GtkWidget *widget,
|
|||||||
|
|
||||||
preview = GIMP_PREVIEW (widget);
|
preview = GIMP_PREVIEW (widget);
|
||||||
|
|
||||||
|
if (preview->expand)
|
||||||
|
{
|
||||||
|
requisition->width = 2 * preview->renderer->border_width + 1;
|
||||||
|
requisition->height = 2 * preview->renderer->border_width + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
requisition->width = (preview->renderer->width +
|
requisition->width = (preview->renderer->width +
|
||||||
2 * preview->renderer->border_width);
|
2 * preview->renderer->border_width);
|
||||||
requisition->height = (preview->renderer->height +
|
requisition->height = (preview->renderer->height +
|
||||||
2 * preview->renderer->border_width);
|
2 * preview->renderer->border_width);
|
||||||
|
}
|
||||||
|
|
||||||
if (GTK_WIDGET_CLASS (parent_class)->size_request)
|
if (GTK_WIDGET_CLASS (parent_class)->size_request)
|
||||||
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
|
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
|
||||||
@ -242,6 +251,66 @@ gimp_preview_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
preview = GIMP_PREVIEW (widget);
|
preview = GIMP_PREVIEW (widget);
|
||||||
|
|
||||||
|
if (preview->expand)
|
||||||
|
{
|
||||||
|
width = MIN (GIMP_PREVIEW_MAX_SIZE,
|
||||||
|
allocation->width - 2 * preview->renderer->border_width);
|
||||||
|
height = MIN (GIMP_PREVIEW_MAX_SIZE,
|
||||||
|
allocation->height - 2 * preview->renderer->border_width);
|
||||||
|
|
||||||
|
if (preview->renderer->width != width ||
|
||||||
|
preview->renderer->height != height)
|
||||||
|
{
|
||||||
|
gint border_width = preview->renderer->border_width;
|
||||||
|
|
||||||
|
if (preview->renderer->size != -1 && preview->renderer->viewable)
|
||||||
|
{
|
||||||
|
gint preview_width;
|
||||||
|
gint preview_height;
|
||||||
|
gint scaled_width;
|
||||||
|
gint scaled_height;
|
||||||
|
|
||||||
|
gimp_viewable_get_preview_size (preview->renderer->viewable,
|
||||||
|
GIMP_PREVIEW_MAX_SIZE,
|
||||||
|
preview->renderer->is_popup,
|
||||||
|
preview->renderer->dot_for_dot,
|
||||||
|
&preview_width,
|
||||||
|
&preview_height);
|
||||||
|
|
||||||
|
gimp_viewable_calc_preview_size (preview->renderer->viewable,
|
||||||
|
preview_width,
|
||||||
|
preview_height,
|
||||||
|
width, height,
|
||||||
|
TRUE, 1.0, 1.0,
|
||||||
|
&scaled_width, &scaled_height,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (scaled_width > width)
|
||||||
|
{
|
||||||
|
scaled_height = scaled_height * width / scaled_width;
|
||||||
|
scaled_width = scaled_width * width / scaled_width;
|
||||||
|
}
|
||||||
|
else if (scaled_height > height)
|
||||||
|
{
|
||||||
|
scaled_width = scaled_width * height / scaled_height;
|
||||||
|
scaled_height = scaled_height * height / scaled_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_preview_renderer_set_size (preview->renderer,
|
||||||
|
MAX (scaled_width, scaled_height),
|
||||||
|
border_width);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_preview_renderer_set_size_full (preview->renderer,
|
||||||
|
width, height,
|
||||||
|
border_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_preview_renderer_remove_idle (preview->renderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
width = (preview->renderer->width +
|
width = (preview->renderer->width +
|
||||||
2 * preview->renderer->border_width);
|
2 * preview->renderer->border_width);
|
||||||
height = (preview->renderer->height +
|
height = (preview->renderer->height +
|
||||||
@ -642,6 +711,19 @@ gimp_preview_set_size_full (GimpPreview *preview,
|
|||||||
border_width);
|
border_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_preview_set_expand (GimpPreview *preview,
|
||||||
|
gboolean expand)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
||||||
|
|
||||||
|
if (preview->expand != expand)
|
||||||
|
{
|
||||||
|
preview->expand = expand ? TRUE : FALSE;
|
||||||
|
gtk_widget_queue_resize (GTK_WIDGET (preview));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||||
gboolean dot_for_dot)
|
gboolean dot_for_dot)
|
||||||
|
@ -50,6 +50,7 @@ struct _GimpPreview
|
|||||||
gboolean clickable;
|
gboolean clickable;
|
||||||
gboolean eat_button_events;
|
gboolean eat_button_events;
|
||||||
gboolean show_popup;
|
gboolean show_popup;
|
||||||
|
gboolean expand;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
gboolean in_button;
|
gboolean in_button;
|
||||||
@ -105,6 +106,8 @@ void gimp_preview_set_size_full (GimpPreview *preview,
|
|||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
gint border_width);
|
gint border_width);
|
||||||
|
void gimp_preview_set_expand (GimpPreview *preview,
|
||||||
|
gboolean expand);
|
||||||
void gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
void gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||||
gboolean dot_for_dot);
|
gboolean dot_for_dot);
|
||||||
void gimp_preview_set_border_color (GimpPreview *preview,
|
void gimp_preview_set_border_color (GimpPreview *preview,
|
||||||
|
@ -27,12 +27,14 @@
|
|||||||
|
|
||||||
#include "core/gimpbrush.h"
|
#include "core/gimpbrush.h"
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
|
#include "core/gimpgradient.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
#include "text/gimptextlayer.h"
|
#include "text/gimptextlayer.h"
|
||||||
|
|
||||||
#include "gimppreviewrendererbrush.h"
|
#include "gimppreviewrendererbrush.h"
|
||||||
#include "gimppreviewrendererdrawable.h"
|
#include "gimppreviewrendererdrawable.h"
|
||||||
#include "gimppreviewrenderertextlayer.h"
|
#include "gimppreviewrenderertextlayer.h"
|
||||||
|
#include "gimppreviewrenderergradient.h"
|
||||||
#include "gimppreviewrendererimage.h"
|
#include "gimppreviewrendererimage.h"
|
||||||
|
|
||||||
|
|
||||||
@ -60,6 +62,10 @@ gimp_preview_renderer_type_from_viewable_type (GType viewable_type)
|
|||||||
{
|
{
|
||||||
type = GIMP_TYPE_PREVIEW_RENDERER_DRAWABLE;
|
type = GIMP_TYPE_PREVIEW_RENDERER_DRAWABLE;
|
||||||
}
|
}
|
||||||
|
else if (g_type_is_a (viewable_type, GIMP_TYPE_GRADIENT))
|
||||||
|
{
|
||||||
|
type = GIMP_TYPE_PREVIEW_RENDERER_GRADIENT;
|
||||||
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
244
app/widgets/gimpviewrenderergradient.c
Normal file
244
app/widgets/gimpviewrenderergradient.c
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimppreviewrenderergradient.c
|
||||||
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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 PURPOSE. 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
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
|
#include "libgimpmath/gimpmath.h"
|
||||||
|
|
||||||
|
#include "widgets-types.h"
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#warning FIXME #include "display/display-types.h"
|
||||||
|
#endif
|
||||||
|
#include "display/display-types.h"
|
||||||
|
|
||||||
|
#include "core/gimpgradient.h"
|
||||||
|
|
||||||
|
#include "display/gimpdisplayshell-render.h"
|
||||||
|
|
||||||
|
#include "gimppreviewrenderergradient.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void gimp_preview_renderer_gradient_class_init (GimpPreviewRendererGradientClass *klass);
|
||||||
|
static void gimp_preview_renderer_gradient_init (GimpPreviewRendererGradient *renderer);
|
||||||
|
|
||||||
|
static void gimp_preview_renderer_gradient_finalize (GObject *object);
|
||||||
|
|
||||||
|
static void gimp_preview_renderer_gradient_render (GimpPreviewRenderer *renderer,
|
||||||
|
GtkWidget *widget);
|
||||||
|
|
||||||
|
|
||||||
|
static GimpPreviewRendererClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
GType
|
||||||
|
gimp_preview_renderer_gradient_get_type (void)
|
||||||
|
{
|
||||||
|
static GType renderer_type = 0;
|
||||||
|
|
||||||
|
if (! renderer_type)
|
||||||
|
{
|
||||||
|
static const GTypeInfo renderer_info =
|
||||||
|
{
|
||||||
|
sizeof (GimpPreviewRendererGradientClass),
|
||||||
|
NULL, /* base_init */
|
||||||
|
NULL, /* base_finalize */
|
||||||
|
(GClassInitFunc) gimp_preview_renderer_gradient_class_init,
|
||||||
|
NULL, /* class_finalize */
|
||||||
|
NULL, /* class_data */
|
||||||
|
sizeof (GimpPreviewRendererGradient),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) gimp_preview_renderer_gradient_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
renderer_type = g_type_register_static (GIMP_TYPE_PREVIEW_RENDERER,
|
||||||
|
"GimpPreviewRendererGradient",
|
||||||
|
&renderer_info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return renderer_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_preview_renderer_gradient_class_init (GimpPreviewRendererGradientClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
|
GimpPreviewRendererClass *renderer_class;
|
||||||
|
|
||||||
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
|
renderer_class = GIMP_PREVIEW_RENDERER_CLASS (klass);
|
||||||
|
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
|
object_class->finalize = gimp_preview_renderer_gradient_finalize;
|
||||||
|
|
||||||
|
renderer_class->render = gimp_preview_renderer_gradient_render;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_preview_renderer_gradient_init (GimpPreviewRendererGradient *renderer)
|
||||||
|
{
|
||||||
|
renderer->even = NULL;
|
||||||
|
renderer->odd = NULL;
|
||||||
|
renderer->width = -1;
|
||||||
|
renderer->left = 0.0;
|
||||||
|
renderer->right = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_preview_renderer_gradient_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GimpPreviewRendererGradient *renderer;
|
||||||
|
|
||||||
|
renderer = GIMP_PREVIEW_RENDERER_GRADIENT (object);
|
||||||
|
|
||||||
|
if (renderer->even)
|
||||||
|
{
|
||||||
|
g_free (renderer->even);
|
||||||
|
renderer->even = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderer->odd)
|
||||||
|
{
|
||||||
|
g_free (renderer->odd);
|
||||||
|
renderer->odd = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_preview_renderer_gradient_render (GimpPreviewRenderer *renderer,
|
||||||
|
GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GimpPreviewRendererGradient *rendergrad;
|
||||||
|
GimpGradient *gradient;
|
||||||
|
guchar *even;
|
||||||
|
guchar *odd;
|
||||||
|
guchar *buf;
|
||||||
|
gint x;
|
||||||
|
gint y;
|
||||||
|
gint a;
|
||||||
|
gdouble dx, cur_x;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
|
rendergrad = GIMP_PREVIEW_RENDERER_GRADIENT (renderer);
|
||||||
|
|
||||||
|
gradient = GIMP_GRADIENT (renderer->viewable);
|
||||||
|
|
||||||
|
if (renderer->width != rendergrad->width)
|
||||||
|
{
|
||||||
|
if (rendergrad->even)
|
||||||
|
g_free (rendergrad->even);
|
||||||
|
|
||||||
|
if (rendergrad->odd)
|
||||||
|
g_free (rendergrad->odd);
|
||||||
|
|
||||||
|
rendergrad->even = g_new (guchar, renderer->rowstride);
|
||||||
|
rendergrad->odd = g_new (guchar, renderer->rowstride);
|
||||||
|
|
||||||
|
rendergrad->width = renderer->width;
|
||||||
|
}
|
||||||
|
|
||||||
|
even = rendergrad->even;
|
||||||
|
odd = rendergrad->odd;
|
||||||
|
|
||||||
|
dx = (rendergrad->right - rendergrad->left) / (renderer->width - 1);
|
||||||
|
cur_x = rendergrad->left;
|
||||||
|
|
||||||
|
for (x = 0; x < renderer->width; x++)
|
||||||
|
{
|
||||||
|
guchar r, g, b;
|
||||||
|
|
||||||
|
gimp_gradient_get_color_at (gradient, cur_x, &color);
|
||||||
|
cur_x += dx;
|
||||||
|
|
||||||
|
a = ((gint) (color.a * 255.0)) << 8;
|
||||||
|
|
||||||
|
gimp_rgb_get_uchar (&color, &r, &g, &b);
|
||||||
|
|
||||||
|
if (x & 0x4)
|
||||||
|
{
|
||||||
|
*even++ = render_blend_dark_check[a | r];
|
||||||
|
*even++ = render_blend_dark_check[a | g];
|
||||||
|
*even++ = render_blend_dark_check[a | b];
|
||||||
|
|
||||||
|
*odd++ = render_blend_light_check[a | r];
|
||||||
|
*odd++ = render_blend_light_check[a | g];
|
||||||
|
*odd++ = render_blend_light_check[a | b];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*even++ = render_blend_light_check[a | r];
|
||||||
|
*even++ = render_blend_light_check[a | g];
|
||||||
|
*even++ = render_blend_light_check[a | b];
|
||||||
|
|
||||||
|
*odd++ = render_blend_dark_check[a | r];
|
||||||
|
*odd++ = render_blend_dark_check[a | g];
|
||||||
|
*odd++ = render_blend_dark_check[a | b];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! renderer->buffer)
|
||||||
|
renderer->buffer = g_new (guchar, renderer->height * renderer->rowstride);
|
||||||
|
|
||||||
|
buf = renderer->buffer;
|
||||||
|
|
||||||
|
for (y = 0; y < renderer->height; y++)
|
||||||
|
{
|
||||||
|
if (y & 0x4)
|
||||||
|
memcpy (buf, rendergrad->even, renderer->rowstride);
|
||||||
|
else
|
||||||
|
memcpy (buf, rendergrad->odd, renderer->rowstride);
|
||||||
|
|
||||||
|
buf += renderer->rowstride;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer->needs_render = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_preview_renderer_gradient_set_offsets (GimpPreviewRendererGradient *renderer,
|
||||||
|
gdouble left,
|
||||||
|
gdouble right,
|
||||||
|
gboolean instant_update)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER_GRADIENT (renderer));
|
||||||
|
|
||||||
|
left = CLAMP (left, 0.0, 1.0);
|
||||||
|
right = CLAMP (right, left, 1.0);
|
||||||
|
|
||||||
|
if (left != renderer->left || right != renderer->right)
|
||||||
|
{
|
||||||
|
renderer->left = left;
|
||||||
|
renderer->right = right;
|
||||||
|
|
||||||
|
gimp_preview_renderer_invalidate (GIMP_PREVIEW_RENDERER (renderer));
|
||||||
|
|
||||||
|
if (instant_update)
|
||||||
|
gimp_preview_renderer_update (GIMP_PREVIEW_RENDERER (renderer));
|
||||||
|
}
|
||||||
|
}
|
62
app/widgets/gimpviewrenderergradient.h
Normal file
62
app/widgets/gimpviewrenderergradient.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimppreviewrenderergradient.h
|
||||||
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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 PURPOSE. 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
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_PREVIEW_RENDERER_GRADIENT_H__
|
||||||
|
#define __GIMP_PREVIEW_RENDERER_GRADIENT_H__
|
||||||
|
|
||||||
|
#include "gimppreviewrenderer.h"
|
||||||
|
|
||||||
|
#define GIMP_TYPE_PREVIEW_RENDERER_GRADIENT (gimp_preview_renderer_gradient_get_type ())
|
||||||
|
#define GIMP_PREVIEW_RENDERER_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PREVIEW_RENDERER_GRADIENT, GimpPreviewRendererGradient))
|
||||||
|
#define GIMP_PREVIEW_RENDERER_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PREVIEW_RENDERER_GRADIENT, GimpPreviewRendererGradientClass))
|
||||||
|
#define GIMP_IS_PREVIEW_RENDERER_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_PREVIEW_RENDERER_GRADIENT))
|
||||||
|
#define GIMP_IS_PREVIEW_RENDERER_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PREVIEW_RENDERER_GRADIENT))
|
||||||
|
#define GIMP_PREVIEW_RENDERER_GRADIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PREVIEW_RENDERER_GRADIENT, GimpPreviewRendererGradientClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpPreviewRendererGradientClass GimpPreviewRendererGradientClass;
|
||||||
|
|
||||||
|
struct _GimpPreviewRendererGradient
|
||||||
|
{
|
||||||
|
GimpPreviewRenderer parent_instance;
|
||||||
|
|
||||||
|
guchar *even;
|
||||||
|
guchar *odd;
|
||||||
|
gint width;
|
||||||
|
gdouble left;
|
||||||
|
gdouble right;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpPreviewRendererGradientClass
|
||||||
|
{
|
||||||
|
GimpPreviewRendererClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_preview_renderer_gradient_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
void gimp_preview_renderer_gradient_set_offsets (GimpPreviewRendererGradient *renderer,
|
||||||
|
gdouble left,
|
||||||
|
gdouble right,
|
||||||
|
gboolean instant_update);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_PREVIEW_RENDERER_GRADIENT_H__ */
|
@ -39,6 +39,7 @@ typedef struct _GimpCellRendererViewable GimpCellRendererViewable;
|
|||||||
typedef struct _GimpPreviewRenderer GimpPreviewRenderer;
|
typedef struct _GimpPreviewRenderer GimpPreviewRenderer;
|
||||||
typedef struct _GimpPreviewRendererBrush GimpPreviewRendererBrush;
|
typedef struct _GimpPreviewRendererBrush GimpPreviewRendererBrush;
|
||||||
typedef struct _GimpPreviewRendererDrawable GimpPreviewRendererDrawable;
|
typedef struct _GimpPreviewRendererDrawable GimpPreviewRendererDrawable;
|
||||||
|
typedef struct _GimpPreviewRendererGradient GimpPreviewRendererGradient;
|
||||||
typedef struct _GimpPreviewRendererTextLayer GimpPreviewRendererTextLayer;
|
typedef struct _GimpPreviewRendererTextLayer GimpPreviewRendererTextLayer;
|
||||||
typedef struct _GimpPreviewRendererImage GimpPreviewRendererImage;
|
typedef struct _GimpPreviewRendererImage GimpPreviewRendererImage;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user