Changed GimpViewable preview rendering to have a context to get
2006-08-29 Michael Natterer <mitch@gimp.org> Changed GimpViewable preview rendering to have a context to get FG/BG/whatever from. Use the context to enable dynamic FG/BG colors in gradients. Fixes bug #127676 and bug #352214. Addresses bug #128367 (doesn't fix it because there's no loading/saving and no GUI yet). * app/core/core-enums.[ch]: added enum GimpGradientColor to enable specifying gradient colors in terms of foreground and background. * app/core/gimpgradient.[ch]: added color_type members to the GimpGradientSegment struct and honor them in gimp_gradient_get_color_at(). Added GimpContext parameters to all functions which finally call get_color_at(). * app/core/gimp-gradients.c: use the new method to implement the builtin gradients. * app/core/gimpviewable.[ch]: added GimpContext parameters to all get_preview() and get_pixbuf() functions. * app/core/gimpbrush.c * app/core/gimpbuffer.c * app/core/gimpdrawable-preview.[ch] * app/core/gimpgradient.c * app/core/gimpimage-preview.[ch] * app/core/gimpimagefile.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpundo.[ch] * app/text/gimpfont.c * app/vectors/gimpvectors-preview.[ch]: changed ::get_preview() and ::get_pixbuf() implementations accordingly. * app/core/gimpdrawable-blend.c * app/core/gimppalette-import.[ch] * app/dialogs/dialogs-constructors.c * app/dialogs/palette-import-dialog.c * app/dialogs/resize-dialog.c * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell.c * app/display/gimpnavigationeditor.c * app/paint/gimppaintoptions.c * app/tools/gimpeditselectiontool.c * app/tools/gimptexttool.c * app/actions/gradient-editor-commands.c * app/widgets/gimpaction.c * app/widgets/gimpbrusheditor.[ch] * app/widgets/gimpbufferview.c * app/widgets/gimpcellrendererviewable.c * app/widgets/gimpchanneltreeview.c * app/widgets/gimpclipboard.c * app/widgets/gimpcoloreditor.c * app/widgets/gimpcomponenteditor.c * app/widgets/gimpcontainerbox.c * app/widgets/gimpcontainercombobox.c * app/widgets/gimpcontainereditor.c * app/widgets/gimpcontainerentry.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainertreeview.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdevicestatus.c * app/widgets/gimpdnd.[ch] * app/widgets/gimpdrawabletreeview.c * app/widgets/gimpfiledialog.c * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpgradientselect.c * app/widgets/gimpitemtreeview.c * app/widgets/gimplayertreeview.c * app/widgets/gimppaletteeditor.[ch] * app/widgets/gimppropwidgets.[ch] * app/widgets/gimpselectioneditor.c * app/widgets/gimpthumbbox.[ch] * app/widgets/gimptoolbox-image-area.c * app/widgets/gimptoolbox-indicator-area.c * app/widgets/gimptooloptionseditor.c * app/widgets/gimpundoeditor.c * app/widgets/gimpvectorstreeview.c * app/widgets/gimpview-popup.[ch] * app/widgets/gimpview.[ch] * app/widgets/gimpviewablebutton.c * app/widgets/gimpviewabledialog.c * app/widgets/gimpviewrenderer.[ch] * app/widgets/gimpviewrenderer-frame.c * app/widgets/gimpviewrendererbrush.c * app/widgets/gimpviewrendererbuffer.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrenderergradient.c * app/widgets/gimpviewrendererimage.c * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb: added tons of GimpContext members and parameters, implement GimpDocked::set_context() in many widgets. Pass these locally remembered contexts to GimpViewable functions. Did some minor cleanups on the way. There are still some minor FIXMEs around where the code uses a NULL context (which is allowed by the APIs) * app/pdb/drawable_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c: regenerated.
This commit is contained in:

committed by
Michael Natterer

