mirror of https://github.com/GNOME/gimp.git
First prototype of a button in the levels tool dialog that will jump the
2008-05-13 Michael Natterer <mitch@gimp.org> First prototype of a button in the levels tool dialog that will jump the the curves tool with the same settings: * app/gegl/gimplevelsconfig.[ch]: add new function gimp_levels_config_to_curves_config() which converts a GimpLevelsConfig to a GimpCurvesConfig. Still lacks support for gamma. * app/tools/gimplevelstool.c: add "Edit this Settings as Curves" button and jump to curves when clicked. Still ugly. svn path=/trunk/; revision=25654
This commit is contained in:
parent
85cc5d92e5
commit
ddf2dca558
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2008-05-13 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
First prototype of a button in the levels tool dialog that will
|
||||
jump the the curves tool with the same settings:
|
||||
|
||||
* app/gegl/gimplevelsconfig.[ch]: add new function
|
||||
gimp_levels_config_to_curves_config() which converts a
|
||||
GimpLevelsConfig to a GimpCurvesConfig. Still lacks support
|
||||
for gamma.
|
||||
|
||||
* app/tools/gimplevelstool.c: add "Edit this Settings as Curves"
|
||||
button and jump to curves when clicked. Still ugly.
|
||||
|
||||
2008-05-13 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpcurve-map.c (gimp_curve_map_pixels): use memcpy()
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
/* temp cruft */
|
||||
#include "base/levels.h"
|
||||
|
||||
#include "core/gimpcurve.h"
|
||||
|
||||
#include "gimpcurvesconfig.h"
|
||||
#include "gimplevelsconfig.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
@ -522,6 +525,58 @@ gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
|
|||
g_object_thaw_notify (G_OBJECT (config));
|
||||
}
|
||||
|
||||
GimpCurvesConfig *
|
||||
gimp_levels_config_to_curves_config (GimpLevelsConfig *config)
|
||||
{
|
||||
GimpCurvesConfig *curves;
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LEVELS_CONFIG (config), NULL);
|
||||
|
||||
curves = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
|
||||
|
||||
for (channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel <= GIMP_HISTOGRAM_ALPHA;
|
||||
channel++)
|
||||
{
|
||||
GimpCurve *curve = curves->curve[channel];
|
||||
gint border_point;
|
||||
gint point;
|
||||
|
||||
if (config->low_input[channel] > 0.0 ||
|
||||
config->low_output[channel] > 0.0)
|
||||
{
|
||||
border_point = gimp_curve_get_closest_point (curve, 0.0);
|
||||
point = gimp_curve_get_closest_point (curve,
|
||||
config->low_input[channel]);
|
||||
|
||||
gimp_curve_set_point (curve, point,
|
||||
config->low_input[channel],
|
||||
config->low_output[channel]);
|
||||
|
||||
if (point != border_point)
|
||||
gimp_curve_set_point (curve, border_point, -1, -1);
|
||||
}
|
||||
|
||||
if (config->high_input[channel] < 1.0 ||
|
||||
config->high_output[channel] < 1.0)
|
||||
{
|
||||
border_point = gimp_curve_get_closest_point (curve, 1.0);
|
||||
point = gimp_curve_get_closest_point (curve,
|
||||
config->high_input[channel]);
|
||||
|
||||
gimp_curve_set_point (curve, point,
|
||||
config->high_input[channel],
|
||||
config->high_output[channel]);
|
||||
|
||||
if (point != border_point)
|
||||
gimp_curve_set_point (curve, border_point, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
return curves;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_levels_config_load_cruft (GimpLevelsConfig *config,
|
||||
gpointer fp,
|
||||
|
|
|
@ -73,6 +73,9 @@ void gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
|
|||
const GimpRGB *gray,
|
||||
const GimpRGB *white);
|
||||
|
||||
GimpCurvesConfig *
|
||||
gimp_levels_config_to_curves_config (GimpLevelsConfig *config);
|
||||
|
||||
gboolean gimp_levels_config_load_cruft (GimpLevelsConfig *config,
|
||||
gpointer fp,
|
||||
GError **error);
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#include "gegl/gimplevelsconfig.h"
|
||||
#include "gegl/gimpoperationlevels.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawable-histogram.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
@ -47,6 +50,7 @@
|
|||
|
||||
#include "gimphistogramoptions.h"
|
||||
#include "gimplevelstool.h"
|
||||
#include "tool_manager.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -119,6 +123,9 @@ static void levels_high_output_changed (GtkAdjustment *adjustment
|
|||
static void levels_input_picker_toggled (GtkWidget *widget,
|
||||
GimpLevelsTool *tool);
|
||||
|
||||
static void levels_to_curves_callback (GtkWidget *widget,
|
||||
GimpLevelsTool *tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpLevelsTool, gimp_levels_tool, GIMP_TYPE_IMAGE_MAP_TOOL)
|
||||
|
||||
|
@ -620,11 +627,11 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
|
||||
/* all channels frame */
|
||||
frame = gimp_frame_new (_("All Channels"));
|
||||
gtk_box_pack_end (GTK_BOX (image_map_tool->main_vbox), frame,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
hbox = gtk_hbox_new (FALSE, 6);
|
||||
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
@ -673,6 +680,17 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
G_CALLBACK (gimp_levels_tool_dialog_unmap),
|
||||
tool);
|
||||
|
||||
button = gtk_button_new_from_stock (GIMP_STOCK_TOOL_LEVELS);
|
||||
gtk_button_set_label (GTK_BUTTON (button),
|
||||
_("Edit this Settings as Curves"));
|
||||
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), button,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (levels_to_curves_callback),
|
||||
tool);
|
||||
|
||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
|
||||
config->channel);
|
||||
}
|
||||
|
@ -1113,3 +1131,37 @@ gimp_levels_tool_color_picked (GimpColorTool *color_tool,
|
|||
value, tool->config->channel, color);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
levels_to_curves_callback (GtkWidget *widget,
|
||||
GimpLevelsTool *tool)
|
||||
{
|
||||
GimpCurvesConfig *curves;
|
||||
GimpDisplay *display;
|
||||
GimpContext *user_context;
|
||||
GimpToolInfo *tool_info;
|
||||
GimpTool *new_tool;
|
||||
|
||||
curves = gimp_levels_config_to_curves_config (tool->config);
|
||||
|
||||
display = GIMP_TOOL (tool)->display;
|
||||
|
||||
user_context = gimp_get_user_context (display->gimp);
|
||||
|
||||
tool_info = gimp_container_get_child_by_name (display->gimp->tool_info_list,
|
||||
"gimp-curves-tool");
|
||||
|
||||
g_object_ref (tool);
|
||||
|
||||
gimp_context_set_tool (user_context, tool_info);
|
||||
tool_manager_initialize_active (display->gimp, display);
|
||||
|
||||
new_tool = tool_manager_get_active (display->gimp);
|
||||
|
||||
gimp_config_copy (GIMP_CONFIG (curves),
|
||||
GIMP_CONFIG (GIMP_IMAGE_MAP_TOOL (new_tool)->config),
|
||||
0);
|
||||
|
||||
g_object_unref (tool);
|
||||
g_object_unref (curves);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue