Commit 1522b841 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

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.
parent 3f588521
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>
 
* app/tools/gimpbycolorselecttool.c
......@@ -165,8 +165,6 @@ gradient_editor_load_left_cmd_callback (GtkWidget *widget,
}
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -283,8 +281,6 @@ gradient_editor_load_right_cmd_callback (GtkWidget *widget,
}
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -330,8 +326,6 @@ gradient_editor_blending_func_cmd_callback (GtkWidget *widget,
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -365,8 +359,6 @@ gradient_editor_coloring_type_cmd_callback (GtkWidget *widget,
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -493,9 +485,7 @@ gradient_editor_flip_cmd_callback (GtkWidget *widget,
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -601,9 +591,7 @@ gradient_editor_split_midpoint_cmd_callback (GtkWidget *widget,
editor->control_sel_r = rseg;
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -771,9 +759,7 @@ gradient_editor_delete_cmd_callback (GtkWidget *widget,
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -801,9 +787,7 @@ gradient_editor_recenter_cmd_callback (GtkWidget *widget,
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -862,9 +846,7 @@ gradient_editor_redistribute_cmd_callback (GtkWidget *widget,
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -883,8 +865,6 @@ gradient_editor_blend_color_cmd_callback (GtkWidget *widget,
TRUE, FALSE);
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -903,8 +883,6 @@ gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
FALSE, TRUE);
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:
gradient_editor_replace_selection (editor, editor->left_saved_segments);
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);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
}
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
static void
......@@ -1000,13 +976,12 @@ gradient_editor_right_color_changed (ColorNotebook *cnb,
case COLOR_NOTEBOOK_CANCEL:
gradient_editor_replace_selection (editor, editor->right_saved_segments);
GIMP_DATA (gradient)->dirty = editor->right_saved_dirty;
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient));
color_notebook_free (cnb);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
}
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
static GimpGradientSegment *
......@@ -1126,9 +1101,7 @@ gradient_editor_split_uniform_callback (GtkWidget *widget,
editor->control_sel_r = rseg;
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
static void
......@@ -1245,7 +1218,5 @@ gradient_editor_replicate_callback (GtkWidget *widget,
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
......@@ -62,9 +62,6 @@ static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
static void gimp_navigation_view_abox_resized (GtkWidget *widget,
GtkAllocation *allocation,
GimpNavigationView *view);
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
gint x,
gint y,
......@@ -147,7 +144,6 @@ gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
static void
gimp_navigation_view_init (GimpNavigationView *view)
{
GtkWidget *abox;
GtkWidget *frame;
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_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);
g_signal_connect (abox, "size_allocate",
G_CALLBACK (gimp_navigation_view_abox_resized),
view);
view->preview = gimp_navigation_preview_new (NULL, GIMP_PREVIEW_SIZE_MEDIUM);
gtk_container_add (GTK_CONTAINER (abox), view->preview);
view->preview = gimp_preview_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
GIMP_TYPE_IMAGE,
GIMP_PREVIEW_SIZE_MEDIUM, 0, TRUE);
gtk_widget_set_size_request (view->preview,
GIMP_PREVIEW_SIZE_HUGE, GIMP_PREVIEW_SIZE_HUGE);
gimp_preview_set_expand (GIMP_PREVIEW (view->preview), TRUE);
gtk_container_add (GTK_CONTAINER (frame), view->preview);
gtk_widget_show (view->preview);
g_signal_connect (view->preview, "marker_changed",
......@@ -467,71 +460,6 @@ gimp_navigation_view_button_release (GtkWidget *widget,
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
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
gint x,
......
......@@ -62,9 +62,6 @@ static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
static void gimp_navigation_view_abox_resized (GtkWidget *widget,
GtkAllocation *allocation,
GimpNavigationView *view);
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
gint x,
gint y,
......@@ -147,7 +144,6 @@ gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
static void
gimp_navigation_view_init (GimpNavigationView *view)
{
GtkWidget *abox;
GtkWidget *frame;
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_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);
g_signal_connect (abox, "size_allocate",
G_CALLBACK (gimp_navigation_view_abox_resized),
view);
view->preview = gimp_navigation_preview_new (NULL, GIMP_PREVIEW_SIZE_MEDIUM);
gtk_container_add (GTK_CONTAINER (abox), view->preview);
view->preview = gimp_preview_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
GIMP_TYPE_IMAGE,
GIMP_PREVIEW_SIZE_MEDIUM, 0, TRUE);
gtk_widget_set_size_request (view->preview,
GIMP_PREVIEW_SIZE_HUGE, GIMP_PREVIEW_SIZE_HUGE);
gimp_preview_set_expand (GIMP_PREVIEW (view->preview), TRUE);
gtk_container_add (GTK_CONTAINER (frame), view->preview);
gtk_widget_show (view->preview);
g_signal_connect (view->preview, "marker_changed",
......@@ -467,71 +460,6 @@ gimp_navigation_view_button_release (GtkWidget *widget,
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
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
gint x,
......
......@@ -165,8 +165,6 @@ gradient_editor_load_left_cmd_callback (GtkWidget *widget,
}
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -283,8 +281,6 @@ gradient_editor_load_right_cmd_callback (GtkWidget *widget,
}
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -330,8 +326,6 @@ gradient_editor_blending_func_cmd_callback (GtkWidget *widget,
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -365,8 +359,6 @@ gradient_editor_coloring_type_cmd_callback (GtkWidget *widget,
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -493,9 +485,7 @@ gradient_editor_flip_cmd_callback (GtkWidget *widget,
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -601,9 +591,7 @@ gradient_editor_split_midpoint_cmd_callback (GtkWidget *widget,
editor->control_sel_r = rseg;
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -771,9 +759,7 @@ gradient_editor_delete_cmd_callback (GtkWidget *widget,
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -801,9 +787,7 @@ gradient_editor_recenter_cmd_callback (GtkWidget *widget,
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -862,9 +846,7 @@ gradient_editor_redistribute_cmd_callback (GtkWidget *widget,
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
void
......@@ -883,8 +865,6 @@ gradient_editor_blend_color_cmd_callback (GtkWidget *widget,
TRUE, FALSE);
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
void
......@@ -903,8 +883,6 @@ gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
FALSE, TRUE);
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:
gradient_editor_replace_selection (editor, editor->left_saved_segments);
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);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
}
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
static void
......@@ -1000,13 +976,12 @@ gradient_editor_right_color_changed (ColorNotebook *cnb,
case COLOR_NOTEBOOK_CANCEL:
gradient_editor_replace_selection (editor, editor->right_saved_segments);
GIMP_DATA (gradient)->dirty = editor->right_saved_dirty;
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient));
color_notebook_free (cnb);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
}
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
}
static GimpGradientSegment *
......@@ -1126,9 +1101,7 @@ gradient_editor_split_uniform_callback (GtkWidget *widget,
editor->control_sel_r = rseg;
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
static void
......@@ -1245,7 +1218,5 @@ gradient_editor_replicate_callback (GtkWidget *widget,
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor,
GRAD_UPDATE_GRADIENT | GRAD_UPDATE_CONTROL);
gimp_gradient_editor_update (editor);
}
......@@ -135,6 +135,8 @@ libappwidgets_a_sources = \
gimppreviewrendererbrush.h \
gimppreviewrendererdrawable.c \
gimppreviewrendererdrawable.h \
gimppreviewrenderergradient.c \
gimppreviewrenderergradient.h \
gimppreviewrendererimage.c \
gimppreviewrendererimage.h \
gimppreviewrenderertextlayer.c \
......
......@@ -36,19 +36,20 @@
#include "libgimp/gimpintl.h"
#define BRUSH_PREVIEW_WIDTH 128
#define BRUSH_PREVIEW_HEIGHT 96
/* local function prototypes */
static void gimp_brush_editor_class_init (GimpBrushEditorClass *klass);
static void gimp_brush_editor_init (GimpBrushEditor *editor);
static void gimp_brush_editor_class_init (GimpBrushEditorClass *klass);
static void gimp_brush_editor_init (GimpBrushEditor *editor);
static void gimp_brush_editor_set_data (GimpDataEditor *editor,
GimpData *data);
static void gimp_brush_editor_set_data (GimpDataEditor *editor,
GimpData *data);
static void gimp_brush_editor_update_brush (GtkAdjustment *adjustment,
GimpBrushEditor *editor);
static void gimp_brush_editor_preview_resize (GtkWidget *widget,
GtkAllocation *allocation,
GimpBrushEditor *editor);
static void gimp_brush_editor_update_brush (GtkAdjustment *adjustment,
GimpBrushEditor *editor);
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_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,
GIMP_TYPE_BRUSH,
125, 100, 0,