parent
1f50f13c36
commit
b53aa45a76
@ -66,16 +66,18 @@ static GObject * gimp_palette_editor_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
|
||||
static void gimp_palette_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info);
|
||||
static GList *gimp_palette_editor_get_aux_info (GimpDocked *docked);
|
||||
|
||||
static void gimp_palette_editor_destroy (GtkObject *object);
|
||||
static void gimp_palette_editor_unmap (GtkWidget *widget);
|
||||
|
||||
static void gimp_palette_editor_set_data (GimpDataEditor *editor,
|
||||
GimpData *data);
|
||||
|
||||
static void gimp_palette_editor_set_context (GimpDocked *docked,
|
||||
GimpContext *context);
|
||||
static void gimp_palette_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info);
|
||||
static GList *gimp_palette_editor_get_aux_info (GimpDocked *docked);
|
||||
|
||||
static void palette_editor_invalidate_preview (GimpPalette *palette,
|
||||
GimpPaletteEditor *editor);
|
||||
|
||||
@ -154,6 +156,19 @@ gimp_palette_editor_class_init (GimpPaletteEditorClass *klass)
|
||||
editor_class->title = _("Palette Editor");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_editor_docked_iface_init (GimpDockedInterface *iface)
|
||||
{
|
||||
parent_docked_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
if (! parent_docked_iface)
|
||||
parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
|
||||
|
||||
iface->set_context = gimp_palette_editor_set_context;
|
||||
iface->set_aux_info = gimp_palette_editor_set_aux_info;
|
||||
iface->get_aux_info = gimp_palette_editor_get_aux_info;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_editor_init (GimpPaletteEditor *editor)
|
||||
{
|
||||
@ -198,7 +213,8 @@ gimp_palette_editor_init (GimpPaletteEditor *editor)
|
||||
gtk_container_add (GTK_CONTAINER (eventbox), alignment);
|
||||
gtk_widget_show (alignment);
|
||||
|
||||
editor->view = gimp_view_new_full_by_types (GIMP_TYPE_PALETTE_VIEW,
|
||||
editor->view = gimp_view_new_full_by_types (NULL,
|
||||
GIMP_TYPE_PALETTE_VIEW,
|
||||
GIMP_TYPE_PALETTE,
|
||||
PREVIEW_WIDTH, PREVIEW_HEIGHT, 0,
|
||||
FALSE, TRUE, FALSE);
|
||||
@ -258,18 +274,6 @@ gimp_palette_editor_init (GimpPaletteEditor *editor)
|
||||
editor);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_editor_docked_iface_init (GimpDockedInterface *iface)
|
||||
{
|
||||
parent_docked_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
if (! parent_docked_iface)
|
||||
parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
|
||||
|
||||
iface->set_aux_info = gimp_palette_editor_set_aux_info;
|
||||
iface->get_aux_info = gimp_palette_editor_get_aux_info;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_palette_editor_constructor (GType type,
|
||||
guint n_params,
|
||||
@ -306,54 +310,6 @@ gimp_palette_editor_constructor (GType type,
|
||||
return object;
|
||||
}
|
||||
|
||||
#define AUX_INFO_ZOOM_FACTOR "zoom-factor"
|
||||
|
||||
static void
|
||||
gimp_palette_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info)
|
||||
{
|
||||
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (docked);
|
||||
GList *list;
|
||||
|
||||
parent_docked_iface->set_aux_info (docked, aux_info);
|
||||
|
||||
for (list = aux_info; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
if (! strcmp (aux->name, AUX_INFO_ZOOM_FACTOR))
|
||||
{
|
||||
gdouble zoom_factor;
|
||||
|
||||
zoom_factor = g_ascii_strtod (aux->value, NULL);
|
||||
|
||||
editor->zoom_factor = CLAMP (zoom_factor, 0.1, 4.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GList *
|
||||
gimp_palette_editor_get_aux_info (GimpDocked *docked)
|
||||
{
|
||||
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (docked);
|
||||
GList *aux_info;
|
||||
|
||||
aux_info = parent_docked_iface->get_aux_info (docked);
|
||||
|
||||
if (editor->zoom_factor != 1.0)
|
||||
{
|
||||
GimpSessionInfoAux *aux;
|
||||
gchar value[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
g_ascii_formatd (value, sizeof (value), "%.2f", editor->zoom_factor);
|
||||
|
||||
aux = gimp_session_info_aux_new (AUX_INFO_ZOOM_FACTOR, value);
|
||||
aux_info = g_list_append (aux_info, aux);
|
||||
}
|
||||
|
||||
return aux_info;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_editor_destroy (GtkObject *object)
|
||||
{
|
||||
@ -431,24 +387,82 @@ gimp_palette_editor_set_data (GimpDataEditor *editor,
|
||||
editor);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_editor_set_context (GimpDocked *docked,
|
||||
GimpContext *context)
|
||||
{
|
||||
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (docked);
|
||||
|
||||
parent_docked_iface->set_context (docked, context);
|
||||
|
||||
gimp_view_renderer_set_context (GIMP_VIEW (editor->view)->renderer,
|
||||
context);
|
||||
}
|
||||
|
||||
#define AUX_INFO_ZOOM_FACTOR "zoom-factor"
|
||||
|
||||
static void
|
||||
gimp_palette_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info)
|
||||
{
|
||||
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (docked);
|
||||
GList *list;
|
||||
|
||||
parent_docked_iface->set_aux_info (docked, aux_info);
|
||||
|
||||
for (list = aux_info; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
if (! strcmp (aux->name, AUX_INFO_ZOOM_FACTOR))
|
||||
{
|
||||
gdouble zoom_factor;
|
||||
|
||||
zoom_factor = g_ascii_strtod (aux->value, NULL);
|
||||
|
||||
editor->zoom_factor = CLAMP (zoom_factor, 0.1, 4.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GList *
|
||||
gimp_palette_editor_get_aux_info (GimpDocked *docked)
|
||||
{
|
||||
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (docked);
|
||||
GList *aux_info;
|
||||
|
||||
aux_info = parent_docked_iface->get_aux_info (docked);
|
||||
|
||||
if (editor->zoom_factor != 1.0)
|
||||
{
|
||||
GimpSessionInfoAux *aux;
|
||||
gchar value[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
g_ascii_formatd (value, sizeof (value), "%.2f", editor->zoom_factor);
|
||||
|
||||
aux = gimp_session_info_aux_new (AUX_INFO_ZOOM_FACTOR, value);
|
||||
aux_info = g_list_append (aux_info, aux);
|
||||
}
|
||||
|
||||
return aux_info;
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
gimp_palette_editor_new (Gimp *gimp,
|
||||
gimp_palette_editor_new (GimpContext *context,
|
||||
GimpMenuFactory *menu_factory)
|
||||
{
|
||||
GimpPalette *palette;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
palette = gimp_context_get_palette (gimp_get_user_context (gimp));
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||
|
||||
return g_object_new (GIMP_TYPE_PALETTE_EDITOR,
|
||||
"menu-factory", menu_factory,
|
||||
"menu-identifier", "<PaletteEditor>",
|
||||
"ui-path", "/palette-editor-popup",
|
||||
"data-factory", gimp->palette_factory,
|
||||
"data", palette,
|
||||
"data-factory", context->gimp->palette_factory,
|
||||
"context", context,
|
||||
"data", gimp_context_get_palette (context),
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user